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:edu.utdallas.bigsecret.cipher.test.TestAesEcb.java
@Test public void testDecryptByteArrayInt() { byte[] key = Bytes.toBytes("1234567890123456"); try {//from w w w . j av a 2s .co m AesEcb cip = new AesEcb(key); byte[] originalData = Bytes.toBytes("mr. anderson, we missed you"); System.out.println("Original Data: "); printArray(originalData); byte[] encData = cip.encrypt(originalData); System.out.println("Encrypted Data: "); printArray(encData); byte[] pad = new byte[2]; pad[0] = 1; pad[1] = 0; byte[] padded = ArrayUtils.addAll(pad, encData); byte[] decData = cip.decrypt(padded, 2); System.out.println("Decrypted Data: "); printArray(decData); if (!Arrays.equals(originalData, decData)) { fail("AesEcb encryption decryption mechanism failed. Data changes after encryption and decryption!!"); } } catch (Exception e) { fail("AesEcb encrypt test failed."); e.printStackTrace(); } }
From source file:edu.utdallas.bigsecret.cipher.test.TestAesCtr.java
@Test public void testDecryptByteArrayInt() { byte[] key = Bytes.toBytes("1234567890123456"); try {/*from w w w. j av a 2 s . c om*/ AesCtr cip = new AesCtr(key); byte[] originalData = Bytes.toBytes("He is the one."); System.out.println("Original Data: "); printArray(originalData); byte[] encData = cip.encrypt(originalData); System.out.println("Encrypted Data: "); printArray(encData); byte[] pad = new byte[2]; pad[0] = 1; pad[1] = 0; byte[] padded = ArrayUtils.addAll(pad, encData); byte[] decData = cip.decrypt(padded, 2); System.out.println("Decrypted Data: "); printArray(decData); if (!Arrays.equals(originalData, decData)) { fail("AesCtr encryption decryption mechanism failed. Data changes after encryption and decryption!!"); } } catch (Exception e) { fail("AesCtr encrypt test failed."); e.printStackTrace(); } }
From source file:de.alpharogroup.io.annotations.ImportResourcesExtensions.java
/** * Gets a {@link Map} with {@link ImportResource} objects and the corresponding to the found * class from the given package Name. The search is made recursive. The key from an entry of the * map is the class where the {@link ImportResource} objects found and the value is an Array of * the {@link ImportResource} objects that contains in the class. * * @param packageName//from w w w . j a v a 2s. co m * the package name * @return the import resources * @throws ClassNotFoundException * occurs if a given class cannot be located by the specified class loader * @throws IOException * Signals that an I/O exception has occurred. */ public static Map<Class<?>, ImportResource[]> getImportResources(final String packageName) throws ClassNotFoundException, IOException { final Map<Class<?>, ImportResource[]> resourcesMap = new LinkedHashMap<>(); final Class<ImportResources> importResourcesClass = ImportResources.class; final Class<ImportResource> importResourceClass = ImportResource.class; final Set<Class<?>> importResourcesClasses = AnnotationExtensions.getAllAnnotatedClasses(packageName, importResourcesClass); final Set<Class<?>> importResourceClasses = AnnotationExtensions.getAllAnnotatedClasses(packageName, importResourceClass); importResourcesClasses.addAll(importResourceClasses); for (final Class<?> annotatedClass : importResourcesClasses) { final ImportResources importResources = annotatedClass.getAnnotation(ImportResources.class); ImportResource[] importResourcesArray = null; ImportResource[] importResourceArray = null; if (importResources != null) { importResourcesArray = importResources.resources(); } final ImportResource importResource = annotatedClass.getAnnotation(ImportResource.class); if (importResource != null) { importResourceArray = new ImportResource[1]; importResourceArray[0] = importResource; } final ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray, importResourcesArray); Arrays.sort(array, new ImportResourceComparator()); resourcesMap.put(annotatedClass, array); } return resourcesMap; }
From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.collector.TesseractResultRecordCollector.java
/** * //from www .j a va 2 s .co m * Constructor by * @param dimFields dimFields * @param measureFields measureFields */ public TesseractResultRecordCollector(String[] dimFields, String[] measureFields, Set<String> groupByFields) { this.dimFields = dimFields; this.measureFields = measureFields; this.result = new ArrayList<ResultRecord>(); this.currBinaryDocValuesMap = new HashMap<String, BinaryDocValues>(); this.currDoubleValuesMap = new HashMap<String, FieldCache.Doubles>(); this.meta = new Meta((String[]) ArrayUtils.addAll(dimFields, measureFields)); if (groupByFields == null) { groupByFields = new HashSet<String>(1); } this.groupByFields = groupByFields; }
From source file:com.github.tojo.session.cookies.SignatureStrategyDefaultImpl.java
@Override public byte[] sign(byte[] sessionData) { assertNotNullAndEmpty(sessionData);/*from w ww.j av a2 s.co m*/ byte[] signature = null; try { Mac mac = Mac.getInstance(HMAC_SHA256); mac.init(key); signature = mac.doFinal(sessionData); } catch (NoSuchAlgorithmException | InvalidKeyException e) { throw new InitializationException(e); } byte[] signedSessionData = ArrayUtils.addAll(signature, sessionData); return signedSessionData; }
From source file:ee.sk.hwcrypto.demo.signature.TestSigningData.java
private static byte[] addPadding(byte[] digest, DigestAlgorithm digestAlgorithm) { return ArrayUtils.addAll(digestAlgorithm.digestInfoPrefix(), digest); }
From source file:hudson.plugins.cloneworkspace.CloneWorkspaceCompleteDirScanner.java
/** * Ant pattern to FileFilter converter (mimic the {@link hudson.util.DirScanner.Glob} behavior) *//*www. ja v a 2 s . c o m*/ public static FileFilter AntToFileFilter(File directory, String includes, String excludes, boolean useDefaultExcludes) { // Identical steps as the DirScanner.Glob to interpret the Ant pattern FileSet fs = Util.createFileSet(directory, includes, excludes); fs.setDefaultexcludes(useDefaultExcludes); // Join lists to copy both files and directories DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project()); String[] includedFilesName = (String[]) ArrayUtils.addAll(ds.getIncludedDirectories(), ds.getIncludedFiles()); // Create matching File object List<File> includedFiles = new ArrayList<File>(); for (String itemPath : includedFilesName) { includedFiles.add(new File(directory, itemPath)); } return new CompleteFileFilter(includedFiles); }
From source file:alluxio.cli.AbstractShell.java
/** * Handles the specified shell command request, displaying usage if the command format is invalid. * * @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 */// w w w . jav a2 s. c o m public int run(String... argv) { if (argv.length == 0) { printUsage(); return -1; } // Sanity check on the number of arguments String cmd = argv[0]; Command command = mCommands.get(cmd); if (command == null) { String[] replacementCmd = getReplacementCmd(cmd); if (replacementCmd == null) { // Unknown command (we didn't find the cmd in our dict) System.err.println(String.format("%s is an unknown command.", cmd)); printUsage(); return -1; } else { // 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); 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; try { cmdline = command.parseAndValidateArgs(args); } catch (InvalidArgumentException e) { System.out.println("Usage: " + command.getUsage()); LOG.error("Invalid arguments for command {}:", command.getCommandName(), e); return -1; } // Handle the command try { return command.run(cmdline); } catch (Exception e) { System.out.println(e.getMessage()); LOG.error("Error running " + StringUtils.join(argv, " "), e); return -1; } }
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); }/*from ww w . ja v a 2 s . c om*/ outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } outputNestedLayerEnd(writer); } }
From source file:com.opengamma.web.analytics.blotter.OtcTradeBuilderTest.java
private static BeanDataSource createTradeData(Object... valuePairs) { Object[] basicData = { "type", "OtcTrade", "counterparty", "testCpty", "tradeDate", "2012-12-21", "tradeTime", "10:00", "premium", "1234", "premiumCurrency", "GBP", "premiumDate", "2012-12-25", "premiumTime", "13:00", "attributes", ATTRIBUTES }; Object[] tradeData = ArrayUtils.addAll(basicData, valuePairs); return BlotterTestUtils.beanData(tradeData); }