// Path: src/main/java/RFLogger.java
// public class RFLogger {
// 
//     private String fileName = "./classes/log.properties";
//     private static java.util.logging.Logger logger = null;
//     
//     private static ConsoleHandler consoleHandler;
//     
//     private static SimpleFormatter simpleFormatter;
// 
//     private RFLogger() {
// 
//         // Create the logger.
//         logger = java.util.logging.Logger.getLogger(RFLogger.class.getName());
// 
//         try {
//             java.util.logging.LogManager.getLogManager().readConfiguration(new FileInputStream(fileName));
// 
//         }
//         catch (IOException e) {
//             System.out.println("Unable to configure logging for " + fileName);
// 
//             e.printStackTrace();
// 
//             System.out.println("Resorting to console handler.");
// 
//         
//             //Create consoleHandler.
//             consoleHandler = new ConsoleHandler();
//         
//             //Assigning handler to logger object.
//             logger.addHandler(consoleHandler);
//         
//             //Setting levels to handler and logger.
//             consoleHandler.setLevel(Level.INFO);
//             logger.setLevel(Level.ALL);
//         
//             // Creating SimpleFormatter for human readable format.
//             simpleFormatter = new SimpleFormatter();
// 
//             // Setting formatter to all handlers.
//             consoleHandler.setFormatter(simpleFormatter);
// 
//             // Remove parent handlers in order to respect our formatting only.
//             // logger.setUseParentHandlers(false);
//         }
//     }
//     
//     private static java.util.logging.Logger getLogger() {
//         if(logger == null){
//             new RFLogger();
//         }
//         return logger;
//     }
//     
//     public static void log(Level level, String msg, Throwable thrown){
//         getLogger().log(level, msg, thrown);
//     }
//     
//     public static void log(Level level, String msg){
//         getLogger().log(level, msg);
//     }
// 
// }


import com.kogalur.randomforest.RFLogger;
import java.util.Arrays;
import java.util.logging.Level;
package com.kogalur.randomforest;






class Ensemble {

    /* 
       >>> CAUTION 
       These are mapped to the native types in src/main/global.h 
       <<< CAUTION
    */

    // Name of the ensemble.
    String name;
    
    // Type of ensemble (char), (int), or (double).
    EnsembleType type;

    // Position or slot in list.
    int slot;

    // Size of ensemble vector;
    long size;

    // Multi-dimensional view of the ensemble.  This is the number of dimensions.
    int auxDimSize;

    // Multi-dimensional view of the ensemble.  This is the size of the internal dimensions.
    int[] auxDim;
    
    // Generic object containing the ensemble vector.  This will be of type (double) or (int).
    Object ensembleVector;

    // Constructor called from native-code.  Before exiting the
    // C-code, we loop over a list and populate each ensemble and it's
    // associated fields.
    void Ensemble(String name,
                  byte   nativeType,
                  int    slot,
                  long   size,
                  int    auxDimSize,
                  int[]  auxDim,
                  Object ensembleVector) {

        int actualLength = 0;
        
        if (nativeType == EnsembleType.CHAR.getValue()) {
            type = EnsembleType.CHAR;
            actualLength = ((char[]) (ensembleVector)).length;
        }
        else if (nativeType == EnsembleType.INT.getValue()) {
            type = EnsembleType.INT;
            actualLength = ((int[]) (ensembleVector)).length;
        }
        else if (nativeType == EnsembleType.DOUBLE.getValue()) {
            type = EnsembleType.DOUBLE;
            actualLength = ((double[]) (ensembleVector)).length;
        }                                    
        else {
// Path: src/main/java/RFLogger.java
// public class RFLogger {
// 
//     private String fileName = "./classes/log.properties";
//     private static java.util.logging.Logger logger = null;
//     
//     private static ConsoleHandler consoleHandler;
//     
//     private static SimpleFormatter simpleFormatter;
// 
//     private RFLogger() {
// 
//         // Create the logger.
//         logger = java.util.logging.Logger.getLogger(RFLogger.class.getName());
// 
//         try {
//             java.util.logging.LogManager.getLogManager().readConfiguration(new FileInputStream(fileName));
// 
//         }
//         catch (IOException e) {
//             System.out.println("Unable to configure logging for " + fileName);
// 
//             e.printStackTrace();
// 
//             System.out.println("Resorting to console handler.");
// 
//         
//             //Create consoleHandler.
//             consoleHandler = new ConsoleHandler();
//         
//             //Assigning handler to logger object.
//             logger.addHandler(consoleHandler);
//         
//             //Setting levels to handler and logger.
//             consoleHandler.setLevel(Level.INFO);
//             logger.setLevel(Level.ALL);
//         
//             // Creating SimpleFormatter for human readable format.
//             simpleFormatter = new SimpleFormatter();
// 
//             // Setting formatter to all handlers.
//             consoleHandler.setFormatter(simpleFormatter);
// 
//             // Remove parent handlers in order to respect our formatting only.
//             // logger.setUseParentHandlers(false);
//         }
//     }
//     
//     private static java.util.logging.Logger getLogger() {
//         if(logger == null){
//             new RFLogger();
//         }
//         return logger;
//     }
//     
//     public static void log(Level level, String msg, Throwable thrown){
//         getLogger().log(level, msg, thrown);
//     }
//     
//     public static void log(Level level, String msg){
//         getLogger().log(level, msg);
//     }
// 
// }


// Path: src/main/java/Ensemble.java
import com.kogalur.randomforest.RFLogger;
import java.util.Arrays;
import java.util.logging.Level;

package com.kogalur.randomforest;






class Ensemble {

    /* 
       >>> CAUTION 
       These are mapped to the native types in src/main/global.h 
       <<< CAUTION
    */

    // Name of the ensemble.
    String name;
    
    // Type of ensemble (char), (int), or (double).
    EnsembleType type;

    // Position or slot in list.
    int slot;

    // Size of ensemble vector;
    long size;

    // Multi-dimensional view of the ensemble.  This is the number of dimensions.
    int auxDimSize;

    // Multi-dimensional view of the ensemble.  This is the size of the internal dimensions.
    int[] auxDim;
    
    // Generic object containing the ensemble vector.  This will be of type (double) or (int).
    Object ensembleVector;

    // Constructor called from native-code.  Before exiting the
    // C-code, we loop over a list and populate each ensemble and it's
    // associated fields.
    void Ensemble(String name,
                  byte   nativeType,
                  int    slot,
                  long   size,
                  int    auxDimSize,
                  int[]  auxDim,
                  Object ensembleVector) {

        int actualLength = 0;
        
        if (nativeType == EnsembleType.CHAR.getValue()) {
            type = EnsembleType.CHAR;
            actualLength = ((char[]) (ensembleVector)).length;
        }
        else if (nativeType == EnsembleType.INT.getValue()) {
            type = EnsembleType.INT;
            actualLength = ((int[]) (ensembleVector)).length;
        }
        else if (nativeType == EnsembleType.DOUBLE.getValue()) {
            type = EnsembleType.DOUBLE;
            actualLength = ((double[]) (ensembleVector)).length;
        }                                    
        else {
            RFLogger.log(Level.SEVERE, "Ensemble type (native) not found:  " + nativeType);