Class UtilityFunctions

java.lang.Object
com.scriptbasic.utility.functions.UtilityFunctions

public class UtilityFunctions
extends java.lang.Object
Static methods in this class are registered in the interpreter when the interpreter starts. The interpreter calls the static method MethodRegisterUtility.registerFunctions(Class, Interpreter) and that function registers the methods in this class with their own name so that BASIC programs can call the functions like BASIC built in functions.
Author:
Peter Verhas date July 15, 2012
  • Method Summary

    Modifier and Type Method Description
    static java.lang.Integer asc​(java.lang.Object arg)
    Returns an Integer representing the character code corresponding to the first letter in a string.
    static byte[] byteBuffer​(int len)
    Create a new byte buffer of length len.
    static java.lang.Double cdbl​(java.lang.Object arg)  
    static java.lang.String chr​(java.lang.Object charcode)
    Returns a String containing the character associated with the specified character code.
    static java.lang.Long clng​(java.lang.Object arg)  
    static java.lang.Long getByte​(byte[] buffer, java.lang.Long i)  
    static byte[] getStringBytes​(java.lang.String s)  
    static java.lang.Boolean isDefined​(java.lang.Object s)  
    static java.lang.Boolean isNull​(java.lang.Object s)  
    static java.lang.Boolean isUndef​(java.lang.Object s)  
    static java.lang.Long length​(java.lang.Object arg)  
    static void logDebug​(java.lang.String message)  
    static void logError​(java.lang.String message)  
    static void logInfo​(java.lang.String message)  
    static java.lang.Object newMagicBean()  
    static void setByte​(byte[] buffer, java.lang.Long i, java.lang.Long v)  
    static java.lang.String stringifyBuffer​(byte[] buffer)  
    static java.lang.Object undef()
    This function returns the undef value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newMagicBean

      public static java.lang.Object newMagicBean()
    • logError

      public static void logError​(java.lang.String message)
    • logInfo

      public static void logInfo​(java.lang.String message)
    • logDebug

      public static void logDebug​(java.lang.String message)
    • undef

      public static java.lang.Object undef()
      This function returns the undef value.
      Returns:
      the undef value
    • isUndef

      public static java.lang.Boolean isUndef​(java.lang.Object s)
      Parameters:
      s - is some value or object
      Returns:
      true if the parameter is undefined
    • isDefined

      public static java.lang.Boolean isDefined​(java.lang.Object s)
      Parameters:
      s - is some value or object
      Returns:
      true if the parameter is defined (not isUndef).
    • isNull

      public static java.lang.Boolean isNull​(java.lang.Object s)
      Parameters:
      s - is some value or object
      Returns:
      true if the parameter is null
    • byteBuffer

      public static byte[] byteBuffer​(int len)
      Create a new byte buffer of length len.
      Parameters:
      len - the length of the buffer allocated.
      Returns:
      the new buffer
    • getByte

      public static java.lang.Long getByte​(byte[] buffer, java.lang.Long i)
    • setByte

      public static void setByte​(byte[] buffer, java.lang.Long i, java.lang.Long v) throws BasicRuntimeException
      Throws:
      BasicRuntimeException
    • getStringBytes

      public static byte[] getStringBytes​(java.lang.String s)
    • stringifyBuffer

      public static java.lang.String stringifyBuffer​(byte[] buffer)
    • length

      public static java.lang.Long length​(java.lang.Object arg)
    • cdbl

      public static java.lang.Double cdbl​(java.lang.Object arg) throws BasicRuntimeException
      Throws:
      BasicRuntimeException
    • clng

      public static java.lang.Long clng​(java.lang.Object arg) throws BasicRuntimeException
      Throws:
      BasicRuntimeException
    • chr

      public static java.lang.String chr​(java.lang.Object charcode) throws BasicRuntimeException
      Returns a String containing the character associated with the specified character code.
      Parameters:
      charcode - argument is a Long that identifies a character
      Returns:
      character
      Throws:
      BasicRuntimeException - fail if incorrect character code
    • asc

      public static java.lang.Integer asc​(java.lang.Object arg) throws BasicRuntimeException
      Returns an Integer representing the character code corresponding to the first letter in a string.
      Parameters:
      arg - string argument
      Returns:
      character code corresponding to the first letter
      Throws:
      BasicRuntimeException - fail on empty input