/** * <p>Reverses a String that is delimited by a specific character.</p> * * <p>The Strings between the delimiters are not reversed. * Thus java.lang.String becomes String.lang.java (if the delimiter * is <code>'.'</code>).</p> * * <pre> * StringUtils.reverseDelimited(null, *) = null * StringUtils.reverseDelimited("", *) = "" * StringUtils.reverseDelimited("a.b.c", 'x') = "a.b.c" * StringUtils.reverseDelimited("a.b.c", ".") = "c.b.a" * </pre> * * @param str the String to reverse, may be null * @param separatorChar the separator character to use * @return the reversed String, <code>null</code> if null String input * @since 2.0 */ public static String reverseDelimited(String str, char separatorChar) { if (str == null) { return null; } // could implement manually, but simple way is to reuse other, // probably slower, methods. String[] strs = split(str, separatorChar); ArrayUtils.reverse(strs); return join(strs, separatorChar); }
public static EigenPair[] createReverseSortedEigenpairs(double[] eigenvalues, double[][] eigenvectors) { EigenPair[] eigenPairs = createSortedEigenpairs(eigenvalues, eigenvectors); reverse(eigenPairs); return eigenPairs; }
ArrayUtils.reverse(strs); if (separatorChars == null) { return join(strs, ' ');
/** * Read DECIMAL(P, S). * The representation of decimal in Teradata binary format is * the byte number to read is decided solely by the precision(P), * HiveDecimal is constructed through the byte array and scale. * the null DECIMAL will use 0x00 to pad. * * @param scale the scale * @param byteNum the byte num * @return the hive decimal * @throws IOException the io exception */ public HiveDecimal readDecimal(int scale, int byteNum) throws IOException { byte[] decimalContent = new byte[byteNum]; int numOfBytesRead = in.read(decimalContent); if (decimalContent.length != 0 && numOfBytesRead != byteNum) { throw new EOFException( format("Fail to read the decimal. Expect %d bytes, get %d bytes", byteNum, numOfBytesRead)); } ArrayUtils.reverse(decimalContent); return HiveDecimal.create(new BigInteger(decimalContent), scale); }
ArrayUtils.reverse(moduleIds);
ArrayUtils.reverse(content); write(content); if (byteNum > content.length) {
private static Object[][] reverse(Object[][] rows) { Object[][] reversedArray = new Object[rows.length][]; System.arraycopy(rows, 0, reversedArray, 0, rows.length); ArrayUtils.reverse(reversedArray); return reversedArray; }
public SnapshotObjectTO(SnapshotInfo snapshot) { this.path = snapshot.getPath(); this.setId(snapshot.getId()); VolumeInfo vol = snapshot.getBaseVolume(); if (vol != null) { this.volume = (VolumeObjectTO)vol.getTO(); this.setVmName(vol.getAttachedVmName()); } SnapshotInfo parentSnapshot = snapshot.getParent(); ArrayList<String> parentsArry = new ArrayList<String>(); if (parentSnapshot != null) { this.parentSnapshotPath = parentSnapshot.getPath(); while(parentSnapshot != null) { parentsArry.add(parentSnapshot.getPath()); parentSnapshot = parentSnapshot.getParent(); } parents = parentsArry.toArray(new String[parentsArry.size()]); ArrayUtils.reverse(parents); } this.dataStore = snapshot.getDataStore().getTO(); this.setName(snapshot.getName()); this.hypervisorType = snapshot.getHypervisorType(); this.quiescevm = false; }
public void reverse() { ArrayUtils.reverse(backend); }
private static long convertIndicatorToRLPSize(byte[] indicator) { byte[] rawDataNumber= Arrays.copyOfRange(indicator, 1, indicator.length); ArrayUtils.reverse(rawDataNumber); long RLPSize = 0; for (int i=0;i<rawDataNumber.length;i++) { RLPSize += (rawDataNumber[i] & 0xFF) * Math.pow(256, i); } return RLPSize; }
public static BigInteger fromIntArray(int[] input) { if (input.length != 2) { throw new IllegalArgumentException("input must have length 2"); } ArrayUtils.reverse(input); byte[] array = new byte[input.length * 4]; ByteBuffer bbuf = ByteBuffer.wrap(array); IntBuffer ibuf = bbuf.asIntBuffer(); ibuf.put(input); return new BigInteger(array); }
public static BigInteger generateId(String name, BigInteger parentId) { byte[] parentIdBytes = new byte[8]; ByteBuffer.wrap(parentIdBytes).put(parentId.toByteArray()); // GO ArrayUtils.reverse(parentIdBytes); byte[] bytes = name.getBytes(); byte[] result = Hashes.sha3_256(parentIdBytes, bytes); byte[] low = Arrays.copyOfRange(result, 0, 4); byte[] high = Arrays.copyOfRange(result, 4, 8); ArrayUtils.reverse(low); ArrayUtils.reverse(high); byte[] last = ArrayUtils.addAll(high, low); return new BigInteger(last); }
public static EigenPair[] createReverseSortedEigenpairs(double[] eigenvalues, double[][] eigenvectors) { EigenPair[] eigenPairs = createSortedEigenpairs(eigenvalues, eigenvectors); reverse(eigenPairs); return eigenPairs; }
/** * Returns a new byte array containing the contents of the input byte array * reversed. The input byte array is not modified. */ public byte[] reverse(byte[] input) { byte[] bytes = ArrayUtils.clone(input); ArrayUtils.reverse(bytes); return bytes; }
public Binary evaluate(Binary bytes) { ArrayUtils.reverse(bytes.data()); return bytes; } }
public void sendMessage(String str) { log.debug("Writing message: {}", str); try { BufferedOutputStream bos = new BufferedOutputStream(this.socket.getOutputStream()); byte[] len = ByteBuffer.allocate(8).putLong(str.length()).array(); ArrayUtils.reverse(len); ByteBuffer wrap = ByteBuffer.allocate(str.length() + 8); byte[] array = wrap.put(len).put(str.getBytes()).array(); bos.write(array); bos.flush(); } catch (IOException e) { log.error("occurred some exception", e); } }
static byte[] getKey(byte[] row, byte[] col, long timeStamp) { Preconditions.checkArgument(EncodingUtils.sizeOfVarLong(row.length) <= 2); byte[] rowSize = EncodingUtils.encodeVarLong(row.length); ArrayUtils.reverse(rowSize); byte[] key = new byte[row.length + col.length + 8 + rowSize.length]; ByteBuffer.wrap(key).order(ByteOrder.BIG_ENDIAN) .put(row) .put(col) .putLong(timeStamp) .put(rowSize); return key; }
protected String[] getSortedUsernames18xDesc(int offset, int pageSize) { String[] usernames = getSortedUsernames18x(); ArrayUtils.reverse(usernames); return Arrays.copyOfRange(usernames, offset, offset + pageSize); }
private static void keywords(LexerlessGrammarBuilder b) { b.rule(LETTER_OR_DIGIT).is(javaIdentifierPart(b)); for (JavaKeyword tokenType : JavaKeyword.values()) { b.rule(tokenType).is(tokenType.getValue(), b.nextNot(LETTER_OR_DIGIT), SPACING); } String[] keywords = JavaKeyword.keywordValues(); Arrays.sort(keywords); ArrayUtils.reverse(keywords); b.rule(KEYWORD).is( b.firstOf( keywords[0], keywords[1], ArrayUtils.subarray(keywords, 2, keywords.length)), b.nextNot(LETTER_OR_DIGIT)); }
private static void keywords(LexerlessGrammarBuilder b) { b.rule(LETTER_OR_DIGIT).is(javaIdentifierPart(b)); for (JavaKeyword tokenType : JavaKeyword.values()) { b.rule(tokenType).is(tokenType.getValue(), b.nextNot(LETTER_OR_DIGIT), SPACING); } String[] keywords = JavaKeyword.keywordValues(); Arrays.sort(keywords); ArrayUtils.reverse(keywords); b.rule(KEYWORD).is( b.firstOf( keywords[0], keywords[1], ArrayUtils.subarray(keywords, 2, keywords.length)), b.nextNot(LETTER_OR_DIGIT)); }