Example usage for org.apache.commons.lang ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

Usage

From source file:com.opengamma.analytics.financial.interestrate.swap.method.SwapCalculatorTest.java

@Test
public void parSpreadCurveSensitivityIborSpreadIborSpreadBeforeFirstFixing() {
    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 5, 14);
    final Swap<Coupon, Coupon> swap = SWAP_IBORSPREAD_IBORSPREAD_DEFINITION.toDerivative(referenceDate,
            FIXING_TS_3_6, CURVE_NAMES);
    final String fwdCurveName = ((CouponIborSpread) swap.getSecondLeg().getNthPayment(0)).getForwardCurveName();
    InterestRateCurveSensitivity pscsComputed = swap.accept(PSCSC, CURVES);
    pscsComputed = pscsComputed.cleaned();
    final double[] timesDsc = new double[swap.getFirstLeg().getNumberOfPayments()];
    for (int loopcpn = 0; loopcpn < swap.getFirstLeg().getNumberOfPayments(); loopcpn++) {
        timesDsc[loopcpn] = swap.getFirstLeg().getNthPayment(loopcpn).getPaymentTime();
    }/*ww  w.  j a  v a2  s. c  o  m*/
    final List<DoublesPair> sensiDscFD = FDCurveSensitivityCalculator.curveSensitvityFDCalculator(swap, PSC,
            CURVES, swap.getFirstLeg().getDiscountCurve(), timesDsc, 1.0E-10);
    final List<DoublesPair> sensiDscComputed = pscsComputed.getSensitivities()
            .get(swap.getFirstLeg().getDiscountCurve());
    assertTrue("parSpread: curve sensitivity - dsc",
            InterestRateCurveSensitivityUtils.compare(sensiDscFD, sensiDscComputed, TOLERANCE_SPREAD_DELTA));

    final Set<Double> timesFwdSet = new TreeSet<>();
    for (int loopcpn = 0; loopcpn < swap.getFirstLeg().getNumberOfPayments(); loopcpn++) {
        timesFwdSet
                .add(((CouponIborSpread) swap.getFirstLeg().getNthPayment(loopcpn)).getFixingPeriodStartTime());
        timesFwdSet
                .add(((CouponIborSpread) swap.getFirstLeg().getNthPayment(loopcpn)).getFixingPeriodEndTime());
    }
    for (int loopcpn = 0; loopcpn < swap.getSecondLeg().getNumberOfPayments(); loopcpn++) {
        timesFwdSet.add(
                ((CouponIborSpread) swap.getSecondLeg().getNthPayment(loopcpn)).getFixingPeriodStartTime());
        timesFwdSet
                .add(((CouponIborSpread) swap.getSecondLeg().getNthPayment(loopcpn)).getFixingPeriodEndTime());
    }
    final Double[] timesFwd = timesFwdSet.toArray(new Double[timesFwdSet.size()]);
    final List<DoublesPair> sensiFwdFD = FDCurveSensitivityCalculator.curveSensitvityFDCalculator(swap, PSC,
            CURVES, fwdCurveName, ArrayUtils.toPrimitive(timesFwd), 1.0E-10);
    final List<DoublesPair> sensiFwdComputed = pscsComputed.getSensitivities().get(fwdCurveName);
    assertTrue("parSpread: curve sensitivity - fwd",
            InterestRateCurveSensitivityUtils.compare(sensiFwdFD, sensiFwdComputed, TOLERANCE_SPREAD_DELTA));
}

From source file:balony.summarizeJFrame.java

public void setupData() {
    if (myAD == null) {
        return;/*  w ww . j  av a  2  s.c o m*/
    }

    summaryData = new HashMap<String, sumData>();

    System.out.println("Setting up summary data");
    for (int i = 1; i <= myAD.getSets(); i++) {
        for (int j = 1; j <= myAD.getPlates(); j++) {
            for (int k = 1; k <= myAD.getRows(); k++) {
                for (int l = 1; l <= myAD.getCols(); l++) {

                    String myOrf = orfs[j][k][l];

                    sumData sD;

                    if (!summaryData.keySet().contains(myOrf)) {
                        sD = new sumData();
                        sD.ctrlSpots = new ArrayList<Double>();
                        sD.expSpots = new ArrayList<Double>();
                        if (!genes[j][k][l].isEmpty()) {
                            sD.gene = genes[j][k][l];
                        } else {
                            sD.gene = myOrf;
                        }
                    } else {
                        sD = summaryData.get(myOrf);
                    }

                    sD.ctrlSpots.add(myAD.ctrlSpots[i][j][k][l]);
                    sD.expSpots.add(myAD.expSpots[i][j][k][l]);

                    summaryData.put(myOrf, sD);

                }
            }
        }
    }

    tableData = new Object[summaryData.size()][columnNames.length];

    int i = 0;

    for (String s : summaryData.keySet()) {

        double ctrl, exp, ratio;

        tableData[i][COL_ORF] = s;
        tableData[i][COL_GENE] = summaryData.get(s).gene;
        tableData[i][COL_CTRL_N] = summaryData.get(s).ctrlSpots.size();
        tableData[i][COL_EXP_N] = summaryData.get(s).expSpots.size();

        ArrayList<Double> c = summaryData.get(s).ctrlSpots;
        int j = c.size();
        double ctrls[] = ArrayUtils.toPrimitive(c.toArray(new Double[j]));

        if (jComboBox2.getSelectedItem().toString().equals("Median")) {
            ctrl = StatUtils.percentile(ctrls, 50);
        } else {

            ctrl = StatUtils.mean(ctrls);
        }

        tableData[i][COL_CTRL] = ctrl;
        tableData[i][COL_CTRL_SD] = Math.sqrt(StatUtils.variance(ctrls));

        ArrayList<Double> e = summaryData.get(s).expSpots;
        j = e.size();
        double exps[] = ArrayUtils.toPrimitive(e.toArray(new Double[j]));

        if (jComboBox2.getSelectedItem().toString().equals("Median")) {
            exp = StatUtils.percentile(exps, 50);
        } else {

            exp = StatUtils.mean(exps);
        }

        tableData[i][COL_EXP] = exp;
        tableData[i][COL_EXP_SD] = Math.sqrt(StatUtils.variance(exps));

        if (ctrl > 0) {
            ratio = exp / ctrl;
        } else {
            ratio = 0;
        }

        tableData[i][COL_RATIO] = ratio;
        tableData[i][COL_DIFF] = exp - ctrl;

        TTest tt = new TTest();
        double pval = tt.tTest(ctrls, exps);
        if (Double.isNaN(pval)) {
            pval = 1d;
        }
        tableData[i][COL_PVAL] = pval;

        i++;
    }

    jTable1.setModel(new MyTableModel());
    jTable1.setAutoCreateRowSorter(true);
    jTable1.repaint();
}

From source file:com.opengamma.analytics.financial.provider.curve.InflationBuildingCurveWithDiscountAndSeasonalityTestUS.java

@Test(enabled = true)
public void comparison1Unit2Units() {
    final InflationProviderDiscount[] units = new InflationProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final PriceIndexCurve[] curveInflation = new PriceIndexCurve[2];

    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(USD);
        curveInflation[loopblock] = units[loopblock].getCurve(US_CPI);

    }/*  w ww  . ja va 2  s . co m*/
    assertEquals("Curve construction: 1 unit / 3 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveInflation[0].getNumberOfParameters(),
            curveInflation[1].getNumberOfParameters());

    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(curveInflation[0].getCurve().getXData()),
            ArrayUtils.toPrimitive(curveInflation[1].getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(curveInflation[0].getCurve().getYData()),
            ArrayUtils.toPrimitive(curveInflation[1].getCurve().getYData()), TOLERANCE_CAL);
}

From source file:com.flexive.ejb.beans.BriefcaseEngineBean.java

/**
 * {@inheritDoc}/*from   www . j a  v  a2  s  . c  o  m*/
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public long[] getItems(long id) throws FxApplicationException {
    Connection con = null;
    PreparedStatement stmt = null;
    final Briefcase br = load(id);
    try {
        con = Database.getDbConnection();
        stmt = con.prepareStatement("SELECT id FROM " + TBL_BRIEFCASE_DATA + " WHERE briefcase_id=?");
        stmt.setLong(1, id);
        final ResultSet rs = stmt.executeQuery();
        final List<Long> result = new ArrayList<Long>();
        while (rs.next()) {
            result.add(rs.getLong(1));
        }
        return ArrayUtils.toPrimitive(result.toArray(new Long[result.size()]));
    } catch (Exception e) {
        EJBUtils.rollback(ctx);
        throw new FxUpdateException(LOG, e, "ex.briefcase.getItems", br.getName(), e);
    } finally {
        closeObjects(BriefcaseEngineBean.class, con, stmt);
    }
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.FilteringController.java

/**
 * Get mean displacement for the experiment.
 *
 * @return//from  w  ww . j av a2 s . co m
 */
private Double getMedianDisplAcrossCondition() {
    Map<PlateCondition, SingleCellConditionDataHolder> preProcessingMap = singleCellPreProcessingController
            .getPreProcessingMap();
    Double[] medianValues = new Double[preProcessingMap.size()];
    for (int i = 0; i < medianValues.length; i++) {
        PlateCondition condition = singleCellPreProcessingController.getPlateConditionList().get(i);
        if (!condition.isComputed()) {
            singleCellPreProcessingController.computeCondition(condition);
        }
        medianValues[i] = getMedianDisplAcrossReplicates(
                singleCellPreProcessingController.getPlateConditionList().get(i));
    }
    return AnalysisUtils.computeMedian(ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(medianValues)));
}

From source file:com.opengamma.analytics.financial.provider.curve.MulticurveBuildingDiscountingDiscountEUR3Test.java

@Test(enabled = false)
public void comparison1Unit3Units() {
    final MulticurveProviderDiscount[] units = new MulticurveProviderDiscount[2];
    final CurveBuildingBlockBundle[] bb = new CurveBuildingBlockBundle[2];
    final YieldAndDiscountCurve[] curveDsc = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd3 = new YieldAndDiscountCurve[2];
    final YieldAndDiscountCurve[] curveFwd6 = new YieldAndDiscountCurve[2];
    for (int loopblock = 0; loopblock < 2; loopblock++) {
        units[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getFirst();
        bb[loopblock] = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(loopblock).getSecond();
        curveDsc[loopblock] = units[loopblock].getCurve(EUR);
        curveFwd3[loopblock] = units[loopblock].getCurve(EURIBOR3M);
        curveFwd6[loopblock] = units[loopblock].getCurve(EURIBOR6M);
    }/*from w ww .  j  ava2  s .co m*/
    assertEquals("Curve construction: 1 unit / 3 units ", curveDsc[0].getNumberOfParameters(),
            curveDsc[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd3[0].getNumberOfParameters(),
            curveFwd3[1].getNumberOfParameters());
    assertEquals("Curve construction: 1 unit / 3 units ", curveFwd6[0].getNumberOfParameters(),
            curveFwd6[1].getNumberOfParameters());
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveDsc[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd3[1]).getCurve().getYData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getXData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getXData()), TOLERANCE_CAL);
    assertArrayEquals("Curve construction: 1 unit / 3 units ",
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[0]).getCurve().getYData()),
            ArrayUtils.toPrimitive(((YieldCurve) curveFwd6[1]).getCurve().getYData()), TOLERANCE_CAL);

    assertEquals("Curve construction: 1 unit / 3 units ", bb[0].getBlock(CURVE_NAME_FWD6_EUR).getFirst(),
            bb[1].getBlock(CURVE_NAME_FWD6_EUR).getFirst());
}

From source file:com.streamsets.pipeline.stage.destination.bigtable.BigtableTarget.java

@Override
public void write(final Batch batch) throws StageException {

    long counter = 0;

    if (conf.timeBasis == TimeBasis.BATCH_START) {
        timeStamp = System.currentTimeMillis();
    }/*w ww  . j  a v  a  2 s . c o m*/

    List<Put> theList = new ArrayList<>();
    Iterator<Record> recordIter = batch.getRecords();
    while (recordIter.hasNext()) {
        Record rec = recordIter.next();

        byte[] rowKey = buildRowKey(rec);
        if (rowKey.length == 0) {
            continue; // next record.
        }

        if (conf.timeBasis == TimeBasis.SYSTEM_TIME) {
            timeStamp = System.currentTimeMillis();

        } else if (conf.timeBasis == TimeBasis.FROM_RECORD) {
            Field f = rec.get(conf.timeStampField);
            if (f != null) {
                if (f.getType() == Field.Type.LONG) {
                    timeStamp = f.getValueAsLong();

                } else { // the field's data type is wrong.
                    errorRecordHandler.onError(new OnRecordErrorException(rec, Errors.BIGTABLE_08,
                            f.getType().name(), conf.timeStampField));
                    continue;

                }

            } else { // the field does not exist.
                errorRecordHandler
                        .onError(new OnRecordErrorException(rec, Errors.BIGTABLE_14, conf.timeStampField));
                continue; // next record.

            }
        }

        /* SDC-4628.  if "Ignore Missing Data Values" is enabled, we need to determine
        if any columns will be inserted for this record.
                
        if no data from any column will be inserted, this record probably should to go
        the On Record Error dest, since there will be no trace of this Row Key in
        Bigtable - at least one field has to be inserted so there is a record of
        this Row Key.
         */
        Map<String, Byte[]> values = new HashMap<>();

        int nullFields = 0;
        int cantConvert = 0;
        for (BigtableFieldMapping f : conf.fieldColumnMapping) {
            Field tempField = rec.get(f.source);
            if (tempField == null) {
                nullFields++;

            } else {
                // field exists - check if it's convertible.
                try {
                    values.put(f.source, ArrayUtils.toObject(convertValue(f, tempField, rec)));
                } catch (OnRecordErrorException ex) {
                    cantConvert++;
                }
            }
        }

        // any conversion failures go to record error.
        if (cantConvert > 0) {
            errorRecordHandler.onError(new OnRecordErrorException(rec, Errors.BIGTABLE_23));
            continue;
        }

        if (!conf.ignoreMissingFields) {
            if (nullFields > 0) { // missing fields, not ignoring them - record goes to error.
                errorRecordHandler.onError(new OnRecordErrorException(rec, Errors.BIGTABLE_23));
                continue;
            }
        } else {
            // null field count matches field path count.  all columns are null.
            if (nullFields == conf.fieldColumnMapping.size()) {
                errorRecordHandler.onError(new OnRecordErrorException(rec, Errors.BIGTABLE_23));
                continue; // next record.
            }
        }

        Put put = new Put(rowKey, timeStamp);

        for (BigtableFieldMapping f : conf.fieldColumnMapping) {
            theList.add(put.addColumn(destinationNames.get(f.column).columnFamily,
                    destinationNames.get(f.column).qualifier, timeStamp,
                    ArrayUtils.toPrimitive(values.get(f.source))));
        }

        counter++;
        if (counter >= conf.numToBuffer) {
            commitRecords(theList);
            theList.clear();
            counter = 0;
        }
    }

    // commit any "leftovers".
    if (counter > 0) {
        commitRecords(theList);
    }
}

From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.sav.SAVFileReader.java

/**
 * Read the given SPSS SAV-format file via a <code>BufferedInputStream</code>
 * object.  This method calls an appropriate method associated with the given 
 * field header by reflection.//  ww w.  j  av  a 2  s .c  om
 * 
 * @param stream a <code>BufferedInputStream</code>.
 * @return an <code>SDIOData</code> object
 * @throws java.io.IOException if an reading error occurs.
 */
@Override
public SDIOData read(BufferedInputStream stream, File dataFile) throws IOException {

    dbgLog.fine("***** SAVFileReader: read() start *****");

    if (dataFile != null) {
        throw new IOException("this plugin does not support external raw data files");
    }

    // the following methods are now executed, in this order:

    // decodeHeader -- this method doesn't read any [meta]data and 
    //    doesn't initialize any values; its only purpose is to 
    //    make sure that the file is indeed an SPSS/SAV file. 
    // 
    // decodeRecordType1 -- there's always one RT1 record; it is 
    //    always 176 byte long. it contains the very basic metadata
    //    about the data file. most notably, the number of observations
    //    and the number of OBS (8 byte values) per observation.
    //
    // decodeRecordType2 -- there are multiple RT2 records. there's 
    //    one RT2 for every OBS (8 byte value); i.e. one per variable,
    //    or more per every String variable split into multiple OBS
    //    segments. this one is a 400 line method, that may benefit 
    //    from being split into smaller methods.
    //
    // decodeRecordType3and4 -- these sections come in pairs, each
    //    pair dedicated to one set of variable labels. 
    // decodeRecordType6,
    //
    // decodeRecordType7 -- this RT contains some extended 
    //    metadata for the data file. (including the information 
    //    about the extended variables, i.e. variables longer than
    //    255 bytes split into 255 byte fragments that are stored 
    //    in the data file as independent variables). 
    //
    // decodeRecordType999 -- this RT does not contain any data; 
    //    its sole function is to indicate that the metadata portion 
    //    of the data file is over and the data section follows. 
    // 
    // decodeRecordTypeData -- this method decodes the data section 
    //    of the file. Inside this method, 2 distinct methods are 
    //    called to process compressed or uncompressed data, depending
    //    on which method is used in this data file. 

    String methodCurrentlyExecuted = null;

    try {
        methodCurrentlyExecuted = "decodeHeader";
        dbgLog.fine("***** SAVFileReader: executing method decodeHeader");
        decodeHeader(stream);

        methodCurrentlyExecuted = "decodeRecordType1";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
        decodeRecordType1(stream);

        methodCurrentlyExecuted = "decodeRecordType2";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType1");
        decodeRecordType2(stream);

        methodCurrentlyExecuted = "decodeRecordType3and4";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType3and4");
        decodeRecordType3and4(stream);

        methodCurrentlyExecuted = "decodeRecordType6";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType6");
        decodeRecordType6(stream);

        methodCurrentlyExecuted = "decodeRecordType7";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType7");
        decodeRecordType7(stream);

        methodCurrentlyExecuted = "decodeRecordType999";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordType999");
        decodeRecordType999(stream);

        methodCurrentlyExecuted = "decodeRecordTypeData";
        dbgLog.fine("***** SAVFileReader: executing method decodeRecordTypeData");
        decodeRecordTypeData(stream);

    } catch (IllegalArgumentException e) {
        //Throwable cause = e.getCause();
        dbgLog.fine("***** SAVFileReader: ATTENTION: IllegalArgumentException thrown while executing "
                + methodCurrentlyExecuted);
        e.printStackTrace();
        throw new IllegalArgumentException("in method " + methodCurrentlyExecuted + ": " + e.getMessage());
    } catch (IOException e) {
        dbgLog.fine("***** SAVFileReader: ATTENTION: IOException thrown while executing "
                + methodCurrentlyExecuted);
        e.printStackTrace();
        throw new IOException("in method " + methodCurrentlyExecuted + ": " + e.getMessage());
    }

    /* Final correction of the "variable type list" values: 
     * The date/time values are stored as character strings by the DVN, 
     * so the type information needs to be adjusted accordingly:
     *          -- L.A., v3.6 
     */
    int[] variableTypeMinimal = ArrayUtils
            .toPrimitive(variableTypelList.toArray(new Integer[variableTypelList.size()]));

    for (int indx = 0; indx < variableTypelList.size(); indx++) {
        int simpleType = 0;
        if (variableTypelList.get(indx) != null) {
            simpleType = variableTypelList.get(indx).intValue();
        }

        if (simpleType <= 0) {
            // NOT marked as a numeric at this point;
            // but is it a date/time/etc.?
            String variableFormatType = variableFormatTypeList[indx];
            if (variableFormatType != null
                    && (variableFormatType.equals("time") || variableFormatType.equals("date"))) {
                variableTypeMinimal[indx] = 1;
            }
        }
    }

    smd.setVariableTypeMinimal(variableTypeMinimal);

    if (sdiodata == null) {
        sdiodata = new SDIOData(smd, savDataSection);
    }
    dbgLog.fine("***** SAVFileReader: read() end *****");
    return sdiodata;

}

From source file:com.flexive.core.storage.genericSQL.GenericTreeStorage.java

/**
 * {@inheritDoc}// ww w.j ava2s. c o  m
 */
@Override
public long[] createNodes(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode,
        long parentNodeId, String path, int position, boolean activateContent) throws FxApplicationException {
    if ("/".equals(path))
        return new long[] { FxTreeNode.ROOT_NODE };
    final List<Long> result = new ArrayList<Long>();
    final Scanner scanner = new Scanner(path);
    long currentParent = parentNodeId;
    scanner.useDelimiter("/");
    if (parentNodeId != -1) {
        acquireLocksForUpdate(con, getTreeNodeInfo(con, mode, parentNodeId), false);
    }
    while (scanner.hasNext()) {
        String name = scanner.next();
        final FxString label = new FxString(true, name);
        name = FxFormatUtils.escapeTreePath(name);
        if (StringUtils.isEmpty(name))
            continue;
        long nodeId = getIdByFQNPath(con, mode, currentParent, "/" + name);
        if (nodeId == -1)
            nodeId = createNode(con, seq, ce, mode, nodeId, currentParent, name, label, position, null, null,
                    activateContent);
        result.add(nodeId);
        currentParent = nodeId;
    }
    return ArrayUtils.toPrimitive(result.toArray(new Long[result.size()]));
}

From source file:com.kbot2.scriptable.methods.data.Bank.java

public void depositAllExcept(int... itemIDs) {
    Item[] items = botEnv.inventory.getItems();
    java.util.List<Integer> out = new LinkedList<Integer>();
    if (items == null)
        return;//from  www  .  j  av  a 2 s .  c o  m
    for (Item item : items) {
        if (item.getID() > 0) {
            boolean found = false;
            for (int id : itemIDs) {
                if (item.getID() == id) {
                    found = true;
                }
            }
            if (!found) {
                for (int id : out) {
                    if (id == item.getID()) {
                        found = true;
                    }
                }
                if (!found) {
                    out.add(item.getID());
                }
            }
        }
    }
    if (out.isEmpty())
        return;
    depositAll(ArrayUtils.toPrimitive(out.toArray(new Integer[1])));
}