org.xwt.js
Class JS

java.lang.Object
  extended byorg.xwt.js.JS
Direct Known Subclasses:
JS.Graft, JS.Obj, Res

public abstract class JS
extends java.lang.Object

The public API for the JS engine. JS itself is actually a class implementing the absolute minimal amount of functionality for an Object which can be manipulated by JavaScript code. The static methods, fields, and inner classes of JS define the publicly visible API for the XWT JavaScript engine; code outside this package should never depend on anything not defined in this file.


Nested Class Summary
static class JS.Array
          The publicly-visible face of JavaScript Array objects
static class JS.Callable
          anything that is callable with the () operator and wasn't compiled from JS code
static class JS.Context
          encapsulates the state of a JavaScript "thread" (ie stack)
static class JS.Exn
          An exception which can be thrown and caught by JavaScript code
static class JS.GlobalScope
          a scope that is populated with js objects and functions normally found in the global scope
static class JS.Graft
          the result of a graft
static class JS.Obj
          A sensible implementation of the abstract methods in the JS class
static class JS.Scope
          Any object which becomes part of the scope chain must support this interface
static class JS.TailCall
           
 
Constructor Summary
JS()
           
 
Method Summary
 java.lang.Object callMethod(java.lang.Object method, JS.Array args, boolean checkOnly)
           
 boolean coerceToBoolean()
           
 java.lang.Number coerceToNumber()
           
 java.lang.String coerceToString()
           
abstract  java.lang.Object get(java.lang.Object key)
           
abstract  java.lang.Object[] keys()
           
static Function parse(java.lang.String sourceName, int firstLine, java.io.Reader sourceCode)
          parse and compile a function
abstract  java.lang.Object put(java.lang.Object key, java.lang.Object val)
           
static boolean toBoolean(java.lang.Object o)
          coerce an object to a Boolean
static double toDouble(java.lang.Object o)
          coerce an object to a Double
static int toInt(java.lang.Object o)
          coerce an object to an Int
static long toLong(java.lang.Object o)
          coerce an object to a Long
static java.lang.Number toNumber(java.lang.Object o)
          coerce an object to a Number
static java.lang.String toString(java.lang.Object o)
          coerce an object to a String
 java.lang.String typeName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JS

public JS()
Method Detail

parse

public static Function parse(java.lang.String sourceName,
                             int firstLine,
                             java.io.Reader sourceCode)
                      throws java.io.IOException
parse and compile a function

Throws:
java.io.IOException

toBoolean

public static boolean toBoolean(java.lang.Object o)
coerce an object to a Boolean


toLong

public static long toLong(java.lang.Object o)
coerce an object to a Long


toInt

public static int toInt(java.lang.Object o)
coerce an object to an Int


toDouble

public static double toDouble(java.lang.Object o)
coerce an object to a Double


toNumber

public static java.lang.Number toNumber(java.lang.Object o)
coerce an object to a Number


toString

public static java.lang.String toString(java.lang.Object o)
coerce an object to a String


get

public abstract java.lang.Object get(java.lang.Object key)
                              throws JS.Exn
Throws:
JS.Exn

put

public abstract java.lang.Object put(java.lang.Object key,
                                     java.lang.Object val)
                              throws JS.Exn
Throws:
JS.Exn

keys

public abstract java.lang.Object[] keys()

callMethod

public java.lang.Object callMethod(java.lang.Object method,
                                   JS.Array args,
                                   boolean checkOnly)
                            throws JS.Exn
Throws:
JS.Exn

coerceToNumber

public java.lang.Number coerceToNumber()

coerceToString

public java.lang.String coerceToString()

coerceToBoolean

public boolean coerceToBoolean()

typeName

public java.lang.String typeName()