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

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

Introduction

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

Prototype

public static short[] add(short[] array, short element) 

Source Link

Document

Copies the given array and adds the given element at the end of the new array.

Usage

From source file:gda.device.scannable.CoupledScannable.java

/**
 * Adds a function to the list//from   www  . j a va 2 s  . co  m
 * 
 * @param newFunction
 */
public void addFunction(Function newFunction) {
    if (!ArrayUtils.contains(theFunctions, newFunction)) {
        theFunctions = (Function[]) ArrayUtils.add(theFunctions, newFunction);
    }
}

From source file:info.archinnov.achilles.internal.context.DaoContext.java

public void pushInsertStatement(PersistenceContext context) {
    log.debug("Push insert statement for PersistenceContext '{}'", context);

    EntityMeta entityMeta = context.getEntityMeta();
    Class<?> entityClass = context.getEntityClass();
    Optional<Integer> ttlO = context.getTtt();
    Optional<Long> timestampO = context.getTimestamp();
    ConsistencyLevel writeLevel = overrider.getWriteLevel(context, entityMeta);
    if (timestampO.isPresent()) {
        final Pair<Insert, Object[]> pair = statementGenerator.generateInsert(context.getEntity(), entityMeta);
        Insert insert = pair.left;//from www  . j  a  v  a2 s .c o  m
        Object[] boundValues = pair.right;
        Insert.Options insertOptions = insert.using(timestamp(timestampO.get()));
        boundValues = ArrayUtils.add(boundValues, timestampO.get());

        if (ttlO.isPresent()) {
            insertOptions = insertOptions.and(ttl(ttlO.get()));
            boundValues = ArrayUtils.add(boundValues, ttlO.get());
        }
        context.pushStatement(new RegularStatementWrapper(insertOptions, boundValues, getCQLLevel(writeLevel)));
    } else {
        PreparedStatement ps = insertPSs.get(entityClass);
        BoundStatementWrapper bsWrapper = binder.bindForInsert(ps, entityMeta, context.getEntity(), writeLevel,
                ttlO);
        context.pushStatement(bsWrapper);
    }
}

From source file:com.fluxtion.learning.fx.utils.PriceOrderGenerator.java

/**
 * Adds the cached currency to the array
 *//*from  w  ww .j  ava  2s .c o m*/
private void addCcy_() {
    CcyPair pair = configToAdd.pair;
    for (CcyConfig ccyConfig : configArray) {
        if (pair == ccyConfig.pair) {
            ccyConfig.bias = configToAdd.bias;
            ccyConfig.delayMircos = configToAdd.delayMircos;
            ccyConfig.orderRate = configToAdd.orderRate;
            ccyConfig.rejectRate = configToAdd.rejectRate;
            return;
        }
    }
    configArray = (CcyConfig[]) ArrayUtils.add(configArray, configToAdd);
}

From source file:net.navasoft.madcoin.backend.services.vo.request.SuccessRequestVOWrapper.java

private ProcessedField[] getTarget(IService service) {
    ProcessedField[] scope = new ProcessedField[] {};
    for (Field attendanceProperty : service.getClass().getDeclaredFields()) {
        if (attendanceProperty.getAnnotation(ProcessedField.class) != null) {
            scope = (ProcessedField[]) ArrayUtils.add(scope,
                    attendanceProperty.getAnnotation(ProcessedField.class));
        }//from   w  w w.j a va2 s  .com
    }
    return scope;
}

From source file:com.aionemu.gameserver.controllers.ObserveController.java

/**
 * //from   www  . j  a  v a2s.c  o  m
 * @param observer
 */
public void addEquipObserver(ActionObserver observer) {
    synchronized (equipObservers) {
        equipObservers = (ActionObserver[]) ArrayUtils.add(equipObservers, observer);
    }
}

From source file:gda.device.scannable.MonoScannable.java

@Override
public void addAcceptableUnit(String newUnit) throws DeviceException {
    Quantity newUnitClass = QuantityFactory.createFromTwoStrings("1.0", newUnit);
    if (newUnitClass instanceof Angle || newUnitClass instanceof Energy || newUnitClass instanceof Length) {
        this.acceptableUnits = (Unit<?>[]) ArrayUtils.add(this.acceptableUnits, newUnitClass.getUnit());
    }// ww w  .j a  v  a 2 s  .  c  om
}

From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java

private void readAllResultsFromDatabases() {
    if (controllers == null) {
        logger.error("No ILoggingScriptController configured in the product plugin_customization.ini file.\n"
                + "Talk to your Data Acq contact to add a uk.ac.gda.client/gda.loggingscriptcontrollers.to_observe entry");
    }//w  w w. j  a va 2  s .c o  m

    for (ILoggingScriptController controller : controllers) {
        ScriptControllerLogResults[] thisTable = controller.getTable();
        for (ScriptControllerLogResults row : thisTable) {
            mapID2Controller.put(row.getUniqueID(), controller);
        }
        results = (ScriptControllerLogResults[]) ArrayUtils.addAll(thisTable, results);
    }

    // recreate the filters
    knownScripts = new String[] {};
    for (ScriptControllerLogResults result : results) {
        String scriptName = result.getScriptName();
        if (!ArrayUtils.contains(knownScripts, scriptName)) {
            knownScripts = (String[]) ArrayUtils.add(knownScripts, scriptName);
            view.updateFilter(knownScripts);
        }
    }
    view.updateFilter(knownScripts);

    orderResultsByTime();
}

From source file:com.ibm.jaggr.core.impl.module.ModuleImplTest.java

@Test
public void testModuleImpl() throws Exception {
    testDepMap.put("p2/a", (String[]) ArrayUtils.add(testDepMap.get("p2/a"), "p1/aliased/d"));
    String configJson = "{paths:{p1:'p1',p2:'p2'}, aliases:[[/\\/aliased\\//, function(s){if (has('foo')) return '/foo/'; else if (has('bar')) return '/bar/'; has('non'); return '/non/'}]]}";
    configRef.set(new ConfigImpl(mockAggregator, tmpdir.toURI(), configJson));

    Features features = new Features();
    features.put("foo", true);
    features.put("bar", true);
    requestAttributes.put(IHttpTransport.FEATUREMAP_REQATTRNAME, features);

    ModuleImpl module = (ModuleImpl) mockAggregator.newModule("p1/p1",
            mockAggregator.getConfig().locateModuleResource("p1/p1"));
    Reader reader = module.getBuild(mockRequest).get();
    System.out.println(module.toString());
    Assert.assertEquals("[expn, js:(has:[conditionFalse, conditionTrue, foo])]",
            module.getCacheKeyGenerators().toString());
    Assert.assertTrue(module.getKeys().size() == 1
            && module.getKeys().containsAll(Arrays.asList(new String[] { "expn:0;js:S:1:0:1;has{foo}" })));
    StringWriter writer = new StringWriter();
    CopyUtil.copy(reader, writer);/*from  w w w.  ja  v  a2 s .c o m*/
    String compiled = writer.toString();
    System.out.println(compiled);
    assertTrue(Pattern.compile("require\\(\\[.*?,\\\"p1/foo/d\\\".*?\\],").matcher(compiled).find());

    features.put("foo", false);
    reader = module.getBuild(mockRequest).get();
    System.out.println(module.toString());
    Assert.assertEquals("[expn, js:(has:[bar, conditionFalse, conditionTrue, foo])]",
            module.getCacheKeyGenerators().toString());
    Assert.assertTrue(module.getKeys().size() == 2 && module.getKeys().containsAll(
            Arrays.asList(new String[] { "expn:0;js:S:1:0:1;has{foo}", "expn:0;js:S:1:0:1;has{bar,!foo}" })));
    writer = new StringWriter();
    CopyUtil.copy(reader, writer);
    compiled = writer.toString();
    assertTrue(Pattern.compile("require\\(\\[.*?,\\\"p1/bar/d\\\".*?\\],").matcher(compiled).find());

    features.put("bar", false);
    reader = module.getBuild(mockRequest).get();
    System.out.println(module.toString());
    List<ICacheKeyGenerator> cacheKeyGenerators = module.getCacheKeyGenerators();
    Assert.assertEquals("[expn, js:(has:[bar, conditionFalse, conditionTrue, foo, non])]",
            module.getCacheKeyGenerators().toString());
    Assert.assertTrue(module.getKeys().size() == 3
            && module.getKeys().containsAll(Arrays.asList(new String[] { "expn:0;js:S:1:0:1;has{foo}",
                    "expn:0;js:S:1:0:1;has{bar,!foo}", "expn:0;js:S:1:0:1;has{!bar,!foo}" })));
    writer = new StringWriter();
    CopyUtil.copy(reader, writer);
    compiled = writer.toString();
    System.out.println(compiled);
    assertTrue(Pattern.compile("require\\(\\[.*?,\\\"p1/non/d\\\".*?\\],").matcher(compiled).find());

    features.remove("bar");
    features.put("foo", true);
    reader = module.getBuild(mockRequest).get();
    System.out.println(module.toString());
    Assert.assertTrue(cacheKeyGenerators == module.getCacheKeyGenerators());
    Assert.assertTrue(module.getKeys().size() == 3
            && module.getKeys().containsAll(Arrays.asList(new String[] { "expn:0;js:S:1:0:1;has{foo}",
                    "expn:0;js:S:1:0:1;has{bar,!foo}", "expn:0;js:S:1:0:1;has{!bar,!foo}" })));
    writer = new StringWriter();
    CopyUtil.copy(reader, writer);
    compiled = writer.toString();
    System.out.println(compiled);
    assertTrue(Pattern.compile("require\\(\\[.*?,\\\"p1/foo/d\\\".*?\\],").matcher(compiled).find());

    features.put("bar", true);
    reader = module.getBuild(mockRequest).get();
    System.out.println(module.toString());
    Assert.assertTrue(cacheKeyGenerators == module.getCacheKeyGenerators());
    Assert.assertTrue(module.getKeys().size() == 4 && module.getKeys().containsAll(
            Arrays.asList(new String[] { "expn:0;js:S:1:0:1;has{foo}", "expn:0;js:S:1:0:1;has{bar,foo}",
                    "expn:0;js:S:1:0:1;has{bar,!foo}", "expn:0;js:S:1:0:1;has{!bar,!foo}" })));
    writer = new StringWriter();
    CopyUtil.copy(reader, writer);
    compiled = writer.toString();
    assertTrue(Pattern.compile("require\\(\\[.*?,\\\"p1/foo/d\\\".*?\\],").matcher(compiled).find());
}

From source file:com.aionemu.gameserver.controllers.ObserveController.java

/**
 * //  w  ww.  java 2s. c om
 * @param observer
 */
public void addAttackCalcObserver(AttackCalcObserver observer) {
    synchronized (attackCalcObservers) {
        attackCalcObservers = (AttackCalcObserver[]) ArrayUtils.add(attackCalcObservers, observer);
    }
}

From source file:gda.jython.scriptcontroller.logging.LoggingScriptController.java

@Override
public ScriptControllerLogResults[] getTable() {
    ResultSet rs = null;//  w  w w .ja  v a  2 s  .  c  o m
    try {
        ScriptControllerLogResults[] results = new ScriptControllerLogResults[] {};
        String myVisit = InterfaceProvider.getBatonStateProvider().getBatonHolder().getVisitID();

        psSimpleListAll.setString(1, myVisit);
        rs = psSimpleListAll.executeQuery();
        Boolean atFirst = rs.next();
        while (atFirst) {
            ScriptControllerLogResults result = new ScriptControllerLogResults(rs.getString(1), rs.getString(2),
                    rs.getTimestamp(3), rs.getTimestamp(4));
            results = (ScriptControllerLogResults[]) ArrayUtils.add(results, result);
            atFirst = rs.next();
        }
        return results;
    } catch (SQLException e) {
        logger.error("Exception fetching stored log messages in " + getName(), e);
        return new ScriptControllerLogResults[] {};
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
            }
        }
    }
}