/** * Adds the names of the standard objects and their * prototypes to the list of excluded names. */ public void excludeStandardObjectNames() { String[] names = { "Object", "Object.prototype", "Function", "Function.prototype", "String", "String.prototype", "Math", // no Math.prototype "Array", "Array.prototype", "Error", "Error.prototype", "Number", "Number.prototype", "Date", "Date.prototype", "RegExp", "RegExp.prototype", "Script", "Script.prototype", "Continuation", "Continuation.prototype", }; for (int i=0; i < names.length; i++) { addExcludedName(names[i]); } String[] optionalNames = { "XML", "XML.prototype", "XMLList", "XMLList.prototype", }; for (int i=0; i < optionalNames.length; i++) { addOptionalExcludedName(optionalNames[i]); } }
/** * ScriptableOutputStream constructor. * Creates a ScriptableOutputStream for use in serializing * JavaScript objects. Calls excludeStandardObjectNames. * * @param out the OutputStream to write to. * @param scope the scope containing the object. */ public ScriptableOutputStream(OutputStream out, Scriptable scope) throws IOException { super(out); this.scope = scope; table = new HashMap<Object,String>(); table.put(scope, ""); enableReplaceObject(true); excludeStandardObjectNames(); // XXX }
/** * Adds a qualified name to the list of objects to be excluded from * serialization. Names excluded from serialization are looked up * in the new scope and replaced upon deserialization. * @param name a fully qualified name (of the form "a.b.c", where * "a" must be a property of the top-level object) * @throws IllegalArgumentException if the object is not found or is not * a {@link Scriptable}. */ public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
public void excludeAllIds(Object[] ids) { for (Object id: ids) { if (id instanceof String && (scope.get((String) id, scope) instanceof Scriptable)) { this.addExcludedName((String)id); } } }
public static void serialize(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException { if (args.length < 2) { throw Context.reportRuntimeError( "Expected an object to serialize and a filename to write " + "the serialization to"); } Object obj = args[0]; String filename = Context.toString(args[1]); FileOutputStream fos = new FileOutputStream(filename); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj); ScriptableOutputStream out = new ScriptableOutputStream(fos, scope); out.writeObject(obj); out.close(); }
public void excludeAllIds(Object[] ids) { for (Object id: ids) { if (id instanceof String && (scope.get((String) id, scope) instanceof Scriptable)) { this.addExcludedName((String)id); } } }
public static void serialize(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IOException { if (args.length < 2) { throw Context.reportRuntimeError( "Expected an object to serialize and a filename to write " + "the serialization to"); } Object obj = args[0]; String filename = Context.toString(args[1]); FileOutputStream fos = new FileOutputStream(filename); Scriptable scope = ScriptableObject.getTopLevelScope(thisObj); ScriptableOutputStream out = new ScriptableOutputStream(fos, scope); out.writeObject(obj); out.close(); }
/** * ScriptableOutputStream constructor. * Creates a ScriptableOutputStream for use in serializing * JavaScript objects. Calls excludeStandardObjectNames. * * @param out the OutputStream to write to. * @param scope the scope containing the object. */ public ScriptableOutputStream(OutputStream out, Scriptable scope) throws IOException { super(out); this.scope = scope; table = new HashMap<Object,String>(); table.put(scope, ""); enableReplaceObject(true); excludeStandardObjectNames(); // XXX }
/** * Adds the names of the standard objects and their * prototypes to the list of excluded names. */ public void excludeStandardObjectNames() { String[] names = { "Object", "Object.prototype", "Function", "Function.prototype", "String", "String.prototype", "Math", // no Math.prototype "Array", "Array.prototype", "Error", "Error.prototype", "Number", "Number.prototype", "Date", "Date.prototype", "RegExp", "RegExp.prototype", "Script", "Script.prototype", "Continuation", "Continuation.prototype", }; for (int i=0; i < names.length; i++) { addExcludedName(names[i]); } String[] optionalNames = { "XML", "XML.prototype", "XMLList", "XMLList.prototype", }; for (int i=0; i < optionalNames.length; i++) { addOptionalExcludedName(optionalNames[i]); } }
/** * Adds a qualified name to the list of objects to be excluded from * serialization. Names excluded from serialization are looked up * in the new scope and replaced upon deserialization. * @param name a fully qualified name (of the form "a.b.c", where * "a" must be a property of the top-level object) * @throws IllegalArgumentException if the object is not found or is not * a {@link Scriptable}. */ public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
public void excludeAllIds(Object[] ids) { for (Object id: ids) { if (id instanceof String && (scope.get((String) id, scope) instanceof Scriptable)) { this.addExcludedName((String)id); } } }
/** * ScriptableOutputStream constructor. * Creates a ScriptableOutputStream for use in serializing * JavaScript objects. Calls excludeStandardObjectNames. * * @param out the OutputStream to write to. * @param scope the scope containing the object. */ public ScriptableOutputStream(OutputStream out, Scriptable scope) throws IOException { super(out); this.scope = scope; table = new HashMap<Object,String>(); table.put(scope, ""); enableReplaceObject(true); excludeStandardObjectNames(); // XXX }
/** * Adds the names of the standard objects and their * prototypes to the list of excluded names. */ public void excludeStandardObjectNames() { String[] names = { "Object", "Object.prototype", "Function", "Function.prototype", "String", "String.prototype", "Math", // no Math.prototype "Array", "Array.prototype", "Error", "Error.prototype", "Number", "Number.prototype", "Date", "Date.prototype", "RegExp", "RegExp.prototype", "Script", "Script.prototype", "Continuation", "Continuation.prototype", }; for (int i=0; i < names.length; i++) { addExcludedName(names[i]); } String[] optionalNames = { "XML", "XML.prototype", "XMLList", "XMLList.prototype", }; for (int i=0; i < optionalNames.length; i++) { addOptionalExcludedName(optionalNames[i]); } }
/** * Adds a qualified name to the list of objects to be excluded from * serialization. Names excluded from serialization are looked up * in the new scope and replaced upon deserialization. * @param name a fully qualified name (of the form "a.b.c", where * "a" must be a property of the top-level object) * @throws IllegalArgumentException if the object is not found or is not * a {@link Scriptable}. */ public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
public void excludeAllIds(Object[] ids) { for (Object id: ids) { if (id instanceof String && (scope.get((String) id, scope) instanceof Scriptable)) { this.addExcludedName((String)id); } } }
/** * ScriptableOutputStream constructor. * Creates a ScriptableOutputStream for use in serializing * JavaScript objects. Calls excludeStandardObjectNames. * * @param out the OutputStream to write to. * @param scope the scope containing the object. */ public ScriptableOutputStream(OutputStream out, Scriptable scope) throws IOException { super(out); this.scope = scope; table = new Hashtable(31); table.put(scope, ""); enableReplaceObject(true); excludeStandardObjectNames(); }
/** * Adds the names of the standard objects and their * prototypes to the list of excluded names. */ public void excludeStandardObjectNames() { String[] names = { "Object", "Object.prototype", "Function", "Function.prototype", "String", "String.prototype", "Math", // no Math.prototype "Array", "Array.prototype", "Error", "Error.prototype", "Number", "Number.prototype", "Date", "Date.prototype", "RegExp", "RegExp.prototype", "Script", "Script.prototype", "Continuation", "Continuation.prototype", }; for (int i=0; i < names.length; i++) { addExcludedName(names[i]); } String[] optionalNames = { "XML", "XML.prototype", "XMLList", "XMLList.prototype", }; for (int i=0; i < optionalNames.length; i++) { addOptionalExcludedName(optionalNames[i]); } }
/** * Adds a qualified name to the list of objects to be excluded from * serialization. Names excluded from serialization are looked up * in the new scope and replaced upon deserialization. * @param name a fully qualified name (of the form "a.b.c", where * "a" must be a property of the top-level object) * @throws IllegalArgumentException if the object is not found or is not * a {@link Scriptable}. */ public void addExcludedName(String name) { Object obj = lookupQualifiedName(scope, name); if (!(obj instanceof Scriptable)) { throw new IllegalArgumentException("Object for excluded name " + name + " not found."); } table.put(obj, name); }
public void excludeAllIds(Object[] ids) { for (Object id: ids) { if (id instanceof String && (scope.get((String) id, scope) instanceof Scriptable)) { this.addExcludedName((String)id); } } }
/** * ScriptableOutputStream constructor. * Creates a ScriptableOutputStream for use in serializing * JavaScript objects. Calls excludeStandardObjectNames. * * @param out the OutputStream to write to. * @param scope the scope containing the object. */ public ScriptableOutputStream(OutputStream out, Scriptable scope) throws IOException { super(out); this.scope = scope; table = new HashMap<Object,String>(); table.put(scope, ""); enableReplaceObject(true); excludeStandardObjectNames(); // XXX }