helma.scripting.rhino
Class GlobalObject

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by org.mozilla.javascript.IdScriptableObject
          extended by org.mozilla.javascript.ImporterTopLevel
              extended by helma.scripting.rhino.GlobalObject
All Implemented Interfaces:
PropertyRecorder, java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.IdFunctionCall, org.mozilla.javascript.Scriptable

public class GlobalObject
extends org.mozilla.javascript.ImporterTopLevel
implements PropertyRecorder

Helma global object defines a number of custom global functions.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
GlobalObject(RhinoCore core, Application app, boolean isThreadScope)
          Creates a new GlobalObject object.
 
Method Summary
 boolean authenticate(java.lang.String user, java.lang.String pwd)
           
 void clearChangeSet()
          Clear the set of changed properties.
 java.lang.Object createSkin(java.lang.String str)
          Create a Skin object from a string
 void defineLibraryScope(java.lang.String name)
          Deprecated. should be implemented in JavaScript instead
static java.lang.Object deserialize(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj)
          Read a previously serialized JavaScript object from a file.
static java.lang.Object dontEnum(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj)
          Set DONTENUM attrubutes on the given properties in this object.
 java.lang.String encode(java.lang.Object obj)
           
 java.lang.String encodeForm(java.lang.Object obj)
           
 java.lang.String encodeXml(java.lang.Object obj)
           
 java.lang.String format(java.lang.Object obj)
           
 java.lang.String formatParagraphs(java.lang.Object obj)
           
 java.lang.Object get(java.lang.String name, org.mozilla.javascript.Scriptable start)
          Override ScriptableObject.get() to use the per-thread scope if possible, and return the per-thread scope for "global".
 java.util.Set getChangeSet()
          Returns a set containing the names of properties changed since the last time startRecording() was called.
 java.lang.String getClassName()
          Get the global object's class name
 java.lang.Object getDBConnection(java.lang.String dbsource)
          Get a Helma DB connection specified in db.properties
 java.lang.Object getHtmlDocument(java.lang.Object src)
          Try to parse an object to a XML DOM tree.
 java.lang.String getProperty(java.lang.String propname, java.lang.Object defvalue)
           
 java.lang.Object getURL(java.lang.String location, java.lang.Object opt)
          Retrieve a Document from the specified URL.
 java.lang.Object getXmlDocument(java.lang.Object src)
          Try to parse an object to a XML DOM tree.
 void init()
          Initializes the global object.
 void put(java.lang.String name, org.mozilla.javascript.Scriptable start, java.lang.Object value)
          Override ScriptableObject.put() to implement PropertyRecorder interface and to synchronize method.
 boolean renderSkin(java.lang.Object skinobj, java.lang.Object paramobj)
           
 java.lang.String renderSkinAsString(java.lang.Object skinobj, java.lang.Object paramobj)
           
static void seal(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj)
          The seal function seals all supplied arguments.
static void serialize(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, java.lang.Object[] args, org.mozilla.javascript.Function funObj)
          Serialize a JavaScript object to a file.
 void startRecording()
          Tell this PropertyRecorder to start recording changes to properties
 void stopRecording()
          Tell this PropertyRecorder to stop recording changes to properties
 java.lang.String stripTags(java.lang.String str)
          (Try to) strip all HTML/XML style tags from the given string argument
 java.lang.Object toJava(java.lang.Object obj)
          Convert an object into a wrapper that exposes the java methods of the object to JavaScript.
 java.lang.String toString()
           
 java.lang.Object unwrapJavaMap(java.lang.Object obj)
          Unwrap a map previously wrapped using wrapJavaMap(Object).
 java.lang.Object wrapJavaMap(java.lang.Object obj)
          Wrap a java.util.Map so that it looks and behaves like a native JS object
 void write(java.lang.String str)
           
 void writeln(java.lang.String str)
           
 
Methods inherited from class org.mozilla.javascript.ImporterTopLevel
execIdCall, findPrototypeId, has, importPackage, init, initPrototypeId, initStandardObjects
 
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultPut, delete, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, getAttributes, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeMethod, initPrototypeValue, instanceIdInfo, setAttributes, setInstanceIdValue
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, equivalentValues, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GlobalObject

public GlobalObject(RhinoCore core,
                    Application app,
                    boolean isThreadScope)
Creates a new GlobalObject object.

Parameters:
core - ...
app - ...
Method Detail

init

public void init()
Initializes the global object. This is only done for the shared global objects not the per-thread ones.


getClassName

public java.lang.String getClassName()
Get the global object's class name

Specified by:
getClassName in interface org.mozilla.javascript.Scriptable
Overrides:
getClassName in class org.mozilla.javascript.ImporterTopLevel
Returns:
the class name for the global object

put

public void put(java.lang.String name,
                org.mozilla.javascript.Scriptable start,
                java.lang.Object value)
Override ScriptableObject.put() to implement PropertyRecorder interface and to synchronize method.

Specified by:
put in interface org.mozilla.javascript.Scriptable
Overrides:
put in class org.mozilla.javascript.IdScriptableObject
Parameters:
name -
start -
value -

get

public java.lang.Object get(java.lang.String name,
                            org.mozilla.javascript.Scriptable start)
Override ScriptableObject.get() to use the per-thread scope if possible, and return the per-thread scope for "global".

Specified by:
get in interface org.mozilla.javascript.Scriptable
Overrides:
get in class org.mozilla.javascript.ImporterTopLevel
Parameters:
name -
start -
Returns:
the property for the given name

renderSkin

public boolean renderSkin(java.lang.Object skinobj,
                          java.lang.Object paramobj)
                   throws java.io.UnsupportedEncodingException,
                          java.io.IOException
Parameters:
skinobj - ...
paramobj - ...
Returns:
...
Throws:
java.io.UnsupportedEncodingException
java.io.IOException

renderSkinAsString

public java.lang.String renderSkinAsString(java.lang.Object skinobj,
                                           java.lang.Object paramobj)
                                    throws java.io.UnsupportedEncodingException,
                                           java.io.IOException
Parameters:
skinobj - ...
paramobj - ...
Returns:
...
Throws:
java.io.UnsupportedEncodingException
java.io.IOException

getProperty

public java.lang.String getProperty(java.lang.String propname,
                                    java.lang.Object defvalue)
Parameters:
propname - ...
defvalue - ...
Returns:
...

authenticate

public boolean authenticate(java.lang.String user,
                            java.lang.String pwd)
Parameters:
user - ...
pwd - ...
Returns:
...

createSkin

public java.lang.Object createSkin(java.lang.String str)
Create a Skin object from a string

Parameters:
str - the source string to parse
Returns:
a parsed skin object

getDBConnection

public java.lang.Object getDBConnection(java.lang.String dbsource)
                                 throws java.lang.Exception
Get a Helma DB connection specified in db.properties

Parameters:
dbsource - the db source name
Returns:
a DatabaseObject for the specified DbConnection
Throws:
java.lang.Exception

getURL

public java.lang.Object getURL(java.lang.String location,
                               java.lang.Object opt)
Retrieve a Document from the specified URL.

Parameters:
location - the URL to retrieve
opt - either a LastModified date or an ETag string for conditional GETs
Returns:
a wrapped MIME object

getXmlDocument

public java.lang.Object getXmlDocument(java.lang.Object src)
Try to parse an object to a XML DOM tree. The argument must be either a URL, a piece of XML, an InputStream or a Reader.


getHtmlDocument

public java.lang.Object getHtmlDocument(java.lang.Object src)
Try to parse an object to a XML DOM tree. The argument must be either a URL, a piece of XML, an InputStream or a Reader.


defineLibraryScope

public void defineLibraryScope(java.lang.String name)
Deprecated. should be implemented in JavaScript instead

Creates a libary namespace in the global scope.

Parameters:
name - the name of the libary namespace

wrapJavaMap

public java.lang.Object wrapJavaMap(java.lang.Object obj)
Wrap a java.util.Map so that it looks and behaves like a native JS object

Parameters:
obj - a map
Returns:
a wrapper that makes the map look like a JS object

unwrapJavaMap

public java.lang.Object unwrapJavaMap(java.lang.Object obj)
Unwrap a map previously wrapped using wrapJavaMap(Object).

Parameters:
obj - the wrapped map
Returns:
the map exposed as java object

toJava

public java.lang.Object toJava(java.lang.Object obj)
Convert an object into a wrapper that exposes the java methods of the object to JavaScript. This is useful for treating native numbers, strings, etc as their java counterpart such as java.lang.Double, java.lang.String etc.

Parameters:
obj - a java object that is wrapped in a special way Rhino
Returns:
the object wrapped as NativeJavaObject, exposing the public methods of the underlying class.

encode

public java.lang.String encode(java.lang.Object obj)
Parameters:
obj - ...
Returns:
...

encodeXml

public java.lang.String encodeXml(java.lang.Object obj)
Parameters:
obj - ...
Returns:
...

encodeForm

public java.lang.String encodeForm(java.lang.Object obj)
Parameters:
obj - ...
Returns:
...

format

public java.lang.String format(java.lang.Object obj)
Parameters:
obj - ...
Returns:
...

formatParagraphs

public java.lang.String formatParagraphs(java.lang.Object obj)
Parameters:
obj - ...
Returns:
...

write

public void write(java.lang.String str)
Parameters:
str - ...

writeln

public void writeln(java.lang.String str)
Parameters:
str - ...

seal

public static void seal(org.mozilla.javascript.Context cx,
                        org.mozilla.javascript.Scriptable thisObj,
                        java.lang.Object[] args,
                        org.mozilla.javascript.Function funObj)
The seal function seals all supplied arguments.


stripTags

public java.lang.String stripTags(java.lang.String str)
(Try to) strip all HTML/XML style tags from the given string argument

Parameters:
str - a string
Returns:
the string with tags removed

serialize

public static void serialize(org.mozilla.javascript.Context cx,
                             org.mozilla.javascript.Scriptable thisObj,
                             java.lang.Object[] args,
                             org.mozilla.javascript.Function funObj)
                      throws java.io.IOException
Serialize a JavaScript object to a file.

Throws:
java.io.IOException

deserialize

public static java.lang.Object deserialize(org.mozilla.javascript.Context cx,
                                           org.mozilla.javascript.Scriptable thisObj,
                                           java.lang.Object[] args,
                                           org.mozilla.javascript.Function funObj)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Read a previously serialized JavaScript object from a file.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

dontEnum

public static java.lang.Object dontEnum(org.mozilla.javascript.Context cx,
                                        org.mozilla.javascript.Scriptable thisObj,
                                        java.lang.Object[] args,
                                        org.mozilla.javascript.Function funObj)
Set DONTENUM attrubutes on the given properties in this object. This is set on the JavaScript Object prototype.


startRecording

public void startRecording()
Tell this PropertyRecorder to start recording changes to properties

Specified by:
startRecording in interface PropertyRecorder

stopRecording

public void stopRecording()
Tell this PropertyRecorder to stop recording changes to properties

Specified by:
stopRecording in interface PropertyRecorder

getChangeSet

public java.util.Set getChangeSet()
Returns a set containing the names of properties changed since the last time startRecording() was called.

Specified by:
getChangeSet in interface PropertyRecorder
Returns:
a Set containing the names of changed properties

clearChangeSet

public void clearChangeSet()
Clear the set of changed properties.

Specified by:
clearChangeSet in interface PropertyRecorder

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.