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:de.tudarmstadt.ukp.dkpro.core.testing.IOTestRunner.java

public static void testOneWay(Class<? extends CollectionReader> aReader, String aExpectedFile, String aFile,
        Object... aExtraParams) throws Exception {
    String outputFolder = aReader.getSimpleName() + "-" + FilenameUtils.getBaseName(aFile);
    if (DkproTestContext.get() != null) {
        outputFolder = DkproTestContext.get().getTestOutputFolderName();
    }//w w  w.j  ava 2 s  .  c  o  m
    File output = new File("target/test-output/" + outputFolder + "/dump.txt");

    Object[] extraParams = aExtraParams;
    extraParams = ArrayUtils.add(extraParams, CasDumpWriter.PARAM_TARGET_LOCATION);
    extraParams = ArrayUtils.add(extraParams, output);
    extraParams = ArrayUtils.add(extraParams, CasDumpWriter.PARAM_SORT);
    extraParams = ArrayUtils.add(extraParams, true);

    testOneWay2(aReader, CasDumpWriter.class, aExpectedFile, "dump.txt", aFile, extraParams);
}

From source file:net.navasoft.madcoin.backend.services.controller.exception.ControllerException.java

/**
 * Literal.//from   ww  w .jav  a  2 s. c  o m
 * 
 * @param genericReplacements
 *            the generic replacements
 * @return the string[]
 * @since 24/08/2014, 08:21:59 PM
 */
protected static String[] literal(Object[] genericReplacements) {
    String[] results = (String[]) Array.newInstance(String.class, 0);
    for (Object translated : genericReplacements) {
        if (translated instanceof UserTypes) {
            results = (String[]) ArrayUtils.add(results, ((UserTypes) translated).getExternalValue().name());
        } else if (translated instanceof Integer) {
        } else {
            results = (String[]) ArrayUtils.add(results, translated.toString());
        }
    }
    return results;
}

From source file:net.navasoft.madcoin.backend.services.vo.response.impl.AppCategoriesSuccessResponseVO.java

/**
 * Sets the business lines.//from ww w .  j  a va  2 s. c om
 * 
 * @param existentBusinessLines
 *            the new business lines
 * @since 24/08/2014, 06:05:43 PM
 */
@Override
public void setBusinessLines(BusinessLines... existentBusinessLines) {
    lob = (BusinessLines[]) Array.newInstance(BusinessLines.class, 0);
    lob = (BusinessLines[]) ArrayUtils.add(lob, existentBusinessLines[0]);
}

From source file:br.gov.frameworkdemoiselle.util.contrib.Reflections.java

@SuppressWarnings("unchecked")
public static <T> T[] getAnnotatedValues(Collection<?> collection, Class<? extends Annotation> aclazz,
        Class<T> T) {//from   w ww . j  a v a  2  s  . com
    T[] values = null;
    if (collection != null)
        for (Object item : collection)
            try {
                values = (T[]) ArrayUtils.add(values, (T) getAnnotatedValue(item, aclazz, true));
            } catch (Exception e) {
            }
    return values;
}

From source file:gda.device.detector.countertimer.TfgScalerWithLogValues.java

/**
 * When set to true ln(I0/It) and ln(I0/Iref) will be added to the output columns
 * //w  w w . ja v  a  2  s. c o m
 * @param outputLogValues
 *            The outputLogValues to set.
 */

public void setOutputLogValues(boolean outputLogValues) {
    this.outputLogValues = outputLogValues;

    // adjust the extraNmaes and outputFormat arrays
    if (!configured) {
        return;
    }
    if (outputLogValues) {
        if (!ArrayUtils.contains(extraNames, LNI0IT_LABEL)) {
            extraNames = (String[]) ArrayUtils.add(extraNames, LNI0IT_LABEL);
            outputFormat = (String[]) ArrayUtils.add(outputFormat, "%.5f");
        }
        if (!ArrayUtils.contains(extraNames, LNITIREF_LABEL)) {
            extraNames = (String[]) ArrayUtils.add(extraNames, LNITIREF_LABEL);
            outputFormat = (String[]) ArrayUtils.add(outputFormat, "%.5f");
        }
    } else {
        int numInputs = inputNames.length;
        if (ArrayUtils.contains(extraNames, LNI0IT_LABEL)) {
            int index = ArrayUtils.indexOf(extraNames, LNI0IT_LABEL);
            extraNames = (String[]) ArrayUtils.remove(extraNames, index);
            outputFormat = (String[]) ArrayUtils.remove(outputFormat, index + numInputs);
        }
        if (ArrayUtils.contains(extraNames, LNITIREF_LABEL)) {
            int index = ArrayUtils.indexOf(extraNames, LNITIREF_LABEL);
            extraNames = (String[]) ArrayUtils.remove(extraNames, index);
            outputFormat = (String[]) ArrayUtils.remove(outputFormat, index + numInputs);
        }

    }
}

From source file:info.magnolia.cms.util.Rule.java

/**
 * add to allow list//w w  w  . j  ava2s .co  m
 * @param nodeType
 */
public void addAllowType(String nodeType) {
    if (nodeType != null) {
        this.allowedTypes = (String[]) ArrayUtils.add(allowedTypes, nodeType);
    }
}

From source file:br.gov.frameworkdemoiselle.ldap.template.Entry.java

public void removeAttribute(String attribute) {
    removeOnMerge = (String[]) ArrayUtils.add(removeOnMerge, attribute);
}

From source file:com.haulmont.cuba.core.sys.PersistentEntitiesMetadataLoader.java

@Override
protected void initMetaProperty(MetaClass metaClass, MetaProperty metaProperty) {
    super.initMetaProperty(metaClass, metaProperty);

    if (metaProperty.getRange() == null || !metaProperty.getRange().isClass())
        return;/*w  ww .ja v  a  2  s .c om*/

    AnnotatedElement annotatedElement = metaProperty.getAnnotatedElement();

    OnDelete onDelete = annotatedElement.getAnnotation(OnDelete.class);
    if (onDelete != null) {
        Map<String, Object> metaAnnotations = metaClass.getAnnotations();

        MetaProperty[] properties = (MetaProperty[]) metaAnnotations.get(OnDelete.class.getName());
        properties = (MetaProperty[]) ArrayUtils.add(properties, metaProperty);
        metaAnnotations.put(OnDelete.class.getName(), properties);
    }

    OnDeleteInverse onDeleteInverse = annotatedElement.getAnnotation(OnDeleteInverse.class);
    if (onDeleteInverse != null) {
        Map<String, Object> metaAnnotations = metaProperty.getRange().asClass().getAnnotations();

        MetaProperty[] properties = (MetaProperty[]) metaAnnotations.get(OnDeleteInverse.class.getName());
        properties = (MetaProperty[]) ArrayUtils.add(properties, metaProperty);
        metaAnnotations.put(OnDeleteInverse.class.getName(), properties);
    }
}

From source file:info.magnolia.voting.voters.VoterSet.java

public void addVoter(Voter voter) {
    if (voter.isEnabled()) {
        voters = (Voter[]) ArrayUtils.add(voters, voter);
    }
}

From source file:info.archinnov.achilles.internal.statement.SliceQueryStatementGenerator.java

public RegularStatementWrapper generateWhereClauseForSelectSliceQuery(CQLSliceQuery<?> sliceQuery,
        Select select) {//from  ww w .ja  v  a2 s . c o m
    Where where = select.where();
    List<Object> fixedComponents = sliceQuery.getFixedComponents();
    List<String> componentNames = sliceQuery.getComponentNames();
    String varyingComponentName = sliceQuery.getVaryingComponentName();
    OrderingMode ordering = sliceQuery.getOrdering();

    Object lastStartComp = sliceQuery.getLastStartComponent();
    Object lastEndComp = sliceQuery.getLastEndComponent();
    Object[] boundValues = new Object[fixedComponents.size()];

    for (int i = 0; i < fixedComponents.size(); i++) {
        where.and(eq(componentNames.get(i), fixedComponents.get(i)));
        boundValues[i] = fixedComponents.get(i);
    }

    if (lastStartComp != null)
        boundValues = ArrayUtils.add(boundValues, lastStartComp);
    if (lastEndComp != null)
        boundValues = ArrayUtils.add(boundValues, lastEndComp);

    if (ordering == ASCENDING) {

        switch (sliceQuery.getBounding()) {
        case INCLUSIVE_BOUNDS:
            if (lastStartComp != null)
                where.and(gte(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(lte(varyingComponentName, lastEndComp));
            break;
        case EXCLUSIVE_BOUNDS:
            if (lastStartComp != null)
                where.and(gt(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(lt(varyingComponentName, lastEndComp));
            break;
        case INCLUSIVE_START_BOUND_ONLY:
            if (lastStartComp != null)
                where.and(gte(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(lt(varyingComponentName, lastEndComp));
            break;
        case INCLUSIVE_END_BOUND_ONLY:
            if (lastStartComp != null)
                where.and(gt(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(lte(varyingComponentName, lastEndComp));
            break;
        }
    } else // ordering == DESCENDING
    {
        switch (sliceQuery.getBounding()) {
        case INCLUSIVE_BOUNDS:
            if (lastStartComp != null)
                where.and(lte(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(gte(varyingComponentName, lastEndComp));
            break;
        case EXCLUSIVE_BOUNDS:
            if (lastStartComp != null)
                where.and(lt(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(gt(varyingComponentName, lastEndComp));
            break;
        case INCLUSIVE_START_BOUND_ONLY:
            if (lastStartComp != null)
                where.and(lte(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(gt(varyingComponentName, lastEndComp));
            break;
        case INCLUSIVE_END_BOUND_ONLY:
            if (lastStartComp != null)
                where.and(lt(varyingComponentName, lastStartComp));
            if (lastEndComp != null)
                where.and(gte(varyingComponentName, lastEndComp));
            break;
        }
    }
    where.setFetchSize(sliceQuery.getBatchSize());
    log.trace("Generated WHERE clause for slice query : {}", where.getQueryString());
    return new RegularStatementWrapper(where, boundValues, sliceQuery.getConsistencyLevel());
}