Package helma.scripting.rhino
Class GlobalObject
java.lang.Object
org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.IdScriptableObject
org.mozilla.javascript.TopLevel
org.mozilla.javascript.ImporterTopLevel
helma.scripting.rhino.GlobalObject
- All Implemented Interfaces:
PropertyRecorder
,Serializable
,org.mozilla.javascript.ConstProperties
,org.mozilla.javascript.debug.DebuggableObject
,org.mozilla.javascript.IdFunctionCall
,org.mozilla.javascript.Scriptable
,org.mozilla.javascript.SymbolScriptable
public class GlobalObject
extends org.mozilla.javascript.ImporterTopLevel
implements PropertyRecorder
Helma global object defines a number of custom global functions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.mozilla.javascript.TopLevel
org.mozilla.javascript.TopLevel.Builtins
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
org.mozilla.javascript.ScriptableObject.KeyComparator
-
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
ConstructorsConstructorDescriptionGlobalObject
(RhinoCore core, Application app, boolean isThreadScope) Creates a new GlobalObject object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
authenticate
(String user, String pwd) void
Clear the set of changed properties.createSkin
(String str) Create a Skin object from a stringvoid
defineLibraryScope
(String name) Deprecated.should be implemented in JavaScript insteaddefinePrototype
(String name, org.mozilla.javascript.Scriptable desc) static Object
deserialize
(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) Read a previously serialized JavaScript object from a file.static Object
dontEnum
(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) Set DONTENUM attrubutes on the given properties in this object.formatParagraphs
(Object obj) Override ScriptableObject.get() to use the per-thread scope if possible, and return the per-thread scope for "global".Returns a set containing the names of properties changed since the last time startRecording() was called.Get the global object's class namegetDBConnection
(String dbsource) Get a Helma DB connection specified in db.propertiesgetHtmlDocument
(Object src) Try to parse an object to a XML DOM tree.getProperty
(String propname, Object defvalue) Retrieve a Document from the specified URL.getXmlDocument
(Object src) Try to parse an object to a XML DOM tree.void
init()
Initializes the global object.void
Override ScriptableObject.put() to implement PropertyRecorder interface and to synchronize method.boolean
renderSkin
(Object skinobj, Object paramobj) renderSkinAsString
(Object skinobj, Object paramobj) static void
seal
(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, 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, Object[] args, org.mozilla.javascript.Function funObj) Serialize a JavaScript object to a file.void
Tell this PropertyRecorder to start recording changes to propertiesvoid
Tell this PropertyRecorder to stop recording changes to propertiesConvert an object into a wrapper that exposes the java methods of the object to JavaScript.toString()
unwrapJavaMap
(Object obj) Unwrap a map previously wrapped usingwrapJavaMap(Object)
.wrapJavaMap
(Object obj) Wrap a java.util.Map so that it looks and behaves like a native JS objectvoid
void
Methods inherited from class org.mozilla.javascript.ImporterTopLevel
execIdCall, findPrototypeId, has, importPackage, init, initPrototypeId, initStandardObjects
Methods inherited from class org.mozilla.javascript.TopLevel
cacheBuiltins, getBuiltinCtor, getBuiltinCtor, getBuiltinPrototype, getBuiltinPrototype
Methods inherited from class org.mozilla.javascript.IdScriptableObject
activatePrototypeMap, addIdFunctionProperty, defaultGet, defaultHas, defaultPut, defineOwnProperty, delete, delete, ensureType, ensureType, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, findInstanceIdInfo, findPrototypeId, get, getAttributes, getAttributes, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, getOwnPropertyDescriptor, has, hasPrototypeMap, initPrototypeConstructor, initPrototypeMethod, initPrototypeMethod, initPrototypeMethod, initPrototypeValue, initPrototypeValue, instanceIdInfo, put, setAttributes, setInstanceIdAttributes, setInstanceIdValue
Methods inherited from class org.mozilla.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChangeForSlot, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Constructor Details
-
GlobalObject
Creates a new GlobalObject object.- Parameters:
core
- ...app
- ...
-
-
Method Details
-
init
public void init()Initializes the global object. This is only done for the shared global objects not the per-thread ones. -
getClassName
Get the global object's class name- Specified by:
getClassName
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
getClassName
in classorg.mozilla.javascript.ImporterTopLevel
- Returns:
- the class name for the global object
-
put
Override ScriptableObject.put() to implement PropertyRecorder interface and to synchronize method.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classorg.mozilla.javascript.IdScriptableObject
- Parameters:
name
-start
-value
-
-
get
Override ScriptableObject.get() to use the per-thread scope if possible, and return the per-thread scope for "global".- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classorg.mozilla.javascript.ImporterTopLevel
- Parameters:
name
-start
-- Returns:
- the property for the given name
-
renderSkin
public boolean renderSkin(Object skinobj, Object paramobj) throws UnsupportedEncodingException, IOException - Parameters:
skinobj
- ...paramobj
- ...- Returns:
- ...
- Throws:
UnsupportedEncodingException
IOException
-
renderSkinAsString
public String renderSkinAsString(Object skinobj, Object paramobj) throws UnsupportedEncodingException, IOException - Parameters:
skinobj
- ...paramobj
- ...- Returns:
- ...
- Throws:
UnsupportedEncodingException
IOException
-
getProperty
- Parameters:
propname
- ...defvalue
- ...- Returns:
- ...
-
authenticate
- Parameters:
user
- ...pwd
- ...- Returns:
- ...
-
createSkin
Create a Skin object from a string- Parameters:
str
- the source string to parse- Returns:
- a parsed skin object
-
getDBConnection
Get a Helma DB connection specified in db.properties- Parameters:
dbsource
- the db source name- Returns:
- a DatabaseObject for the specified DbConnection
- Throws:
Exception
-
getURL
Retrieve a Document from the specified URL.- Parameters:
location
- the URL to retrievecondition
- either a LastModified date or an ETag string for conditional GETstimeout
- the optional timeout value in milliseconds used for connecting to and reading from the given URL.- Returns:
- a wrapped MIME object
-
getXmlDocument
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
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
Deprecated.should be implemented in JavaScript insteadCreates a libary namespace in the global scope.- Parameters:
name
- the name of the libary namespace
-
wrapJavaMap
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
Unwrap a map previously wrapped usingwrapJavaMap(Object)
.- Parameters:
obj
- the wrapped map- Returns:
- the map exposed as java object
-
toJava
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.
-
format
- Parameters:
obj
- ...- Returns:
- ...
-
formatParagraphs
- Parameters:
obj
- ...- Returns:
- ...
-
write
- Parameters:
str
- ...
-
writeln
- Parameters:
str
- ...
-
seal
public static void seal(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) The seal function seals all supplied arguments. -
serialize
public static void serialize(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) throws IOException Serialize a JavaScript object to a file.- Throws:
IOException
-
deserialize
public static Object deserialize(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, Object[] args, org.mozilla.javascript.Function funObj) throws IOException, ClassNotFoundException Read a previously serialized JavaScript object from a file.- Throws:
IOException
ClassNotFoundException
-
dontEnum
public static Object dontEnum(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable thisObj, 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. -
definePrototype
-
startRecording
public void startRecording()Tell this PropertyRecorder to start recording changes to properties- Specified by:
startRecording
in interfacePropertyRecorder
-
stopRecording
public void stopRecording()Tell this PropertyRecorder to stop recording changes to properties- Specified by:
stopRecording
in interfacePropertyRecorder
-
getChangeSet
Returns a set containing the names of properties changed since the last time startRecording() was called.- Specified by:
getChangeSet
in interfacePropertyRecorder
- Returns:
- a Set containing the names of changed properties
-
clearChangeSet
public void clearChangeSet()Clear the set of changed properties.- Specified by:
clearChangeSet
in interfacePropertyRecorder
-
toString
-