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:at.gv.egiz.bku.slcommands.impl.cms.ReferencedHashDataInput.java
public InputStream getHashDataInput() throws IOException { InputStream hashDataInputStream = urlDereferencer.dereference(urlReference).getStream(); try {/*from w ww. jav a 2 s . c o m*/ byte[] content = IOUtils.toByteArray(hashDataInputStream); if (excludedByteRange != null) { int from = excludedByteRange.getFrom().intValue(); int to = excludedByteRange.getTo().intValue(); byte[] signedContent = ArrayUtils.addAll(ArrayUtils.subarray(content, 0, from), ArrayUtils.subarray(content, to, content.length)); return new ByteArrayInputStream(signedContent); } else { return new ByteArrayInputStream(content); } } finally { hashDataInputStream.close(); } }
From source file:com.tutu.flume.ExtendableSinkCounter.java
public ExtendableSinkCounter(String name, Collection<String> args) { super(MonitoredCounterGroup.Type.SINK, name, (String[]) ArrayUtils.addAll(ATTRIBUTES, args.toArray())); }
From source file:info.magnolia.cms.filters.CompositeFilter.java
public void setFilters(MgnlFilter[] filters) { this.filters = (MgnlFilter[]) ArrayUtils.addAll(this.filters, filters); }
From source file:com.sforce.cd.apexUnit.client.fileReader.ApexManifestFileReader.java
public String[] fetchClassNamesFromManifestFiles(String files) { String[] apexClassesStrArr = null; String[] apexClassesStrArrForManifest = null; LOG.info("Reading from Manifest files: " + files); String[] manifestFiles = files.split(","); for (String file : manifestFiles) { LOG.info("Reading Manifest file from location : " + file); InputStream inStr;//from www. j a va 2s. c o m try { inStr = this.getClass().getClassLoader().getResourceAsStream(file); if (inStr != null) { apexClassesStrArrForManifest = readInputStreamAndConstructClassArray(inStr); } else { ApexUnitUtils.shutDownWithErrMsg( "Unable to find the file " + file + " in the src->main->resources folder"); } } catch (IOException e) { ApexUnitUtils.shutDownWithDebugLog(e, "IOException while trying to read the manifest file " + file); } if (apexClassesStrArrForManifest != null) { apexClassesStrArr = (String[]) ArrayUtils.addAll(apexClassesStrArr, apexClassesStrArrForManifest); } else { LOG.warn("Given manifest file " + file + " contains invalid/no test classes. 0 Apex test class id's returned"); } } Set<String> uniqueSetOfClasses = new HashSet<String>(); if (apexClassesStrArr != null && apexClassesStrArr.length > 0) { for (String apexClass : apexClassesStrArr) { if (!uniqueSetOfClasses.add(apexClass)) { LOG.warn("Duplicate entry found across manifest files for : " + ApexClassFetcherUtils.apexClassMap.get(apexClass) + " . Skipping multiple execution/code coverage computation of this test class/source class"); } } } String[] uniqueClassesAsArray = uniqueSetOfClasses.toArray(new String[uniqueSetOfClasses.size()]); if (LOG.isDebugEnabled()) { ApexClassFetcherUtils.logTheFetchedApexClasses(apexClassesStrArr); } return uniqueClassesAsArray; }
From source file:com.gargoylesoftware.htmlunit.WebResponseImplTest.java
private void recognizeBOM(final String encoding, final byte[] markerBytes) throws Exception { final WebClient webClient = new WebClient(); final MockWebConnection webConnection = new MockWebConnection(); final String html = "<html><head><script src='foo.js'></script></head><body></body></html>"; // see http://en.wikipedia.org/wiki/Byte_Order_Mark final String[] expectedAlerts = { "\u6211\u662F\u6211\u7684 " + "\u064A\u0627 \u0623\u0647\u0644\u0627\u064B" }; final byte[] script = ("alert('" + expectedAlerts[0] + "');").getBytes(encoding); webConnection.setDefaultResponse(ArrayUtils.addAll(markerBytes, script), 200, "OK", "text/javascript"); webConnection.setResponse(URL_FIRST, html); webClient.setWebConnection(webConnection); final List<String> collectedAlerts = new ArrayList<String>(); webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts)); webClient.getPage(URL_FIRST); assertEquals(expectedAlerts, collectedAlerts); }
From source file:net.michaelpigg.xbeelib.protocol.XbeeAddressTest.java
public void test64BitCombinedAddress() throws DecoderException { logger.info("test64BitCombinedAddress"); XbeeAddress address = XbeeAddress.getAddress(TEST_ADDR); byte[] combinedAddress = address.getCombinedAddress(); final byte[] expected = ArrayUtils.addAll(TEST_ADDR, XbeeAddress.BROADCAST_16_BIT); logger.info("actual value {}", Hex.encodeHexString(combinedAddress)); logger.info("expected value {}", Hex.encodeHexString(expected)); assertEquals(combinedAddress, expected); }
From source file:de.alpharogroup.io.annotations.ImportResourcesUtils.java
/** * Gets a map with 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 ImportResource objects found and the value is an Array of the ImportResource * objects that contains in the class.//from w ww . j av a2 s .c o m * * @param packageName * the package name * @return the import resources * @throws ClassNotFoundException * the class not found exception * @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 = AnnotationUtils.getAllAnnotatedClasses(packageName, importResourcesClass); final Set<Class<?>> importResourceClasses = AnnotationUtils.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:net.jolm.util.UserPasswordHelper.java
/** * Calculates hash of clear text password to be stored in the userPassword * field./* w ww .j av a 2 s. c om*/ * * @param clearpass * The password in plaintext that should be hashed. * @param alg * The algorithm to caculate the hash. * @param salt * The salt that is to be used together with the schemes {SMD5} * and {SSHA}. Should be between 8 and 16 Bytes. salt should be * null for any other scheme. * @return The base64-encoded hashed pwd with the following format: - * {MD5}base64(MD5-hash) for MD5 hashes - {SHA}base64(SHA-hash) for * SHA hashes - {SMD5}base64(MD5-hash+salt bytes) for SMD5 hashes - * {SSHA}base64(SHA-hash+salt bytes) for SSHA hashes Or null if t is * not one of 2, 3, 4, 5. */ public static byte[] clearPassToUserPassword(String clearpass, HashAlg alg, byte[] salt) { if (alg == null) { throw new IllegalArgumentException("Invalid hash argorithm."); } try { MessageDigest digester = null; StringBuilder resultInText = new StringBuilder(); switch (alg) { case MD5: resultInText.append("{MD5}"); digester = MessageDigest.getInstance("MD5"); break; case SMD5: resultInText.append("{SMD5}"); digester = MessageDigest.getInstance("MD5"); break; case SHA: resultInText.append("{SHA}"); digester = MessageDigest.getInstance("SHA"); break; case SSHA: resultInText.append("{SSHA}"); digester = MessageDigest.getInstance("SHA"); break; default: break; } digester.reset(); digester.update(clearpass.getBytes(DEFAULT_ENCODING)); byte[] hash = null; if (salt != null && (alg == HashAlg.SMD5 || alg == HashAlg.SSHA)) { digester.update(salt); hash = ArrayUtils.addAll(digester.digest(), salt); } else { hash = digester.digest(); } resultInText.append(new String(Base64.encodeBase64(hash), DEFAULT_ENCODING)); return resultInText.toString().getBytes(DEFAULT_ENCODING); } catch (UnsupportedEncodingException uee) { log.warn("Error occurred while hashing password ", uee); return new byte[0]; } catch (java.security.NoSuchAlgorithmException nse) { log.warn("Error occurred while hashing password ", nse); return new byte[0]; } }
From source file:com.aionemu.gameserver.services.reward.BonusService.java
public BonusItemGroup[] getGroupsByType(BonusType type) { switch (type) { case BOSS:/*w w w . ja va 2 s . c o m*/ return itemGroups.getBossGroups(); case ENCHANT: return itemGroups.getEnchantGroups(); case FOOD: return itemGroups.getFoodGroups(); case GATHER: return (BonusItemGroup[]) ArrayUtils.addAll(itemGroups.getOreGroups(), itemGroups.getGatherGroups()); case MANASTONE: return itemGroups.getManastoneGroups(); case MEDICINE: return itemGroups.getMedicineGroups(); case TASK: return itemGroups.getCraftGroups(); case MOVIE: return null; default: log.warn("Bonus of type " + type + " is not implemented"); return null; } }
From source file:com.github.tojo.session.cookies.SessionInACookieDefaultImpl.java
@Override public CookieValue encode(SessionData sessionData) throws CipherStrategyException { try {// w w w .jav a 2 s.c om // 1. create session id SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG", "SUN"); byte[] sessionId = new byte[SESSION_ID_LENGTH]; secureRandom.nextBytes(sessionId); // 2. prefix session data with the session id byte[] dataWithSessionId = ArrayUtils.addAll(sessionId, sessionData.asBytes()); // 3. calculate the cookie value CookieValue cookieValue = encryptSignAndEncode(dataWithSessionId); // 4. hit timeout strategy timeoutStrategy.issue(sessionData, cookieValue); return cookieValue; } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new RuntimeException(e); } }