Class RMUtils

java.lang.Object
com.inductiveautomation.rm.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
     
    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 Boolean
    Returns the Boolean for a given object (assumed to be Number or String).
    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 <T> T
    clone(T anObj)
    Returns a clone of the given object (supports List, Map, RMObject, null and others by reflection).
    static <T> T
    cloneDeep(T anObj)
    Clones the given object, recursively, if the object is a collection.
    static int
    compare(Object anObj1, Object anObj2)
    Returns result of comparing two values.
    static boolean
    doOnce(String anId)
    Returns whether to do something once based on given unique id string.
    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 BigDecimal
    Returns the BigDecimal 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[]
    Returns bytes for an input stream.
    static byte[]
    getBytes(Object aSource)
    Returns a byte array from a File, String path, InputStream, URL, byte[], etc.
    static byte[]
    Returns bytes for an input stream.
    static Date
    getDate(Object anObj)
    Returns a date for given object of arbitrary type.
    static Double
    Returns a Double for a given object.
    static Float
    Returns a Float for a given object.
    static String
    Returns the hostname for this machine.
    static int
    getId(String anId)
    Returns a unique id for a string each time it's called, starting with 0.
    Returns an input stream from a File, String path, URL, byte array, InputStream, etc.
    static Integer
    Returns the Integer for a given object.
    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 long
    Returns the long value for a given object (assumed to be a string or number).
    static Number
    Returns the Number for a given object (assumed to be Number or String).
    static void
    printlnOnce(PrintStream aStream, String aString)
    Does a println of a given message to given print writer once.
    static void
    Sets this JVM to be headless.
    static String
    Returns a String for a given arbitrary object.
    static void
    writeBytes(byte[] bytes, Object aDest)
    Writes the given bytes to the given output object (string path or file).

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

      public static boolean isEmbedded
    • isApplet

      public static boolean isApplet
    • isJava5

      public static boolean isJava5
    • isJava6

      public static boolean isJava6
    • isJava7

      public static boolean isJava7
  • Constructor Details

    • RMUtils

      public RMUtils()
  • Method Details

    • 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).
    • longValue

      public static long longValue(Object anObj)
      Returns the long 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).
    • stringValue

      public static String stringValue(Object anObj)
      Returns a String for a given arbitrary object.
    • booleanValue

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

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

      public static Integer getInteger(Object anObj)
      Returns the Integer for a given object.
    • getFloat

      public static Float getFloat(Object anObj)
      Returns a Float for a given object.
    • getDouble

      public static Double getDouble(Object anObj)
      Returns a Double for a given object.
    • getBigDecimal

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

      public static Date getDate(Object anObj)
      Returns a date for given object of arbitrary type.
    • 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 <T> T clone(T anObj)
      Returns a clone of the given object (supports List, Map, RMObject, null and others by reflection).
    • cloneDeep

      public static <T> T cloneDeep(T 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).
    • compare

      public static int compare(Object anObj1, Object anObj2)
      Returns result of comparing two values.
    • getTempDir

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

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

      public static byte[] getBytes(InputStream aStream)
      Returns bytes for an input stream.
    • getBytes2

      public static byte[] getBytes2(InputStream aStream) throws IOException
      Returns bytes for an input stream.
      Throws:
      IOException
    • getInputStream

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

      public static void writeBytes(@Nullable byte[] bytes, Object aDest)
      Writes the given bytes to the given output object (string path or file).
    • 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.
    • 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.
    • setHeadless

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

      public static int getId(String anId)
      Returns a unique id for a string each time it's called, starting with 0.
    • doOnce

      public static boolean doOnce(String anId)
      Returns whether to do something once based on given unique id string.
    • printlnOnce

      public static void printlnOnce(PrintStream aStream, String aString)
      Does a println of a given message to given print writer once.