|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
public abstract class Base
Base class for providing standard functionality.
Nested Class Summary | |
---|---|
static class |
Base.CommonMonitor A class which acts as CommonMonitor. |
static class |
Base.LoggingWriter Inner class for over-riding the destination of log(), out() and err() calls. |
static class |
Base.StackFrame A class that provides "stack frame" information from a line of a stack trace. |
Field Summary | |
---|---|
static int |
LOG_ALWAYS It is expected that items with a log level of 0 will always be logged. |
static int |
LOG_DEBUG As of Coherence 3.2, the default logging level is 5, so using the level of 5 will show up in the logs by default as a debug message. |
static int |
LOG_ERR Log level 1 indicates an error. |
static int |
LOG_INFO Log level 3 indicates information that should likely be logged. |
static int |
LOG_MAX The maximum logging level indicator. |
static int |
LOG_MIN The minimum logging level indicator. |
static int |
LOG_QUIET As of Coherence 3.2, the default logging level is 5, so using a level higher than 5 will be "quiet" by default, meaning that it will not show up in the logs unless the configured logging level is increased. |
static int |
LOG_WARN Log level 2 indicates a warning. |
static int |
POWER_0 Integer constant representing an exponent of zero. |
static int |
POWER_G Integer constant representing an exponent of 30. |
static int |
POWER_K Integer constant representing an exponent of 10. |
static int |
POWER_M Integer constant representing an exponent of 20. |
static int |
POWER_T Integer constant representing an exponent of 40. |
static int |
UNIT_D Integer constant representing a unit of days. |
static int |
UNIT_H Integer constant representing a unit of hours. |
static int |
UNIT_M Integer constant representing a unit of minutes. |
static int |
UNIT_MS Integer constant representing a unit of milliseconds. |
static int |
UNIT_NS Integer constant representing a unit of nanoseconds. |
static int |
UNIT_S Integer constant representing a unit of seconds. |
static int |
UNIT_US Integer constant representing a unit of microseconds. |
Constructor Summary | |
---|---|
Base() |
Method Summary | |
---|---|
static java.lang.RuntimeException |
azzert() Definite assertion failure. |
static void |
azzert(boolean f) Test an assertion. |
static void |
azzert(boolean f, java.lang.String s) Test an assertion, and print the specified message if the assertion fails. |
static void |
azzertFailed(java.lang.String sMsg) Throw an assertion exception. |
static java.lang.String |
breakLines(java.lang.String sText, int nWidth, java.lang.String sIndent) Breaks the specified string into a multi-line string. |
static java.lang.String |
breakLines(java.lang.String sText, int nWidth, java.lang.String sIndent, boolean fFirstLine) Breaks the specified string into a multi-line string. |
static java.lang.String |
capitalize(java.lang.String s) Capitalize a string. |
static void |
checkNotEmpty(java.lang.String s, java.lang.String sName) Check that the specified string is neither a null nor an empty string. |
static void |
checkNotNull(java.lang.Object o, java.lang.String sName) Check that the specified object is non-null. |
static void |
checkRange(long lValue, long lFrom, long lTo, java.lang.String sName) Check the range of a value. |
static long |
computeSafeWaitTime(long ldtTimeout) Compute the number of milliseconds until the specified time. |
static int |
decimalValue(char ch) Returns the integer value of a decimal digit. |
static java.lang.String |
dup(char ch, int cch) Create a String of the specified length containing the specified character. |
static java.lang.String |
dup(java.lang.String s, int c) Create a String which is a duplicate of the specified number of the passed String. |
static java.lang.ClassLoader |
ensureClassLoader(java.lang.ClassLoader loader) Obtain a non-null ClassLoader. |
static java.lang.RuntimeException |
ensureRuntimeException(java.lang.Throwable e) Convert the passed exception to a RuntimeException if necessary. |
static java.lang.RuntimeException |
ensureRuntimeException(java.lang.Throwable e, java.lang.String s) Convert the passed exception to a RuntimeException if necessary. |
static boolean |
equals(java.lang.Object o1, java.lang.Object o2) Compare two references for equality. |
static boolean |
equalsDeep(java.lang.Object o1, java.lang.Object o2) Deeply compare two references for equality. |
static void |
err() Prints a blank line to the trace Writer. |
static void |
err(java.lang.Class clz) Prints the passed class information to the trace Writer. |
static void |
err(java.lang.Object o) Prints the passed Object to the trace Writer. |
static void |
err(java.lang.String s) Prints the passed String value to the trace Writer. |
static void |
err(java.lang.Throwable e) Prints the passed exception information to the trace Writer. |
static int |
escape(char ch, char[] ach, int of) Format a char to a printable escape if necessary, putting the result into the passed array. |
static java.lang.String |
formatDateTime(long ldt) Format a long value into a human readable date/time string. |
static Base.StackFrame |
getCallerStackFrame() Get the StackFrame information for the caller of the current method. |
static Base.CommonMonitor |
getCommonMonitor(int i) Return the common monitor associated with the specified integer value. |
static Base.CommonMonitor |
getCommonMonitor(long l) Return the common monitor associated with the specified long value. |
static Base.CommonMonitor |
getCommonMonitor(java.lang.Object o) Return the common monitor associated with the specified object based on its identity hashCode. |
static java.lang.ClassLoader |
getContextClassLoader() Try to determine the ClassLoader that supports the current context. |
static java.lang.ClassLoader |
getContextClassLoader(java.lang.Object o) Try to determine the ClassLoader that supports the current context. |
static java.lang.String |
getDeepMessage(java.lang.Throwable t, java.lang.String sDelim) Extract a throwable's message, and all causal messages. |
static java.io.PrintWriter |
getErr() Obtains the current writer used for tracing. |
static long |
getLastSafeTimeMillis() Returns the last "safe" time as computed by a previous call to the getSafeTimeMillis() method. |
static java.io.PrintWriter |
getLog() Obtains the current writer used for logging. |
static int |
getMaxDecDigits(int n) Calculate the number of decimal digits needed to display the passed value. |
static int |
getMaxHexDigits(int n) Calculate the number of hex digits needed to display the passed value. |
static java.lang.Throwable |
getOriginalException(java.lang.RuntimeException e) Unwind the wrapper (runtime) exception to extract the original |
static java.io.PrintWriter |
getOut() Obtains the current writer used for printing. |
static java.util.Random |
getRandom() Obtain a Random object that can be used to get random values. |
static com.tangosol.util.Binary |
getRandomBinary(int cbMin, int cbMax) Generates a random-length Binary within the length bounds provided whose contents are random bytes. |
static java.lang.String |
getRandomString(int cchMin, int cchMax, boolean fAscii) Generates a random-length String within the length bounds provided. |
static long |
getSafeTimeMillis() Returns a "safe" current time in milliseconds. |
static Base.StackFrame |
getStackFrame() Get the StackFrame information for the current method. |
static Base.StackFrame[] |
getStackFrames() Iterate the StackFrame information for all callers, going from the inside outwards, and starting with the caller of this method. |
static java.lang.String |
getStackTrace() Build a stack trace for the current thread. |
static java.lang.String |
getStackTrace(java.lang.Throwable e) Build a stack trace for the passed exception that does not include the exception description itself. |
static com.tangosol.util.ThreadFactory |
getThreadFactory() Return the configured thread factory. |
static java.util.TimeZone |
getTimeZone(java.lang.String sId) Gets the TimeZone for the given ID. |
static long |
getUpTimeMillis() Return the number of milliseconds which have elapsed since the JVM was started. |
static int |
hashCode(java.lang.Object o) Return the hash code for the supplied object or 0 for null. |
static int |
hexValue(char ch) Returns the integer value of a hexadecimal digit. |
static java.lang.String |
indentString(java.lang.String sText, java.lang.String sIndent) Indent the passed multi-line string. |
static java.lang.String |
indentString(java.lang.String sText, java.lang.String sIndent, boolean fFirstLine) Textually indent the passed multi-line string. |
static boolean |
isDecimal(char ch) Returns true if the passed character is a decimal digit. |
static boolean |
isHex(char ch) Returns true if the passed character is a hexadecimal digit. |
static boolean |
isLogEcho() Determine if the log is echoed to the console. |
static boolean |
isOctal(char ch) Returns true if the passed character is an octal digit. |
static void |
log() Prints a blank line to the log. |
static void |
log(java.lang.Class clz) Prints the passed class information to the log. |
static void |
log(java.lang.Object o) Prints the passed Object to the log. |
static void |
log(java.lang.String s) Prints the passed String value to the log. |
static void |
log(java.lang.Throwable e) Prints the passed exception information to the log. |
static java.lang.Integer |
makeInteger(int n) Deprecated. use Integer.valueOf(int) |
static java.lang.Long |
makeLong(long n) Deprecated. use Long.valueOf(long) |
static java.lang.Thread |
makeThread(java.lang.ThreadGroup group, java.lang.Runnable runnable, java.lang.String sName) Create a Thread with the specified group, runnable, and name, using the configured ThreadFactory, as specified by the tangosol.coherence.threadfactory system property. |
static int |
octalValue(char ch) Returns the integer value of an octal digit. |
static void |
out() Prints a blank line. |
static void |
out(java.lang.Class clz) Prints the passed class information. |
static void |
out(java.lang.Object o) Prints the passed Object. |
static void |
out(java.lang.String s) Prints the passed String value. |
static void |
out(java.lang.Throwable e) Prints the passed exception information. |
static long |
pad(long lMin, long lMultiple) Return the smallest value that is not less than the first argument and is a multiple of the second argument. |
static long |
parseBandwidth(java.lang.String s) Parse the given string representation of a number of bytes per second. |
static long |
parseBandwidth(java.lang.String s, int nDefaultPower) Parse the given string representation of a number of bytes per second. |
static java.lang.String[] |
parseDelimitedString(java.lang.String s, char chDelim) Parse a character-delimited String into an array of Strings. |
static int |
parseHex(char ch) Return the integer value of a hexadecimal digit. |
static byte[] |
parseHex(java.lang.String s) Parse the passed String of hexadecimal characters into a binary value. |
static long |
parseMemorySize(java.lang.String s) Parse the given string representation of a number of bytes. |
static long |
parseMemorySize(java.lang.String s, int nDefaultPower) Parse the given string representation of a number of bytes. |
static float |
parsePercentage(java.lang.String s) Parse the given string representation of a percentage value and return its value as a float in the inclusive range of 0.0 and 1.0. |
static long |
parseTime(java.lang.String s) Parse the given string representation of a time duration and return its value as a number of milliseconds. |
static long |
parseTime(java.lang.String s, int nDefaultUnit) Parse the given string representation of a time duration and return its value as a number of milliseconds. |
static long |
parseTimeNanos(java.lang.String s) Parse the given string representation of a time duration and return its value as a number of nanoseconds. |
static long |
parseTimeNanos(java.lang.String s, int nDefaultUnit) Parse the given string representation of a time duration and return its value as a number of nanoseconds. |
static java.lang.String |
printStackTrace(java.lang.Throwable e) Build a stack trace for the passed exception. |
static java.util.List |
randomize(java.util.Collection coll) Randomize the order of the elements within the passed collection. |
static int[] |
randomize(int[] a) Randomize the order of the elements within the passed array. |
static java.lang.Object[] |
randomize(java.lang.Object[] a) Randomize the order of the elements within the passed array. |
static byte[] |
read(java.io.DataInput stream) Read the contents out of the passed stream and return the result as a byte array. |
static byte[] |
read(java.io.DataInputStream stream) Read the contents out of the passed stream and return the result as a byte array. |
static byte[] |
read(java.io.File file) Read the contents out of the specified file and return the result as a byte array. |
static byte[] |
read(java.io.InputStream stream) Read the contents out of the passed stream and return the result as a byte array. |
static int |
read(java.io.InputStream stream, byte[] ab) Read the contents out of the passed stream into the passed byte array and return the length read. |
static java.lang.String |
read(java.io.Reader reader) Read the contents out of the passed Reader and return the result as a String. |
static byte[] |
read(java.net.URL url) Read the contents of the specified URL and return the result as a byte array. |
static java.lang.String |
replace(java.lang.String sText, java.lang.String sFrom, java.lang.String sTo) Replace all occurrences of the specified substring in the specified string. |
static void |
setErr(java.io.PrintWriter writer) Sets the current writer used for tracing. |
static void |
setLog(java.io.PrintWriter writer) Sets the current writer used for logging. |
static void |
setLogEcho(boolean fEcho) Specify whether the log should echo to the console. |
static void |
setOut(java.io.PrintWriter writer) Sets the current writer used for printing. |
static void |
sleep(long cMillis) Convenience method for Thread.sleep(long) . |
static java.lang.String |
toBandwidthString(long cbps) Format the passed bandwidth (in bytes per second) as a String that can be parsed by parseBandwidth(java.lang.String) such that cb==parseBandwidth(toBandwidthString(cb)) holds true for all legal values of cbps. |
static java.lang.String |
toBandwidthString(long cbps, boolean fExact) Format the passed bandwidth (in bytes per second) as a String. |
static java.lang.String |
toCharEscape(char ch) Format a char to a printable escape if necessary. |
static int |
toCrc(byte[] ab) Calculate a CRC32 value from a byte array. |
static int |
toCrc(byte[] ab, int of, int cb) Calculate a CRC32 value from a portion of a byte array. |
static int |
toCrc(byte[] ab, int of, int cb, int nCrc) Continue to calculate a CRC32 value from a portion of a byte array. |
static int |
toCrc(com.tangosol.util.ByteSequence seq) Calculate a CRC32 value from a ByteSequence. |
static int |
toCrc(com.tangosol.util.ByteSequence seq, int of, int cb, int nCrc) Continue to calculate a CRC32 value from a portion of a ByteSequence . |
static java.lang.String |
toDecString(int n, int cDigits) Format the passed non-negative integer as a fixed-length decimal string. |
static java.lang.String |
toDelimitedString(int[] an, java.lang.String sDelim) Format the content of the passed integer array as a delimited string. |
static java.lang.String |
toDelimitedString(java.util.Iterator iter, java.lang.String sDelim) Format the content of the passed Iterator as a delimited string. |
static java.lang.String |
toDelimitedString(long[] al, java.lang.String sDelim) Format the content of the passed long array as a delimited string. |
static java.lang.String |
toDelimitedString(java.lang.Object[] ao, java.lang.String sDelim) Format the content of the passed Object array as a delimited string. |
static java.lang.String |
toHex(byte[] ab) Convert a byte array to the hex sequence of 2 hex digits per byte. |
static java.lang.String |
toHex(int b) Convert a byte to the hex sequence of 2 hex digits. |
static java.lang.String |
toHexDump(byte[] ab, int cBytesPerLine) Convert a byte array to a hex dump. |
static java.lang.String |
toHexEscape(byte b) Convert a byte to a hex sequence of '0' + 'x' + 2 hex digits. |
static java.lang.String |
toHexEscape(byte[] ab) Convert a byte array to a hex sequence of '0' + 'x' + 2 hex digits per byte. |
static java.lang.String |
toHexEscape(byte[] ab, int of, int cb) Convert a byte array to a hex sequence of '0' + 'x' + 2 hex digits per byte. |
static java.lang.String |
toHexEscape(com.tangosol.util.ByteSequence seq, int of, int cb) Convert a ByteSequence to a hex sequence of '0' + 'x' + 2 hex digits per byte. |
static java.lang.String |
toHexString(int n, int cDigits) Format the passed integer as a fixed-length hex string. |
static java.lang.String |
toMemorySizeString(long cb) Format the passed memory size (in bytes) as a String that can be parsed by parseMemorySize(java.lang.String) such that cb==parseMemorySize(toMemorySizeString(cb)) holds true for all legal values of cb. |
static java.lang.String |
toMemorySizeString(long cb, boolean fExact) Format the passed memory size (in bytes) as a String. |
static java.lang.String |
toQuotedCharEscape(char ch) Format a char to a printable escape if necessary as it would appear (quoted) in Java source code. |
static java.lang.String |
toQuotedStringEscape(java.lang.String s) Format a String as it would appear (quoted) in Java source code, escaping characters as necessary. |
static java.lang.String |
toSqlString(java.lang.String s) Escapes the string for SQL. |
static java.lang.String |
toString(java.lang.Class clz) Formats Class information for debug output purposes. |
static java.lang.String |
toString(double dfl, int cMinDigits) Format a double value as a String. |
static java.lang.String |
toStringEscape(java.lang.String s) Format a String escaping characters as necessary. |
static java.lang.String |
toUnicodeEscape(char ch) Format a Unicode character to the Unicode escape sequence of '\' + 'u' + 4 hex digits. |
static void |
trace(boolean fVal) Display the value of a boolean expression. |
static void |
trace(byte[] ab) Display the value of a byte array expression. |
static void |
trace(char chVal) Display the value of a char expression. |
static void |
trace(double dflVal) Display the value of a double expression. |
static void |
trace(float flVal) Display the value of a float expression. |
static void |
trace(int nVal) Display the value of an int expression. |
static void |
trace(long lVal) Display the value of a long expression. |
static void |
trace(java.lang.Object oVal) Display the value of an Object expression. |
static void |
trace(java.lang.String sVal) Display the value of a String expression. |
static java.lang.String |
truncateString(java.util.Collection coll, int cLimit) Provide a string representation of elements within the collection until the concatenated string length exceeds cLimit . |
static java.lang.String |
truncateString(java.lang.String s, int cLimit) Truncate a string to the specified character count. |
static void |
wait(java.lang.Object o, long cMillis) Convenience method for Object.wait(long) . |
Field Detail |
---|
public static final int UNIT_NS
parseTimeNanos(String, int)
, Constant Field Valuespublic static final int UNIT_US
parseTimeNanos(String, int)
, Constant Field Valuespublic static final int UNIT_MS
parseTime(String, int)
, Constant Field Valuespublic static final int UNIT_S
parseTime(String, int)
, Constant Field Valuespublic static final int UNIT_M
parseTime(String, int)
, Constant Field Valuespublic static final int UNIT_H
parseTime(String, int)
, Constant Field Valuespublic static final int UNIT_D
parseTime(String, int)
, Constant Field Valuespublic static final int POWER_0
parseBandwidth(String, int)
, parseMemorySize(String, int)
, Constant Field Valuespublic static final int POWER_K
parseBandwidth(String, int)
, parseMemorySize(String, int)
, Constant Field Valuespublic static final int POWER_M
parseBandwidth(String, int)
, parseMemorySize(String, int)
, Constant Field Valuespublic static final int POWER_G
parseBandwidth(String, int)
, parseMemorySize(String, int)
, Constant Field Valuespublic static final int POWER_T
parseBandwidth(String, int)
, parseMemorySize(String, int)
, Constant Field Valuespublic static final int LOG_MIN
public static final int LOG_MAX
public static final int LOG_ALWAYS
public static final int LOG_ERR
public static final int LOG_WARN
public static final int LOG_INFO
public static final int LOG_DEBUG
public static final int LOG_QUIET
Constructor Detail |
---|
public Base()
Method Detail |
---|
public static void trace(boolean fVal)
public static void trace(char chVal)
public static void trace(int nVal)
public static void trace(long lVal)
public static void trace(float flVal)
public static void trace(double dflVal)
public static void trace(byte[] ab)
public static void trace(java.lang.String sVal)
public static void trace(java.lang.Object oVal)
public static java.lang.RuntimeException azzert()
public static void azzert(boolean f)
public static void azzert(boolean f, java.lang.String s)
public static void azzertFailed(java.lang.String sMsg)
sMsg
- the assertion messagepublic static java.lang.RuntimeException ensureRuntimeException(java.lang.Throwable e)
e
- any Throwable objectpublic static java.lang.RuntimeException ensureRuntimeException(java.lang.Throwable e, java.lang.String s)
e
- any Throwable objects
- an additional descriptionpublic static java.lang.Throwable getOriginalException(java.lang.RuntimeException e)
e
- Runtime exception (wrapper)public static void out()
public static void out(java.lang.Object o)
o
- the Object to print.public static void out(java.lang.String s)
s
- the String to print.public static void out(java.lang.Class clz)
clz
- the class object to print.public static void out(java.lang.Throwable e)
e
- the Throwable object to print.public static void err()
public static void err(java.lang.Object o)
o
- the Object to print.public static void err(java.lang.String s)
s
- the String to print.public static void err(java.lang.Class clz)
clz
- the class object to print.public static void err(java.lang.Throwable e)
e
- the Throwable object to print.public static void log()
public static void log(java.lang.Object o)
o
- the Object to print.public static void log(java.lang.String s)
s
- the String to print.public static void log(java.lang.Class clz)
clz
- the class object to print.public static void log(java.lang.Throwable e)
e
- the Throwable object to print.public static java.lang.ClassLoader ensureClassLoader(java.lang.ClassLoader loader)
loader
- a ClassLoader (may be null)public static java.lang.ClassLoader getContextClassLoader()
public static java.lang.ClassLoader getContextClassLoader(java.lang.Object o)
o
- the calling object, or any object out of the application that is requesting the class loaderpublic static Base.StackFrame getCallerStackFrame()
public static Base.StackFrame getStackFrame()
public static Base.StackFrame[] getStackFrames()
public static java.lang.String getStackTrace()
public static java.lang.String getStackTrace(java.lang.Throwable e)
e
- a Throwable object that contains stack trace informationpublic static java.lang.String getDeepMessage(java.lang.Throwable t, java.lang.String sDelim)
t
- the throwablesDelim
- the delimiter to include between messagespublic static java.lang.String printStackTrace(java.lang.Throwable e)
e
- a Throwable object that contains stack trace informationpublic static java.lang.Thread makeThread(java.lang.ThreadGroup group, java.lang.Runnable runnable, java.lang.String sName)
group
- (optional) the thread's thread grouprunnable
- (optional) the thread's runnablesName
- (optional) the thread's namepublic static com.tangosol.util.ThreadFactory getThreadFactory()
public static void sleep(long cMillis)
Thread.sleep(long)
.
If the thread is interrupted before the sleep time expires, a RuntimeException is thrown and the thread's interrupt state is set.
cMillis
- the maximum time to wait in millisecondspublic static void wait(java.lang.Object o, long cMillis)
Object.wait(long)
.
If the thread is interrupted before being notified or the wait time expires, a RuntimeException is thrown and the thread's interrupt state is set.
o
- the Object to wait forcMillis
- the maximum time to wait in millisecondspublic static Base.CommonMonitor getCommonMonitor(int i)
Common monitors allow for a low-cost means to reduce contention by spreading synchronization over a large number of monitors. An example usage would be to produce an "atomic array" without utilizing the Java 1.5 java.util.concurrent features. For instance to atomically change an element within an array which is being simultaneously updated by multiple threads:
synchronized (getCommonMonitor(System.identityHashCode(aoShared) + i)) { oOld = aoShared[i]; aoShared[i] = oNew; }With this approach many threads may concurrently access various array elements without having to synchronize on the array itself, and contend with each other. The use of common monitors also avoids the overhead of allocating a unique monitor per index. This example additionally makes use of the array's identity hash code to avoid frequent collisions against other atomic arrays for the same indices.
As they are shared, these monitors will apply to any number of unrelated entities, and as such certain precautions must be employed when using them.
tangosol.coherence.commonmonitors
system property.i
- the common monitor identifierpublic static Base.CommonMonitor getCommonMonitor(long l)
l
- the common monitor identifiergetCommonMonitor(int)
public static Base.CommonMonitor getCommonMonitor(java.lang.Object o)
o
- the object to obtain a common monitor forgetCommonMonitor(int)
public static java.lang.String toString(java.lang.Class clz)
clz
- the Class to print information forpublic static boolean isDecimal(char ch)
ch
- The character to checkpublic static int decimalValue(char ch)
ch
- The character to convertpublic static int getMaxDecDigits(int n)
n
- the valuepublic static java.lang.String toDecString(int n, int cDigits)
n
- the valuecDigits
- the length of the resulting decimal stringpublic static long pad(long lMin, long lMultiple)
lMin
- the smallest value to returnlMultiple
- the return value will be a multiple of this argumentpublic static boolean isOctal(char ch)
ch
- The character to checkpublic static int octalValue(char ch)
ch
- The character to convertpublic static boolean isHex(char ch)
ch
- The character to checkpublic static int hexValue(char ch)
ch
- The character to convertpublic static int getMaxHexDigits(int n)
n
- the valuepublic static java.lang.String toHexString(int n, int cDigits)
n
- the valuecDigits
- the length of the resulting hex stringpublic static java.lang.String toHex(int b)
b
- the bytepublic static java.lang.String toHex(byte[] ab)
ab
- the byte arraypublic static java.lang.String toHexEscape(byte b)
b
- the bytepublic static java.lang.String toHexEscape(byte[] ab)
ab
- the byte arraypublic static java.lang.String toHexEscape(byte[] ab, int of, int cb)
ab
- the byte arrayof
- the offset into arraycb
- the number of bytes to convertpublic static java.lang.String toHexEscape(com.tangosol.util.ByteSequence seq, int of, int cb)
seq
- the ByteSequenceof
- the offset into the byte sequencecb
- the number of bytes to convertpublic static java.lang.String toHexDump(byte[] ab, int cBytesPerLine)
ab
- the byte array to format as a hex stringcBytesPerLine
- the number of bytes to display on a linepublic static byte[] parseHex(java.lang.String s)
s
- the hex String to evaluatepublic static int parseHex(char ch)
ch
- the hex character to evaluatepublic static java.lang.String toString(double dfl, int cMinDigits)
dfl
- a double valuecMinDigits
- the minimum number of digits of precision to displaypublic static java.lang.String toUnicodeEscape(char ch)
ch
- the characterpublic static java.lang.String toCharEscape(char ch)
ch
- the charpublic static java.lang.String toQuotedCharEscape(char ch)
ch
- the characterpublic static java.lang.String toStringEscape(java.lang.String s)
s
- the Stringpublic static java.lang.String toQuotedStringEscape(java.lang.String s)
s
- the Stringpublic static int escape(char ch, char[] ach, int of)
ch
- the character to formatach
- the array of characters to format intoof
- the offset in the array to format atpublic static java.lang.String toSqlString(java.lang.String s)
public static java.lang.String indentString(java.lang.String sText, java.lang.String sIndent)
sText
- the string to indentsIndent
- a string used to indent each linepublic static java.lang.String indentString(java.lang.String sText, java.lang.String sIndent, boolean fFirstLine)
sText
- the string to indentsIndent
- a string used to indent each linefFirstLine
- true indents all lines; false indents all but the firstpublic static java.lang.String breakLines(java.lang.String sText, int nWidth, java.lang.String sIndent)
sText
- the string to breaknWidth
- the max width of resulting lines (including the indent)sIndent
- a string used to indent each linepublic static java.lang.String breakLines(java.lang.String sText, int nWidth, java.lang.String sIndent, boolean fFirstLine)
sText
- the string to breaknWidth
- the max width of resulting lines (including the indent)sIndent
- a string used to indent each linefFirstLine
- if true indents all lines; otherwise indents all but the firstpublic static java.lang.String dup(char ch, int cch)
ch
- the character to fill the String withcch
- the length of the Stringpublic static java.lang.String dup(java.lang.String s, int c)
s
- the String to fill the new String withc
- the number of duplicates to put into the new Stringpublic static java.lang.String replace(java.lang.String sText, java.lang.String sFrom, java.lang.String sTo)
sText
- string to changesFrom
- pattern to change fromsTo
- pattern to change topublic static java.lang.String[] parseDelimitedString(java.lang.String s, char chDelim)
s
- character-delimited String to parsechDelim
- character delimiterpublic static java.lang.String toDelimitedString(int[] an, java.lang.String sDelim)
an
- the arraysDelim
- the delimiterpublic static java.lang.String toDelimitedString(long[] al, java.lang.String sDelim)
al
- the arraysDelim
- the delimiterpublic static java.lang.String toDelimitedString(java.lang.Object[] ao, java.lang.String sDelim)
ao
- the arraysDelim
- the delimiterpublic static java.lang.String toDelimitedString(java.util.Iterator iter, java.lang.String sDelim)
iter
- the IteratorsDelim
- the delimiterpublic static java.lang.String capitalize(java.lang.String s)
s
- the string to capitalizepublic static java.lang.String truncateString(java.lang.String s, int cLimit)
s
- the String to be truncatedcLimit
- expected character countpublic static java.lang.String truncateString(java.util.Collection coll, int cLimit)
cLimit
.coll
- the collection of elements to describecLimit
- expected character countpublic static long parseBandwidth(java.lang.String s)
[\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[[B|b][P|p][S|s]]?
where the first non-digit (from left to right) indicates the factor with which the preceding decimal value should be multiplied:
If the string value does not contain a factor, a factor of one is assumed.
The optional last three characters indicate the unit of measure, [b][P|p][S|s] in the case of bits per second and [B][P|p][S|s] in the case of bytes per second. If the string value does not contain a unit, a unit of bits per second is assumed.
s
- a string with the format: [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[[B|b][P|p][S|s]]?public static long parseBandwidth(java.lang.String s, int nDefaultPower)
[\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[[B|b][P|p][S|s]]?
where the first non-digit (from left to right) indicates the factor with which the preceding decimal value should be multiplied:
If the string value does not contain an explicit or implicit factor, a factor calculated by raising 2 to the given default power is used. The default power can be one of:
The optional last three characters indicate the unit of measure, [b][P|p][S|s] in the case of bits per second and [B][P|p][S|s] in the case of bytes per second. If the string value does not contain a unit, a unit of bits per second is assumed.
s
- a string with the format: [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[[B|b][P|p][S|s]]?nDefaultPower
- the exponent used to calculate the factor used in the conversion if one is not implied by the given stringpublic static java.lang.String toBandwidthString(long cbps)
parseBandwidth(java.lang.String)
such that cb==parseBandwidth(toBandwidthString(cb)) holds true for all legal values of cbps.cbps
- the number of bytes per secondpublic static java.lang.String toBandwidthString(long cbps, boolean fExact)
cbps
- the number of bytes per secondfExact
- true if the String representation must be exact, or false if it can be an approximationpublic static long parseMemorySize(java.lang.String s)
[\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[B|b]?
where the first non-digit (from left to right) indicates the factor with which the preceding decimal value should be multiplied:
If the string value does not contain a factor, a factor of one is assumed.
The optional last character B or b indicates a unit of bytes.
s
- a string with the format [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[B|b]?public static long parseMemorySize(java.lang.String s, int nDefaultPower)
[\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[B|b]?
where the first non-digit (from left to right) indicates the factor with which the preceding decimal value should be multiplied:
If the string value does not contain an explicit or implicit factor, a factor calculated by raising 2 to the given default power is used. The default power can be one of:
The optional last character B or b indicates a unit of bytes.
s
- a string with the format [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[B|b]?nDefaultPower
- the exponent used to calculate the factor used in the conversion if one is not implied by the given stringpublic static java.lang.String toMemorySizeString(long cb)
parseMemorySize(java.lang.String)
such that cb==parseMemorySize(toMemorySizeString(cb)) holds true for all legal values of cb.cb
- the number of bytes of memorypublic static java.lang.String toMemorySizeString(long cb, boolean fExact)
cb
- the number of bytes of memoryfExact
- true if the String representation must be exact, or false if it can be an approximationpublic static long parseTime(java.lang.String s)
[\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
where the first non-digits (from left to right) indicate the unit of time duration:
If the string value does not contain a unit, a unit of milliseconds is assumed.
s
- a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?parseTimeNanos(String)
public static long parseTime(java.lang.String s, int nDefaultUnit)
[\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
where the first non-digits (from left to right) indicate the unit of time duration:
If the string value does not contain a unit, the specified default unit is assumed. The default unit can be one of:
s
- a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?nDefaultUnit
- the unit to use in the conversion to milliseconds if one is not specified in the supplied stringparseTimeNanos(String, int)
public static long parseTimeNanos(java.lang.String s)
[\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
where the first non-digits (from left to right) indicate the unit of time duration:
If the string value does not contain a unit, a unit of nanoseconds is assumed.
s
- a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?public static long parseTimeNanos(java.lang.String s, int nDefaultUnit)
[\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
where the first non-digits (from left to right) indicate the unit of time duration:
If the string value does not contain a unit, the specified default unit is assumed. The default unit can be one of:
s
- a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?nDefaultUnit
- the unit to use in the conversion to nanoseconds if one is not specified in the supplied stringpublic static java.lang.String formatDateTime(long ldt)
ldt
- a Java long containing a date/time valuepublic static float parsePercentage(java.lang.String s)
[\d]+[[.][\d]+]?[%]
where the digits are within the closed interval [0.0, 100.0].
s
- a string with the format [\d]+[[.][\d]+]?[%]public static int hashCode(java.lang.Object o)
o
- the object to hashpublic static boolean equals(java.lang.Object o1, java.lang.Object o2)
o1
-o2
-public static boolean equalsDeep(java.lang.Object o1, java.lang.Object o2)
o1
-o2
-public static int toCrc(byte[] ab)
ab
- an array of bytespublic static int toCrc(byte[] ab, int of, int cb)
ab
- an array of bytesof
- the offset into the arraycb
- the number of bytes to evaluatepublic static int toCrc(byte[] ab, int of, int cb, int nCrc)
ab
- an array of bytesof
- the offset into the arraycb
- the number of bytes to evaluatenCrc
- the previous CRC valuepublic static int toCrc(com.tangosol.util.ByteSequence seq)
seq
- a ByteSequencepublic static int toCrc(com.tangosol.util.ByteSequence seq, int of, int cb, int nCrc)
seq
- a ByteSequenceof
- the offset into the ByteSequencecb
- the number of bytes to evaluatenCrc
- the previous CRC valuepublic static long getUpTimeMillis()
public static long getSafeTimeMillis()
SafeClock
public static long getLastSafeTimeMillis()
getSafeTimeMillis()
method.SafeClock
public static long computeSafeWaitTime(long ldtTimeout)
Note: this method will only return zero if ldtTimeout == Long.MAX_VALUE.
ldtTimeout
- the timeout as computed by getSafeTimeMillis()
public static java.util.TimeZone getTimeZone(java.lang.String sId)
TimeZone
for the given ID.
This method will cache returned TimeZones to avoid the contention caused by the TimeZone.getTimeZone(java.lang.String)
implementation.
sId
- the ID for a TimeZone
TimeZone
, or the GMT zone if the given ID cannot be understood.TimeZone.getTimeZone(String)
@Deprecated
public static java.lang.Integer makeInteger(int n)
Integer.valueOf(int)
n
- an int
@Deprecated
public static java.lang.Long makeLong(long n)
Long.valueOf(long)
n
- a longpublic static java.util.Random getRandom()
public static java.util.List randomize(java.util.Collection coll)
coll
- the Collection to randomize; the passed Collection is not alteredpublic static java.lang.Object[] randomize(java.lang.Object[] a)
a
- an array of objects to randomizepublic static int[] randomize(int[] a)
a
- an array of int values to randomizepublic static com.tangosol.util.Binary getRandomBinary(int cbMin, int cbMax)
cbMin
- the minimum number of bytes in the resulting BinarycbMax
- the maximum number of bytes in the resulting Binarypublic static java.lang.String getRandomString(int cchMin, int cchMax, boolean fAscii)
cchMin
- the minimum length of the resulting StringcchMax
- the maximum length of the resulting StringfAscii
- true if the resulting String should contain only ASCII valuespublic static void checkRange(long lValue, long lFrom, long lTo, java.lang.String sName)
lValue
- the value to checklFrom
- the lower limit of the range (inclusive)lTo
- the upper limit of the range (inclusive)sName
- the display name of the valuejava.lang.IllegalArgumentException
- if the value is out of rangepublic static void checkNotNull(java.lang.Object o, java.lang.String sName)
o
- the object to checksName
- the name of the corresponding parameterjava.lang.IllegalArgumentException
- if o is nullpublic static void checkNotEmpty(java.lang.String s, java.lang.String sName)
s
- the string to checksName
- the name of the corresponding parameterjava.lang.IllegalArgumentException
- if s is null or empty stringpublic static java.io.PrintWriter getOut()
public static void setOut(java.io.PrintWriter writer)
writer
- the java.io.PrintWriter instance to use for printing; may be nullpublic static java.io.PrintWriter getErr()
public static void setErr(java.io.PrintWriter writer)
writer
- the java.io.PrintWriter instance to use for tracing; may be nullpublic static java.io.PrintWriter getLog()
public static void setLog(java.io.PrintWriter writer)
writer
- the java.io.PrintWriter instance to use for logging; may be nullpublic static boolean isLogEcho()
public static void setLogEcho(boolean fEcho)
fEcho
- true if the log should echo to the consolepublic static int read(java.io.InputStream stream, byte[] ab) throws java.io.IOException
stream
- a java.io.InputStream object to read fromab
- a byte array to read intojava.io.IOException
public static byte[] read(java.io.InputStream stream) throws java.io.IOException
stream
- a java.io.InputStream object to read fromjava.io.IOException
public static byte[] read(java.io.DataInput stream) throws java.io.IOException
stream
- a java.io.DataInput object to read fromjava.io.IOException
public static byte[] read(java.io.DataInputStream stream) throws java.io.IOException
stream
- a java.io.DataInputStream object to read fromjava.io.IOException
public static java.lang.String read(java.io.Reader reader) throws java.io.IOException
reader
- a java.io.Reader object to read fromjava.io.IOException
public static byte[] read(java.io.File file) throws java.io.IOException
file
- the java.io.File object to read the contents ofjava.io.IOException
public static byte[] read(java.net.URL url) throws java.io.IOException
url
- the java.net.URL object to read the contents ofjava.io.IOException
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |