List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:ru.apertum.qsystem.client.forms.FBreaksChangeDialog.java
@Action public void addBreak() { final GregorianCalendar gc = new GregorianCalendar(2015, 1, 1, Integer.parseInt(cbSH.getSelectedItem().toString()), Integer.parseInt(cbSM.getSelectedItem().toString())); final Date d1 = gc.getTime(); gc.set(GregorianCalendar.HOUR_OF_DAY, Integer.parseInt(cbFH.getSelectedItem().toString())); gc.set(GregorianCalendar.MINUTE, Integer.parseInt(cbFM.getSelectedItem().toString())); if (d1.before(gc.getTime())) { breaks = (QBreak[]) ArrayUtils.add(breaks, new QBreak(d1, gc.getTime(), breaksParent)); loadBreaks(breaks);// w w w. ja va 2s.c o m } else { JOptionPane.showConfirmDialog(this, getLocaleMessage("add_break_dialog.err1.message"), getLocaleMessage("add_break_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } }
From source file:ru.catssoftware.gameserver.skills.conditions.ConditionLogic.java
public final void add(Condition condition) { if (condition == null) throw new IllegalStateException("Tried to add a 'null' condition to an <" + getClass().getSimpleName().replace("ConditionLogic", "").toLowerCase() + "> condition"); _conditions = (Condition[]) ArrayUtils.add(_conditions, condition); }
From source file:schedoscope.example.osm.mapreduce.GeohashMapper.java
@Override public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String[] rec = value.toString().split("\t"); String hash = GeoHash.geoHashStringWithCharacterPrecision(Double.valueOf(rec[4]), Double.valueOf(rec[5]), hashPrecision);/*from w ww . j ava 2 s.com*/ String output = StringUtils.join(ArrayUtils.add(rec, hash), "\t"); context.write(NullWritable.get(), new Text(output)); }
From source file:uk.ac.diamond.scisoft.ncd.passerelle.actors.forkjoin.NcdNormalisationForkJoinTransformer.java
@Override protected void configureActorParameters() throws HDF5Exception { super.configureActorParameters(); calibrationGroupID = H5.H5Gopen(entryGroupID, calibration, HDF5Constants.H5P_DEFAULT); H5L_info_t linkInfo = H5.H5Lget_info(calibrationGroupID, "data", HDF5Constants.H5P_DEFAULT); if (linkInfo.type == HDF5Constants.H5L_TYPE_EXTERNAL) { String[] buff = new String[(int) linkInfo.address_val_size]; H5.H5Lget_val(calibrationGroupID, "data", buff, HDF5Constants.H5P_DEFAULT); if (buff[0] != null && buff[1] != null) { String linkData = buff[0]; String linkFilename = buff[1]; linkFileID = H5.H5Fopen(linkFilename, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT); inputCalibrationID = H5.H5Dopen(linkFileID, linkData, HDF5Constants.H5P_DEFAULT); } else {//from ww w .ja va 2 s.co m throw new HDF5Exception("Invalid external link data for Normalisation dataset."); } } else { inputCalibrationID = H5.H5Dopen(calibrationGroupID, "data", HDF5Constants.H5P_DEFAULT); } calibrationIDs = new DataSliceIdentifiers(); calibrationIDs.setIDs(calibrationGroupID, inputCalibrationID); int rankCal = H5.H5Sget_simple_extent_ndims(calibrationIDs.dataspace_id); long[] tmpFramesCal = new long[rankCal]; H5.H5Sget_simple_extent_dims(calibrationIDs.dataspace_id, tmpFramesCal, null); // This is a workaround to add extra dimensions to the end of scaler // data shape // to match them with scan data dimensions int extraDims = frames.length - dimension + 1 - rankCal; if (extraDims > 0) { rankCal += extraDims; for (int dm = 0; dm < extraDims; dm++) { tmpFramesCal = ArrayUtils.add(tmpFramesCal, 1); } } framesCal = Arrays.copyOf(tmpFramesCal, rankCal); for (int i = 0; i < frames.length - dimension; i++) { if (frames[i] != framesCal[i]) { frames[i] = Math.min(frames[i], framesCal[i]); } } }
From source file:uk.ac.diamond.scisoft.ncd.passerelle.actors.NcdNormalisationTransformer.java
@Override protected void doInitialize() throws InitializationException { super.doInitialize(); try {//from ww w.j av a 2 s . c o m calibration = ((StringToken) calibrationParam.getToken()).stringValue(); calibrationGroupID = H5.H5Gopen(entryGroupID, calibration, HDF5Constants.H5P_DEFAULT); inputCalibrationID = H5.H5Dopen(calibrationGroupID, "data", HDF5Constants.H5P_DEFAULT); calibrationIDs = new DataSliceIdentifiers(); calibrationIDs.setIDs(calibrationGroupID, inputCalibrationID); int rankCal = H5.H5Sget_simple_extent_ndims(calibrationIDs.dataspace_id); long[] tmpFramesCal = new long[rankCal]; H5.H5Sget_simple_extent_dims(calibrationIDs.dataspace_id, tmpFramesCal, null); // This is a workaround to add extra dimensions to the end of scaler // data shape // to match them with scan data dimensions int extraDims = frames.length - dimension + 1 - rankCal; if (extraDims > 0) { rankCal += extraDims; for (int dm = 0; dm < extraDims; dm++) { tmpFramesCal = ArrayUtils.add(tmpFramesCal, 1); } } framesCal = Arrays.copyOf(tmpFramesCal, rankCal); for (int i = 0; i < frames.length - dimension; i++) { if (frames[i] != framesCal[i]) { frames[i] = Math.min(frames[i], framesCal[i]); } } normGroupID = NcdNexusUtils.makegroup(processingGroupID, dataName, Nexus.DETECT); int type = HDF5Constants.H5T_NATIVE_FLOAT; normDataID = NcdNexusUtils.makedata(normGroupID, "data", type, frames, true, "counts"); type = HDF5Constants.H5T_NATIVE_DOUBLE; normErrorsID = NcdNexusUtils.makedata(normGroupID, "errors", type, frames, true, "counts"); absScaling = ((DoubleToken) absScalingParam.getToken()).doubleValue(); normChannel = ((IntToken) normChannelParam.getToken()).intValue(); // TODO: add axis support // if (qaxis != null) { // setQaxis(qaxis, qaxisUnit); // writeQaxisData(frames.length, normGroupID); // } // writeNcdMetadata(normGroupID); } catch (Exception e) { throw new InitializationException(ErrorCode.ACTOR_INITIALISATION_ERROR, "Error initializing my actor", this, e); } }
From source file:uk.ac.diamond.scisoft.ncd.reduction.LazyNormalisation.java
public void configure(int dim, long[] frames, int entry_group_id, int processing_group_id) throws HDF5Exception { calibration_group_id = H5.H5Gopen(entry_group_id, calibration, HDF5Constants.H5P_DEFAULT); input_calibration_id = H5.H5Dopen(calibration_group_id, "data", HDF5Constants.H5P_DEFAULT); calibration_ids = new DataSliceIdentifiers(); calibration_ids.setIDs(calibration_group_id, input_calibration_id); rankCal = H5.H5Sget_simple_extent_ndims(calibration_ids.dataspace_id); long[] tmpFramesCal = new long[rankCal]; H5.H5Sget_simple_extent_dims(calibration_ids.dataspace_id, tmpFramesCal, null); // This is a workaround to add extra dimensions to the end of scaler data shape // to match them with scan data dimensions int extraDims = frames.length - dim + 1 - rankCal; if (extraDims > 0) { rankCal += extraDims;/*from ww w .j a v a2s. com*/ for (int dm = 0; dm < extraDims; dm++) { tmpFramesCal = ArrayUtils.add(tmpFramesCal, 1); } } framesCal = Arrays.copyOf(tmpFramesCal, rankCal); for (int i = 0; i < frames.length - dim; i++) { if (frames[i] != framesCal[i]) { frames[i] = Math.min(frames[i], framesCal[i]); } } norm_group_id = NcdNexusUtils.makegroup(processing_group_id, LazyNormalisation.name, Nexus.DETECT); int type = HDF5Constants.H5T_NATIVE_FLOAT; norm_data_id = NcdNexusUtils.makedata(norm_group_id, "data", type, frames, true, "counts"); type = HDF5Constants.H5T_NATIVE_DOUBLE; norm_errors_id = NcdNexusUtils.makedata(norm_group_id, "errors", type, frames, true, "counts"); setAbsScaling(absScaling); setNormChannel(normChannel); if (qaxis != null) { setQaxis(qaxis, qaxisUnit); writeQaxisData(frames.length, norm_group_id); } writeNcdMetadata(norm_group_id); }
From source file:uk.ac.gda.client.experimentdefinition.components.ExperimentRunEditor.java
private CellEditor[] createCellEditors(final TableViewer tableViewer) { CellEditor[] editors = new CellEditor[1]; Table table = tableViewer.getTable(); TextCellEditor nameEd = new TextCellEditor(table); ((Text) nameEd.getControl()).setTextLimit(60); // NOTE Must not add verify listener - it breaks things. editors[0] = nameEd;// www .j av a2 s.co m try { IFolder containingFolder = runObjectManager.getContainingFolder(); final List<IExperimentBeanDescription> beanTypes = ExperimentBeanManager.INSTANCE.getBeanDescriptions(); String[] columnNames = runObjectManager.getOrderedColumnBeanTypes(); for (int index = 0; index < columnNames.length; index++) { String columnName = columnNames[index]; for (IExperimentBeanDescription type : beanTypes) { if (type.includeInNew() && columnName.equals(type.getBeanType())) { IExperimentBeanDescription[] beanTypesToFilterOn = new IExperimentBeanDescription[0]; for (IExperimentBeanDescription beanType : beanTypes) { if (beanType.getBeanType().equals(type.getBeanType())) { beanTypesToFilterOn = (IExperimentBeanDescription[]) ArrayUtils .add(beanTypesToFilterOn, beanType); } } editors = (CellEditor[]) ArrayUtils.add(editors, new XMLChooserEditor(table, containingFolder, beanTypesToFilterOn)); break; } } } } catch (Exception e1) { logger.error("Could not create editors for Run Editor View.", e1); } SpinnerCellEditor repEd = new SpinnerCellEditor(table); repEd.setMaximum(999); repEd.setMinimum(1); editors = (CellEditor[]) ArrayUtils.add(editors, repEd); return editors; }
From source file:uk.ac.gda.client.experimentdefinition.ExperimentEditorManager.java
private void closeUnwantedEditors(IEditorPart[] ourEditors) { IEditorReference[] openEdRefs = getActivePage().getEditorReferences(); IEditorInput[] ourEdParts = new IEditorInput[ourEditors.length]; for (int i = 0; i < ourEditors.length; i++) ourEdParts[i] = ourEditors[i].getEditorInput(); IEditorReference[] edRefsToClose = new IEditorReference[0]; for (IEditorReference edRef : openEdRefs) { try {/* w ww . j a va2s .c om*/ if (!ArrayUtils.contains(ourEdParts, edRef.getEditorInput())) edRefsToClose = (IEditorReference[]) ArrayUtils.add(edRefsToClose, edRef); } catch (PartInitException e) { logger.warn("Exception initialising " + edRef.getContentDescription(), e); } } getActivePage().closeEditors(edRefsToClose, true); }
From source file:v201208.creativesetservice.UpdateCreativeSetExample.java
public static void main(String[] args) { try {/*from w w w . j av a 2 s. c o m*/ // Log SOAP XML request and response. DfpServiceLogger.log(); // Get DfpUser from "~/dfp.properties". DfpUser user = new DfpUser(); // Get the CreativeSetService. CreativeSetServiceInterface creativeSetService = user .getService(DfpService.V201208.CREATIVE_SET_SERVICE); // Set the ID of the creative set to get and the companion creative to // add. Long creativeSetId = Long.parseLong("INSERT_CREATIVE_SET_ID_HERE"); Long companionCreativeId = Long.parseLong("INSERT_COMPANION_CREATIVE_ID_HERE"); // Get the creative set. CreativeSet creativeSet = creativeSetService.getCreativeSet(creativeSetId); // Add the companion creative to the creative set. creativeSet.setCompanionCreativeIds( ArrayUtils.add(creativeSet.getCompanionCreativeIds(), companionCreativeId)); // Update the creative set on the server. creativeSet = creativeSetService.updateCreativeSet(creativeSet); // Display results. System.out.println("A creative set with ID \"" + creativeSet.getId() + "\", master creative ID \"" + creativeSet.getMasterCreativeId() + "\", and companion creative IDs {" + StringUtils.join(ArrayUtils.toObject(creativeSet.getCompanionCreativeIds()), ',') + "} was updated."); } catch (Exception e) { e.printStackTrace(); } }
From source file:v201211.creativesetservice.UpdateCreativeSetExample.java
public static void main(String[] args) { try {/*from w w w . j a va 2 s. co m*/ // Log SOAP XML request and response. DfpServiceLogger.log(); // Get DfpUser from "~/dfp.properties". DfpUser user = new DfpUser(); // Get the CreativeSetService. CreativeSetServiceInterface creativeSetService = user .getService(DfpService.V201211.CREATIVE_SET_SERVICE); // Set the ID of the creative set to get and the companion creative to // add. Long creativeSetId = Long.parseLong("INSERT_CREATIVE_SET_ID_HERE"); Long companionCreativeId = Long.parseLong("INSERT_COMPANION_CREATIVE_ID_HERE"); // Get the creative set. CreativeSet creativeSet = creativeSetService.getCreativeSet(creativeSetId); // Add the companion creative to the creative set. creativeSet.setCompanionCreativeIds( ArrayUtils.add(creativeSet.getCompanionCreativeIds(), companionCreativeId)); // Update the creative set on the server. creativeSet = creativeSetService.updateCreativeSet(creativeSet); // Display results. System.out.println("A creative set with ID \"" + creativeSet.getId() + "\", master creative ID \"" + creativeSet.getMasterCreativeId() + "\", and companion creative IDs {" + StringUtils.join(ArrayUtils.toObject(creativeSet.getCompanionCreativeIds()), ',') + "} was updated."); } catch (Exception e) { e.printStackTrace(); } }