|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
public abstract class Base
Base class for providing standard functionality.
Nested Class Summary | |
---|---|
static class |
Base.StackFrame
A class that provides "stack frame" information from a line of a stack trace. |
Field Summary | |
---|---|
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 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 Object |
getCommonMonitor(int i)
Return the common monitor associated with the specified integer value. |
static Object |
getCommonMonitor(long l)
Return the common monitor associated with the specified long value. |
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 PrintWriter |
getErr()
Obtains the current writer used for tracing. |
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 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 int[] |
randomize(int[] a)
Randomize the order of the elements within the passed array. |
static List |
randomize(List list)
Randomize the order of the elements within the passed list. |
static Object[] |
randomize(Object[] a)
Randomize the order of the elements within the passed 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 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 |
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. |
protected static long |
updateSafeTimeMillis(long ldtAssumed)
Updates and returns a "safe" current time in milliseconds based on the "unsafe" assumed time. |
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 ValuesConstructor 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 object
public static RuntimeException ensureRuntimeException(Throwable e, String s)
e
- any Throwable objects
- an additional description
public 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 getContextClassLoader()
public static ClassLoader getContextClassLoader(Object o)
o
- the calling object, or any object out of the application
that is requesting the class loader
public 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 information
public static String printStackTrace(Throwable e)
e
- a Throwable object that contains stack trace information
public 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 name
public static Object 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. 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 identifier
public static Object getCommonMonitor(long l)
l
- the common monitor identifier
getCommonMonitor(int)
public static String toString(Class clz)
clz
- the Class to print information for
public 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 value
public static String toDecString(int n, int cDigits)
n
- the valuecDigits
- the length of the resulting decimal string
public static long pad(long lMin, long lMultiple)
lMin
- the smallest value to returnlMultiple
- the return value will be a multiple of this argument
public 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 value
public static String toHexString(int n, int cDigits)
n
- the valuecDigits
- the length of the resulting hex string
public static String toHex(int b)
b
- the byte
public static String toHex(byte[] ab)
ab
- the byte array
public static String toHexEscape(byte b)
b
- the byte
public static String toHexEscape(byte[] ab)
ab
- the byte array
public static String toHexEscape(byte[] ab, int of, int cb)
ab
- the byte arrayof
- the offset into arraycb
- the number of bytes to convert
public 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 line
public static byte[] parseHex(String s)
s
- the hex String to evaluate
public static int parseHex(char ch)
ch
- the hex character to evaluate
public static String toUnicodeEscape(char ch)
ch
- the character
public static String toCharEscape(char ch)
ch
- the char
public static String toQuotedCharEscape(char ch)
ch
- the character
public static String toStringEscape(String s)
s
- the String
public static String toQuotedStringEscape(String s)
s
- the String
public 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 at
public static String toSqlString(String s)
public static String indentString(String sText, String sIndent)
sText
- the string to indentsIndent
- a string used to indent each line
public 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 first
public 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 line
public 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 first
public static String dup(char ch, int cch)
ch
- the character to fill the String withcch
- the length of the String
public 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 String
public static String replace(String sText, String sFrom, String sTo)
sText
- string to changesFrom
- pattern to change fromsTo
- pattern to change to
public static String[] parseDelimitedString(String s, char chDelim)
s
- character-delimited String to parsechDelim
- character delimiter
public static String toDelimitedString(int[] an, String sDelim)
an
- the arraysDelim
- the delimiter
public static String toDelimitedString(long[] al, String sDelim)
al
- the arraysDelim
- the delimiter
public static String toDelimitedString(Object[] ao, String sDelim)
ao
- the arraysDelim
- the delimiter
public static String toDelimitedString(Iterator iter, String sDelim)
iter
- the IteratorsDelim
- the delimiter
public 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
string
public 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 second
public 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 approximation
public 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
string
public 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 memory
public 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 approximation
public 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 string
parseTimeNanos(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 string
public static String formatDateTime(long ldt)
ldt
- a Java long containing a date/time value
public 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 bytes
public static int toCrc(byte[] ab, int of, int cb)
ab
- an array of bytesof
- the offset into the arraycb
- the number of bytes to evaluate
public 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 value
public static long getSafeTimeMillis()
System.currentTimeMillis()
this method guarantees
that the time never "goes back".
More specifically, when called twice on the same thread, the second
call will never return a value that is less then the value returned by
the first call. If a system time correction becomes necessary, an
attempt will be made to gradually compensate the returned value, so in
the long run the value returned by this method is the same as the
system time.
Additionally, the following always holds true:
Base.getSafeTime() >= System.currentTimeMillis();
protected static long updateSafeTimeMillis(long ldtAssumed)
Base.updateSafeSafeTime(assumed) >= assumed;
ldtAssumed
- the assumed current time in milliseconds
public static Integer makeInteger(int n)
n
- an int
public static Long makeLong(long n)
n
- a long
public static Random getRandom()
public static List randomize(List list)
list
- the List to randomize; the passed List is not altered
public static Object[] randomize(Object[] a)
a
- an array of objects to randomize
public static int[] randomize(int[] a)
a
- an array of int values to randomize
public 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 Binary
public 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
values
public 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 into
IOException
public static byte[] read(InputStream stream) throws IOException
stream
- a java.io.InputStream object to read from
IOException
public static String read(Reader reader) throws IOException
reader
- a java.io.Reader object to read from
IOException
public static byte[] read(File file) throws IOException
file
- the java.io.File object to read the contents of
IOException
public static byte[] read(URL url) throws IOException
url
- the java.net.URL object to read the contents of
IOException
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |