public class DataHelper
extends java.lang.Object
修飾子とタイプ | フィールド | 説明 |
---|---|---|
static byte |
BOOLEAN_FALSE |
deprecated - used only in DatabaseLookupMessage
|
static int |
BOOLEAN_LENGTH |
推奨されていません。
unused
|
static byte |
BOOLEAN_TRUE |
deprecated - used only in DatabaseLookupMessage
|
static byte |
BOOLEAN_UNKNOWN |
推奨されていません。
unused
|
static int |
DATE_LENGTH |
|
static int |
MAX_COMPRESSION |
|
static int |
MAX_UNCOMPRESSED |
|
static int |
NO_COMPRESSION |
コンストラクタ | 説明 |
---|---|
DataHelper() |
修飾子とタイプ | メソッド | 説明 |
---|---|---|
static int |
compareTo(byte[] lhs,
byte[] rhs) |
Big endian compare, treats bytes as unsigned.
|
static byte[] |
compress(byte[] orig) |
Compress the data and return a new GZIP compressed byte array.
|
static byte[] |
compress(byte[] orig,
int offset,
int size) |
Compress the data and return a new GZIP compressed byte array.
|
static byte[] |
compress(byte[] orig,
int offset,
int size,
int level) |
Compress the data and return a new GZIP compressed byte array.
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out) |
Copy in to out.
|
static byte[] |
decompress(byte[] orig) |
Decompress the GZIP compressed data (returning null on error).
|
static byte[] |
decompress(byte[] orig,
int offset,
int length) |
Decompress the GZIP compressed data (returning null on error).
|
static boolean |
eq(byte[] lhs,
byte[] rhs) |
Run a comparison on the byte arrays, byte by byte.
|
static boolean |
eq(byte[] lhs,
int offsetLeft,
byte[] rhs,
int offsetRight,
int length) |
Unlike eq(byte[], byte[]), this returns false if either lhs or rhs is null.
|
static boolean |
eq(byte lhs,
byte rhs) |
推奨されていません。
inefficient
|
static boolean |
eq(int lhs,
int rhs) |
推奨されていません。
inefficient
|
static boolean |
eq(long lhs,
long rhs) |
推奨されていません。
inefficient
|
static boolean |
eq(java.lang.Object lhs,
java.lang.Object rhs) |
Helper util to compare two objects, including null handling.
|
static boolean |
eq(java.util.Collection<?> lhs,
java.util.Collection<?> rhs) |
Run a deep comparison across the two collections.
|
static boolean |
eqCT(byte[] lhs,
int offsetLeft,
byte[] rhs,
int offsetRight,
int length) |
Unlike eq(), this throws NPE if either lhs or rhs is null.
|
static java.lang.String |
escapeHTML(java.lang.String unescaped) |
Escape a string for inclusion in HTML
|
static java.lang.String |
formatDuration(long ms) |
NOTE: formatDuration2() recommended in most cases for readability
|
static java.lang.String |
formatDuration2(double ms) |
Like formatDuration2(long) but with microsec and nanosec also.
|
static java.lang.String |
formatDuration2(long ms) |
Like formatDuration but with a non-breaking space after the number,
0 is unitless, and the unit is translated.
|
static java.lang.String |
formatSize(long bytes) |
This is binary, i.e.
|
static java.lang.String |
formatSize2(long bytes) |
This is binary, i.e.
|
static java.lang.String |
formatSize2(long bytes,
boolean nonBreaking) |
This is binary, i.e.
|
static java.lang.String |
formatSize2Decimal(long bytes) |
This is decimal, i.e.
|
static java.lang.String |
formatSize2Decimal(long bytes,
boolean nonBreaking) |
This is decimal, i.e.
|
static java.lang.Boolean |
fromBoolean(byte[] data,
int offset) |
推奨されていません。
unused
|
static java.util.Date |
fromDate(byte[] src,
int offset) |
|
static byte[] |
fromHexString(java.lang.String val) |
推奨されていません。
unused
|
static long |
fromLong(byte[] src,
int offset,
int numBytes) |
Big endian.
|
static long |
fromLongLE(byte[] src,
int offset,
int numBytes) |
Little endian, i.e.
|
static int |
fromProperties(byte[] source,
int offset,
java.util.Properties target) |
Reads the props from the byte array and puts them in the Properties target
See readProperties() for the format.
|
static byte[] |
getASCII(java.lang.String orig) |
Roughly the same as orig.getBytes("ISO-8859-1") but much faster and
will not throw an exception.
|
static java.lang.String |
getUTF8(byte[] orig) |
Same as new String(orig, "UTF-8") but throws an unchecked RuntimeException
instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
|
static java.lang.String |
getUTF8(byte[] orig,
int offset,
int len) |
Same as new String(orig, "UTF-8") but throws an unchecked RuntimeException
instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
|
static byte[] |
getUTF8(java.lang.String orig) |
Same as orig.getBytes("UTF-8") but throws an unchecked RuntimeException
instead of an UnsupportedEncodingException if no UTF-8, for ease of use.
|
static byte[] |
getUTF8(java.lang.StringBuffer orig) |
推奨されていません。
unused
|
static int |
hashCode(byte[] b) |
Calculate the hashcode of the byte array, using 0 for null
|
static int |
hashCode(java.lang.Object obj) |
Calculate the hashcode of the object, using 0 for null
|
static int |
hashCode(java.util.Collection<?> col) |
Calculate the hashcode of the collection, using 0 for null
|
static int |
hashCode(java.util.Date obj) |
Calculate the hashcode of the date, using 0 for null
|
static void |
loadProps(java.util.Properties props,
java.io.File file) |
A more efficient Properties.load
Some of the other differences:
- UTF-8 encoding, not ISO-8859-1
- No escaping! This does not process or drop backslashes
- '#' or ';' starts a comment line, but '!' does not
- Leading whitespace is not trimmed
- '=' is the only key-termination character (not ':' or whitespace)
As of 0.9.10, an empty value is allowed.
|
static void |
loadProps(java.util.Properties props,
java.io.File file,
boolean forceLowerCase) |
|
static void |
loadProps(java.util.Properties props,
java.io.InputStream inStr) |
|
static void |
loadProps(java.util.Properties props,
java.io.InputStream inStr,
boolean forceLowerCase) |
|
static int |
read(java.io.InputStream in,
byte[] target) |
This is different than InputStream.read(target), in that it
does repeated reads until the full data is received.
|
static int |
read(java.io.InputStream in,
byte[] target,
int offset,
int length) |
WARNING - This is different than InputStream.read(target, offset, length)
for a nonzero offset, in that it
returns the new offset (== old offset + length).
|
static java.lang.Boolean |
readBoolean(java.io.InputStream in) |
推奨されていません。
unused
|
static java.util.Date |
readDate(java.io.InputStream in) |
Read in a date from the stream as specified by the I2P data structure spec.
|
static java.lang.String |
readLine(java.io.InputStream in) |
Read a newline delimited line from the stream, returning the line (without
the newline), or null if EOF reached on an empty line
Warning - strips \n but not \r
Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
Warning - not UTF-8
|
static boolean |
readLine(java.io.InputStream in,
java.lang.StringBuilder buf) |
Read in a line, placing it into the buffer (excluding the newline).
|
static boolean |
readLine(java.io.InputStream in,
java.lang.StringBuilder buf,
java.security.MessageDigest hash) |
update the hash along the way
Warning - strips \n but not \r
Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
Warning - not UTF-8
|
static java.lang.String |
readLine(java.io.InputStream in,
java.security.MessageDigest hash) |
update the hash along the way
Warning - strips \n but not \r
Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded
Warning - not UTF-8
|
static long |
readLong(java.io.InputStream rawStream,
int numBytes) |
Read the stream for an integer as defined by the I2P data structure specification.
|
static java.util.Properties |
readProperties(java.io.InputStream rawStream) |
Read a mapping from the stream, as defined by the I2P data structure spec,
and store it into a Properties object.
|
static java.util.Properties |
readProperties(java.io.InputStream rawStream,
java.util.Properties props) |
Ditto, load into an existing properties
As of 0.9.18, throws DataFormatException on duplicate key
|
static java.lang.String |
readString(java.io.InputStream in) |
Read in a string from the stream as specified by the I2P data structure spec.
|
static void |
replace(java.lang.StringBuilder buf,
java.lang.String from,
java.lang.String to) |
Replace all instances of "from" with "to" in the StringBuilder buf.
|
static void |
skip(java.io.InputStream in,
long n) |
This is different than InputStream.skip(), in that it
does repeated reads until the full amount is skipped.
|
static <T> void |
sort(java.util.List<T> list,
java.util.Comparator<? super T> c) |
Same as Collections.sort(), but guaranteed not to throw an IllegalArgumentException if the
sort is unstable.
|
static <T> void |
sort(T[] a,
java.util.Comparator<? super T> c) |
Same as Arrays.sort(), but guaranteed not to throw an IllegalArgumentException if the
sort is unstable.
|
static java.lang.String[] |
split(java.lang.String s,
java.lang.String regex) |
Same as s.split(regex) but caches the compiled pattern for speed.
|
static java.lang.String[] |
split(java.lang.String s,
java.lang.String regex,
int limit) |
Same as s.split(regex, limit) but caches the compiled pattern for speed.
|
static void |
storeProps(java.util.Properties props,
java.io.File file) |
Writes the props to the file, unsorted (unless props is an OrderedProperties)
Note that this does not escape the \r or \n that are unescaped in loadProps() above.
|
static java.lang.String |
stripHTML(java.lang.String orig) |
Strip out any HTML (simply removing any less than / greater than symbols)
|
static void |
toBoolean(byte[] data,
int offset,
boolean value) |
推奨されていません。
unused
|
static void |
toBoolean(byte[] data,
int offset,
java.lang.Boolean value) |
推奨されていません。
unused
|
static void |
toDate(byte[] target,
int offset,
long when) |
|
static byte[] |
toDate(java.util.Date date) |
推奨されていません。
unused
|
static java.lang.String |
toDecimalString(byte[] buf,
int len) |
推奨されていません。
unused
|
static java.lang.String |
toHexString(byte[] data) |
Lower-case hex without leading zeros.
|
static void |
toLong(byte[] target,
int offset,
int numBytes,
long value) |
Big endian.
|
static byte[] |
toLong(int numBytes,
long value) |
Big endian.
|
static void |
toLongLE(byte[] target,
int offset,
int numBytes,
long value) |
Little endian, i.e.
|
static int |
toProperties(byte[] target,
int offset,
java.util.Properties props) |
推奨されていません。
|
static byte[] |
toProperties(java.util.Properties opts) |
Writes the props to returned byte array, not sorted
(unless the opts param is an OrderedProperties)
Strings will be UTF-8 encoded in the byte array.
|
static java.lang.String |
toString(byte[] buf) |
Lower-case hex with leading zeros.
|
static java.lang.String |
toString(byte[] buf,
int len) |
Lower-case hex with leading zeros.
|
static java.lang.String |
toString(java.util.Collection<?> col) |
Pretty print the collection
|
static java.lang.String |
toString(java.util.Map<?,?> options) |
Pretty print the mapping, unsorted
(unless the options param is an OrderedProperties)
|
static java.lang.String |
toString(java.util.Properties options) |
Pretty print the mapping, unsorted
(unless the options param is an OrderedProperties)
|
static void |
write(java.io.OutputStream out,
byte[] data,
java.security.MessageDigest hash) |
update the hash along the way
|
static void |
writeBoolean(java.io.OutputStream out,
java.lang.Boolean bool) |
推奨されていません。
unused
|
static void |
writeDate(java.io.OutputStream out,
java.util.Date date) |
Write out a date to the stream as specified by the I2P data structure spec.
|
static void |
writeLong(java.io.OutputStream rawStream,
int numBytes,
long value) |
Write an integer as defined by the I2P data structure specification to the stream.
|
static void |
writeProperties(java.io.OutputStream rawStream,
java.util.Properties props) |
Write a mapping to the stream, as defined by the I2P data structure spec,
and store it into a Properties object.
|
static void |
writeProperties(java.io.OutputStream rawStream,
java.util.Properties props,
boolean utf8) |
Writes the props to the stream, sorted by property name.
|
static void |
writeProperties(java.io.OutputStream rawStream,
java.util.Properties props,
boolean utf8,
boolean sort) |
Writes the props to the stream, sorted by property name if sort == true or
if props is an OrderedProperties.
|
static void |
writeString(java.io.OutputStream out,
java.lang.String string) |
Write out a string to the stream as specified by the I2P data structure spec.
|
static void |
writeStringUTF8(java.io.OutputStream out,
java.lang.String string) |
Write out a string to the stream as specified by the I2P data structure spec.
|
static byte[] |
xor(byte[] lhs,
byte[] rhs) |
|
static void |
xor(byte[] lhs,
int startLeft,
byte[] rhs,
int startRight,
byte[] out,
int startOut,
int len) |
xor the lhs with the rhs, storing the result in out.
|
public static final int DATE_LENGTH
public static final byte BOOLEAN_TRUE
public static final byte BOOLEAN_FALSE
@Deprecated public static final byte BOOLEAN_UNKNOWN
@Deprecated public static final int BOOLEAN_LENGTH
public static final int MAX_UNCOMPRESSED
public static final int MAX_COMPRESSION
public static final int NO_COMPRESSION
public static java.util.Properties readProperties(java.io.InputStream rawStream) throws DataFormatException, java.io.IOException
rawStream
- stream to read the mapping fromDataFormatException
- if the format is invalidjava.io.IOException
- if there is a problem reading the datapublic static java.util.Properties readProperties(java.io.InputStream rawStream, java.util.Properties props) throws DataFormatException, java.io.IOException
props
- the Properties to load intorawStream
- stream to read the mapping fromDataFormatException
- if the format is invalidjava.io.IOException
- if there is a problem reading the datapublic static void writeProperties(java.io.OutputStream rawStream, java.util.Properties props) throws DataFormatException, java.io.IOException
rawStream
- stream to write toprops
- properties to write out, may be nullDataFormatException
- if there is not enough valid data to write out,
or a length limit is exceededjava.io.IOException
- if there is an IO error writing out the datapublic static void writeProperties(java.io.OutputStream rawStream, java.util.Properties props, boolean utf8) throws DataFormatException, java.io.IOException
props
- source may be nullDataFormatException
- if a length limit is exceededjava.io.IOException
public static void writeProperties(java.io.OutputStream rawStream, java.util.Properties props, boolean utf8, boolean sort) throws DataFormatException, java.io.IOException
props
- source may be nullsort
- should we sort the properties? (set to false if already sorted, e.g. OrderedProperties)DataFormatException
- if any string is over 255 bytes long, or if the total length
(not including the two length bytes) is greater than 65535 bytes.java.io.IOException
@Deprecated public static int toProperties(byte[] target, int offset, java.util.Properties props) throws DataFormatException, java.io.IOException
DataFormatException
java.io.IOException
public static int fromProperties(byte[] source, int offset, java.util.Properties target) throws DataFormatException
source
- sourcetarget
- returned PropertiesDataFormatException
public static byte[] toProperties(java.util.Properties opts) throws DataFormatException
DataFormatException
- if key, value, or total is too longpublic static java.lang.String toString(java.util.Properties options)
public static java.lang.String toString(java.util.Map<?,?> options)
public static void loadProps(java.util.Properties props, java.io.File file) throws java.io.IOException
java.io.IOException
public static void loadProps(java.util.Properties props, java.io.File file, boolean forceLowerCase) throws java.io.IOException
forceLowerCase
- if true forces the keys to lower case (not the values)java.io.IOException
public static void loadProps(java.util.Properties props, java.io.InputStream inStr) throws java.io.IOException
java.io.IOException
public static void loadProps(java.util.Properties props, java.io.InputStream inStr, boolean forceLowerCase) throws java.io.IOException
forceLowerCase
- if true forces the keys to lower case (not the values)java.io.IOException
public static void storeProps(java.util.Properties props, java.io.File file) throws java.io.IOException
java.lang.IllegalArgumentException
- if a key contains any of "#=\n" or starts with ';',
or a value contains '#' or '\n'java.io.IOException
public static java.lang.String toString(java.util.Collection<?> col)
public static java.lang.String toString(byte[] buf)
buf
- may be null (returns "")public static java.lang.String toString(byte[] buf, int len)
buf
- may be nulllen
- number of bytes. If greater than buf.length, additional zeros will be prependedpublic static java.lang.String toDecimalString(byte[] buf, int len)
buf
- may be null (returns "0")len
- unusedpublic static final java.lang.String toHexString(byte[] data)
data
- may be null (returns "00")public static final byte[] fromHexString(java.lang.String val)
val
- non-null, may have leading minus signpublic static long readLong(java.io.InputStream rawStream, int numBytes) throws DataFormatException, java.io.IOException
rawStream
- stream to read fromnumBytes
- number of bytes to read and format into a number, 1 to 8DataFormatException
- if negative (only possible if numBytes = 8) (since 0.8.12)java.io.EOFException
- since 0.8.2, if there aren't enough bytes to read the numberjava.io.IOException
- if there is an IO error reading the numberpublic static void writeLong(java.io.OutputStream rawStream, int numBytes, long value) throws DataFormatException, java.io.IOException
value
- value to write out, non-negativerawStream
- stream to write tonumBytes
- number of bytes to write the number into, 1-8 (padding as necessary)DataFormatException
- if value is negative or if numBytes not 1-8java.io.IOException
- if there is an IO error writing to the streampublic static byte[] toLong(int numBytes, long value) throws java.lang.IllegalArgumentException
numBytes
- 1-8value
- non-negativejava.lang.IllegalArgumentException
public static void toLong(byte[] target, int offset, int numBytes, long value) throws java.lang.IllegalArgumentException
numBytes
- 1-8value
- non-negativejava.lang.IllegalArgumentException
public static void toLongLE(byte[] target, int offset, int numBytes, long value)
numBytes
- 1-8value
- non-negativepublic static long fromLong(byte[] src, int offset, int numBytes)
src
- if null returns 0numBytes
- 1-8java.lang.ArrayIndexOutOfBoundsException
java.lang.IllegalArgumentException
- if negative (only possible if numBytes = 8)public static long fromLongLE(byte[] src, int offset, int numBytes)
numBytes
- 1-8java.lang.ArrayIndexOutOfBoundsException
java.lang.IllegalArgumentException
- if negative (only possible if numBytes = 8)public static java.util.Date readDate(java.io.InputStream in) throws DataFormatException, java.io.IOException
in
- stream to read fromDataFormatException
- if the stream doesn't contain a validly formatted datejava.io.IOException
- if there is an IO error reading the datepublic static void writeDate(java.io.OutputStream out, java.util.Date date) throws DataFormatException, java.io.IOException
out
- stream to write todate
- date to write (can be null)DataFormatException
- if the date is not validjava.io.IOException
- if there is an IO error writing the date@Deprecated public static byte[] toDate(java.util.Date date) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static void toDate(byte[] target, int offset, long when) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.util.Date fromDate(byte[] src, int offset) throws DataFormatException
public static java.lang.String readString(java.io.InputStream in) throws DataFormatException, java.io.IOException
in
- stream to read fromDataFormatException
- if the stream doesn't contain a validly formatted stringjava.io.EOFException
- since 0.8.2, if there aren't enough bytes to read the stringjava.io.IOException
- if there is an IO error reading the stringpublic static void writeString(java.io.OutputStream out, java.lang.String string) throws DataFormatException, java.io.IOException
out
- stream to write stringstring
- string to write out: null strings are perfectly valid, but strings of excess length will
cause a DataFormatException to be thrownDataFormatException
- if the string is not validjava.io.IOException
- if there is an IO error writing the stringpublic static void writeStringUTF8(java.io.OutputStream out, java.lang.String string) throws DataFormatException, java.io.IOException
out
- stream to write stringstring
- UTF-8 string to write out: null strings are perfectly valid, but strings of excess length will
cause a DataFormatException to be thrownDataFormatException
- if the string is not validjava.io.IOException
- if there is an IO error writing the string@Deprecated public static java.lang.Boolean readBoolean(java.io.InputStream in) throws DataFormatException, java.io.IOException
in
- stream to read fromDataFormatException
- if the boolean is not validjava.io.IOException
- if there is an IO error reading the boolean@Deprecated public static void writeBoolean(java.io.OutputStream out, java.lang.Boolean bool) throws DataFormatException, java.io.IOException
out
- stream to write tobool
- boolean value, or nullDataFormatException
- if the boolean is not validjava.io.IOException
- if there is an IO error writing the boolean@Deprecated public static java.lang.Boolean fromBoolean(byte[] data, int offset)
@Deprecated public static void toBoolean(byte[] data, int offset, boolean value)
@Deprecated public static void toBoolean(byte[] data, int offset, java.lang.Boolean value)
public static final boolean eq(java.lang.Object lhs, java.lang.Object rhs)
This treats (null == null) as true, and (null == (!null)) as false.
public static final boolean eq(java.util.Collection<?> lhs, java.util.Collection<?> rhs)
This treats (null == null) as true, (null == (!null)) as false, and then comparing each element via eq(object, object).
If the size of the collections are not equal, the comparison returns false. The collection order should be consistent, as this simply iterates across both and compares based on the value of each at each step along the way.
public static final boolean eq(byte[] lhs, byte[] rhs)
This treats (null == null) as true, (null == (!null)) as false, and unequal length arrays as false. Variable time.
@Deprecated public static final boolean eq(int lhs, int rhs)
@Deprecated public static final boolean eq(long lhs, long rhs)
@Deprecated public static final boolean eq(byte lhs, byte rhs)
public static final boolean eq(byte[] lhs, int offsetLeft, byte[] rhs, int offsetRight, int length)
java.lang.ArrayIndexOutOfBoundsException
- if either array isn't long enoughpublic static final boolean eqCT(byte[] lhs, int offsetLeft, byte[] rhs, int offsetRight, int length)
java.lang.NullPointerException
- if lhs or rhs is nulljava.lang.ArrayIndexOutOfBoundsException
- if either array isn't long enoughpublic static final int compareTo(byte[] lhs, byte[] rhs)
public static final byte[] xor(byte[] lhs, byte[] rhs)
public static final void xor(byte[] lhs, int startLeft, byte[] rhs, int startRight, byte[] out, int startOut, int len)
lhs
- one of the source arraysstartLeft
- starting index in the lhs array to begin the xorrhs
- the other source arraystartRight
- starting index in the rhs array to begin the xorout
- output arraystartOut
- starting index in the out array to store the resultlen
- how many bytes into the various arrays to xorpublic static int hashCode(java.lang.Object obj)
public static int hashCode(java.util.Date obj)
public static int hashCode(byte[] b)
public static int hashCode(java.util.Collection<?> col)
public static void skip(java.io.InputStream in, long n) throws java.io.IOException
java.io.IOException
public static int read(java.io.InputStream in, byte[] target) throws java.io.IOException
java.io.EOFException
- if the full length is not read (since 0.9.27)java.io.IOException
public static int read(java.io.InputStream in, byte[] target, int offset, int length) throws java.io.IOException
java.io.EOFException
- if the full length is not read (since 0.9.27)java.io.IOException
public static java.lang.String readLine(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public static java.lang.String readLine(java.io.InputStream in, java.security.MessageDigest hash) throws java.io.IOException
hash
- null OKjava.io.IOException
public static boolean readLine(java.io.InputStream in, java.lang.StringBuilder buf) throws java.io.IOException
java.io.IOException
public static boolean readLine(java.io.InputStream in, java.lang.StringBuilder buf, java.security.MessageDigest hash) throws java.io.IOException
hash
- null OKjava.io.IOException
public static void write(java.io.OutputStream out, byte[] data, java.security.MessageDigest hash) throws java.io.IOException
java.io.IOException
public static java.lang.String formatDuration(long ms)
public static java.lang.String formatDuration2(long ms)
public static java.lang.String formatDuration2(double ms)
public static java.lang.String formatSize(long bytes)
public static java.lang.String formatSize2(long bytes)
public static java.lang.String formatSize2(long bytes, boolean nonBreaking)
nonBreaking
- use an HTML thin non-breaking space ( )public static java.lang.String formatSize2Decimal(long bytes)
public static java.lang.String formatSize2Decimal(long bytes, boolean nonBreaking)
nonBreaking
- use an HTML thin non-breaking space ( )public static java.lang.String stripHTML(java.lang.String orig)
orig
- may be null, returns empty string if nullpublic static java.lang.String escapeHTML(java.lang.String unescaped)
unescaped
- the unescaped string, may be nullpublic static byte[] compress(byte[] orig)
java.lang.IllegalArgumentException
- if input size is over 40KBjava.lang.IllegalStateException
- on compression failure, as of 0.9.29public static byte[] compress(byte[] orig, int offset, int size)
java.lang.IllegalArgumentException
- if size is over 40KBjava.lang.IllegalStateException
- on compression failure, as of 0.9.29public static byte[] compress(byte[] orig, int offset, int size, int level)
level
- the compression level, 0 to 9java.lang.IllegalArgumentException
- if size is over 40KBjava.lang.IllegalStateException
- on compression failure, as of 0.9.29public static byte[] decompress(byte[] orig) throws java.io.IOException
java.io.IOException
- if uncompressed is over 40 KB,
or on a decompression errorpublic static byte[] decompress(byte[] orig, int offset, int length) throws java.io.IOException
java.io.IOException
- if uncompressed is over 40 KB,
or on a decompression errorpublic static byte[] getUTF8(java.lang.String orig)
java.lang.RuntimeException
public static byte[] getUTF8(java.lang.StringBuffer orig)
java.lang.RuntimeException
public static java.lang.String getUTF8(byte[] orig)
java.lang.RuntimeException
public static java.lang.String getUTF8(byte[] orig, int offset, int len)
java.lang.RuntimeException
public static byte[] getASCII(java.lang.String orig)
orig
- non-null, truncates to 8-bit charspublic static java.lang.String[] split(java.lang.String s, java.lang.String regex)
s
- non-nullregex
- non-null, don't forget to enclose multiple choices with []java.util.regex.PatternSyntaxException
- uncheckedpublic static java.lang.String[] split(java.lang.String s, java.lang.String regex, int limit)
s
- non-nullregex
- non-null, don't forget to enclose multiple choices with []limit
- result thresholdjava.util.regex.PatternSyntaxException
- uncheckedpublic static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- non-nullout
- non-nulljava.io.IOException
public static <T> void sort(java.util.List<T> list, java.util.Comparator<? super T> c)
list
- the list to be sorted.c
- the comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be used.public static <T> void sort(T[] a, java.util.Comparator<? super T> c)
a
- the array to be sorted.c
- the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used.public static void replace(java.lang.StringBuilder buf, java.lang.String from, java.lang.String to)
buf
- contains the string to be searchedfrom
- the string to be replacedto
- the replacement string