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.OEAdapter.java

/**
 * @param theOE/*from   w  w w.ja va 2s. co  m*/
 */
public OEAdapter(OE theOE) {
    this.theOE = theOE;

    // set the output format correctly
    String[] format = new String[0];
    for (int i = 0; i < theOE.getDOFNames().length; i++) {
        format = (String[]) ArrayUtils.add(format, "%5.5g");
    }
    this.setOutputFormat(format);

    // set the input names
    this.inputNames = this.getDOFNames();
}

From source file:info.magnolia.module.delta.ArrayDelegateTask.java

/**
 * Tasks are meant to be immutable. Avoid this if possible.
 */
public void addTask(Task task) {
    this.tasks = (Task[]) ArrayUtils.add(tasks, task);
}

From source file:de.tudarmstadt.lt.n2n.utilities.PatternGenerator.java

public String[] merge_wildcards(String[] pattern) {
    String[] merged_pattern = new String[1];
    merged_pattern[0] = pattern[0];//from w w w. j av  a2 s. c o  m
    for (int i = 1; i < pattern.length; i++) {
        if (WILDCARD.equals(pattern[i]) && WILDCARD.equals(pattern[i - 1]))
            continue;
        merged_pattern = (String[]) ArrayUtils.add(merged_pattern, pattern[i]);
    }
    return merged_pattern;
}

From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java

public void extractBySpeciesGroups(String metadataUrl, String q, String[] fq, Writer writer) throws Exception {

    List<FacetField.Count> speciesGroups = extractFacet(q, fq, "species_group");
    for (FacetField.Count spg : speciesGroups) {
        List<FacetField.Count> orders = extractFacet(q,
                (String[]) ArrayUtils.add(fq, "species_group:" + spg.getName()), "order");
        for (FacetField.Count o : orders) {
            outputNestedMappableLayerStart("order", o.getName(), writer);
            List<FacetField.Count> families = extractFacet(q,
                    (String[]) ArrayUtils.add(fq, "order:" + o.getName()), "family");
            for (FacetField.Count f : families) {
                outputNestedMappableLayerStart("family", f.getName(), writer);
                List<FacetField.Count> genera = extractFacet(q,
                        (String[]) ArrayUtils.addAll(fq,
                                new String[] { "family:" + f.getName(), "species_group:" + spg.getName() }),
                        "genus");
                for (FacetField.Count g : genera) {
                    outputNestedMappableLayerStart("genus", g.getName(), writer);
                    List<FacetField.Count> species = extractFacet(q,
                            (String[]) ArrayUtils.addAll(fq, new String[] { "genus:" + g.getName(),
                                    "species_group:" + spg.getName(), "family:" + f.getName() }),
                            "species");
                    for (FacetField.Count s : species) {
                        outputLayer(metadataUrl, "species", s.getName(), writer);
                    }//w w w .  jav  a  2 s .c  o  m
                    outputNestedLayerEnd(writer);
                }
                outputNestedLayerEnd(writer);
            }
            outputNestedLayerEnd(writer);
        }
        outputNestedLayerEnd(writer);
    }
}

From source file:com.delphix.session.impl.sasl.PlainSaslServer.java

public String[] parse(byte[] message) throws SaslException {
    // Validate the SASL message
    PlainSasl.validate(message);/*  w w  w  . j a v  a 2 s .  c o m*/

    // Append separator to the end of the message
    message = ArrayUtils.add(message, PlainSasl.SEPARATOR_BYTE);

    // Parse the user info formatted as value + SEPARATOR
    String[] userInfo = new String[3];

    byte[] segment;
    int beginIndex = 0;
    int endIndex;

    for (int i = 0; i < userInfo.length; i++) {
        endIndex = ArrayUtils.indexOf(message, PlainSasl.SEPARATOR_BYTE, beginIndex);

        if (endIndex < 0) {
            throw new SaslException("invalid sasl message");
        } else {
            segment = ArrayUtils.subarray(message, beginIndex, endIndex);
            userInfo[i] = fromUTF(segment);
        }

        beginIndex = endIndex + 1;
    }

    // Check if there is anything else beyond the last separator
    if (beginIndex < message.length) {
        throw new SaslException("invalid sasl message");
    }

    // Validate the user info
    PlainSasl.validate(userInfo);

    return userInfo;
}

From source file:msi.gama.common.geometry.GamaGeometryFactory.java

/**
 * Linear rings are created using a simple coordinate array, without enforcing any clockwiseness condition.
 *//* www .  ja  v a  2  s  . com*/
@Override
public LinearRing createLinearRing(final Coordinate[] coordinates) {
    Coordinate[] coords = coordinates;
    if (!isRing(coords)) {
        coords = (Coordinate[]) ArrayUtils.add(coords, coords[0]);
    }
    return createLinearRing(JTS_COORDINATES_FACTORY.create(coords));
}

From source file:info.magnolia.cms.filters.CompositeFilter.java

public void addFilter(MgnlFilter filter) {
    this.filters = (MgnlFilter[]) ArrayUtils.add(this.filters, filter);
}

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

/**
 * Instantiates a new session//from  w  w w.ja v a 2  s  .co  m
 * net.navasoft.madcoin.backend.model.controller.impl exception.
 * 
 * @param exceptionMessages
 *            the exception messages
 * @param injected
 *            the injected
 * @param key
 *            the key
 * @param parameters
 *            the parameters
 * @since 28/07/2014, 11:34:20 PM
 */
public SessionControllerException(final MessageSource exceptionMessages, final Locale injected,
        final AllowedExceptionMessage key, Object... parameters) {
    super(exceptionMessages.getMessage(key.getPropertyKey(), literal(parameters), injected));
    locatedMessage = key.getPropertyKey();
    language = injected;
    reasonsToFail = (Object[]) Array.newInstance(Object.class, 0);
    reasonsToFail = ArrayUtils.add(reasonsToFail, parameters[0]);
    reasonsToFail = ArrayUtils.add(reasonsToFail, parameters[1]);
    setAllowedTips(parameters[parameters.length - 1]);
    formulateTips();
}

From source file:gda.data.scan.datawriter.scannablewriter.StringComponentWriter.java

@Override
public Collection<SelfCreatingLink> makeComponent(final NeXusFileInterface file, int[] dim, final String path,
        final String scannableName, final String componentName, final Object pos, final String unit)
        throws NexusException {

    final String name = enterLocation(file, path);

    stringlength = 127;/*from   ww w .  j a  v a 2 s. c o  m*/

    final Object slab = getComponentSlab(pos);
    final int slablength = Array.getLength(slab);

    if (Arrays.equals(dim, new int[] { 1 })) {
        stringlength = slablength;
    } else if (slablength + 10 > stringlength) { // if strings vary more than that we are in trouble
        stringlength = slablength + 10;
    }

    dim = makedatadimfordim(dim);

    if (dim[dim.length - 1] == 1) {
        dim[dim.length - 1] = stringlength;
    } else {
        dim = ArrayUtils.add(dim, stringlength);
    }
    rank = dim.length;

    file.makedata(name, NexusFile.NX_CHAR, rank, dim);
    file.opendata(name);

    if (componentName != null) {
        file.putattr("local_name", (scannableName + "." + componentName).getBytes(UTF8), NexusFile.NX_CHAR);
    }

    addCustomAttributes(file, scannableName, componentName);
    file.putslab(slab, nulldimfordim(dim), slabsizedimfordim(dim));

    file.closedata();
    leaveLocation(file);

    return Collections.emptySet();
}

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

/**
 * Instantiates a new session/*from  w ww .  j a va  2  s . co m*/
 * net.navasoft.madcoin.backend.model.controller.impl exception.
 * 
 * @param exceptionMessages
 *            the exception messages
 * @param injected
 *            the injected
 * @param key
 *            the key
 * @param parameters
 *            the parameters
 * @since 28/07/2014, 11:34:20 PM
 */
public BusinessControllerException(final MessageSource exceptionMessages, final Locale injected,
        final AllowedExceptionMessage key, Object... parameters) {
    super(exceptionMessages.getMessage(key.getPropertyKey(), literal(parameters), injected));
    locatedMessage = key.getPropertyKey();
    language = injected;
    if (parameters != null) {
        reasonsToFail = (Object[]) Array.newInstance(Object.class, 0);
        for (Object param : parameters) {
            reasonsToFail = ArrayUtils.add(reasonsToFail, param);
        }
    }
}