Package com.ribs

Class RibsUtils


  • public class RibsUtils
    extends java.lang.Object
    This class offers a number of useful general purpose utilities used by ribs classes.

    Copyright (c) 2004 ReportMill Software, Inc. All Rights Reserved. Contact ReportMill .

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RibsUtils.RBException
      This Error subclass lets us rethrow exceptions.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean isMac  
      static boolean isWindows  
    • Constructor Summary

      Constructors 
      Constructor Description
      RibsUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean copyFile​(java.io.File in, java.io.File out)
      Copies a file from one location to another.
      static boolean equals​(java.lang.Object obj1, java.lang.Object obj2)
      Returns whether two objects are equal (either can be null).
      static byte[] getBytes​(java.lang.Object aSource)
      Returns the bytes derived from reading source (supports File, String path, URL, InputStream, byte[] and more).
      static java.lang.Class getClassForName​(java.lang.String aName)
      Returns a class for a given name.
      static java.lang.String getClassNameShort​(java.lang.Object anObj)
      Returns just the class name string (w/o package name).
      static java.io.File getFile​(java.lang.Object aSource)
      Returns the File derived from reading source (supports File, String path).
      static java.io.InputStream getInputStream​(java.lang.Object aSource)
      Returns the input stream dervied from reading source (supports File, String path, InputStream and more).
      static java.lang.reflect.Method getMethod​(java.lang.Object anObj, java.lang.String aMethod, java.lang.Class parameterType)
      Returns the method for the given object, method name and parameter type class.
      static java.lang.reflect.Method getMethod​(java.lang.Object anObj, java.lang.String aMethod, java.lang.Class[] parameterTypes)
      Returns the method for the given object, method name and paramter types class array.
      static java.lang.Object invoke​(java.lang.Object anObj, java.lang.reflect.Method aMethod, java.lang.Object aValue)
      Calls the given method on the given object with the given parameter.
      static java.lang.Object invoke​(java.lang.Object anObj, java.lang.reflect.Method aMethod, java.lang.Object[] parameters)
      Calls the given method name on the given object with the given arg array and class array.
      static java.lang.Object invoke​(java.lang.Object anObj, java.lang.String aMethod)
      Calls the given method name on the given object.
      static java.lang.Object invoke​(java.lang.Object anObj, java.lang.String aMethod, java.lang.Object[] parameters, java.lang.Class[] parameterTypes)
      Calls the given method name on the given object with the given arg array and class array.
      static java.lang.Object invoke​(java.lang.Object anObj, java.lang.String aMethod, java.lang.Object aValue, java.lang.Class parameterType)
      Calls the given method name on the given object with the given parameter of the given class.
      static java.lang.Object newInstance​(java.lang.Class aClass, boolean complain)
      Returns a new instance.
      static java.util.prefs.Preferences prefs()
      Returns the user Preferences object.
      static void prefsPut​(java.lang.String aKey, java.lang.Object anObj)
      Adds an object to the user Preferences object.
      static void setPrefsClass​(java.lang.Class aClass)
      Sets the class that ribs preferences are associated with.
      static java.lang.String writeBytes​(byte[] bytes, int anOffset, int aLength, java.lang.String aPath, boolean safely)
      Writes the given byte array to given path.
      static java.lang.String writeBytes​(byte[] bytes, java.lang.String aPath, boolean safely)
      Writes the given byte array to given path.
      • Methods inherited from class java.lang.Object

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

      • isWindows

        public static boolean isWindows
      • isMac

        public static boolean isMac
    • Constructor Detail

      • RibsUtils

        public RibsUtils()
    • Method Detail

      • equals

        public static boolean equals​(java.lang.Object obj1,
                                     java.lang.Object obj2)
        Returns whether two objects are equal (either can be null).
      • getClassNameShort

        public static java.lang.String getClassNameShort​(java.lang.Object anObj)
        Returns just the class name string (w/o package name).
      • getClassForName

        public static java.lang.Class getClassForName​(java.lang.String aName)
        Returns a class for a given name.
      • newInstance

        public static java.lang.Object newInstance​(java.lang.Class aClass,
                                                   boolean complain)
        Returns a new instance.
      • prefs

        public static java.util.prefs.Preferences prefs()
        Returns the user Preferences object.
      • prefsPut

        public static void prefsPut​(java.lang.String aKey,
                                    java.lang.Object anObj)
        Adds an object to the user Preferences object.
      • setPrefsClass

        public static void setPrefsClass​(java.lang.Class aClass)
        Sets the class that ribs preferences are associated with.
      • getBytes

        public static byte[] getBytes​(java.lang.Object aSource)
        Returns the bytes derived from reading source (supports File, String path, URL, InputStream, byte[] and more).
      • getInputStream

        public static java.io.InputStream getInputStream​(java.lang.Object aSource)
        Returns the input stream dervied from reading source (supports File, String path, InputStream and more).
      • getFile

        public static java.io.File getFile​(java.lang.Object aSource)
        Returns the File derived from reading source (supports File, String path).
      • copyFile

        public static boolean copyFile​(java.io.File in,
                                       java.io.File out)
        Copies a file from one location to another.
      • writeBytes

        public static java.lang.String writeBytes​(byte[] bytes,
                                                  java.lang.String aPath,
                                                  boolean safely)
        Writes the given byte array to given path. If safely is true, it moves original to backup file before save.
      • writeBytes

        public static java.lang.String writeBytes​(byte[] bytes,
                                                  int anOffset,
                                                  int aLength,
                                                  java.lang.String aPath,
                                                  boolean safely)
        Writes the given byte array to given path. If safely is true, it moves original to backup file before save.
      • getMethod

        public static java.lang.reflect.Method getMethod​(java.lang.Object anObj,
                                                         java.lang.String aMethod,
                                                         java.lang.Class parameterType)
        Returns the method for the given object, method name and parameter type class.
      • getMethod

        public static java.lang.reflect.Method getMethod​(java.lang.Object anObj,
                                                         java.lang.String aMethod,
                                                         java.lang.Class[] parameterTypes)
        Returns the method for the given object, method name and paramter types class array.
      • invoke

        public static java.lang.Object invoke​(java.lang.Object anObj,
                                              java.lang.String aMethod)
        Calls the given method name on the given object.
      • invoke

        public static java.lang.Object invoke​(java.lang.Object anObj,
                                              java.lang.String aMethod,
                                              java.lang.Object aValue,
                                              java.lang.Class parameterType)
        Calls the given method name on the given object with the given parameter of the given class.
      • invoke

        public static java.lang.Object invoke​(java.lang.Object anObj,
                                              java.lang.String aMethod,
                                              java.lang.Object[] parameters,
                                              java.lang.Class[] parameterTypes)
        Calls the given method name on the given object with the given arg array and class array.
      • invoke

        public static java.lang.Object invoke​(java.lang.Object anObj,
                                              java.lang.reflect.Method aMethod,
                                              java.lang.Object aValue)
        Calls the given method on the given object with the given parameter.
      • invoke

        public static java.lang.Object invoke​(java.lang.Object anObj,
                                              java.lang.reflect.Method aMethod,
                                              java.lang.Object[] parameters)
        Calls the given method name on the given object with the given arg array and class array.