Class Base

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Base.LoggingWriter
      Inner class for over-riding the destination of log(), out() and err() calls.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int LOG_ALWAYS
      It is expected that items with a log level of 0 will always be logged.
      static int LOG_CONFIG
      Log level 4 indicates configuration related log message.
      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

      Constructors 
      Constructor Description
      Base()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      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 String capitalize​(String s)
      Capitalize a string.
      static void checkNotEmpty​(String s, String sName)
      Check that the specified string is neither a null nor an empty string.
      static <T> T checkNotNull​(T o, String sName)
      Check that the specified object is non-null and return it.
      static void checkRange​(long lValue, long lFrom, long lTo, 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 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 BigDecimal ensureBigDecimal​(Number num)
      Ensure the specified Number is a BigDecimal value or convert it into a new BigDecimal object.
      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 StackTrace.StackFrame getCallerStackFrame()
      Get the StackFrame information for the caller of the current method.
      static com.oracle.coherence.common.util.CommonMonitor getCommonMonitor​(int i)
      Return the common monitor associated with the specified integer value.
      static com.oracle.coherence.common.util.CommonMonitor getCommonMonitor​(long l)
      Return the common monitor associated with the specified long value.
      static com.oracle.coherence.common.util.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 int getProcessRandom()
      Return a random number assigned to this process.
      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 Binary getRandomBinary​(int cbMin, int cbMax, byte... abHead)
      Generates a random-length Binary including abHead at the head of the Binary, in addition to random bytes within the length bounds provided.
      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 StackTrace.StackFrame getStackFrame()
      Get the StackFrame information for the current method.
      static StackTrace.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​(Thread t)
      Print stack trace for running 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 TimeZone getTimeZone​(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​(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 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 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​(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)
      Deprecated.
      static Long makeLong​(long n)
      Deprecated.
      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 <T> T[] mergeArray​(T[] a1, T[] a2)
      Merge two array with type T elements.
      static boolean[] mergeBooleanArray​(boolean[] af1, boolean[] af2)
      Merge two boolean arrays.
      static byte[] mergeByteArray​(byte[] ab1, byte[] ab2)
      Merge two byte arrays.
      static char[] mergeCharArray​(char[] ac1, char[] ac2)
      Merge two char arrays.
      static double[] mergeDoubleArray​(double[] adfl1, double[] adfl2)
      Merge two double arrays.
      static float[] mergeFloatArray​(float[] afl1, float[] afl2)
      Merge two float arrays.
      static int[] mergeIntArray​(int[] ai1, int[] ai2)
      Merge two int arrays.
      static long[] mergeLongArray​(long[] al1, long[] al2)
      Merge two long arrays.
      static int mod​(int n, int m)
      Calculate a modulo of two integer numbers.
      static long mod​(long n, long m)
      Calculate a modulo of two long numbers.
      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 hexadecimal digit.
      static byte[] parseHex​(String s)
      Parse the passed String of hexadecimal 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 float parsePercentage​(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​(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 long[] randomize​(long[] 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 List randomize​(Collection coll)
      Randomize the order of the elements within the passed collection.
      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 String replace​(String sText, String sFrom, String sTo)
      Replace all occurrences 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 void sleep​(long cMillis)
      Convenience method for Thread.sleep(long).
      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 int toCrc​(ByteSequence seq)
      Calculate a CRC32 value from a ByteSequence.
      static int toCrc​(ByteSequence seq, int of, int cb, int nCrc)
      Continue to calculate a CRC32 value from a portion of a ByteSequence .
      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​(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 toDelimitedString​(Iterator<?> iter, String sDelim)
      Format the content of the passed Iterator 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 toHexEscape​(ByteSequence seq, int of, int cb)
      Convert a ByteSequence 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​(double dfl, int cMinDigits)
      Format a double value as a String.
      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 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​(Object oVal)
      Display the value of an Object expression.
      static void trace​(String sVal)
      Display the value of a String expression.
      static String truncateString​(String s, int cLimit)
      Truncate a string to the specified character count.
      static String truncateString​(Collection<?> coll, int cLimit)
      Provide a string representation of elements within the collection until the concatenated string length exceeds cLimit.
      static void wait​(Object o, long cMillis)
      Convenience method for Object.wait(long).
    • Constructor Detail

      • Base

        public Base()
    • Method Detail

      • trace

        public static void trace​(boolean fVal)
        Display the value of a boolean expression.
        Parameters:
        fVal - the boolean value
      • trace

        public static void trace​(char chVal)
        Display the value of a char expression.
        Parameters:
        chVal - the char value
      • trace

        public static void trace​(int nVal)
        Display the value of an int expression.
        Parameters:
        nVal - the int value
      • trace

        public static void trace​(long lVal)
        Display the value of a long expression.
        Parameters:
        lVal - the long value
      • trace

        public static void trace​(float flVal)
        Display the value of a float expression.
        Parameters:
        flVal - the float value
      • trace

        public static void trace​(double dflVal)
        Display the value of a double expression.
        Parameters:
        dflVal - the double value
      • trace

        public static void trace​(byte[] ab)
        Display the value of a byte array expression.
        Parameters:
        ab - the byte array value
      • trace

        public static void trace​(String sVal)
        Display the value of a String expression.
        Parameters:
        sVal - the String value
      • trace

        public static void trace​(Object oVal)
        Display the value of an Object expression.
        Parameters:
        oVal - the Object value
      • azzert

        public static RuntimeException azzert()
        Definite assertion failure.
        Returns:
        null
      • azzert

        public static void azzert​(boolean f)
        Test an assertion.
        Parameters:
        f - the boolean to be checked
      • azzert

        public static void azzert​(boolean f,
                                  String s)
        Test an assertion, and print the specified message if the assertion fails.
        Parameters:
        f - the boolean to be checked
        s - the assertion message
      • azzertFailed

        public static void azzertFailed​(String sMsg)
        Throw an assertion exception.
        Parameters:
        sMsg - the assertion message
      • out

        public static void out()
        Prints a blank line.
      • out

        public static void out​(Object o)
        Prints the passed Object.
        Parameters:
        o - the Object to print.
      • out

        public static void out​(String s)
        Prints the passed String value.
        Parameters:
        s - the String to print.
      • out

        public static void out​(Class<?> clz)
        Prints the passed class information.
        Parameters:
        clz - the class object to print.
      • out

        public static void out​(Throwable e)
        Prints the passed exception information.
        Parameters:
        e - the Throwable object to print.
      • err

        public static void err()
        Prints a blank line to the trace Writer.
      • err

        public static void err​(Object o)
        Prints the passed Object to the trace Writer.
        Parameters:
        o - the Object to print.
      • err

        public static void err​(String s)
        Prints the passed String value to the trace Writer.
        Parameters:
        s - the String to print.
      • err

        public static void err​(Class<?> clz)
        Prints the passed class information to the trace Writer.
        Parameters:
        clz - the class object to print.
      • err

        public static void err​(Throwable e)
        Prints the passed exception information to the trace Writer.
        Parameters:
        e - the Throwable object to print.
      • log

        public static void log()
        Prints a blank line to the log.
      • log

        public static void log​(Object o)
        Prints the passed Object to the log.
        Parameters:
        o - the Object to print
      • log

        public static void log​(String s)
        Prints the passed String value to the log.
        Parameters:
        s - the String to print
      • log

        public static void log​(Class<?> clz)
        Prints the passed class information to the log.
        Parameters:
        clz - the class object to print
      • log

        public static void log​(Throwable e)
        Prints the passed exception information to the log.
        Parameters:
        e - the Throwable object to print
      • ensureClassLoader

        public static ClassLoader ensureClassLoader​(ClassLoader loader)
        Obtain a non-null ClassLoader.
        Parameters:
        loader - a ClassLoader (may be null)
        Returns:
        the passed ClassLoader (if not null), or the ContextClassLoader
      • getContextClassLoader

        public static ClassLoader getContextClassLoader()
        Try to determine the ClassLoader that supports the current context.
        Returns:
        a ClassLoader to use for the current context
      • getContextClassLoader

        public static ClassLoader getContextClassLoader​(Object o)
        Try to determine the ClassLoader that supports the current context.
        Parameters:
        o - the calling object, or any object out of the application that is requesting the class loader
        Returns:
        a ClassLoader to use for the current context
      • getCallerStackFrame

        public static StackTrace.StackFrame getCallerStackFrame()
        Get the StackFrame information for the caller of the current method.
        Returns:
        the StackFrame information for the caller of the current method
      • getStackFrame

        public static StackTrace.StackFrame getStackFrame()
        Get the StackFrame information for the current method.
        Returns:
        the StackFrame information for the current method
      • getStackFrames

        public static StackTrace.StackFrame[] getStackFrames()
        Iterate the StackFrame information for all callers, going from the inside outwards, and starting with the caller of this method.
        Returns:
        an Iterator of StackFrames
      • getStackTrace

        public static String getStackTrace()
        Build a stack trace for the current thread.
        Returns:
        a String containing a printable stack trace
      • getStackTrace

        public static String getStackTrace​(Throwable e)
        Build a stack trace for the passed exception that does not include the exception description itself.
        Parameters:
        e - a Throwable object that contains stack trace information
        Returns:
        a String containing a printable stack trace
      • getStackTrace

        public static String getStackTrace​(Thread t)
        Print stack trace for running thread.
        Parameters:
        t - thread
        Returns:
        thread stack trace or empty string if thread is not running
        Since:
        Coherence 12.2.1.4.16
      • getDeepMessage

        public static String getDeepMessage​(Throwable t,
                                            String sDelim)
        Extract a throwable's message, and all causal messages.
        Parameters:
        t - the throwable
        sDelim - the delimiter to include between messages
        Returns:
        the concatenated messages
      • printStackTrace

        public static String printStackTrace​(Throwable e)
        Build a stack trace for the passed exception.
        Parameters:
        e - a Throwable object that contains stack trace information
        Returns:
        a String containing a printable stack trace
      • ensureBigDecimal

        public static BigDecimal ensureBigDecimal​(Number num)
        Ensure the specified Number is a BigDecimal value or convert it into a new BigDecimal object.
        Parameters:
        num - a Number object
        Returns:
        a BigDecimal object that is equal to the passed in Number
      • makeThread

        public 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.
        Parameters:
        group - (optional) the thread's thread group
        runnable - (optional) the thread's runnable
        sName - (optional) the thread's name
        Returns:
        a new thread using the specified parameters
      • getThreadFactory

        public static ThreadFactory getThreadFactory()
        Return the configured thread factory.
        Returns:
        the configured thread factory, or null if none has been configured
      • sleep

        public static void sleep​(long cMillis)
        Convenience method for 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.

        Parameters:
        cMillis - the maximum time to wait in milliseconds
      • wait

        public static void wait​(Object o,
                                long cMillis)
        Convenience method for 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.

        Parameters:
        o - the Object to wait for
        cMillis - the maximum time to wait in milliseconds
      • getCommonMonitor

        public static com.oracle.coherence.common.util.CommonMonitor getCommonMonitor​(int i)
        Return the common monitor associated with the specified integer value.
        Parameters:
        i - the common monitor identifier
        Returns:
        the associated monitor
        See Also:
        CommonMonitor
      • getCommonMonitor

        public static com.oracle.coherence.common.util.CommonMonitor getCommonMonitor​(long l)
        Return the common monitor associated with the specified long value.
        Parameters:
        l - the common monitor identifier
        Returns:
        the associated monitor
        See Also:
        CommonMonitor
      • getCommonMonitor

        public static com.oracle.coherence.common.util.CommonMonitor getCommonMonitor​(Object o)
        Return the common monitor associated with the specified object based on its identity hashCode.
        Parameters:
        o - the object to obtain a common monitor for
        Returns:
        the associated monitor
        See Also:
        CommonMonitor
      • toString

        public static String toString​(Class<?> clz)
        Formats Class information for debug output purposes.
        Parameters:
        clz - the Class to print information for
        Returns:
        a String describing the Class in detail
      • isDecimal

        public static boolean isDecimal​(char ch)
        Returns true if the passed character is a decimal digit.
        Parameters:
        ch - The character to check
        Returns:
        true if the passed character is a decimal digit
      • decimalValue

        public static int decimalValue​(char ch)
        Returns the integer value of a decimal digit.
        Parameters:
        ch - The character to convert
        Returns:
        the integer value of a decimal digit
      • getMaxDecDigits

        public static int getMaxDecDigits​(int n)
        Calculate the number of decimal digits needed to display the passed value.
        Parameters:
        n - the value
        Returns:
        the number of decimal digits needed to display the value
      • toDecString

        public static String toDecString​(int n,
                                         int cDigits)
        Format the passed non-negative integer as a fixed-length decimal string.
        Parameters:
        n - the value
        cDigits - the length of the resulting decimal string
        Returns:
        the decimal value formatted to the specified length string
      • pad

        public 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. Effectively rounds the first argument up to a multiple of the second.
        Parameters:
        lMin - the smallest value to return
        lMultiple - the return value will be a multiple of this argument
        Returns:
        the smallest multiple of the second argument that is not less than the first
      • isOctal

        public static boolean isOctal​(char ch)
        Returns true if the passed character is an octal digit.
        Parameters:
        ch - The character to check
        Returns:
        true if the passed character is an octal digit
      • octalValue

        public static int octalValue​(char ch)
        Returns the integer value of an octal digit.
        Parameters:
        ch - The character to convert
        Returns:
        the integer value of an octal digit
      • isHex

        public static boolean isHex​(char ch)
        Returns true if the passed character is a hexadecimal digit.
        Parameters:
        ch - The character to check
        Returns:
        true if the passed character is a hexadecimal digit
      • hexValue

        public static int hexValue​(char ch)
        Returns the integer value of a hexadecimal digit.
        Parameters:
        ch - The character to convert
        Returns:
        the integer value
      • getMaxHexDigits

        public static int getMaxHexDigits​(int n)
        Calculate the number of hex digits needed to display the passed value.
        Parameters:
        n - the value
        Returns:
        the number of hex digits needed to display the value
      • toHexString

        public static String toHexString​(int n,
                                         int cDigits)
        Format the passed integer as a fixed-length hex string.
        Parameters:
        n - the value
        cDigits - the length of the resulting hex string
        Returns:
        the hex value formatted to the specified length string
      • toHex

        public static String toHex​(int b)
        Convert a byte to the hex sequence of 2 hex digits.
        Parameters:
        b - the byte
        Returns:
        the hex sequence
      • toHex

        public static String toHex​(byte[] ab)
        Convert a byte array to the hex sequence of 2 hex digits per byte. This is a replacement for Text.toString(char[]).
        Parameters:
        ab - the byte array
        Returns:
        the hex sequence
      • toHexEscape

        public static String toHexEscape​(byte b)
        Convert a byte to a hex sequence of '0' + 'x' + 2 hex digits.
        Parameters:
        b - the byte
        Returns:
        the hex sequence
      • toHexEscape

        public static String toHexEscape​(byte[] ab)
        Convert a byte array to a hex sequence of '0' + 'x' + 2 hex digits per byte.
        Parameters:
        ab - the byte array
        Returns:
        the hex sequence
      • toHexEscape

        public 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.
        Parameters:
        ab - the byte array
        of - the offset into array
        cb - the number of bytes to convert
        Returns:
        the hex sequence
      • toHexEscape

        public static String toHexEscape​(ByteSequence seq,
                                         int of,
                                         int cb)
        Convert a ByteSequence to a hex sequence of '0' + 'x' + 2 hex digits per byte.
        Parameters:
        seq - the ByteSequence
        of - the offset into the byte sequence
        cb - the number of bytes to convert
        Returns:
        the hex sequence
        Since:
        Coherence 3.7
      • toHexDump

        public static String toHexDump​(byte[] ab,
                                       int cBytesPerLine)
        Convert a byte array to a hex dump. This is a replacement for Text.toString(byte[] ab, int cBytesPerLine).
        Parameters:
        ab - the byte array to format as a hex string
        cBytesPerLine - the number of bytes to display on a line
        Returns:
        a multi-line hex dump
      • parseHex

        public static byte[] parseHex​(String s)
        Parse the passed String of hexadecimal characters into a binary value. This implementation allows the passed String to be prefixed with "0x".
        Parameters:
        s - the hex String to evaluate
        Returns:
        the byte array value of the passed hex String
      • parseHex

        public static int parseHex​(char ch)
        Return the integer value of a hexadecimal digit.
        Parameters:
        ch - the hex character to evaluate
        Returns:
        the integer value of the passed hex character
      • toString

        public static String toString​(double dfl,
                                      int cMinDigits)
        Format a double value as a String.
        Parameters:
        dfl - a double value
        cMinDigits - the minimum number of digits of precision to display
        Returns:
        the double value formatted as a String
      • toUnicodeEscape

        public static String toUnicodeEscape​(char ch)
        Format a Unicode character to the Unicode escape sequence of '\' + 'u' + 4 hex digits.
        Parameters:
        ch - the character
        Returns:
        the Unicode escape sequence
      • toCharEscape

        public static String toCharEscape​(char ch)
        Format a char to a printable escape if necessary.
        Parameters:
        ch - the char
        Returns:
        a printable String representing the passed char
      • toQuotedCharEscape

        public static String toQuotedCharEscape​(char ch)
        Format a char to a printable escape if necessary as it would appear (quoted) in Java source code. This is a replacement for Text.printableChar().
        Parameters:
        ch - the character
        Returns:
        a printable String in single quotes representing the passed char
      • toStringEscape

        public static String toStringEscape​(String s)
        Format a String escaping characters as necessary.
        Parameters:
        s - the String
        Returns:
        a printable String representing the passed String
      • toQuotedStringEscape

        public static String toQuotedStringEscape​(String s)
        Format a String as it would appear (quoted) in Java source code, escaping characters as necessary. This is a replacement for Text.printableString().
        Parameters:
        s - the String
        Returns:
        a printable String in double quotes representing the passed String
      • escape

        public 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. The array must be large enough to accept six characters.
        Parameters:
        ch - the character to format
        ach - the array of characters to format into
        of - the offset in the array to format at
        Returns:
        the number of characters used to format the char
      • toSqlString

        public static String toSqlString​(String s)
        Escapes the string for SQL.
        Parameters:
        s - the String to escape
        Returns:
        the string quoted for SQL and escaped as necessary
      • indentString

        public static String indentString​(String sText,
                                          String sIndent)
        Indent the passed multi-line string.
        Parameters:
        sText - the string to indent
        sIndent - a string used to indent each line
        Returns:
        the string, indented
      • indentString

        public static String indentString​(String sText,
                                          String sIndent,
                                          boolean fFirstLine)
        Textually indent the passed multi-line string.
        Parameters:
        sText - the string to indent
        sIndent - a string used to indent each line
        fFirstLine - true indents all lines; false indents all but the first
        Returns:
        the string, indented
      • breakLines

        public static String breakLines​(String sText,
                                        int nWidth,
                                        String sIndent)
        Breaks the specified string into a multi-line string.
        Parameters:
        sText - the string to break
        nWidth - the max width of resulting lines (including the indent)
        sIndent - a string used to indent each line
        Returns:
        the string, broken and indented
      • breakLines

        public static String breakLines​(String sText,
                                        int nWidth,
                                        String sIndent,
                                        boolean fFirstLine)
        Breaks the specified string into a multi-line string.
        Parameters:
        sText - the string to break
        nWidth - the max width of resulting lines (including the indent)
        sIndent - a string used to indent each line
        fFirstLine - if true indents all lines; otherwise indents all but the first
        Returns:
        the string, broken and indented
      • dup

        public static String dup​(char ch,
                                 int cch)
        Create a String of the specified length containing the specified character.
        Parameters:
        ch - the character to fill the String with
        cch - the length of the String
        Returns:
        a String containing the character <ch> repeated <cch> times
      • dup

        public static String dup​(String s,
                                 int c)
        Create a String which is a duplicate of the specified number of the passed String.
        Parameters:
        s - the String to fill the new String with
        c - the number of duplicates to put into the new String
        Returns:
        a String containing the String s repeated c times
      • replace

        public static String replace​(String sText,
                                     String sFrom,
                                     String sTo)
        Replace all occurrences of the specified substring in the specified string.
        Parameters:
        sText - string to change
        sFrom - pattern to change from
        sTo - pattern to change to
        Returns:
        modified string
      • parseDelimitedString

        public static String[] parseDelimitedString​(String s,
                                                    char chDelim)
        Parse a character-delimited String into an array of Strings.
        Parameters:
        s - character-delimited String to parse
        chDelim - character delimiter
        Returns:
        an array of String objects parsed from the passed String
      • toDelimitedString

        public static String toDelimitedString​(int[] an,
                                               String sDelim)
        Format the content of the passed integer array as a delimited string.
        Parameters:
        an - the array
        sDelim - the delimiter
        Returns:
        the formatted string
      • toDelimitedString

        public static String toDelimitedString​(long[] al,
                                               String sDelim)
        Format the content of the passed long array as a delimited string.
        Parameters:
        al - the array
        sDelim - the delimiter
        Returns:
        the formatted string
      • toDelimitedString

        public static String toDelimitedString​(Object[] ao,
                                               String sDelim)
        Format the content of the passed Object array as a delimited string.
        Parameters:
        ao - the array
        sDelim - the delimiter
        Returns:
        the formatted string
      • toDelimitedString

        public static String toDelimitedString​(Iterator<?> iter,
                                               String sDelim)
        Format the content of the passed Iterator as a delimited string.
        Parameters:
        iter - the Iterator
        sDelim - the delimiter
        Returns:
        the formatted string
      • capitalize

        public static String capitalize​(String s)
        Capitalize a string.
        Parameters:
        s - the string to capitalize
        Returns:
        the capitalized string
      • truncateString

        public static String truncateString​(String s,
                                            int cLimit)
        Truncate a string to the specified character count.
        Parameters:
        s - the String to be truncated
        cLimit - expected character count
        Returns:
        the truncated String
      • truncateString

        public static String truncateString​(Collection<?> coll,
                                            int cLimit)
        Provide a string representation of elements within the collection until the concatenated string length exceeds cLimit.
        Parameters:
        coll - the collection of elements to describe
        cLimit - expected character count
        Returns:
        the truncated string representation of the provided collection
      • parseBandwidth

        public static long parseBandwidth​(String s)
        Parse the given string representation of a number of bytes per second. The supplied string must be in the format:

        [\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:

        • K or k (kilo, 210)
        • M or m (mega, 220)
        • G or g (giga, 230)
        • T or t (tera, 240)

        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.

        Parameters:
        s - a string with the format: [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[[B|b][P|p][S|s]]?
        Returns:
        the number of bytes per second represented by the given string
      • parseBandwidth

        public static long parseBandwidth​(String s,
                                          int nDefaultPower)
        Parse the given string representation of a number of bytes per second. The supplied string must be in the format:

        [\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:

        • K or k (kilo, 210)
        • M or m (mega, 220)
        • G or g (giga, 230)
        • T or t (tera, 240)

        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.

        Parameters:
        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
        Returns:
        the number of bytes per second represented by the given string
      • toBandwidthString

        public 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.
        Parameters:
        cbps - the number of bytes per second
        Returns:
        a String representation of the given bandwidth
      • toBandwidthString

        public static String toBandwidthString​(long cbps,
                                               boolean fExact)
        Format the passed bandwidth (in bytes per second) as a String. This method will possibly round the memory size for purposes of producing a more-easily read String value unless the fExact parameters is passed as true; if fExact is true, then cb==parseBandwidth(toBandwidthString(cb, true)) holds true for all legal values of cbps.
        Parameters:
        cbps - the number of bytes per second
        fExact - true if the String representation must be exact, or false if it can be an approximation
        Returns:
        a String representation of the given bandwidth
      • parseMemorySize

        public static long parseMemorySize​(String s)
        Parse the given string representation of a number of bytes. The supplied string must be in the format:

        [\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:

        • K or k (kilo, 210)
        • M or m (mega, 220)
        • G or g (giga, 230)
        • T or t (tera, 240)

        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.

        Parameters:
        s - a string with the format [\d]+[[.][\d]+]?[K|k|M|m|G|g|T|t]?[B|b]?
        Returns:
        the number of bytes represented by the given string
      • parseMemorySize

        public static long parseMemorySize​(String s,
                                           int nDefaultPower)
        Parse the given string representation of a number of bytes. The supplied string must be in the format:

        [\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:

        • K or k (kilo, 210)
        • M or m (mega, 220)
        • G or g (giga, 230)
        • T or t (tera, 240)

        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.

        Parameters:
        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
        Returns:
        the number of bytes represented by the given string
      • toMemorySizeString

        public 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.
        Parameters:
        cb - the number of bytes of memory
        Returns:
        a String representation of the given memory size
      • toMemorySizeString

        public static String toMemorySizeString​(long cb,
                                                boolean fExact)
        Format the passed memory size (in bytes) as a String. This method will possibly round the memory size for purposes of producing a more-easily read String value unless the fExact parameters is passed as true; if fExact is true, then cb==parseMemorySize(toMemorySizeString(cb, true)) holds true for all legal values of cb.
        Parameters:
        cb - the number of bytes of memory
        fExact - true if the String representation must be exact, or false if it can be an approximation
        Returns:
        a String representation of the given memory size
      • parseTime

        public static long parseTime​(String s)
        Parse the given string representation of a time duration and return its value as a number of milliseconds. The supplied string must be in the format:

        [\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:

        • NS or ns (nanoseconds)
        • US or us (microseconds)
        • MS or ms (milliseconds)
        • S or s (seconds)
        • M or m (minutes)
        • H or h (hours)
        • D or d (days)

        If the string value does not contain a unit, a unit of milliseconds is assumed.

        Parameters:
        s - a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
        Returns:
        the number of milliseconds represented by the given string rounded down to the nearest millisecond
        See Also:
        parseTimeNanos(String)
      • parseTime

        public 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. The supplied string must be in the format:

        [\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:

        • NS or ns (nanoseconds)
        • US or us (microseconds)
        • MS or ms (milliseconds)
        • S or s (seconds)
        • M or m (minutes)
        • H or h (hours)
        • D or d (days)

        If the string value does not contain a unit, the specified default unit is assumed. The default unit can be one of:

        Parameters:
        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
        Returns:
        the number of milliseconds represented by the given string rounded down to the nearest millisecond
        See Also:
        parseTimeNanos(String, int)
      • parseTimeNanos

        public static long parseTimeNanos​(String s)
        Parse the given string representation of a time duration and return its value as a number of nanoseconds. The supplied string must be in the format:

        [\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:

        • NS or ns (nanoseconds)
        • US or us (microseconds)
        • MS or ms (milliseconds)
        • S or s (seconds)
        • M or m (minutes)
        • H or h (hours)
        • D or d (days)

        If the string value does not contain a unit, a unit of nanoseconds is assumed.

        Parameters:
        s - a string with the format [\d]+[[.][\d]+]?[NS|ns|US|us|MS|ms|S|s|M|m|H|h|D|d]?
        Returns:
        the number of nanoseconds represented by the given string rounded down to the nearest nanosecond
      • parseTimeNanos

        public 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. The supplied string must be in the format:

        [\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:

        • NS or ns (nanoseconds)
        • US or us (microseconds)
        • MS or ms (milliseconds)
        • S or s (seconds)
        • M or m (minutes)
        • H or h (hours)
        • D or d (days)

        If the string value does not contain a unit, the specified default unit is assumed. The default unit can be one of:

        Parameters:
        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
        Returns:
        the number of nanoseconds represented by the given string rounded down to the nearest nanosecond
      • formatDateTime

        public static String formatDateTime​(long ldt)
        Format a long value into a human readable date/time string.
        Parameters:
        ldt - a Java long containing a date/time value
        Returns:
        a human readable date/time string
      • parsePercentage

        public static float parsePercentage​(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. The supplied string must be in the format:

        [\d]+[[.][\d]+]?[%]

        where the digits are within the closed interval [0.0, 100.0].

        Parameters:
        s - a string with the format [\d]+[[.][\d]+]?[%]
        Returns:
        a float representing the percentage value in the closed interval [0.0, 1.0]
      • hashCode

        public static int hashCode​(Object o)
        Return the hash code for the supplied object or 0 for null.
        Parameters:
        o - the object to hash
        Returns:
        the hash code for the supplied object
      • equals

        public static boolean equals​(Object o1,
                                     Object o2)
        Compare two references for equality.
        Parameters:
        o1 - an object
        o2 - an object to be compared with o1 for references equality
        Returns:
        true if equal, false otherwise
      • equalsDeep

        public static boolean equalsDeep​(Object o1,
                                         Object o2)
        Deeply compare two references for equality. This dives down into arrays, including nested arrays.
        Parameters:
        o1 - an object
        o2 - an object to be compared with o1 for deeply equality
        Returns:
        true if deeply equal, false otherwise
      • toCrc

        public static int toCrc​(byte[] ab)
        Calculate a CRC32 value from a byte array.
        Parameters:
        ab - an array of bytes
        Returns:
        the 32-bit CRC value
      • toCrc

        public static int toCrc​(byte[] ab,
                                int of,
                                int cb)
        Calculate a CRC32 value from a portion of a byte array.
        Parameters:
        ab - an array of bytes
        of - the offset into the array
        cb - the number of bytes to evaluate
        Returns:
        the 32-bit CRC value
      • toCrc

        public static int toCrc​(byte[] ab,
                                int of,
                                int cb,
                                int nCrc)
        Continue to calculate a CRC32 value from a portion of a byte array.
        Parameters:
        ab - an array of bytes
        of - the offset into the array
        cb - the number of bytes to evaluate
        nCrc - the previous CRC value
        Returns:
        the 32-bit CRC value
      • toCrc

        public static int toCrc​(ByteSequence seq)
        Calculate a CRC32 value from a ByteSequence.
        Parameters:
        seq - a ByteSequence
        Returns:
        the 32-bit CRC value
      • toCrc

        public static int toCrc​(ByteSequence seq,
                                int of,
                                int cb,
                                int nCrc)
        Continue to calculate a CRC32 value from a portion of a ByteSequence .
        Parameters:
        seq - a ByteSequence
        of - the offset into the ByteSequence
        cb - the number of bytes to evaluate
        nCrc - the previous CRC value
        Returns:
        the 32-bit CRC value
      • getUpTimeMillis

        public static long getUpTimeMillis()
        Return the number of milliseconds which have elapsed since the JVM was started.
        Returns:
        the number of milliseconds which have elapsed since the JVM was started
      • getSafeTimeMillis

        public static long getSafeTimeMillis()
        Returns a "safe" current time in milliseconds.
        Returns:
        the difference, measured in milliseconds, between the corrected current time and midnight, January 1, 1970 UTC.
        See Also:
        SafeClock
      • getLastSafeTimeMillis

        public static long getLastSafeTimeMillis()
        Returns the last "safe" time as computed by a previous call to the getSafeTimeMillis() method.
        Returns:
        the last "safe" time in milliseconds
        See Also:
        SafeClock
      • computeSafeWaitTime

        public static long computeSafeWaitTime​(long ldtTimeout)
        compute the number of milliseconds until the specified time.

        Note: this method will only return zero if ldtTimeout == Long.MAX_VALUE.

        Parameters:
        ldtTimeout - the timeout as computed by getSafeTimeMillis()
        Returns:
        the number of milliseconds to wait, or negative if the timeout has expired
      • makeInteger

        @Deprecated
        public static Integer makeInteger​(int n)
        Deprecated.
        Factory method to produce Integer objects with an optimization that uses cached Integer objects for all relatively-low numbers.
        Parameters:
        n - an int
        Returns:
        an Integer whose value is the passed int
        Since:
        Coherence 3.2
      • makeLong

        @Deprecated
        public static Long makeLong​(long n)
        Deprecated.
        Factory method to produce Long objects with an optimization that uses cached Long objects for all relatively-low numbers.
        Parameters:
        n - a long
        Returns:
        a Long whose value is the passed long
        Since:
        Coherence 3.2
      • getProcessRandom

        public static int getProcessRandom()
        Return a random number assigned to this process.

        This value will remain the same across invocations, but is generally different across JVMs.

        Returns:
        the process's random number.
      • getRandom

        public static Random getRandom()
        Obtain a Random object that can be used to get random values.
        Returns:
        a random number generator
        Since:
        Coherence 3.2
      • randomize

        public static List randomize​(Collection coll)
        Randomize the order of the elements within the passed collection.
        Parameters:
        coll - the Collection to randomize; the passed Collection is not altered
        Returns:
        a new and immutable List whose contents are identical to those of the passed collection except for the order in which they appear
        Since:
        Coherence 3.2
      • randomize

        public static Object[] randomize​(Object[] a)
        Randomize the order of the elements within the passed array.
        Parameters:
        a - an array of objects to randomize
        Returns:
        the array that was passed in, and with its contents unchanged except for the order in which they appear
        Since:
        Coherence 3.2
      • randomize

        public static int[] randomize​(int[] a)
        Randomize the order of the elements within the passed array.
        Parameters:
        a - an array of int values to randomize
        Returns:
        the array that was passed in, and with its contents unchanged except for the order in which they appear
        Since:
        Coherence 3.2
      • randomize

        public static long[] randomize​(long[] a)
        Randomize the order of the elements within the passed array.
        Parameters:
        a - an array of long values to randomize
        Returns:
        the array that was passed in, and with its contents unchanged except for the order in which they appear
        Since:
        Coherence 12.2.1.4
      • getRandomBinary

        public static Binary getRandomBinary​(int cbMin,
                                             int cbMax)
        Generates a random-length Binary within the length bounds provided whose contents are random bytes.
        Parameters:
        cbMin - the minimum number of bytes in the resulting Binary
        cbMax - the maximum number of bytes in the resulting Binary
        Returns:
        a randomly generated Binary object
        Since:
        Coherence 3.2
      • getRandomBinary

        public static Binary getRandomBinary​(int cbMin,
                                             int cbMax,
                                             byte... abHead)
        Generates a random-length Binary including abHead at the head of the Binary, in addition to random bytes within the length bounds provided.
        Parameters:
        cbMin - the minimum number of bytes in the resulting Binary
        cbMax - the maximum number of bytes in the resulting Binary
        abHead - the head of the returned Binary
        Returns:
        a randomly generated Binary object with a length of [len(abHead) + cbMin, cbMax]
        Since:
        Coherence 12.1.3
      • getRandomString

        public static String getRandomString​(int cchMin,
                                             int cchMax,
                                             boolean fAscii)
        Generates a random-length String within the length bounds provided. If the ASCII option is indicated, the characters will be in the range [32-127], otherwise the characters will be in the range [0x0000-0xFFFF].
        Parameters:
        cchMin - the minimum length of the resulting String
        cchMax - the maximum length of the resulting String
        fAscii - true if the resulting String should contain only ASCII values
        Returns:
        a randomly generated String object
        Since:
        Coherence 3.2
      • checkRange

        public static void checkRange​(long lValue,
                                      long lFrom,
                                      long lTo,
                                      String sName)
        Check the range of a value.
        Parameters:
        lValue - the value to check
        lFrom - the lower limit of the range (inclusive)
        lTo - the upper limit of the range (inclusive)
        sName - the display name of the value
        Throws:
        IllegalArgumentException - if the value is out of range
      • checkNotNull

        public static <T> T checkNotNull​(T o,
                                         String sName)
        Check that the specified object is non-null and return it.
        Type Parameters:
        T - the type parameter for the object to check
        Parameters:
        o - the object to check
        sName - the name of the corresponding parameter
        Returns:
        the specified object
        Throws:
        IllegalArgumentException - if o is null
      • checkNotEmpty

        public static void checkNotEmpty​(String s,
                                         String sName)
        Check that the specified string is neither a null nor an empty string.
        Parameters:
        s - the string to check
        sName - the name of the corresponding parameter
        Throws:
        IllegalArgumentException - if s is null or empty string
      • mod

        public static int mod​(int n,
                              int m)
        Calculate a modulo of two integer numbers. For a positive dividend the result is the same as the Java remainder operation (n % m). For a negative dividend the result is still positive and equals to (n % m + m).
        Parameters:
        n - the dividend
        m - the divisor (must be positive)
        Returns:
        the modulo
      • mod

        public static long mod​(long n,
                               long m)
        Calculate a modulo of two long numbers. For a positive dividend the result is the same as the Java remainder operation (n % m). For a negative dividend the result is still positive and equals to (n % m + m).
        Parameters:
        n - the dividend
        m - the divisor (must be positive)
        Returns:
        the modulo
      • getOut

        public static PrintWriter getOut()
        Obtains the current writer used for printing.
        Returns:
        the current writer used for printing; never null
      • setOut

        public static void setOut​(PrintWriter writer)
        Sets the current writer used for printing.
        Parameters:
        writer - the java.io.PrintWriter instance to use for printing; may be null
      • getErr

        public static PrintWriter getErr()
        Obtains the current writer used for tracing.
        Returns:
        the current writer used for tracing; never null
      • setErr

        public static void setErr​(PrintWriter writer)
        Sets the current writer used for tracing.
        Parameters:
        writer - the java.io.PrintWriter instance to use for tracing; may be null
      • getLog

        public static PrintWriter getLog()
        Obtains the current writer used for logging.
        Returns:
        the current writer used for logging; never null
      • setLog

        public static void setLog​(PrintWriter writer)
        Sets the current writer used for logging.
        Parameters:
        writer - the java.io.PrintWriter instance to use for logging; may be null
      • isLogEcho

        public static boolean isLogEcho()
        Determine if the log is echoed to the console.
        Returns:
        true if the log is echoed to the console
      • setLogEcho

        public static void setLogEcho​(boolean fEcho)
        Specify whether the log should echo to the console.
        Parameters:
        fEcho - true if the log should echo to the console
      • read

        public static int read​(InputStream stream,
                               byte[] ab)
                        throws IOException
        Read the contents out of the passed stream into the passed byte array and return the length read. This method will read up to the number of bytes that can fit into the passed array.
        Parameters:
        stream - a java.io.InputStream object to read from
        ab - a byte array to read into
        Returns:
        the number of bytes read from the InputStream and stored into the passed byte array
        Throws:
        IOException - if an I/O error occurs
      • read

        public static byte[] read​(InputStream stream)
                           throws IOException
        Read the contents out of the passed stream and return the result as a byte array.
        Parameters:
        stream - a java.io.InputStream object to read from
        Returns:
        a byte array containing the contents of the passed InputStream
        Throws:
        IOException - if an I/O error occurs
      • read

        public static byte[] read​(DataInput stream)
                           throws IOException
        Read the contents out of the passed stream and return the result as a byte array.
        Parameters:
        stream - a java.io.DataInput object to read from
        Returns:
        a byte array containing the contents of the passed stream
        Throws:
        IOException - if an I/O error occurs
      • read

        public static byte[] read​(DataInputStream stream)
                           throws IOException
        Read the contents out of the passed stream and return the result as a byte array.
        Parameters:
        stream - a java.io.DataInputStream object to read from
        Returns:
        a byte array containing the contents of the passed InputStream
        Throws:
        IOException - if an I/O error occurs
      • read

        public static String read​(Reader reader)
                           throws IOException
        Read the contents out of the passed Reader and return the result as a String.
        Parameters:
        reader - a java.io.Reader object to read from
        Returns:
        a String containing the contents of the passed Reader
        Throws:
        IOException - if an I/O error occurs
      • read

        public static byte[] read​(File file)
                           throws IOException
        Read the contents out of the specified file and return the result as a byte array.
        Parameters:
        file - the java.io.File object to read the contents of
        Returns:
        the contents of the specified File as a byte array
        Throws:
        IOException - if an I/O error occurs
      • read

        public static byte[] read​(URL url)
                           throws IOException
        Read the contents of the specified URL and return the result as a byte array.
        Parameters:
        url - the java.net.URL object to read the contents of
        Returns:
        the contents of the specified URL as a byte array
        Throws:
        IOException - if an I/O error occurs
      • mergeByteArray

        public static byte[] mergeByteArray​(byte[] ab1,
                                            byte[] ab2)
        Merge two byte arrays.
        Parameters:
        ab1 - first array to merge
        ab2 - second array to merge
        Returns:
        merged array
      • mergeBooleanArray

        public static boolean[] mergeBooleanArray​(boolean[] af1,
                                                  boolean[] af2)
        Merge two boolean arrays.
        Parameters:
        af1 - first array to merge
        af2 - second array to merge
        Returns:
        the merged array
      • mergeDoubleArray

        public static double[] mergeDoubleArray​(double[] adfl1,
                                                double[] adfl2)
        Merge two double arrays.
        Parameters:
        adfl1 - first array to merge
        adfl2 - second array to merge
        Returns:
        the merged array
      • mergeFloatArray

        public static float[] mergeFloatArray​(float[] afl1,
                                              float[] afl2)
        Merge two float arrays.
        Parameters:
        afl1 - first array to merge
        afl2 - second array to merge
        Returns:
        merged array
      • mergeLongArray

        public static long[] mergeLongArray​(long[] al1,
                                            long[] al2)
        Merge two long arrays.
        Parameters:
        al1 - first array to merge
        al2 - second array to merge
        Returns:
        merged array
      • mergeIntArray

        public static int[] mergeIntArray​(int[] ai1,
                                          int[] ai2)
        Merge two int arrays.
        Parameters:
        ai1 - first array to merge
        ai2 - second array to merge
        Returns:
        merged array
      • mergeCharArray

        public static char[] mergeCharArray​(char[] ac1,
                                            char[] ac2)
        Merge two char arrays.
        Parameters:
        ac1 - first array to merge
        ac2 - second array to merge
        Returns:
        merged array
      • mergeArray

        public static <T> T[] mergeArray​(T[] a1,
                                         T[] a2)
        Merge two array with type T elements.
        Type Parameters:
        T - type of array element
        Parameters:
        a1 - first array to merge
        a2 - second array to merge
        Returns:
        the merged array