Class Misc


  • public class Misc
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String blanks  
      private static int C1  
      private static int C2  
      static java.lang.String dots  
      static int[] INT0  
      static boolean isJava9ea  
      private static java.io.FilenameFilter jarFilter  
      static int numberOfCores
      For multi-core machine "tuning" - the number of cores
      private static int seed  
      static java.lang.invoke.MethodHandles.Lookup UIMAlookup  
      private static java.util.regex.Pattern whitespace  
    • Constructor Summary

      Constructors 
      Constructor Description
      Misc()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addAll​(java.util.Collection<java.lang.String> c, java.lang.String... v)
      Takes trailing arguments of strings and adds them all the first
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(int[] indent, java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      static java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,​java.lang.Integer> appender)  
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb, java.util.Collection<T> c)
      For standardized prettyprinting, to string.
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit)  
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      Does two styles of list formatting: Style 1: [ item1, item 2, item3] Style 2: [ item1, item2, item3 ] Starts as style 1, switches to style 2 when length > 60
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb, java.util.Collection<T> c, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.util.List<T> c, int limit)  
      static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.util.List<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      static void addNlIfMissing​(java.lang.StringBuffer sb)  
      static void addNlIfMissing​(java.lang.StringBuilder sb)  
      private static void addPathToURLs​(java.util.List<java.net.URL> urls, java.io.File cp)  
      static void addUrlsFromPath​(java.lang.String p, java.util.List<java.net.URL> urls)
      Given a String corresponding to one file path, which may be a directory, or may end in *, add the URLS it represents to the urls argument.
      static void assertUie​(boolean v)
      Check and throw UIMA Internal Error if false
      static void assertUie​(boolean v, java.lang.Throwable e)  
      static java.lang.String classNameFromByteCode​(byte[] bytes)
      extract the slashified version of the fully qualified class name from the bytecode for a class
      static java.net.URL[] classpath2urls​(java.lang.String classpath)
      Convert a classpath having multiple parts separated by the pathSeparator, expanding paths that end with "*" as needed.
      static int compareStrings​(java.lang.String s1, java.lang.String s2)  
      static boolean contains​(java.lang.ClassLoader[] cls, java.lang.ClassLoader cl)  
      static boolean contains​(java.lang.String[] strings, java.lang.String item)  
      static void debug​(java.lang.Object o)  
      static void decreasingMessage​(java.util.concurrent.atomic.AtomicInteger errorCount, java.util.function.Supplier<java.lang.String> messageSupplier, java.util.function.Consumer<java.lang.String> publishMessage)  
      static void decreasingWithTrace​(java.util.concurrent.atomic.AtomicInteger errorCount, java.lang.String message, Logger logger)
      Issues message at warning or fine level (fine if enabled, includes stack trace)
      static java.lang.String dumpByteArray​(byte[] b, int limit)  
      static java.lang.StringBuilder dumpCallers​(java.lang.StackTraceElement[] e, int s, int n)  
      static java.lang.String elide​(java.lang.String s, int n)  
      static java.lang.String elide​(java.lang.String s, int n, boolean pad)  
      static java.lang.String elideString​(java.lang.String s, int len)  
      private static boolean endsWithNl​(java.lang.StringBuffer sb)  
      private static boolean endsWithNl​(java.lang.StringBuilder sb)  
      static boolean equalStrings​(java.lang.String s1, java.lang.String s2)  
      static java.lang.String expandClasspath​(java.lang.String classpath)  
      private static java.lang.String formatcaller​(java.lang.StackTraceElement e)  
      static java.lang.String formatcaller​(java.lang.String className, java.lang.String methodName, int lineNumber)  
      static java.lang.String getCaller()  
      static java.lang.StringBuilder getCallers​(int s, int n)  
      static java.lang.ClassLoader[] getCallingClass_classLoaders()  
      static boolean getNoValueSystemProperty​(java.lang.String name)  
      static int getPrivateStaticIntFieldNoInherit​(java.lang.Class<?> clazz, java.lang.String fieldName)  
      static java.lang.invoke.MethodHandle getProtectedFieldGetter​(java.lang.Class<?> clazz, java.lang.String protectedField)  
      static java.lang.invoke.MethodHandle getProtectedMethodHandle​(java.lang.Class<?> clazz, java.lang.invoke.MethodHandles.Lookup methodHandleAccessContext, java.lang.String protectedMethod, java.lang.Class<?>... args)
      Given a class, a lookup context, and a protected method and its arg classes, return the method handle for that method.
      static java.lang.invoke.MethodHandle getProtectedMethodHandle​(java.lang.Class<?> clazz, java.lang.String protectedMethod, java.lang.Class<?>... args)
      Given a class, and a protected method and its arg classes, return the method handle for that method.
      static int getStaticIntField​(java.lang.Class<?> clazz, java.lang.String fieldName)
      Gets an int from a named field.
      static int getStaticIntFieldNoInherit​(java.lang.Class<?> clazz, java.lang.String fieldName)  
      static java.net.URL[] getURLs​(java.lang.String s)  
      static <T> T getWithExpand​(java.util.List<T> a, int i)
      Get item from array list.
      static int hashInt​(int k1)  
      static long hashStringLong​(java.lang.String s)
      a hash for strings as a long - less likely to be a collision
      static byte[] hex_string_to_bytearray​(java.lang.String s)  
      static java.lang.StringBuilder indent​(java.lang.StringBuilder sb, int indent)  
      static java.lang.StringBuilder indent​(java.lang.StringBuilder sb, int[] indent)  
      static java.lang.RuntimeException internalError()  
      static void internalError​(java.lang.Throwable e)  
      static boolean isJava9ea()  
      static java.lang.String javaClassName2UimaTypeName​(java.lang.String className)
      Convert a JCas class name (fully qualified) to a UIMA type name Normally this is the same, but for two prefixes, it's slightly different Also, class names for primitives (int, byte, etc.
      static boolean maybeShrink​(boolean secondTimeShrinkable, int size, int capacity, int factor, int minCapacity, java.util.function.IntConsumer realloc, java.lang.Runnable reset)  
      static int nextHigherPowerOf2​(int i)
      Convert an int argument to the next higher power of 2 if not already a power of 2
      static int nextHigherPowerOfX​(int i, int x)
      Convert an int argument to the next higher power of 2 to the x power
      static java.lang.String null2str​(java.lang.String s)  
      static <T> java.lang.String ppList​(int[] indent, java.util.List<T> items)
      format a list of items for pretty printing as [item1, item2, ...
      static <T> java.lang.String ppList​(int[] indent, java.util.List<T> items, int max)  
      static <T> java.lang.String ppList​(int[] indent, java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      static <T> java.lang.String ppList​(java.util.List<T> items)
      format a list of items for pretty printing as [item1, item2, ...
      static <T> java.lang.String ppList​(java.util.List<T> items, int max)  
      static <T> java.lang.String ppList​(java.util.List<T> items, int max, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      private static java.lang.String readModifiedUTF8​(java.nio.ByteBuffer bb)
      read ByteBuffer modified UTF into String see http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
      static java.lang.String replaceWhiteSpace​(java.lang.String s, java.lang.String replacement)  
      static <T> java.util.List<T> setAsList​(java.util.Set<T> set)  
      static <T> void setWithExpand​(java.util.List<T> a, int i, T value)  
      static <T> T shareExisting​(T obj, java.util.WeakHashMap<T,​java.lang.ref.WeakReference<T>> cache)
      Some objects can be shared, if "equal", rather than creating duplicates, if they're read-only.
      static void sleep​(int milliseconds)  
      private static <T> java.lang.StringBuilder style2​(int[] indent, java.lang.StringBuilder sb, java.util.Collection<T> c, int limit, java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)  
      private static <T> java.lang.StringBuilder style2​(java.lang.StringBuilder sb, int size, int limit, int indent, int incr, java.util.function.BiConsumer<java.lang.StringBuilder,​java.lang.Integer> appender)  
      static void timeLoops​(java.lang.String title, int iterations, Runnable_withException r)  
      static void toFile​(java.io.ByteArrayOutputStream baos, java.io.File file)
      Writes a byte array output stream to a file
      static void toFile​(java.io.ByteArrayOutputStream baos, java.lang.String name)
      Writes a byte array output stream to a file
      static java.lang.String typeName2ClassName​(java.lang.String typeName)
      Convert a UIMA type name to a JCas class name (fully qualified) Normally this is the same, but for two prefixes, it's slightly different
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • isJava9ea

        public static final boolean isJava9ea
      • blanks

        public static final java.lang.String blanks
      • INT0

        public static final int[] INT0
      • whitespace

        private static final java.util.regex.Pattern whitespace
      • UIMAlookup

        public static final java.lang.invoke.MethodHandles.Lookup UIMAlookup
      • jarFilter

        private static java.io.FilenameFilter jarFilter
      • numberOfCores

        public static final int numberOfCores
        For multi-core machine "tuning" - the number of cores
    • Constructor Detail

      • Misc

        public Misc()
    • Method Detail

      • replaceWhiteSpace

        public static java.lang.String replaceWhiteSpace​(java.lang.String s,
                                                         java.lang.String replacement)
      • null2str

        public static java.lang.String null2str​(java.lang.String s)
      • hex_string_to_bytearray

        public static byte[] hex_string_to_bytearray​(java.lang.String s)
      • dumpByteArray

        public static java.lang.String dumpByteArray​(byte[] b,
                                                     int limit)
      • getCallers

        public static java.lang.StringBuilder getCallers​(int s,
                                                         int n)
        Parameters:
        s - starting frames above invoker
        n - max number of callers to return
        Returns:
        x called by: y ...
      • dumpCallers

        public static java.lang.StringBuilder dumpCallers​(java.lang.StackTraceElement[] e,
                                                          int s,
                                                          int n)
      • getCaller

        public static java.lang.String getCaller()
        Returns:
        the name of the caller in the stack and their caller
      • formatcaller

        private static java.lang.String formatcaller​(java.lang.StackTraceElement e)
      • formatcaller

        public static java.lang.String formatcaller​(java.lang.String className,
                                                    java.lang.String methodName,
                                                    int lineNumber)
      • getCallingClass_classLoaders

        public static java.lang.ClassLoader[] getCallingClass_classLoaders()
      • elide

        public static java.lang.String elide​(java.lang.String s,
                                             int n)
        Parameters:
        s - the string to possibly elide
        n - the length, after which, elision happens
        Returns:
        the elided string, padded on the left to length n
      • elide

        public static java.lang.String elide​(java.lang.String s,
                                             int n,
                                             boolean pad)
        Parameters:
        s - the string to possibly elide
        n - the length, after which, elision happens
        pad - true to include left padding to length n
        Returns:
        the elided string, padded on the left to length n
      • indent

        public static java.lang.StringBuilder indent​(java.lang.StringBuilder sb,
                                                     int[] indent)
        Parameters:
        sb - the stringBuilder to indent
        indent - the indent amount (passed as array of 1 item, to allow it to be final for lambdas
        Returns:
        the stringBuilder, with nl if needed, and indention
      • indent

        public static java.lang.StringBuilder indent​(java.lang.StringBuilder sb,
                                                     int indent)
        Parameters:
        sb - the stringBuilder to indent
        indent - the indent amount
        Returns:
        the stringBuilder, with nl if needed, and indention
      • addNlIfMissing

        public static void addNlIfMissing​(java.lang.StringBuilder sb)
      • addNlIfMissing

        public static void addNlIfMissing​(java.lang.StringBuffer sb)
      • endsWithNl

        private static boolean endsWithNl​(java.lang.StringBuilder sb)
      • endsWithNl

        private static boolean endsWithNl​(java.lang.StringBuffer sb)
      • getURLs

        public static java.net.URL[] getURLs​(java.lang.String s)
                                      throws java.net.MalformedURLException,
                                             java.io.IOException,
                                             java.net.URISyntaxException
        Throws:
        java.net.MalformedURLException
        java.io.IOException
        java.net.URISyntaxException
      • addUrlsFromPath

        public static void addUrlsFromPath​(java.lang.String p,
                                           java.util.List<java.net.URL> urls)
                                    throws java.net.MalformedURLException,
                                           java.io.IOException,
                                           java.net.URISyntaxException
        Given a String corresponding to one file path, which may be a directory, or may end in *, add the URLS it represents to the urls argument.
        Parameters:
        p - a Jar path, or a Directory, or a directory ending with a directory-separator and a single * p may be relative or absolute, following the definition of same in the Java File class.
        urls - the list to add the URLs to
        Throws:
        java.net.MalformedURLException - -
        java.io.IOException - -
        java.net.URISyntaxException - -
      • addPathToURLs

        private static void addPathToURLs​(java.util.List<java.net.URL> urls,
                                          java.io.File cp)
                                   throws java.net.MalformedURLException
        Throws:
        java.net.MalformedURLException
      • classpath2urls

        public static java.net.URL[] classpath2urls​(java.lang.String classpath)
        Convert a classpath having multiple parts separated by the pathSeparator, expanding paths that end with "*" as needed.
        Parameters:
        classpath - - to scan and convert to list of URLs
        Returns:
        the urls
      • expandClasspath

        public static java.lang.String expandClasspath​(java.lang.String classpath)
      • getNoValueSystemProperty

        public static boolean getNoValueSystemProperty​(java.lang.String name)
        Parameters:
        name - of property
        Returns:
        true if property is defined, or is defined and set to anything except "false"; false if property is not defined, or is defined and set to "false".
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb,
                                                                             java.util.Collection<T> c)
        For standardized prettyprinting, to string. Adds a collection of things (toString) separated by , and surrounded by [ ], to a StringBuilder
        Type Parameters:
        T - the kind of elements in the collection
        Parameters:
        sb - where the formatted collection results are appended to
        c - the collection
        Returns:
        the StringBuilder for chaining
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb,
                                                                             java.util.Collection<T> c,
                                                                             int limit)
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb,
                                                                             java.util.Collection<T> c,
                                                                             java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.util.List<T> c,
                                                                             int limit)
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.util.List<T> c,
                                                                             int limit,
                                                                             java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(int[] indent,
                                                                             java.util.List<T> c,
                                                                             int limit,
                                                                             java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb,
                                                                             java.util.Collection<T> c,
                                                                             int limit,
                                                                             java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
        Does two styles of list formatting: Style 1: [ item1, item 2, item3] Style 2: [ item1, item2, item3 ] Starts as style 1, switches to style 2 when length > 60
        Type Parameters:
        T - the type of the collection
        Parameters:
        sb - where the string is assembled
        c - the collection to process
        limit - the maximum number of items, if negative, no limit
        appender - the appender
        Returns:
        argument sb, appeneded
      • addElementsToStringBuilder

        public static <T> java.lang.StringBuilder addElementsToStringBuilder​(int[] indent,
                                                                             java.lang.StringBuilder sb,
                                                                             java.util.Collection<T> c,
                                                                             int limit,
                                                                             java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      • addElementsToStringBuilder

        public static java.lang.StringBuilder addElementsToStringBuilder​(java.lang.StringBuilder sb,
                                                                         int size,
                                                                         int limit,
                                                                         int indent,
                                                                         int incr,
                                                                         java.util.function.BiConsumer<java.lang.StringBuilder,​java.lang.Integer> appender)
      • style2

        private static <T> java.lang.StringBuilder style2​(int[] indent,
                                                          java.lang.StringBuilder sb,
                                                          java.util.Collection<T> c,
                                                          int limit,
                                                          java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
      • style2

        private static <T> java.lang.StringBuilder style2​(java.lang.StringBuilder sb,
                                                          int size,
                                                          int limit,
                                                          int indent,
                                                          int incr,
                                                          java.util.function.BiConsumer<java.lang.StringBuilder,​java.lang.Integer> appender)
      • toFile

        public static void toFile​(java.io.ByteArrayOutputStream baos,
                                  java.lang.String name)
        Writes a byte array output stream to a file
        Parameters:
        baos - the array to write
        name - the name of the file
      • toFile

        public static void toFile​(java.io.ByteArrayOutputStream baos,
                                  java.io.File file)
        Writes a byte array output stream to a file
        Parameters:
        baos - the array to write
        file - the file
      • nextHigherPowerOf2

        public static int nextHigherPowerOf2​(int i)
        Convert an int argument to the next higher power of 2 if not already a power of 2
        Parameters:
        i - the value to convert
        Returns:
        the next higher power of 2, or i if it is already a power of 2
      • nextHigherPowerOfX

        public static int nextHigherPowerOfX​(int i,
                                             int x)
        Convert an int argument to the next higher power of 2 to the x power
        Parameters:
        i - the value to convert
        x - the power of 2 to use
        Returns:
        the next higher power of 2 to the x, or i if it is already == to 2 to the x
      • getProtectedMethodHandle

        public static java.lang.invoke.MethodHandle getProtectedMethodHandle​(java.lang.Class<?> clazz,
                                                                             java.lang.invoke.MethodHandles.Lookup methodHandleAccessContext,
                                                                             java.lang.String protectedMethod,
                                                                             java.lang.Class<?>... args)
        Given a class, a lookup context, and a protected method and its arg classes, return the method handle for that method. Using that method handle is slow, but converting it to a lambda makes for JIT-able fast access.
        Parameters:
        clazz - -
        methodHandleAccessContext - -
        protectedMethod - -
        args - -
        Returns:
        -
      • getProtectedMethodHandle

        public static java.lang.invoke.MethodHandle getProtectedMethodHandle​(java.lang.Class<?> clazz,
                                                                             java.lang.String protectedMethod,
                                                                             java.lang.Class<?>... args)
        Given a class, and a protected method and its arg classes, return the method handle for that method. Note: uses the UIMA context as the lookup context Using that method handle is slow, but converting it to a lambda makes for JIT-able fast access.
        Parameters:
        clazz - -
        protectedMethod - -
        args - -
        Returns:
        -
      • getProtectedFieldGetter

        public static java.lang.invoke.MethodHandle getProtectedFieldGetter​(java.lang.Class<?> clazz,
                                                                            java.lang.String protectedField)
      • getStaticIntField

        public static int getStaticIntField​(java.lang.Class<?> clazz,
                                            java.lang.String fieldName)
        Gets an int from a named field. If the field isn't present, returns Integer.MIN_VALUE;
        Parameters:
        clazz - the class where the field is
        fieldName - the name of the field
        Returns:
        the value or Integer.MIN_VALUE if not present
      • getStaticIntFieldNoInherit

        public static int getStaticIntFieldNoInherit​(java.lang.Class<?> clazz,
                                                     java.lang.String fieldName)
      • getPrivateStaticIntFieldNoInherit

        public static int getPrivateStaticIntFieldNoInherit​(java.lang.Class<?> clazz,
                                                            java.lang.String fieldName)
      • addAll

        public static void addAll​(java.util.Collection<java.lang.String> c,
                                  java.lang.String... v)
        Takes trailing arguments of strings and adds them all the first
        Parameters:
        c - the collection to add the strings to
        v - 0 or more strings as arguments
      • debug

        public static void debug​(java.lang.Object o)
      • assertUie

        public static void assertUie​(boolean v)
        Check and throw UIMA Internal Error if false
        Parameters:
        v - if false, throws
      • assertUie

        public static void assertUie​(boolean v,
                                     java.lang.Throwable e)
      • internalError

        public static java.lang.RuntimeException internalError()
      • internalError

        public static void internalError​(java.lang.Throwable e)
      • hashInt

        public static int hashInt​(int k1)
      • hashStringLong

        public static long hashStringLong​(java.lang.String s)
        a hash for strings as a long - less likely to be a collision
        Parameters:
        s - - the string
        Returns:
        a long hash
      • getWithExpand

        public static <T> T getWithExpand​(java.util.List<T> a,
                                          int i)
        Get item from array list. If index is > length, expand the array, and return null
        Type Parameters:
        T - the type of the items in the list
        Parameters:
        a - the list
        i - the index
        Returns:
        the item at the index or null
      • setWithExpand

        public static <T> void setWithExpand​(java.util.List<T> a,
                                             int i,
                                             T value)
      • equalStrings

        public static boolean equalStrings​(java.lang.String s1,
                                           java.lang.String s2)
      • compareStrings

        public static int compareStrings​(java.lang.String s1,
                                         java.lang.String s2)
      • elideString

        public static java.lang.String elideString​(java.lang.String s,
                                                   int len)
      • shareExisting

        public static <T> T shareExisting​(T obj,
                                          java.util.WeakHashMap<T,​java.lang.ref.WeakReference<T>> cache)
        Some objects can be shared, if "equal", rather than creating duplicates, if they're read-only. This may in general be beneficial by reducing the size of the "working set" via more sharing of read-only objects. Users should insure the read-only property. This routine allows a) creating a potentially sharable object b) checking to see if we already have an "equal" one, and c) if so, using that and allowing the just created one to be GC'd.
        Type Parameters:
        T - the type of the cached object
        Parameters:
        obj - - the object to use a cached substitute for, if one exists
        cache - - the cache
        Returns:
        - the object or a cached version of it.
      • ppList

        public static <T> java.lang.String ppList​(java.util.List<T> items)
        format a list of items for pretty printing as [item1, item2, ... ]
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        items - to print
        Returns:
        [item1, item2, ... ]
      • ppList

        public static <T> java.lang.String ppList​(java.util.List<T> items,
                                                  int max)
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        items - to print
        max - - maximum number of items to print
        Returns:
        [item1, item2, ... ]
      • ppList

        public static <T> java.lang.String ppList​(java.util.List<T> items,
                                                  int max,
                                                  java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        items - to print
        max - - maximum number of items to print
        appender - - appender function
        Returns:
        [item1, item2, ... ]
      • ppList

        public static <T> java.lang.String ppList​(int[] indent,
                                                  java.util.List<T> items)
        format a list of items for pretty printing as [item1, item2, ... ]
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        indent - the amount to use as indentation
        items - to print
        Returns:
        [item1, item2, ... ]
      • ppList

        public static <T> java.lang.String ppList​(int[] indent,
                                                  java.util.List<T> items,
                                                  int max)
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        indent - the amount to use as indentation
        items - to print
        max - - maximum number of items to print
        Returns:
        [item1, item2, ... ]
      • ppList

        public static <T> java.lang.String ppList​(int[] indent,
                                                  java.util.List<T> items,
                                                  int max,
                                                  java.util.function.BiConsumer<java.lang.StringBuilder,​T> appender)
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        indent - the amount to use as indentation
        items - to print
        max - - maximum number of items to print
        appender - - appender function
        Returns:
        [item1, item2, ... ]
      • typeName2ClassName

        public static java.lang.String typeName2ClassName​(java.lang.String typeName)
        Convert a UIMA type name to a JCas class name (fully qualified) Normally this is the same, but for two prefixes, it's slightly different
        Parameters:
        typeName - the UIMA type name, fully qualified
        Returns:
        the fully qualified JCas class name
      • javaClassName2UimaTypeName

        public static java.lang.String javaClassName2UimaTypeName​(java.lang.String className)
        Convert a JCas class name (fully qualified) to a UIMA type name Normally this is the same, but for two prefixes, it's slightly different Also, class names for primitives (int, byte, etc. ) converted to int, byte, etc.
        Parameters:
        className - the Java JCas class name for a UIMA type, fully qualified
        Returns:
        the fully qualified UIMA Type name
      • timeLoops

        public static void timeLoops​(java.lang.String title,
                                     int iterations,
                                     Runnable_withException r)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sleep

        public static void sleep​(int milliseconds)
      • maybeShrink

        public static boolean maybeShrink​(boolean secondTimeShrinkable,
                                          int size,
                                          int capacity,
                                          int factor,
                                          int minCapacity,
                                          java.util.function.IntConsumer realloc,
                                          java.lang.Runnable reset)
      • isJava9ea

        public static boolean isJava9ea()
      • classNameFromByteCode

        public static java.lang.String classNameFromByteCode​(byte[] bytes)
        extract the slashified version of the fully qualified class name from the bytecode for a class
        Parameters:
        bytes - the bytecode to extract from
        Returns:
        the slashified class name eg. x/y/z/Myclass
      • readModifiedUTF8

        private static java.lang.String readModifiedUTF8​(java.nio.ByteBuffer bb)
        read ByteBuffer modified UTF into String see http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4
      • setAsList

        public static <T> java.util.List<T> setAsList​(java.util.Set<T> set)
      • contains

        public static boolean contains​(java.lang.String[] strings,
                                       java.lang.String item)
      • contains

        public static boolean contains​(java.lang.ClassLoader[] cls,
                                       java.lang.ClassLoader cl)
      • decreasingWithTrace

        public static void decreasingWithTrace​(java.util.concurrent.atomic.AtomicInteger errorCount,
                                               java.lang.String message,
                                               Logger logger)
        Issues message at warning or fine level (fine if enabled, includes stack trace)
        Parameters:
        errorCount - the count of errors used to decrease the frequency
        message - the message
        logger - the logger to use
      • decreasingMessage

        public static void decreasingMessage​(java.util.concurrent.atomic.AtomicInteger errorCount,
                                             java.util.function.Supplier<java.lang.String> messageSupplier,
                                             java.util.function.Consumer<java.lang.String> publishMessage)