|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
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 RuntimeException |
azzert() Definite assertion failure. |
static void |
azzert(boolean f) Test an assertion. |
static void |
azzert(boolean f, String s) Test an assertion, and print the specified message if the assertion fails. |
static void |
azzertFailed(String sMsg) Throw an assertion exception. |
static String |
breakLines(String sText, int nWidth, String sIndent) Breaks the specified string into a multi-line string. |
static String |
breakLines(String sText, int nWidth, String sIndent, boolean fFirstLine) Breaks the specified string into a multi-line string. |
static int |
decimalValue(char ch) Returns the integer value of a decimal digit. |
static String |
dup(char ch, int cch) Create a String of the specified length containing the specified character. |
static String |
dup(String s, int c) Create a String which is a duplicate of the specified number of the passed String. |
static ClassLoader |
ensureClassLoader(ClassLoader loader) Obtain a non-null ClassLoader. |
static RuntimeException |
ensureRuntimeException(Throwable e) Convert the passed exception to a RuntimeException if necessary. |
static RuntimeException |
ensureRuntimeException(Throwable e, String s) Convert the passed exception to a RuntimeException if necessary. |
static boolean |
equals(Object o1, Object o2) Compare two references for equality. |
static boolean |
equalsDeep(Object o1, Object o2) Deeply compare two references for equality. |
static void |
err() Prints a blank line to the trace Writer. |
static void |
err(Class clz) Prints the passed class information to the trace Writer. |
static void |
err(Object o) Prints the passed Object to the trace Writer. |
static void |
err(String s) Prints the passed String value to the trace Writer. |
static void |
err(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 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(Object o) Return the common monitor associated with the specified object based on its identity hashcode. |
static ClassLoader |
getContextClassLoader() Try to determine the ClassLoader that supports the current context. |
static ClassLoader |
getContextClassLoader(Object o) Try to determine the ClassLoader that supports the current context. |
static String |
getDeepMessage(Throwable t, String sDelim) Extract a throwable's message, and all causal messages. |
static 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 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 Throwable |
getOriginalException(RuntimeException e) Unwind the wrapper (runtime) exception to extract the original |
static PrintWriter |
getOut() Obtains the current writer used for printing. |
static Random |
getRandom() Obtain a Random object that can be used to get random values. |
static Binary |
getRandomBinary(int cbMin, int cbMax) Generates a random-length Binary within the length bounds provided whose contents are random bytes. |
static 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 String |
getStackTrace() Build a stack trace for the current thread. |
static String |
getStackTrace(Throwable e) Build a stack trace for the passed exception that does not include the exception description itself. |
static ThreadFactory |
getThreadFactory() Return the configured thread factory. |
static long |
getUpTimeMillis() Return the number of milliseconds which have elapsed since the JVM was started. |
static int |
hashCode(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 hexidecimal digit. |
static String |
indentString(String sText, String sIndent) Indent the passed multi-line string. |
static String |
indentString(String sText, 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 hexidecimal 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(Class clz) Prints the passed class information to the log. |
static void |
log(Object o) Prints the passed Object to the log. |
static void |
log(String s) Prints the passed String value to the log. |
static void |
log(Throwable e) Prints the passed exception information to the log. |
static Integer |
makeInteger(int n) Factory method to produce Integer objects with an optimization that uses cached Integer objects for all relatively-low numbers. |
static Long |
makeLong(long n) Factory method to produce Long objects with an optimization that uses cached Long objects for all relatively-low numbers. |
static Thread |
makeThread(ThreadGroup group, Runnable runnable, 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(Class clz) Prints the passed class information. |
static void |
out(Object o) Prints the passed Object. |
static void |
out(String s) Prints the passed String value. |
static void |
out(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(String s) Parse the given string representation of a number of bytes per second. |
static long |
parseBandwidth(String s, int nDefaultPower) Parse the given string representation of a number of bytes per second. |
static String[] |
parseDelimitedString(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 hexidecimal digit. |
static byte[] |
parseHex(String s) Parse the passed String of hexidecimal characters into a binary value. |
static long |
parseMemorySize(String s) Parse the given string representation of a number of bytes. |
static long |
parseMemorySize(String s, int nDefaultPower) Parse the given string representation of a number of bytes. |
static long |
parseTime(String s) Parse the given string representation of a time duration and return its value as a number of milliseconds. |
static long |
parseTime(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(String s) Parse the given string representation of a time duration and return its value as a number of nanoseconds. |
static long |
parseTimeNanos(String s, int nDefaultUnit) Parse the given string representation of a time duration and return its value as a number of nanoseconds. |
static String |
printStackTrace(Throwable e) Build a stack trace for the passed exception. |
static List |
randomize(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 Object[] |
randomize(Object[] a) Randomize the order of the elements within the passed array. |
static byte[] |
read(DataInput stream) Read the contents out of the passed stream and return the result as a byte array. |
static byte[] |
read(DataInputStream stream) Read the contents out of the passed stream and return the result as a byte array. |
static byte[] |
read(File file) Read the contents out of the specified file and return the result as a byte array. |
static byte[] |
read(InputStream stream) Read the contents out of the passed stream and return the result as a byte array. |
static int |
read(InputStream stream, byte[] ab) Read the contents out of the passed stream into the passed byte array and return the length read. |
static String |
read(Reader reader) Read the contents out of the passed Reader and return the result as a String. |
static byte[] |
read(URL url) Read the contents of the specified URL and return the result as a byte array. |
static void |
redirectAll(PrintWriter out) As much as possible, print absolutely everything to the specified PrintWriter. |
static String |
replace(String sText, String sFrom, String sTo) Replace all occurences of the specified substring in the specified string. |
static void |
setErr(PrintWriter writer) Sets the current writer used for tracing. |
static void |
setLog(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(PrintWriter writer) Sets the current writer used for printing. |
static 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 String |
toBandwidthString(long cbps, boolean fExact) Format the passed bandwidth (in bytes per second) as a String. |
static 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 String |
toDecString(int n, int cDigits) Format the passed non-negative integer as a fixed-length decimal string. |
static String |
toDelimitedString(int[] an, String sDelim) Format the content of the passed integer array as a delimited string. |
static String |
toDelimitedString(Iterator iter, String sDelim) Format the content of the passed Iterator as a delimited string. |
static String |
toDelimitedString(long[] al, String sDelim) Format the content of the passed long array as a delimited string. |
static String |
toDelimitedString(Object[] ao, String sDelim) Format the content of the passed Object array as a delimited string. |
static String |
toHex(byte[] ab) Convert a byte array to the hex sequence of 2 hex digits per byte. |
static String |
toHex(int b) Convert a byte to the hex sequence of 2 hex digits. |
static String |
toHexDump(byte[] ab, int cBytesPerLine) Convert a byte array to a hex dump. |
static String |
toHexEscape(byte b) Convert a byte to a hex sequence of '0' + 'x' + 2 hex digits. |
static String |
toHexEscape(byte[] ab) Convert a byte array to a hex sequence of '0' + 'x' + 2 hex digits per byte. |
static 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 String |
toHexString(int n, int cDigits) Format the passed integer as a fixed-length hex string. |
static 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 String |
toMemorySizeString(long cb, boolean fExact) Format the passed memory size (in bytes) as a String. |
static String |
toQuotedCharEscape(char ch) Format a char to a printable escape if necessary as it would appear (quoted) in Java source code. |
static String |
toQuotedStringEscape(String s) Format a String as it would appear (quoted) in Java source code, escaping characters as necessary. |
static String |
toSqlString(String s) Escapes the string for SQL. |
static String |
toString(Class clz) Formats Class information for debug output purposes. |
static String |
toString(double dfl, int cMinDigits) Format a double value as a String. |
static String |
toStringEscape(String s) Format a String escaping characters as necessary. |
static String |
toUnicodeEscape(char ch) Format a Unicode character to the Unicode escape sequence of '\' + 'u' + 4 hex digis. |
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(Object oVal) Display the value of an Object expression. |
static void |
trace(String sVal) Display the value of a String expression. |
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(String sVal)
public static void trace(Object oVal)
public static RuntimeException azzert()
public static void azzert(boolean f)
public static void azzert(boolean f, String s)
public static void azzertFailed(String sMsg)
sMsg
- the assertion messagepublic static RuntimeException ensureRuntimeException(Throwable e)
e
- any Throwable objectpublic static RuntimeException ensureRuntimeException(Throwable e, String s)
e
- any Throwable objects
- an additional descriptionpublic static Throwable getOriginalException(RuntimeException e)
e
- Runtime exception (wrapper)public static void out()
public static void out(Object o)
o
- the Object to print.public static void out(String s)
s
- the String to print.public static void out(Class clz)
clz
- the class object to print.public static void out(Throwable e)
e
- the Throwable object to print.public static void err()
public static void err(Object o)
o
- the Object to print.public static void err(String s)
s
- the String to print.public static void err(Class clz)
clz
- the class object to print.public static void err(Throwable e)
e
- the Throwable object to print.public static void log()
public static void log(Object o)
o
- the Object to print.public static void log(String s)
s
- the String to print.public static void log(Class clz)
clz
- the class object to print.public static void log(Throwable e)
e
- the Throwable object to print.public static ClassLoader ensureClassLoader(ClassLoader loader)
loader
- a ClassLoader (may be null)public static ClassLoader getContextClassLoader()
public static ClassLoader getContextClassLoader(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 String getStackTrace()
public static String getStackTrace(Throwable e)
e
- a Throwable object that contains stack trace informationpublic static String getDeepMessage(Throwable t, String sDelim)
t
- the throwablesDelim
- the delimiter to include between messagespublic static String printStackTrace(Throwable e)
e
- a Throwable object that contains stack trace informationpublic static Thread makeThread(ThreadGroup group, Runnable runnable, String sName)
group
- (optional) the thread's thread grouprunnable
- (optional) the thread's runnablesName
- (optional) the thread's namepublic static ThreadFactory getThreadFactory()
public static Base.CommonMonitor getCommonMonitor(int i)
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. <p/> 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(Object o)
o
- the object to obtain a common monitor forgetCommonMonitor(int)
public static String toString(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 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 String toHexString(int n, int cDigits)
n
- the valuecDigits
- the length of the resulting hex stringpublic static String toHex(int b)
b
- the bytepublic static String toHex(byte[] ab)
ab
- the byte arraypublic static String toHexEscape(byte b)
b
- the bytepublic static String toHexEscape(byte[] ab)
ab
- the byte arraypublic static String toHexEscape(byte[] ab, int of, int cb)
ab
- the byte arrayof
- the offset into arraycb
- the number of bytes to convertpublic static 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(String s)
s
- the hex String to evaluatepublic static int parseHex(char ch)
ch
- the hex character to evaluatepublic static String toString(double dfl, int cMinDigits)
dfl
- a double valuecMinDigits
- the minimum number of digits of precision to displaypublic static String toUnicodeEscape(char ch)
ch
- the characterpublic static String toCharEscape(char ch)
ch
- the charpublic static String toQuotedCharEscape(char ch)
ch
- the characterpublic static String toStringEscape(String s)
s
- the Stringpublic static String toQuotedStringEscape(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 String toSqlString(String s)
public static String indentString(String sText, String sIndent)
sText
- the string to indentsIndent
- a string used to indent each linepublic static String indentString(String sText, 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 String breakLines(String sText, int nWidth, 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 String breakLines(String sText, int nWidth, 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 String dup(char ch, int cch)
ch
- the character to fill the String withcch
- the length of the Stringpublic static String dup(String s, int c)
s
- the String to fill the new String withc
- the number of duplicates to put into the new Stringpublic static String replace(String sText, String sFrom, String sTo)
sText
- string to changesFrom
- pattern to change fromsTo
- pattern to change topublic static String[] parseDelimitedString(String s, char chDelim)
s
- character-delimited String to parsechDelim
- character delimiterpublic static String toDelimitedString(int[] an, String sDelim)
an
- the arraysDelim
- the delimiterpublic static String toDelimitedString(long[] al, String sDelim)
al
- the arraysDelim
- the delimiterpublic static String toDelimitedString(Object[] ao, String sDelim)
ao
- the arraysDelim
- the delimiterpublic static String toDelimitedString(Iterator iter, String sDelim)
iter
- the IteratorsDelim
- the delimiterpublic static long parseBandwidth(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 preceeding 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(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 preceeding decimal value should be multiplied:
If the string value does not contain an explict 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 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 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(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 preceeding 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(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 preceeding decimal value should be multiplied:
If the string value does not contain an explict 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 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 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(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(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(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(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 String formatDateTime(long ldt)
ldt
- a Java long containing a date/time valuepublic static int hashCode(Object o)
o
- the object to hashpublic static boolean equals(Object o1, Object o2)
o1
-o2
-public static boolean equalsDeep(Object o1, 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 long getUpTimeMillis()
public static long getSafeTimeMillis()
SafeClock
public static long getLastSafeTimeMillis()
getSafeTimeMillis()
method.SafeClock
public static Integer makeInteger(int n)
n
- an intpublic static Long makeLong(long n)
n
- a longpublic static Random getRandom()
public static List randomize(Collection coll)
coll
- the Collection to randomize; the passed Collection is not alteredpublic static Object[] randomize(Object[] a)
a
- an array of objects to randomizepublic static int[] randomize(int[] a)
a
- an array of int values to randomizepublic static 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 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 PrintWriter getOut()
public static void setOut(PrintWriter writer)
writer
- the java.io.PrintWriter instance to use for printing; may be nullpublic static PrintWriter getErr()
public static void setErr(PrintWriter writer)
writer
- the java.io.PrintWriter instance to use for tracing; may be nullpublic static PrintWriter getLog()
public static void setLog(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 void redirectAll(PrintWriter out)
out
- the PrintWriter to write everything topublic static int read(InputStream stream, byte[] ab) throws IOException
stream
- a java.io.InputStream object to read fromab
- a byte array to read intoIOException
public static byte[] read(InputStream stream) throws IOException
stream
- a java.io.InputStream object to read fromIOException
public static byte[] read(DataInput stream) throws IOException
stream
- a java.io.DataInput object to read fromIOException
public static byte[] read(DataInputStream stream) throws IOException
stream
- a java.io.DataInputStream object to read fromIOException
public static String read(Reader reader) throws IOException
reader
- a java.io.Reader object to read fromIOException
public static byte[] read(File file) throws IOException
file
- the java.io.File object to read the contents ofIOException
public static byte[] read(URL url) throws IOException
url
- the java.net.URL object to read the contents ofIOException
|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |