Package com.ribs

Class RibsUtils

java.lang.Object
com.ribs.RibsUtils

public class RibsUtils extends 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 <info@reportmill.com>.

  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
     
  • Method Summary

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

    • isWindows

      public static boolean isWindows
    • isMac

      public static boolean isMac
  • Constructor Details

    • RibsUtils

      public RibsUtils()
  • Method Details

    • equals

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

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

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

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

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

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

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

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

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

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

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

      public static String writeBytes(byte[] bytes, 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 String writeBytes(byte[] bytes, int anOffset, int aLength, 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 Method getMethod(Object anObj, String aMethod, Class parameterType)
      Returns the method for the given object, method name and parameter type class.
    • getMethod

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

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

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

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

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

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