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:org.openhab.binding.neeo.internal.NeeoRoomProtocol.java

/**
 * Processes a change to the scenario (whether it's been launched or not)
 *
 * @param scenarioKey a non-null, non-empty scenario key
 * @param launch true if the scenario was launched, false otherwise
 *//*from  w  w  w.  ja va 2  s .c o m*/
private void processScenarioChange(String scenarioKey, boolean launch) {
    NeeoUtil.requireNotEmpty(scenarioKey, "scenarioKey cannot be empty");

    final String[] activeScenarios = this.activeScenarios.get();
    final int idx = ArrayUtils.indexOf(activeScenarios, scenarioKey);

    // already set that way
    if ((idx < 0 && !launch) || (idx >= 0 && launch)) {
        return;
    }

    final String[] newScenarios = idx >= 0 ? (String[]) ArrayUtils.remove(activeScenarios, idx)
            : (String[]) ArrayUtils.add(activeScenarios, scenarioKey);

    this.activeScenarios.set(newScenarios);

    refreshScenarioStatus(scenarioKey);
}

From source file:org.opentestsystem.delivery.testreg.upload.parser.ParserTextUtils.java

public static Object[] padEmptyIfNoColumnAtEnd(int totalColumns, Object[] records) {
    if (records.length < totalColumns) {
        return padEmptyIfNoColumnAtEnd(totalColumns, ArrayUtils.add(records, ""));
    }/*  w w w. jav  a  2s.c om*/
    return records;
}

From source file:org.openvpms.web.workspace.patient.history.PatientHistoryQuery.java

/**
 * Constructs a {@link PatientHistoryQuery}.
 *
 * @param patient the patient to query//from w  ww .  ja va2 s .c o m
 */
public PatientHistoryQuery(Party patient) {
    super(patient, "patient", PatientArchetypes.PATIENT_PARTICIPATION, SHORT_NAMES, Act.class);

    String[] actItemShortNames = RelationshipHelper.getTargetShortNames(PatientArchetypes.CLINICAL_EVENT_ITEM);
    shortNames = (String[]) ArrayUtils.addAll(actItemShortNames, DOC_VERSION_SHORT_NAMES);
    selectedShortNames = (String[]) ArrayUtils.add(shortNames, CustomerAccountArchetypes.INVOICE_ITEM);
    model = new ShortNameListModel(actItemShortNames, true, false);
    shortNameSelector = SelectFieldFactory.create(model);
    includeCharges = CheckBoxFactory.create("patient.record.query.includeCharges", true);

    ActionListener listener = new ActionListener() {
        public void onAction(ActionEvent event) {
            updateSelectedShortNames();
            onQuery();
        }
    };
    shortNameSelector.addActionListener(listener);
    shortNameSelector.setCellRenderer(new ShortNameListCellRenderer());

    includeCharges.addActionListener(listener);
    setAuto(true);
}

From source file:org.openvpms.web.workspace.patient.history.PatientHistoryQuery.java

/**
 * Updates the short names to query./*from   w ww.j  a  v  a  2  s . c  o m*/
 */
private void updateSelectedShortNames() {
    int index = shortNameSelector.getSelectedIndex();
    if (model.isAll(index)) {
        selectedShortNames = shortNames;
    } else {
        String shortName = model.getShortName(index);
        selectedShortNames = getSelectedShortNames(shortName);
    }
    if (includeCharges.isSelected()) {
        selectedShortNames = (String[]) ArrayUtils.add(selectedShortNames,
                CustomerAccountArchetypes.INVOICE_ITEM);
    }
}

From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorIT.java

private static void addColumnToModel(ModelInfo info) {
    ColumnInfo[] columns = info.getColumns();

    ColumnInfo col = new ColumnInfo();
    //    col.setDataType(ValueMeta.getTypeDesc(ValueMeta.TYPE_INTEGER));
    col.setDataType(DataType.NUMERIC);/*from w w w  . jav  a  2  s  .c  o  m*/
    col.setId("PC_999");
    col.setTitle("NEW_COLUMN");
    col.setIndex(true);
    col.setFieldType(ColumnInfo.FIELD_TYPE_BOTH);
    col.setAggregateType(AggregationType.SUM.toString());

    ColumnInfo[] newColumns = (ColumnInfo[]) ArrayUtils.add(columns, col);

    info.setColumns(newColumns);
}

From source file:org.polymap.core.data.feature.buffer.LayerFeatureBufferManager.java

protected void checkSubmitModified(FeatureStore fs, FeatureBufferState buffered) throws Exception {
    // check concurrent modifications with the store
    FeatureId fid = buffered.feature().getIdentifier();
    Id fidFilter = ff.id(Collections.singleton(fid));

    List<Feature> stored = loadFeatures(fs, fidFilter);
    if (stored.size() == 0) {
        throw new ConcurrentModificationException("Feature has been removed concurrently: " + fid);
    } else if (stored.size() > 1) {
        throw new IllegalStateException("More than one feature for id: " + fid + "!?");
    }/*from  www. j  ava 2 s . co m*/
    if (isFeatureModified(stored.get(0), buffered.original())) {
        throw new ConcurrentModificationException(
                "Objekt wurde von einem anderen Nutzer gleichzeitig gendert: " + fid);
    }

    // write down
    AttributeDescriptor[] type = {};
    Object[] value = {};

    for (Property origProp : buffered.original().getProperties()) {
        if (origProp.getDescriptor() instanceof AttributeDescriptor) {
            Property newProp = buffered.feature().getProperty(origProp.getName());
            if (isPropertyModified(origProp.getValue(), newProp.getValue())) {
                type = (AttributeDescriptor[]) ArrayUtils.add(type, origProp.getDescriptor());
                value = ArrayUtils.add(value, newProp.getValue());

                log.info("Attribute modified: " + origProp.getDescriptor().getName() + " = "
                        + newProp.getValue() + " (" + fid.getID() + ")");
            }
        }
    }
    fs.modifyFeatures(type, value, fidFilter);
}

From source file:org.polymap.core.data.image.cache304.CacheNewLayerOperationConcern.java

public IUndoableOperation newInstance(final IUndoableOperation op, final OperationInfo info) {
    if (op instanceof NewLayerOperation) {

        return new OperationConcernAdapter() {

            public IStatus execute(IProgressMonitor monitor, IAdaptable _info) throws ExecutionException {
                IStatus result = info.next().execute(monitor, _info);

                Display display = (Display) _info.getAdapter(Display.class);
                display.syncExec(new Runnable() {
                    public void run() {
                        MessageDialog.openInformation(PolymapWorkbench.getShellToParentOn(),
                                Messages.get("CacheNewLayerConcern_title"),
                                Messages.get("CacheNewLayerConcern_msg"));

                        ILayer layer = ((NewLayerOperation) op).getNewLayer();
                        try {
                            PipelineProcessorConfiguration[] configs = layer.getProcessorConfigs();

                            // new config
                            PipelineProcessorConfiguration newConfig = new PipelineProcessorConfiguration(
                                    ImageCacheProcessor.class.getName(), "Image-TileCache");
                            configs = (PipelineProcessorConfiguration[]) ArrayUtils.add(configs, newConfig);

                            layer.setProcessorConfigs(configs);
                        } catch (Exception e) {
                            PolymapWorkbench.handleError(DataPlugin.PLUGIN_ID, this, e.getLocalizedMessage(),
                                    e);/*from w  ww.  j a  v a  2s.c  o m*/
                        }
                    }
                });
                return result;
            }

            protected OperationInfo getInfo() {
                return info;
            }
        };
    }
    return null;
}

From source file:org.polymap.core.runtime.SessionContext.java

public static void addProvider(ISessionContextProvider provider) {
    providers = (ISessionContextProvider[]) ArrayUtils.add(providers, provider);
}

From source file:org.projectforge.business.ldap.LdapObject.java

public void addObjectClass(final String objectClass) {
    if (this.objectClasses == null) {
        this.objectClasses = new String[] { objectClass };
    } else {/*w  w w .j  a va2 s . c  o  m*/
        this.objectClasses = (String[]) ArrayUtils.add(this.objectClasses, objectClass);
    }
}

From source file:org.projectforge.framework.persistence.user.entities.PFUserDO.java

@Override
public ModificationStatus copyValuesFrom(final BaseDO<? extends Serializable> src, String... ignoreFields) {
    // TODO BUG too much magic.
    ignoreFields = (String[]) ArrayUtils.add(ignoreFields, "password"); // NPE save considering ignoreFields
    final PFUserDO user = (PFUserDO) src;
    ModificationStatus modificationStatus = AbstractBaseDO.copyValues(user, this, ignoreFields);
    if (user.getPassword() != null) {
        if (user.getPassword().equals(getPassword()) == false) {
            modificationStatus = ModificationStatus.MAJOR;
        }/*from  ww  w  .j  av  a 2 s.  co m*/
        setPassword(user.getPassword());
        checkAndFixPassword();
    }
    return modificationStatus;
}