l.madhavan

jasq | Class Reference

Character

Provides several methods for determing a character's category.

Static Methods

Character.forDigit(digit, radix) – Returns the character representation of digit in the specified radix; returns null if either either argument is invalid (valid radices are from 2 to 36 inclusive). Example: Character.forDigit(10, 16) returns 'A'.

Character.getNumericValue(ch) – Returns the numeric value of the given character, or -1 if the character does not represent a valid digit in any supported radix. This method does not currently supported extended Unicode numerals. Example: Character.getNumericValue('A') returns the number 10.

Character.isDigit(ch) – Determines whether the given character is a digit. This method recognizes the standard 0-9 digits as well as certain other Unicode numerals such as Arabic and Indian digits.

Character.isLetter(ch) – Determines whether the given character is a letter according to the Unicode standard.

Character.isLetterOrDigit(ch) – Determines whether the given character is either a letter or a digit (with the same semantics as isLetter and isDigit).

Character.isLowerCase(ch) – Determines whether the given character is a lowercase letter according to the Unicode standard.

Character.isUpperCase(ch) – Determines whether the given character is an uppercase letter according to the Unicode standard.

Character.isWhitespace(ch) – Determines whether the given character is a whitespace character (except a non-breaking space) according to the Unicode standard.

Formatter

An interpreter for printf-style format strings.

(Constructor) Formatter()

Methods

format(fmt, ...) – Formats a string according to the format string fmt using the supplied arguments and appends it to the internal buffer. Returns this Formatter object so that multiple calls can be chained. Valid format specifiers are:

out() – returns the internal StringBuffer object used by this formatter.

toString() – returns the formatted string output of this formatter.

Example: new Formatter().format('%d + %d = %d', 2, 3, 5).toString() returns the string 2 + 3 = 5.

Logger

Provides a uniform interface for logging messages to various targets.

(Constructor) Logger(name, target)name is an arbitrary string that identifies messages from this logger. target can be one of:

Methods

getLevel() – returns the threshold level for this logger.

log(level, msg) – Logs the given message at the specified level (if this is below the current logger level, it will not be logged).

setLevel(level) – sets the threshold level for this logger. Only messages that are equal to or above this level are logged. The following level constants are predefined:

config(msg), entering(msg), exiting(msg), info(msg), severe(msg), warning(msg) – convenience methods for logging various kinds of messages.

Map

A collection of key-value pairs. Keys can be a primitive JavaScript type (numbers or strings) or an object that implements the toString method. Values can be of any type.

(Constructor) Map()

Methods

clear() – Removes all the mappings contained in this map.

containsKey(key) – Returns true if this map contains the specified key.

containsValue(value) – Returns true if one or more keys map to the specified value.

get(key) – Returns the value associated with the specified key, or null if the key is not present in this map.

isEmpty() – Returns true if this map is empty (i.e. contains no mappings).

put(key, value) – Associates the specified key with the specified value. Returns the previous value associated with the key, or null if the key did not exist before.

remove(key) – Removes the specified key from the map. Returns the value associated with the key, or null if the key does not exist.

size() – Returns the number of mappings in this map.

Preferences

Provides persistent client-side storage for user preferences. This class relies on browser support for HTML5 Web Storage. Security Note: All applications on the same domain share the same storage area.

(Factory Method) Preferences.getNode(name) – Returns the Preferences node associated with the given name, or null if the browser does not support Local Storage. Applications should choose unique node names to avoid conflicts with other applications on the same domain. Example: var prefs = Preferences.getNode('com.mydomain.myapp');

Methods

get(key, def) – Returns the value associated with the specified key in this preference node. If the key does not exist, the default value def is returned.

put(key, value) – Associates the given value with the specified key in this preference node.

remove(key) – Removes the specified key (if it exists) from this preference node.

Queue

A simple queue data structure.

(Constructor) Queue()

Methods

add(elem) – Adds an element to the back of the queue.

peek() – Returns the element at the front of the queue, without removing it.

remove() – Removes and returns the element at the front of the queue.

size() – Returns the size of the queue.

Random

A pseudo-random number generator.

(Constructor) Random([seed]) – If seed (optional) is specified, it is used to initialize the random number stream; otherwise, a seed is chosen based on the current time. Two objects initialized with the same seed will produce the same sequence of numbers.

Methods

nextBoolean() – Returns the next pseudo-random, uniformly distributed boolean value from this object's sequence.

nextDouble() – Returns the next pseudo-random, uniformly distributed floating-point value between 0.0 and 1.0 from this object's sequence.

nextInt([n]) – Returns the next pseudo-random, uniformly distributed integer value from this object's sequence. If n (optional) is specified, the value lies in the range 0 (inclusive) to n (exclusive); otherwise, the value spans the entire 32-bit range.

setSeed(seed) – Sets a new seed for this object.

Set

A collection of unique elements. Elements can be a primitive JavaScript type (numbers or strings) or an object that implements the toString method.

(Constructor) Set()

Methods

add(elem) – Adds an element to this set. Returns true if the element was added or false if it was already in the set.

clear() – Removes all elements from this set.

contains(elem) – Returns true if this set contains the specified element.

isEmpty() – Returns true if this set is empty.

remove(elem) – Removes the specified element from this set. Returns true if the element was removed or false if the element was not in the set.

size() – Returns the number of elements in this set.

toArray() – Returns an array containing all the elements in this set.

StringBuffer

A string buffer whose contents can be modified.

(Constructor) StringBuffer()

Methods

append(obj) – appends a string representation of obj to the buffer. Returns this StringBuffer object so that multiple calls can be chained.

insert(offset, obj) – inserts a string representation of obj at the specified offset in the buffer. Returns this StringBuffer object so that multiple calls can be chained.

toString() – returns the string contained in the buffer.

Example: new StringBuffer().append('world ').insert(0, 'hello ').append(123).toString() returns the string hello world 123.

Timer

Schedules tasks for future execution.

(Constructor) Timer()

Methods

cancel() – cancels all tasks scheduled with this timer.

schedule(task, delay, [repeat]) – schedules a task to execute after delay milliseconds. task is a reference to the function to be executed. If repeat (optional) is specified and is true, the task will repeat periodically until cancelled, otherwise it will execute only once.

Example: new Timer().schedule(someFunc, 5000, true) schedules myFunc to execute every 5 seconds.