net.sourceforge.htmlunit.corejs.javascript.serialize.ScriptableOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vaadin-client-compiler-deps Show documentation
Show all versions of vaadin-client-compiler-deps Show documentation
Vaadin is a web application framework for Rich Internet Applications (RIA).
Vaadin enables easy development and maintenance of fast and
secure rich web
applications with a stunning look and feel and a wide browser support.
It features a server-side architecture with the majority of the logic
running
on the server. Ajax technology is used at the browser-side to ensure a
rich
and interactive user experience.
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Rhino serialization code, released
* Sept. 25, 2001.
*
* The Initial Developer of the Original Code is
* Norris Boyd.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Norris Boyd
* Attila Szegedi
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU General Public License Version 2 or later (the "GPL"), in which
* case the provisions of the GPL are applicable instead of those above. If
* you wish to allow use of your version of this file only under the terms of
* the GPL and not to allow others to use your version of this file under the
* MPL, indicate your decision by deleting the provisions above and replacing
* them with the notice and other provisions required by the GPL. If you do
* not delete the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* ***** END LICENSE BLOCK ***** */
package net.sourceforge.htmlunit.corejs.javascript.serialize;
import java.util.Map;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.io.*;
import net.sourceforge.htmlunit.corejs.javascript.*;
/**
* Class ScriptableOutputStream is an ObjectOutputStream used
* to serialize JavaScript objects and functions. Note that
* compiled functions currently cannot be serialized, only
* interpreted functions. The top-level scope containing the
* object is not written out, but is instead replaced with
* another top-level object when the ScriptableInputStream
* reads in this object. Also, object corresponding to names
* added to the exclude list are not written out but instead
* are looked up during deserialization. This approach avoids
* the creation of duplicate copies of standard objects
* during deserialization.
*
* @author Norris Boyd
*/
// API class
public class ScriptableOutputStream extends ObjectOutputStream {
/**
* 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