Package fmpp.util

Class MiscUtil


  • public class MiscUtil
    extends java.lang.Object
    Miscellaneous utility methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      MiscUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String[] add​(java.lang.String[] a1, java.lang.String[] a2)
      Concatenates two arrays.
      static java.lang.String causeMessages​(java.lang.Throwable e)
      This is the same as causeTrace(java.lang.Throwable), but it doesn't print the exception class name if the class is inside an fmpp package.
      static java.lang.String causeTrace​(java.lang.Throwable e)
      Returns the cause trace of an exception.
      static void checkXmlSupportAvailability​(java.lang.String requiredForThis)
      Checks if XML API-s (JAXP, SAX2, DOM) are present.
      static java.lang.Class classForName​(java.lang.String className)
      Tries to load the class with the current context class loader, and only then with the current defining class loader.
      static java.util.Map dictionaryToMap​(java.util.Dictionary dict)  
      static int findObject​(java.util.List list, java.lang.Object o)
      Returns the first index of the given object (exactly the same instance) in the list.
      static java.lang.Throwable getCauseException​(java.lang.Throwable e)  
      static boolean listContainsObject​(java.util.List<?> list, java.lang.Object o)
      Checks if the list contains the given object (exactly the same instance).
      static boolean mapContainsObject​(java.util.Map<?,​?> map, java.lang.Object o)
      Checks if the map contains the given object (exactly the same instance) as value.
      static int numberToInt​(java.lang.Number value)
      Loseless convertion to int.
      • Methods inherited from class java.lang.Object

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

      • EMPTY_CLASS_ARRAY

        public static final java.lang.Class[] EMPTY_CLASS_ARRAY
      • EMPTY_OBJECT_ARRAY

        public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
      • EMPTY_STRING_ARRAY

        public static final java.lang.String[] EMPTY_STRING_ARRAY
    • Constructor Detail

      • MiscUtil

        public MiscUtil()
    • Method Detail

      • causeMessages

        public static java.lang.String causeMessages​(java.lang.Throwable e)
        This is the same as causeTrace(java.lang.Throwable), but it doesn't print the exception class name if the class is inside an fmpp package.
      • causeTrace

        public static java.lang.String causeTrace​(java.lang.Throwable e)
        Returns the cause trace of an exception. This is similar to a J2SE 1.4+ stack-trace, but it's shorter, because it does not contain the "at" lines.
      • classForName

        public static java.lang.Class classForName​(java.lang.String className)
                                            throws java.lang.ClassNotFoundException
        Tries to load the class with the current context class loader, and only then with the current defining class loader.
        Throws:
        java.lang.ClassNotFoundException
      • dictionaryToMap

        public static java.util.Map dictionaryToMap​(java.util.Dictionary dict)
      • getCauseException

        public static java.lang.Throwable getCauseException​(java.lang.Throwable e)
      • listContainsObject

        public static boolean listContainsObject​(java.util.List<?> list,
                                                 java.lang.Object o)
        Checks if the list contains the given object (exactly the same instance).
      • mapContainsObject

        public static boolean mapContainsObject​(java.util.Map<?,​?> map,
                                                java.lang.Object o)
        Checks if the map contains the given object (exactly the same instance) as value.
      • findObject

        public static int findObject​(java.util.List list,
                                     java.lang.Object o)
        Returns the first index of the given object (exactly the same instance) in the list.
        Returns:
        the index of the first occurrence, or -1 if not found.
      • checkXmlSupportAvailability

        public static void checkXmlSupportAvailability​(java.lang.String requiredForThis)
                                                throws InstallationException
        Checks if XML API-s (JAXP, SAX2, DOM) are present. Can be a bit slow depending on the actual class loader setup.
        Parameters:
        requiredForThis - a short sentence that describes for human reader if for what do we need the XML support (e.g. "Usage of xml data loader." or "Set XML entity resolver."). This sentence is used in error message of the InstallationException. Can be null.
        Throws:
        InstallationException
      • numberToInt

        public static int numberToInt​(java.lang.Number value)
        Loseless convertion to int.
        Throws:
        java.lang.IllegalArgumentException - if the loseless conversion is not possible. The error message contains the details.
      • add

        public static java.lang.String[] add​(java.lang.String[] a1,
                                             java.lang.String[] a2)
        Concatenates two arrays.