Class RMUtils

java.lang.Object
com.reportmill.base.RMUtils

public class RMUtils extends Object
This class provides a bunch of utility methods for common problems.
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    add(Object obj1, Object obj2)
    Returns the sum of the two given objects (assumed to be strings or numbers).
    static BigDecimal
    Returns the BigDecimal value for a given object (assumed to be a string or number).
    static boolean
    Returns a boolean value for the given object.
    static boolean
    checkString(String aString, boolean isApplication)
    Checks a string to see if it's valid.
    static Object
    clone(Object anObj)
    Returns a clone of the given object (supports List, Map, RMObject, null and others by reflection).
    static Object
    Clones the given object, recursively, if the object is a collection.
    static boolean
    copyFile(File in, File out)
    Copies a file from one location to another.
    static double
    Returns the double value for a given object (assumed to be a string or number).
    static boolean
    equals(Object obj1, Object obj2)
    Returns whether two objects are equal (supports either being null).
    static float
    Returns the float value for a given object (assumed to be a string or number).
    static String
    Returns a build date string (eg, "Jan-26-03") as generated into BuildInfo.txt at build time.
    static byte[]
    getBytes(Object aSource)
    Returns a byte array from a File, String path, InputStream, URL, byte[], etc.
    static Class
    Returns a class for a given name.
    static String
    Returns the class name for the given object (minus the package name).
    static File
    getFile(Object aSource)
    Returns a File object from a File or String path.
    static String
    Returns the hostname for this machine.
    Returns an input stream from a File, String path, URL, byte array, InputStream, etc.
    static String
    Returns the file path for ReportMill.jar.
    static int
    Returns the number of processors on this machine.
    static String
    Returns the temp directory for this machine.
    static float
    Returns the version number of the app.
    static int
    Returns the int value for a given object (assumed to be a string or number).
    static Object
    Returns a new instance of a given class.
    static Number
    number(Object anObj)
    Returns the Number for a given object (assumed to be Number or String).
    static void
    Opens a named file on the user's desktop.
    static void
    openURL(String aName)
    Opens a named URL on the user's desktop.
    static void
    Sets this JVM to be headless.
    static void
    writeBytes(byte[] bytes, int anOffset, int aLength, String aPath)
    Writes the given bytes (within the specified range) to the given path string.
    static void
    writeBytes(byte[] bytes, String aPath)
    Writes the given bytes to the given path string.

    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
    • isApp

      public static boolean isApp
    • isApplet

      public static boolean isApplet
    • isOneWin

      public static boolean isOneWin
    • isJava5

      public static boolean isJava5
  • Constructor Details

    • RMUtils

      public RMUtils()
  • Method Details

    • getClassNameShort

      public static String getClassNameShort(Object anObj)
      Returns the class name for the given object (minus the package name).
    • boolValue

      public static boolean boolValue(Object anObj)
      Returns a boolean value for the given object.
    • intValue

      public static int intValue(Object anObj)
      Returns the int value for a given object (assumed to be a string or number).
    • floatValue

      public static float floatValue(Object anObj)
      Returns the float value for a given object (assumed to be a string or number).
    • doubleValue

      public static double doubleValue(Object anObj)
      Returns the double value for a given object (assumed to be a string or number).
    • number

      public static Number number(Object anObj)
      Returns the Number for a given object (assumed to be Number or String).
    • bigDecimal

      public static BigDecimal bigDecimal(Object anObj)
      Returns the BigDecimal value for a given object (assumed to be a string or number).
    • add

      public static Object add(Object obj1, Object obj2)
      Returns the sum of the two given objects (assumed to be strings or numbers).
    • clone

      public static Object clone(Object anObj)
      Returns a clone of the given object (supports List, Map, RMObject, null and others by reflection).
    • cloneDeep

      public static Object cloneDeep(Object anObj)
      Clones the given object, recursively, if the object is a collection.
    • equals

      public static boolean equals(Object obj1, Object obj2)
      Returns whether two objects are equal (supports either being null).
    • getTempDir

      public static String getTempDir()
      Returns the temp directory for this machine.
    • writeBytes

      public static void writeBytes(byte[] bytes, String aPath)
      Writes the given bytes to the given path string.
    • writeBytes

      public static void writeBytes(byte[] bytes, int anOffset, int aLength, String aPath)
      Writes the given bytes (within the specified range) to the given path string.
    • getFile

      public static File getFile(Object aSource)
      Returns a File object from a File or String path.
    • getInputStream

      public static InputStream getInputStream(Object aSource)
      Returns an input stream from a File, String path, URL, byte array, InputStream, etc.
    • getBytes

      public static byte[] getBytes(Object aSource)
      Returns a byte array from a File, String path, InputStream, URL, byte[], etc.
    • openFile

      public static void openFile(String aName)
      Opens a named file on the user's desktop.
    • openURL

      public static void openURL(String aName)
      Opens a named URL on the user's desktop.
    • checkString

      public static boolean checkString(String aString, boolean isApplication)
      Checks a string to see if it's valid.
    • getHostname

      public static String getHostname()
      Returns the hostname for this machine.
    • getJarPath

      public static String getJarPath()
      Returns the file path for ReportMill.jar.
    • getBuildInfo

      public static String getBuildInfo()
      Returns a build date string (eg, "Jan-26-03") as generated into BuildInfo.txt at build time.
    • getVersion

      public static float getVersion()
      Returns the version number of the app.
    • getProcessorCount

      public static int getProcessorCount()
      Returns the number of processors on this machine.
    • getClassForName

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

      public static Object newInstance(Class aClass)
      Returns a new instance of a given class.
    • setHeadless

      public static void setHeadless()
      Sets this JVM to be headless.
    • copyFile

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