List of usage examples for org.apache.commons.lang ArrayUtils addAll
public static double[] addAll(double[] array1, double[] array2)
Adds all the elements of the given arrays into a new array.
From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java
@Override public void extractHierarchy(String metadataUrl, String q, String[] fq, Writer writer) throws Exception { List<FacetField.Count> kingdoms = extractFacet(q, fq, "kingdom"); for (FacetField.Count k : kingdoms) { outputNestedLayerStart(k.getName(), writer); List<FacetField.Count> phyla = extractFacet(q, (String[]) ArrayUtils.add(fq, "kingdom:" + k.getName()), "phylum"); for (FacetField.Count p : phyla) { outputNestedMappableLayerStart("phylum", p.getName(), writer); List<FacetField.Count> classes = extractFacet(q, (String[]) ArrayUtils.add(fq, "phylum:" + p.getName()), "class"); for (FacetField.Count c : classes) { outputNestedMappableLayerStart("class", c.getName(), writer); List<FacetField.Count> orders = extractFacet(q, (String[]) ArrayUtils.add(fq, "class:" + c.getName()), "order"); for (FacetField.Count o : orders) { outputNestedMappableLayerStart("order", o.getName(), writer); List<FacetField.Count> families = extractFacet(q, (String[]) ArrayUtils.addAll(fq, new String[] { "order:" + o.getName(), "kingdom:" + k.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(), "kingdom:" + k.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(), "kingdom:" + k.getName(), "family:" + f.getName() }), "species"); for (FacetField.Count s : species) { outputLayer(metadataUrl, "species", s.getName(), writer); }//from w ww . ja va 2 s . co m outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } }
From source file:info.archinnov.achilles.internal.statement.StatementGenerator.java
public Pair<Update.Where, Object[]> generateUpdateFields(Object entity, EntityMeta entityMeta, List<PropertyMeta> pms) { log.trace("Generate UPDATE statement for entity class {} and properties {}", entityMeta.getClassName(), pms);//from w w w .j av a 2 s .c om PropertyMeta idMeta = entityMeta.getIdMeta(); Update update = update(entityMeta.getTableName()); Object[] boundValuesForColumns = new Object[pms.size()]; Assignments assignments = null; for (int i = 0; i < pms.size(); i++) { PropertyMeta pm = pms.get(i); Object value = pm.getAndEncodeValueForCassandra(entity); if (i == 0) { assignments = update.with(set(pm.getPropertyName(), value)); } else { assignments.and(set(pm.getPropertyName(), value)); } boundValuesForColumns[i] = value; } final Pair<Update.Where, Object[]> pair = generateWhereClauseForUpdate(entity, idMeta, assignments); final Object[] boundValues = ArrayUtils.addAll(boundValuesForColumns, pair.right); return Pair.create(pair.left, boundValues); }
From source file:alluxio.LocalAlluxioClusterResource.java
/** * Appends new parameters to mConfParams and applies to mTestConf. * * @param s string array to be added to mConfParams *///from w w w .j a v a 2 s. c o m public void addConfParams(String[] s) throws IOException { ArrayUtils.addAll(mConfParams, s); applyConfParams(); }
From source file:hudson.plugins.jobConfigHistory.ConfigInfoCollector.java
/** * Collects configs./* ww w . jav a2 s . c o m*/ * * @param folderName * folderName, usually just the empty string. * @return List of ConfigInfo, may be empty * @throws IOException if an entry could not be read. */ public List<ConfigInfo> collect(final String folderName) throws IOException { final File[] itemDirs; if ("deleted".equals(type)) { itemDirs = overViewhistoryDao.getDeletedJobs(folderName); } else { itemDirs = (File[]) ArrayUtils.addAll(overViewhistoryDao.getDeletedJobs(folderName), overViewhistoryDao.getJobs(folderName)); } Arrays.sort(itemDirs, FileNameComparator.INSTANCE); for (final File itemDir : itemDirs) { getConfigsForType(itemDir, folderName); } return configs; }
From source file:com.adobe.acs.commons.util.ResourceServiceManager.java
@Override @SuppressWarnings({ "squid:S3776", "squid:S1141" }) public synchronized void refreshCache() { log.trace("refreshCache"); ResourceResolver resolver = null;//from w ww. j a va 2s .co m try { resolver = getResourceResolver(); Resource aprRoot = resolver.getResource(getRootPath()); List<String> configuredIds = new ArrayList<String>(); for (Resource child : aprRoot.getChildren()) { if (!JcrConstants.JCR_CONTENT.equals(child.getName())) { log.debug("Updating service for configuration {}", child.getPath()); updateJobService(child.getPath(), child.getChild(JcrConstants.JCR_CONTENT)); configuredIds.add(child.getPath()); } } String filter = "(" + SERVICE_OWNER_KEY + "=" + getClass().getCanonicalName() + ")"; ServiceReference[] serviceReferences = (ServiceReference[]) ArrayUtils.addAll( bctx.getServiceReferences(Runnable.class.getCanonicalName(), filter), bctx.getServiceReferences(EventHandler.class.getCanonicalName(), filter)); if (serviceReferences != null && serviceReferences.length > 0) { log.debug("Found {} registered services", serviceReferences.length); for (ServiceReference reference : serviceReferences) { try { String configurationId = (String) reference.getProperty(CONFIGURATION_ID_KEY); if (!configuredIds.contains(configurationId)) { log.debug("Unregistering service for configuration {}", configurationId); this.unregisterService(configurationId); } } catch (Exception e) { log.warn("Exception unregistering reference " + reference, e); } } } else { log.debug("Did not find any registered services."); } } catch (InvalidSyntaxException e) { log.warn("Unable to search for invalid references due to invalid filter format", e); } finally { if (resolver != null) { resolver.close(); } } }
From source file:marytts.unitselection.analysis.Phone.java
/** * Get all Datagrams in this phone's units * /*from w w w . j a v a2 s. com*/ * @return the left and right unit's Datagrams in an array */ public Datagram[] getUnitDataFrames() { Datagram[] leftUnitFrames = getLeftUnitFrames(); Datagram[] rightUnitFrames = getRightUnitFrames(); Datagram[] frames = (Datagram[]) ArrayUtils.addAll(leftUnitFrames, rightUnitFrames); return frames; }
From source file:edu.cornell.med.icb.goby.alignments.TestAlignmentReader.java
/** * Validate that the method/*w ww . j ava 2s.co m*/ * {@link AlignmentReaderImpl#getBasenames(String[])} * produces the proper results. */ @Test public void basenames() { assertTrue("Basename array should be empty", ArrayUtils.isEmpty(AlignmentReaderImpl.getBasenames())); final String[] nullArray = { null }; assertArrayEquals("Basename array should contain a single null element", nullArray, AlignmentReaderImpl.getBasenames((String) null)); final String[] emptyStringArray = { "" }; assertArrayEquals("Basename array should contain a single empty string element", emptyStringArray, AlignmentReaderImpl.getBasenames("")); final String[] foobarArray = { "foobar" }; assertArrayEquals("Basenames should be unchanged", foobarArray, AlignmentReaderImpl.getBasenames("foobar")); final String[] foobarTxtArray = { "foobar.txt" }; assertArrayEquals("Basenames should be unchanged", foobarTxtArray, AlignmentReaderImpl.getBasenames("foobar.txt")); assertArrayEquals("Basenames should be unchanged", ArrayUtils.addAll(foobarArray, foobarTxtArray), AlignmentReaderImpl.getBasenames("foobar", "foobar.txt")); final String basename = "mybasename"; final String[] basenameArray = { basename }; final String[] filenames = new String[FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS.length]; for (int i = 0; i < FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS.length; i++) { filenames[i] = basename + FileExtensionHelper.COMPACT_ALIGNMENT_FILE_EXTS[i]; } assertArrayEquals("Basename not stripped properly from " + ArrayUtils.toString(filenames), basenameArray, AlignmentReaderImpl.getBasenames(filenames)); }
From source file:com.rackspacecloud.blueflood.types.VarianceTest.java
@Test public void testRollupVariance() throws IOException { int size = TestData.DOUBLE_SRC.length; int GROUPS = 4; // split the input samples into 4 groups int windowSize = size / GROUPS; double[][] input = new double[GROUPS][windowSize]; // 4 groups of 31 samples each int count = 0; int i = 0;/*from w w w. j a v a2 s . co m*/ int j = 0; for (double val : TestData.DOUBLE_SRC) { input[i][j] = val; j++; count++; if (count % windowSize == 0) { i++; j = 0; } } // Compute variance for the 4 groups [simulate 5 MIN rollups from raw points] List<Rollup> rollups = new ArrayList<Rollup>(); List<Results> resultsList = new ArrayList<Results>(); for (i = 0; i < GROUPS; i++) { Rollup rollup = new Rollup(); Results r = new Results(); for (double val : input[i]) { rollup.handleFullResMetric(val); } r.expectedVariance = computeRawVariance(input[i]); r.computedVariance = rollup.getVariance().toDouble(); r.expectedAverage = computeRawAverage(input[i]); r.computedAverage = rollup.getAverage().toDouble(); rollups.add(rollup); resultsList.add(r); } // First check if individual rollup variances and averages are close to raw variance & average for the window // of samples for (i = 0; i < GROUPS; i++) { Results result = resultsList.get(i); assertWithinErrorPercent(result.computedAverage, result.expectedAverage); assertWithinErrorPercent(result.computedVariance, result.expectedVariance); } // Now compute net variance using rollup versions [simulate 10 min rollups by aggregating two 5 min rollups] Rollup rollup10min_0 = new Rollup(); rollup10min_0.handleRollupMetric(rollups.get(0)); rollup10min_0.handleRollupMetric(rollups.get(1)); assertWithinErrorPercent(rollup10min_0.getAverage().toDouble(), computeRawAverage(ArrayUtils.addAll(input[0], input[1]))); assertWithinErrorPercent(rollup10min_0.getVariance().toDouble(), computeRawVariance(ArrayUtils.addAll(input[0], input[1]))); Rollup rollup10min_1 = new Rollup(); rollup10min_1.handleRollupMetric(rollups.get(2)); rollup10min_1.handleRollupMetric(rollups.get(3)); assertWithinErrorPercent(rollup10min_1.getAverage().toDouble(), computeRawAverage(ArrayUtils.addAll(input[2], input[3]))); assertWithinErrorPercent(rollup10min_1.getVariance().toDouble(), computeRawVariance(ArrayUtils.addAll(input[2], input[3]))); // Simulate 20 min rollups by aggregating two 10 min rollups Rollup rollup20min_0 = new Rollup(); rollup20min_0.handleRollupMetric(rollup10min_0); rollup20min_0.handleRollupMetric(rollup10min_1); assertWithinErrorPercent(rollup20min_0.getAverage().toDouble(), computeRawAverage(TestData.DOUBLE_SRC)); assertWithinErrorPercent(rollup20min_0.getVariance().toDouble(), computeRawVariance(TestData.DOUBLE_SRC)); }
From source file:alluxio.shell.AlluxioShell.java
/** * Method which determines how to handle the user's request, will display usage help to the user * if command format is incorrect./*from ww w.j a va 2 s.c o m*/ * * @param argv [] Array of arguments given by the user's input from the terminal * @return 0 if command is successful, -1 if an error occurred */ public int run(String... argv) { if (argv.length == 0) { printUsage(); return -1; } // Sanity check on the number of arguments String cmd = argv[0]; ShellCommand command = mCommands.get(cmd); if (command == null) { // Unknown command (we didn't find the cmd in our dict) String[] replacementCmd = getReplacementCmd(cmd); if (replacementCmd == null) { System.out.println(cmd + " is an unknown command.\n"); printUsage(); return -1; } // Handle command alias, and print out WARNING message for deprecated cmd. String deprecatedMsg = "WARNING: " + cmd + " is deprecated. Please use " + StringUtils.join(replacementCmd, " ") + " instead."; System.out.println(deprecatedMsg); LOG.warn(deprecatedMsg); String[] replacementArgv = (String[]) ArrayUtils.addAll(replacementCmd, ArrayUtils.subarray(argv, 1, argv.length)); return run(replacementArgv); } String[] args = Arrays.copyOfRange(argv, 1, argv.length); CommandLine cmdline = command.parseAndValidateArgs(args); if (cmdline == null) { printUsage(); return -1; } // Handle the command try { command.run(cmdline); return 0; } catch (IOException e) { System.out.println(e.getMessage()); LOG.error("Error running " + StringUtils.join(argv, " "), e); return -1; } }
From source file:app.Des.java
private List<int[]> doKey() { int[] keyPermuted = this.tables.getPc1_Key(this.key); int[] keyL = ArrayUtils.subarray(keyPermuted, 0, keyPermuted.length / 2); int[] keyR = ArrayUtils.subarray(keyPermuted, keyPermuted.length / 2, keyPermuted.length); List<int[]> subkeysL = new ArrayList<>(); List<int[]> subkeysR = new ArrayList<>(); int[] lastL = Arrays.copyOf(keyL, keyL.length); int[] lastR = Arrays.copyOf(keyR, keyR.length); for (int shift : this.tables.getShiftKeyTable()) { int[] newKeyL = this.binMath.doLeftShift(lastL, shift); int[] newKeyR = this.binMath.doLeftShift(lastR, shift); subkeysL.add(newKeyL);/*from ww w . j a v a 2 s .com*/ subkeysR.add(newKeyR); lastL = newKeyL; lastR = newKeyR; } List<int[]> mergedAndPermuted = new ArrayList<>(); for (int i = 0; i < subkeysL.size(); i++) { int[] tempKey = new int[this.B_56]; tempKey = ArrayUtils.clone(subkeysL.get(i)); tempKey = ArrayUtils.addAll(tempKey, subkeysR.get(i)); mergedAndPermuted.add(this.tables.getPc2_Key(tempKey)); } return mergedAndPermuted; }