SparseWare

System Functions

System functions are a set of Sage specific convenient functions for manipulating and/or converting data. System functions are available within the scripting environment via the "sage" object and can also be embedded within configuration strings by prefixing the function name with a dollar sign ($).

Below is an example of embedding the date system function to create table column titles:
Table {
  titleLocation: "top_left"
  columns {
    {title: "{$date('T-3')}"}
    {title: "{$date('T-2')}"}
    {title: "{$date('T-1')}"}
  }
}
The table below describes the available system functions.

static String applicationURL (iWidget context)
 Returns a string representing the application's main URL.
static String applicationURL ()
 Returns a string representing the application's main URL.
static String base64 (String val)
 Base64 encodes the specified string.
static String chop (String val, int size)
 Chops the specified amount of characters for the specified string.
static String cleanQuotedString (String val)
 Cleans a quoted string, removing the quotes and backslash escape sequences.
static String cleanString (String val)
 Cleans a string removing backslash escape sequences.
static String codeBase (iWidget context)
 Returns a string representing the codebase for an application launched via webstart.
static String codeBase ()
 Returns a string representing the codebase for an application launched via webstart.
static List createFilterableList (int len)
 Creates a filterablelist object to use to hold items.
static HashMap createHashMap (int len)
 Creates a hash map.
static List createList (int len)
 Creates a list object to use to hold items.
static ListBoxViewer createListBox (iWidget context, List< RenderableDataItem > rows)
 Creates a new listbox viewer.
static TableViewer createTable (iWidget context, List< Column > columns, List< RenderableDataItem > rows)
 Creates a new table viewer.
static TableViewer createTable (iWidget context, iDataCollection dc, int skip)
 Creates a new table viewer.
static TreeViewer createTree (iWidget context, RenderableDataItem root, List< RenderableDataItem > rows)
 Creates a new tree viewer.
static String currentDate (iWidget context, String format)
 Convenience method for creating a date string from a relative time specification.
static String currentDate (String format)
 Convenience method for creating a date string from a relative time specification.
static String currentTime ()
 Returns a string representing the current time in milliseconds.
static String date (String spec, String format)
 Convenience method for creating a date string from a relative time specification.
static String date (iWidget context, String spec)
 Convenience method for creating a date string from a relative time specification.
static String date (String spec)
 Convenience method for creating a date string from a relative time specification.
static String dateTime (iWidget context, String spec, String format)
 Convenience method for creating a date string from a relative time specification.
static String dateTime (String spec, String format)
 Convenience method for creating a date string from a relative time specification.
static String dateTime (iWidget context, String spec)
 Convenience method for creating a date string from a relative time specification.
static String dateTime (String spec)
 Convenience method for creating a date string from a relative time specification.
static String decrypt (String val, String key, String algorithm)
 Decrypts the specified value.
static String digest (String val, String algorithm)
 Digests the specified value.
static String documentBase (iWidget context)
 Returns a string representing the documentbase for an applet or the codebase for an application launched via webstart.
static String documentBase ()
 Returns a string representing the documentbase for an applet or the codebase for an application launched via webstart.
static String encrypt (String val, String key, String algorithm)
 Encrypts the specified value.
static void eprintln (Object o)
 Prints the string representation of the specified object to standard error.
static String escape (String str)
 Encodes the specifeid string for use as part of a url.
static String format (String pattern, Object...args)
 Formats a string using the specified pattern and arguments.
static boolean getStrictScriptingMode ()
 Gets the strict mode for the scripting environment.
static String hmacMD5 (String val, String key)
 Computes a Hash-based Message Authentication Code (HMAC) using the MD5 hash function.
static String hmacSHA (String val, String key)
 Computes a Hash-based Message Authentication Code (HMAC) using the SHA hash function.
static String length (String val, String tok)
 Returns the length of tokenized segments in the specified string.
static String length (String val)
 Returns the length of the specified string.
static String linefeedToHTMLBreak (String s, boolean html)
 Replaces the linefeeds in the specified string with HTML line breaks (<BR>).
static String linefeedToHTMLBreak (String s)
 Replaces the linefeeds in the specified string with HTML line breaks (<BR>).
static void loadResourceIcons (iWidget context, ActionLink link) throws IOException
 Loads icon resources from a properties files.
static void loadResourceStrings (iWidget context, ActionLink link) throws IOException
 Loads string resources from a properties file.
static void loadTemplate (iWidget context, ActionLink link, String name) throws IOException
 Loads a template that will be cached.
static String lowerCase (String val)
 Returns the lowercase representation of the specified string.
static String mac (String val, String key, String algorithm)
 Computes the Message Authentication Code for the specified value.
static String md5 (String val)
 Computes the MD5 hash of the specified value.
static String nanoTime ()
 Returns a string representing the number nanoseconds of elapsed time.
static String piece (String val, String tok, int start, int end)
 Returns a portion of a token delimited string.
static void println (Object o)
 Prints the string representation of the specified object to standard output.
static String property (iWidget context, String name, String def)
 Returns the system property with the specified name.
static String property (String name, String def)
 Returns the system property with the specified name.
static String random (String val)
 Returns a string representing a random number that is greater than or equal to zero and less than the specified value.
static String random ()
 Returns a string representing a random number.
static String read (iWidget context, Object entity) throws IOException
 Reads the dat for the specified entity.
static void removeRange (List list, int fromIndex, int toIndex)
 Removes from the specified list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
static String replacePiece (String val, String tok, int tlen, int pos, int pos2, String rval)
 Replaces a portion of a token delimited string with a specified value.
static String resolve (iWidget context, String str)
 Convenience method for resolving embedded functions and attributes within the specified string.
static String resolve (String str)
 Convenience method for resolving embedded functions and attributes within the specified string.
static String script (iWidget context, String code)
 Evaluates the specified code within the specified widget context and returns the result.
static String script (String code)
 Evaluates the specified code within the specified widget context and returns the result.
static String scriptVar (iWidget context, String name)
 Returns the string representation of the specified script variable.
static String scriptVar (String name)
 Returns the string representation of the specified script variable.
static String serverBase (iWidget context)
 Returns a string representing the server's base for an application.
static String serverBase ()
 Returns a string representing the server's base for an application.
static void setStrictScriptingMode (boolean strict)
 Sets the strict mode for the scripting environment.
static String sha (String val)
 Computes the SHA hash of the specified value.
static String sound (iWidget context, String sound)
 Plays a predefined sound.
static String sound (String sound)
 Plays a predefined sound.
static String substring (String val, int start, int end)
 Returns a new string that is a substring of the specified string.
static String timeExecution (String code) throws ScriptException
 Returns the amount of time the specified code took to execute.
static String trim (String val)
 Trims leading an trailing whitespace from the specified string.
static String upperCase (String val)
 Returns the lowercase representation of the specified string.

Detailed Description

Author:
Don DeCoteau

Member Function Documentation

static String applicationURL ( iWidget  context  )  [static]

Parameters:
context the widget context
Returns:
a string representing the application's main URL

static String applicationURL (  )  [static]

Returns:
a string representing the application's main URL

static String base64 ( String  val  )  [static]

Parameters:
val the value to be encoded
Returns:
the base64 encoding of the specified string

static String chop ( String  val,
int  size 
) [static]

Parameters:
val the value to chop
size the amount of characters to chop
Returns:
the chopped string

static String cleanQuotedString ( String  val  )  [static]

Parameters:
val the value to be cleaned
Returns:
the cleaned value

static String cleanString ( String  val  )  [static]

Parameters:
val the value to be cleaned
Returns:
the cleaned value

static String codeBase ( iWidget  context  )  [static]

Parameters:
context the widget context
Returns:
a string representing the codebase or null if the app was not launched via webstart

static String codeBase (  )  [static]

Returns:
a string representing the codebase or null if the app was not launched via webstart

static List createFilterableList ( int  len  )  [static]

Parameters:
len the initial capacity for the list;
Returns:
the list

static HashMap createHashMap ( int  len  )  [static]

Parameters:
len the initial capacity for the list;
Returns:
the hash map

static List createList ( int  len  )  [static]

Parameters:
len the initial capacity for the list;
Returns:
the list

static ListBoxViewer createListBox ( iWidget  context,
List< RenderableDataItem rows 
) [static]

Parameters:
context the widget context
rows the rows for the list (can be null)
Returns:
the viewer

static TableViewer createTable ( iWidget  context,
List< Column >  columns,
List< RenderableDataItem rows 
) [static]

Parameters:
context the widget context
columns the columns for the table (can be null)
rows the rows for the tabls (can be null)
Returns:
the viewer

static TableViewer createTable ( iWidget  context,
iDataCollection  dc,
int  skip 
) [static]

Parameters:
context the widget context
dc the data collection
skip the number of initial items top skip
Returns:
the viewer

static TreeViewer createTree ( iWidget  context,
RenderableDataItem  root,
List< RenderableDataItem rows 
) [static]

Parameters:
context the widget context
root the root node for the tree (can be null)
rows the rows for the tree (can be null)
Returns:
the viewer

static String currentDate ( iWidget  context,
String  format 
) [static]

Parameters:
context the widget context
format a format specified for the date output
Returns:
a string object representing the date/time specification

static String currentDate ( String  format  )  [static]

Parameters:
format a format specified for the date output
Returns:
a string object representing the date/time specification

static String currentTime (  )  [static]

Returns:
a string representing the current time in milliseconds

static String date ( String  spec,
String  format 
) [static]

Parameters:
spec the date specification
format the date format string
Returns:
a string object representing the date/time specification

static String date ( iWidget  context,
String  spec 
) [static]

Parameters:
context the widget context
spec the date specification
Returns:
a string object representing the date/time specification

static String date ( String  spec  )  [static]

Parameters:
spec the date specification
Returns:
a string object representing the date/time specification

static String dateTime ( iWidget  context,
String  spec,
String  format 
) [static]

Parameters:
context the widget context
spec the date/time specification
format a format specified for the data output
Returns:
a string object representing the date/time specification

static String dateTime ( String  spec,
String  format 
) [static]

Parameters:
spec the date/time specification
format a format specified for the data output
Returns:
a string object representing the date/time specification

static String dateTime ( iWidget  context,
String  spec 
) [static]

Parameters:
context the widget context
spec the date/time specification
Returns:
a string object representing the date/time specification

static String dateTime ( String  spec  )  [static]

Parameters:
spec the date/time specification
Returns:
a string object representing the date/time specification

static String decrypt ( String  val,
String  key,
String  algorithm 
) [static]

Parameters:
val the value to be decrypted
key the decryption key
algorithm the decryption algorithm
Returns:
the decrypted value

static String digest ( String  val,
String  algorithm 
) [static]

Parameters:
val the value to be digested
algorithm the digest algorithm
Returns:
the digested value

static String documentBase ( iWidget  context  )  [static]

Parameters:
context the widget context
Returns:
a string representing the document base or codebase or null

static String documentBase (  )  [static]

Returns:
a string representing the document base or codebase or null

static String encrypt ( String  val,
String  key,
String  algorithm 
) [static]

Parameters:
val the value to be encrypted
key the encryption key
algorithm the encryption algorithm
Returns:
the encrypted value

static void eprintln ( Object  o  )  [static]

Parameters:
o the object to print

static String escape ( String  str  )  [static]

Parameters:
str the string to encode
Returns:
the encoded string

static String format ( String  pattern,
Object...  args 
) [static]

Parameters:
pattern the printf-style pattern
args the arguments
Returns:
the formatted date

static boolean getStrictScriptingMode (  )  [static]

Returns:
true for strict mode; false otherwise

static String hmacMD5 ( String  val,
String  key 
) [static]

Parameters:
val the value
key the key
Returns:
the results of the computation

static String hmacSHA ( String  val,
String  key 
) [static]

Parameters:
val the value
key the key
Returns:
the results of the computation

static String length ( String  val,
String  tok 
) [static]

Parameters:
val the string
tok the token
Returns:
the length of the specified string (e.g. length("a^b","^") will return 2 length("ab","^") will return 1)

static String length ( String  val  )  [static]

Parameters:
val the string
Returns:
the length of the specified string

static String linefeedToHTMLBreak ( String  s,
boolean  html 
) [static]

Parameters:
s the string containing linefeeds
html true to enclose the string between <html></html> ; false otherwise
Returns:
the converted string

static String linefeedToHTMLBreak ( String  s  )  [static]

Parameters:
s the string containing linefeeds
Returns:
the converted string

static void loadResourceIcons ( iWidget  context,
ActionLink  link 
) throws IOException [static]

Parameters:
context the context
link the link to the properties file
Exceptions:
IOException 

static void loadResourceStrings ( iWidget  context,
ActionLink  link 
) throws IOException [static]

Parameters:
context the context
link the link to the properties file
Exceptions:
IOException 

static void loadTemplate ( iWidget  context,
ActionLink  link,
String  name 
) throws IOException [static]

Parameters:
context the context
link the link to the template file
name the name of the template. If specified it will override the name specified withing the template itself
Exceptions:
IOException 

static String lowerCase ( String  val  )  [static]

Parameters:
val the string
Returns:
the lowercase representation of the specified string

static String mac ( String  val,
String  key,
String  algorithm 
) [static]

Parameters:
val the value
key the key
algorithm the mac algorithm
Returns:
the Message Authentication Code for the specified value

static String md5 ( String  val  )  [static]

Parameters:
val the value
Returns:
the MD5 hash of the specified value

static String nanoTime (  )  [static]

Returns:
a string representing the number nanoseconds of elapsed time

static String piece ( String  val,
String  tok,
int  start,
int  end 
) [static]

Parameters:
val the string
tok the token
start the position if the starting token to retrieve
end the position if the ending token to retrieve
Returns:
a string representing the result

static void println ( Object  o  )  [static]

Parameters:
o the object to print

static String property ( iWidget  context,
String  name,
String  def 
) [static]

Parameters:
context the widget context
name the name of the variable
def the default value if the property is undefined
Returns:
the system property with the specified name

static String property ( String  name,
String  def 
) [static]

Parameters:
name the name of the variable
def the default value if the property is undefined
Returns:
the system property with the specified name

static String random ( String  val  )  [static]

Parameters:
val a number representing an upper bound for the random number
Returns:
a string representing the random number

static String random (  )  [static]

Returns:
a string representing the random number

static String read ( iWidget  context,
Object  entity 
) throws IOException [static]

Parameters:
context the widget context
entity the URL, File, or string representing a URL from which to read
Returns:
the contents of the specifeid entity

static void removeRange ( List  list,
int  fromIndex,
int  toIndex 
) [static]

Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)

Parameters:
list the list
fromIndex index of first element to be removed
toIndex index after last element to be removed

static String replacePiece ( String  val,
String  tok,
int  tlen,
int  pos,
int  pos2,
String  rval 
) [static]

Parameters:
val the string
tok the token
tlen the token length
pos the starting token position to replace from
pos2 the ending token position to replace to
rval the value to replace with
Returns:
a string representing the result

static String resolve ( iWidget  context,
String  str 
) [static]

Parameters:
context the context
str the string to resolve
Returns:
the resolved string

static String resolve ( String  str  )  [static]

Parameters:
str the string to resolve
Returns:
the resolved string

static String script ( iWidget  context,
String  code 
) [static]

Parameters:
context the widget context
code the code to execute
Returns:
the result of the execution

static String script ( String  code  )  [static]

Parameters:
code the code to execute
Returns:
the result of the execution

static String scriptVar ( iWidget  context,
String  name 
) [static]

Parameters:
context the widget context
name the name of the variable
Returns:
the string representation of the specified script variable

static String scriptVar ( String  name  )  [static]

Parameters:
name the name of the variable
Returns:
the string representation of the specified script variable

static String serverBase ( iWidget  context  )  [static]

This is the url to the server (http://server:port/)

Parameters:
context the widget context
Returns:
a string representing the base server URL

static String serverBase (  )  [static]

This is the url to the server (http://server:port/)

Returns:
a string representing the base server URL

static void setStrictScriptingMode ( boolean  strict  )  [static]

Parameters:
strict true for strict mode; false otherwise

static String sha ( String  val  )  [static]

Parameters:
val the value
Returns:
the SHA hash of the specified value

static String sound ( iWidget  context,
String  sound 
) [static]

Parameters:
context the widget context
sound the sound. Current valid values are "beep", "error", "success"
Returns:
null always

static String sound ( String  sound  )  [static]

Parameters:
sound the sound. Current valid values are "beep", "error", "success"
Returns:
null always

static String substring ( String  val,
int  start,
int  end 
) [static]

The substring begins at the specified start and extends to the character at index end - 1. Thus the length of the substring is end-start.

Parameters:
val the string
start the beginning index, inclusive.
end the ending index, exclusive.
Returns:
the specified substring.

static String timeExecution ( String  code  )  throws ScriptException [static]

Parameters:
code the code to execute
Returns:
the amount of time the specified code took to execute

static String trim ( String  val  )  [static]

Parameters:
val the string
Returns:
the trimmed string

static String upperCase ( String  val  )  [static]

Parameters:
val the string
Returns:
the lowercase representation of the specified string