/** * Returns a string representing the current running average. Will return * a String of the double with the precision set in the constructor. * <br> * NOTE: Will use a readLock to get a thread-safe version. * @return */ @Override public String toString() { return DecimalUtil.toString(getAverage(), precision); }
protected void resetCountsAndRebuildRemainingItems() { // reset all counts back to zero for (Node<E> node : allItems) { node.setCount(0); } // now rebuild the whole thing this.rebuildRemainingItems(); }
/** * Return a hexidecimal String representation of the current buffer with each byte * displayed in a 2 character hexidecimal format. Useful for debugging. * Convert a ByteBuffer to a String with a hexidecimal format. * @return The string in hex representation */ public String toHexString() { return toHexString(0, size()); }
/** * Finds an instance of an Enum constant on a class. Useful for safely * getting the value of an enum constant without an exception being thrown * like the Enum.valueOf() method causes. Searches for enum constant * where case is sensitive. */ public static Object findEnumConstant(Class<?> type, String constantName) { return findEnumConstant(type, constantName, true); }
/** * N.B. <code>asBytes()</code> returns a copy of the underlying byte array * * @return The instance as its underlying byte array */ public byte[] asBytes() { return copyByteArray(bytes); }
public static short toShort(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 2); short v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; return v; }
/** * Copy the source file to the target file. * @param sourceFile The source file to copy from * @param targetFile The target file to copy to * @throws FileAlreadyExistsException Thrown if the target file already * exists. This exception is a subclass of IOException, so catching * an IOException is enough if you don't care about this specific reason. * @throws IOException Thrown if an error during the copy */ public static void copy(File sourceFile, File targetFile) throws FileAlreadyExistsException, IOException { copy(sourceFile, targetFile, false); }
/** * Checks if the targetString is contained within the array of strings. This * method will return true if a "null" is contained in the array and the * targetString is also null. * @param strings The array of strings to search. * @param targetString The string to search for * @return True if the string is contained within, otherwise false. Also * returns false if the strings array is null. */ static public boolean contains(String[] strings, String targetString) { return (indexOf(strings, targetString) != -1); }
/** * Quote a string so that it can be used as a string literal in an * SQL statement. * * @param string the string to quote * @return the string surrounded by single quotes and with proper escaping * of any single quotes inside the string */ public static String quoteStringLiteral(String string) { return quoteString(string, '\''); }
private void checkReset() { if (this.resetOnZero && this.size == 0) { reset(); } }
/** * Prints out a dump of the hierarchy of this AddressTree * to the specified PrintStream. */ public void debug(java.io.PrintStream out) { // start at parent node... dumpNode(root, 0, -2, out); }
/** * Creates a synchronized version of a LoadBalancedList by putting a lock * around any method that reads or writes to the internal data structure. * @param list The list to synchronize * @return A wrapper around the original list that provides synchronized access. */ static public <E> LoadBalancedList<E> synchronizedList(LoadBalancedList<E> list) { return new ConcurrentLoadBalancedList<E>(list); }
/** * Returns a string representing the current running average, but will use * the new precision rather than the one in the constructor. * <br> * NOTE: Will use a readLock to get a thread-safe version. * @return */ public String toString(int temporaryPrecision) { return DecimalUtil.toString(getAverage(), temporaryPrecision); }
protected void resetCountsAndRebuildRemainingItems() { // reset all counts back to zero for (Node<E> node : allItems) { node.setCount(0); } // now rebuild the whole thing this.rebuildRemainingItems(); }
/** * N.B. <code>asBytes()</code> returns a copy of the underlying byte array * * @return The instance as its underlying byte array */ public byte[] asBytes() { return copyByteArray(bytes); }
public static long toUnsignedInt(byte[] bytes, int offset, int length) { checkBytes(bytes, offset, length, 4); long v = 0; v |= bytes[offset] & 0xFF; v <<= 8; v |= bytes[offset+1] & 0xFF; v <<= 8; v |= bytes[offset+2] & 0xFF; v <<= 8; v |= bytes[offset+3] & 0xFF; return v; }
/** * Returns a string representing the current running average. Will return * a String of the double with the precision set in the constructor. * <br> * NOTE: Will use a readLock to get a thread-safe version. * @return */ @Override public String toString() { return DecimalUtil.toString(getAverage(), precision); }
/** * Returns a string representing the current running average, but will use * the new precision rather than the one in the constructor. * <br> * NOTE: Will use a readLock to get a thread-safe version. * @return */ public String toString(int temporaryPrecision) { return DecimalUtil.toString(getAverage(), temporaryPrecision); }