Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 61916 invoked by uid 500); 26 Jul 2002 04:40:50 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 61904 invoked by uid 500); 26 Jul 2002 04:40:50 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 26 Jul 2002 04:40:49 -0000 Message-ID: <20020726044049.96948.qmail@icarus.apache.org> From: vgritsenko@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/xscript StringBufferContentHandler.java XScriptManager.java XScriptManagerImpl.java XScriptObject.java XScriptObjectFromURL.java XScriptObjectInlineXML.java XScriptObjectResult.java XScriptVariableScope.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vgritsenko 2002/07/25 21:40:49 Modified: src/java/org/apache/cocoon/components/xscript Tag: cocoon_2_0_3_branch StringBufferContentHandler.java XScriptManager.java XScriptManagerImpl.java XScriptObject.java XScriptObjectFromURL.java XScriptObjectInlineXML.java XScriptObjectResult.java XScriptVariableScope.java Log: reformat code Revision Changes Path No revision No revision 1.4.2.2 +121 -136 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/StringBufferContentHandler.java Index: StringBufferContentHandler.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/StringBufferContentHandler.java,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -r1.4.2.1 -r1.4.2.2 --- StringBufferContentHandler.java 20 Jun 2002 04:24:30 -0000 1.4.2.1 +++ StringBufferContentHandler.java 26 Jul 2002 04:40:49 -0000 1.4.2.2 @@ -50,17 +50,13 @@ */ package org.apache.cocoon.components.xscript; -import java.util.Stack; -import java.io.StringReader; -import java.io.StringBufferInputStream; -import java.io.IOException; - -import org.xml.sax.InputSource; +import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; -import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; +import java.util.Stack; + /** * A ContentHandler that accumulates the SAX stream into @@ -71,124 +67,116 @@ * @version CVS $Id$ * @since August 30, 2001 */ -public class StringBufferContentHandler extends DefaultHandler -{ - private Stack namespaces = new Stack(); - ContentHandler contentHandler; - StringBuffer stringBuffer; - static Object marker = new Object(); - - public StringBufferContentHandler(StringBuffer stringBuffer) - { - this.stringBuffer = stringBuffer; - } - - public void setNextContentHandler(ContentHandler handler) - { - this.contentHandler = handler; - } - - public void startPrefixMapping(String prefix, String uri) - throws SAXException - { - namespaces.push(new NPU(prefix, uri)); - } - - public void endPrefixMapping(String prefix) - throws SAXException - { - namespaces.pop(); - } - - public void startElement(String uri, String loc, String qName, Attributes a) - throws SAXException - { - int lastNamespaceIndex = 0; - - lastNamespaceIndex = namespaces.size() - 1; - while(lastNamespaceIndex >= 0 - && namespaces.elementAt(lastNamespaceIndex) != marker) { - lastNamespaceIndex--; - } - - if (lastNamespaceIndex < 0) { - lastNamespaceIndex = 0; - } else if (namespaces.elementAt(lastNamespaceIndex) == marker) { - lastNamespaceIndex++; - } - - namespaces.push(marker); - - stringBuffer.append("<").append(qName); - - for (int i = 0, len = a.getLength(); i < len; i++) { - // Check if the attribute is a namespace declaration. Some - // parsers (Xerces) sometimes pass the namespace declaration - // as an attribute. We need to catch this case so that we - // don't end up generating the namespace declaration twice. - String attrName = a.getQName(i); - - if (attrName.startsWith("xmlns:")) { - // We have a namespace declaration - String name = a.getLocalName(i); - - // Check whether this namespace has been already declared - boolean found = false; - for (int j = namespaces.size() - 1; - j >= lastNamespaceIndex; - j--) { - Object obj = namespaces.elementAt(j); - if (obj == marker) { - continue; - } - NPU npu = (NPU)obj; - - if (name.equals(npu.prefix)) { - found = true; - break; - } +public class StringBufferContentHandler extends DefaultHandler { + private Stack namespaces = new Stack(); + ContentHandler contentHandler; + StringBuffer stringBuffer; + static Object marker = new Object(); + + public StringBufferContentHandler(StringBuffer stringBuffer) { + this.stringBuffer = stringBuffer; + } + + public void setNextContentHandler(ContentHandler handler) { + this.contentHandler = handler; + } + + public void startPrefixMapping(String prefix, String uri) + throws SAXException { + namespaces.push(new NPU(prefix, uri)); + } + + public void endPrefixMapping(String prefix) + throws SAXException { + namespaces.pop(); + } + + public void startElement(String uri, String loc, String qName, Attributes a) + throws SAXException { + int lastNamespaceIndex = 0; + + lastNamespaceIndex = namespaces.size() - 1; + while (lastNamespaceIndex >= 0 + && namespaces.elementAt(lastNamespaceIndex) != marker) { + lastNamespaceIndex--; } - if (!found) { - namespaces.push(new NPU(name, a.getValue(i))); + if (lastNamespaceIndex < 0) { + lastNamespaceIndex = 0; + } else if (namespaces.elementAt(lastNamespaceIndex) == marker) { + lastNamespaceIndex++; } - } else { - // Normal attribute - stringBuffer.append(" ").append(a.getQName(i)).append("=\""); - escape(stringBuffer, a.getValue(i)); - stringBuffer.append("\""); - } - } - if (namespaces.size() != 0) { - for (int i = namespaces.size() - 1; i >= lastNamespaceIndex; i--) { - Object obj = namespaces.elementAt(i); - if (obj == marker) { - continue; + namespaces.push(marker); + + stringBuffer.append("<").append(qName); + + for (int i = 0, len = a.getLength(); i < len; i++) { + // Check if the attribute is a namespace declaration. Some + // parsers (Xerces) sometimes pass the namespace declaration + // as an attribute. We need to catch this case so that we + // don't end up generating the namespace declaration twice. + String attrName = a.getQName(i); + + if (attrName.startsWith("xmlns:")) { + // We have a namespace declaration + String name = a.getLocalName(i); + + // Check whether this namespace has been already declared + boolean found = false; + for (int j = namespaces.size() - 1; + j >= lastNamespaceIndex; + j--) { + Object obj = namespaces.elementAt(j); + if (obj == marker) { + continue; + } + NPU npu = (NPU) obj; + + if (name.equals(npu.prefix)) { + found = true; + break; + } + } + + if (!found) { + namespaces.push(new NPU(name, a.getValue(i))); + } + } else { + // Normal attribute + stringBuffer.append(" ").append(a.getQName(i)).append("=\""); + escape(stringBuffer, a.getValue(i)); + stringBuffer.append("\""); + } + } + + if (namespaces.size() != 0) { + for (int i = namespaces.size() - 1; i >= lastNamespaceIndex; i--) { + Object obj = namespaces.elementAt(i); + if (obj == marker) { + continue; + } + NPU npu = (NPU) obj; + stringBuffer.append(" xmlns:").append(npu.prefix).append("=\"").append(npu.uri).append("\""); + } } - NPU npu = (NPU)obj; - stringBuffer.append(" xmlns:").append(npu.prefix).append("=\"").append(npu.uri).append("\""); - } - } - stringBuffer.append(">"); - } - - public void endElement(String uri, String loc, String qName) - throws SAXException - { - stringBuffer.append(""); - - Object obj; - do { - obj = namespaces.pop(); - } while (obj != marker); - } - - public void characters(char ch[], int start, int len) - throws SAXException - { - escape(stringBuffer, ch, start, len); - } + stringBuffer.append(">"); + } + + public void endElement(String uri, String loc, String qName) + throws SAXException { + stringBuffer.append(""); + + Object obj; + do { + obj = namespaces.pop(); + } while (obj != marker); + } + + public void characters(char ch[], int start, int len) + throws SAXException { + escape(stringBuffer, ch, start, len); + } /** @@ -226,19 +214,16 @@ } } -class NPU -{ - public String prefix; - public String uri; - - NPU(String prefix, String uri) - { - this.prefix = prefix; - this.uri = uri; - } - - public String toString() - { - return this.prefix + "=" + this.uri; - } +class NPU { + public String prefix; + public String uri; + + NPU(String prefix, String uri) { + this.prefix = prefix; + this.uri = uri; + } + + public String toString() { + return this.prefix + "=" + this.uri; + } } 1.4.2.1 +133 -135 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManager.java Index: XScriptManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManager.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- XScriptManager.java 22 Feb 2002 07:00:15 -0000 1.4 +++ XScriptManager.java 26 Jul 2002 04:40:49 -0000 1.4.2.1 @@ -50,7 +50,6 @@ */ package org.apache.cocoon.components.xscript; -import org.apache.avalon.framework.component.ComponentManager; /** * XScriptManager is the public interface used to @@ -61,137 +60,136 @@ * @version CVS $Id$ * @since August 4, 2001 */ -public interface XScriptManager -{ - String ROLE = "org.apache.cocoon.components.xscript.XScriptManager"; - - String XSCRIPT_NS = "http://apache.org/xsp/xscript/1.0"; - - /** - * The variable's global scope. Each Cocoon instance has exactly one - * global scope for variables. - */ - int GLOBAL_SCOPE = 1; - /** - * The session scope. This scope is specific to a particular - * activation of an XSP page, which is usually identified by the - * session id of the user that sent the HTTP request. From XScript's - * point of view however, the session identifier is not interpreted - * in any way, so a client can define its own notion of "session". - */ - int SESSION_SCOPE = 2; - - /** - * The page scope. This is scope very specific to an XSP page, and - * defines variables visible only within the context of that - * page. No other XSP page can access these variables, unless it - * knows the identifier used by that page to store its - * variables. This identifier is not necessarily the URL or full - * path of that page; it is up to the page to define it. - */ - int PAGE_SCOPE = 3; - - /** - * Search for a variable in all the accessible scopes. The variable - * is first searched in the current session scope. If no variable is - * found here, the current page scope is searched next. If nothing - * is found either, the global scope is searched. - */ - int ALL_SCOPES = 4; - - /** - * Obtains the object value of the - * name variable in scope. The - * context parameter is interpreted differently - * depending on the value of scope, as follows: - * - *
    - * - *
  • if scope is {@link #GLOBAL_SCOPE}, the - * value of context is ignored. - * - *
  • if scope is {@link - * #SESSION_SCOPE}, the value of context is - * interpreted as the session identifier. - * - *
  • if scope is {@link #PAGE_SCOPE}, the value - * of context is interpreted as an identifier of the - * page. This could be the URL of the page or the path of the file - * name in the file system. - * - *
- * - * @param name a String value - * @param scope an int value - * @param context a String value whose interpretation - * depends on scope - * @return a {@link XScriptObject} value - */ - XScriptObject get(String name, int scope, String context) - throws IllegalArgumentException; - - /** - * Search for the first occurence of the variable - * name. - * - *

The search happens first in the session scope - * identified by sessionContext. If no variable is - * found here, the search continues in the page scope identified by - * pageContext. If no variable is found here, it's - * finally searched in the global scope. - * - *

The XScriptObject value of the variable is - * returned if a variable is found in one of the scopes, otherwise - * an exception is thrown. - * - * @param name a String value - * @param sessionContext a String value - * @param pageContext a String value - * @return a XScriptObject value - * @exception IllegalArgumentException if an error occurs - */ - XScriptObject getFirst(String name, - String sessionContext, - String pageContext) - throws IllegalArgumentException; - - /** - * Defines or overwrites the value of variable - * name in scope. The context - * argument is interpreted as described in {@link #get(String, int, - * String)}. - * - * @param name a String value - * @param value a XScriptObject value - * @param scope an int value - * @param context a String value whose interpretation - * depends on scope - */ - void put(String name, XScriptObject value, int scope, String context) - throws IllegalArgumentException; - - /** - * Removes a variable previously declared in scope - * within context. Such a variable could be declared - * using the {@link #put(String, XScriptObject, int, String)} - * method. - * - * @param name a String value - * @param scope an int value - * @param context a String value - */ - void remove(String name, int scope, String context); - - /** - * Remove the first appearance of name in the all the - * currently accessible scopes. The search happens as described in - * {@link #getFirst(String,String,String)}. - * - * @param name a String value - * @param sessionContext a String value - * @param pageContext a String value - * @exception IllegalArgumentException if an error occurs - */ - void removeFirst(String name, String sessionContext, String pageContext) - throws IllegalArgumentException; +public interface XScriptManager { + String ROLE = "org.apache.cocoon.components.xscript.XScriptManager"; + + String XSCRIPT_NS = "http://apache.org/xsp/xscript/1.0"; + + /** + * The variable's global scope. Each Cocoon instance has exactly one + * global scope for variables. + */ + int GLOBAL_SCOPE = 1; + /** + * The session scope. This scope is specific to a particular + * activation of an XSP page, which is usually identified by the + * session id of the user that sent the HTTP request. From XScript's + * point of view however, the session identifier is not interpreted + * in any way, so a client can define its own notion of "session". + */ + int SESSION_SCOPE = 2; + + /** + * The page scope. This is scope very specific to an XSP page, and + * defines variables visible only within the context of that + * page. No other XSP page can access these variables, unless it + * knows the identifier used by that page to store its + * variables. This identifier is not necessarily the URL or full + * path of that page; it is up to the page to define it. + */ + int PAGE_SCOPE = 3; + + /** + * Search for a variable in all the accessible scopes. The variable + * is first searched in the current session scope. If no variable is + * found here, the current page scope is searched next. If nothing + * is found either, the global scope is searched. + */ + int ALL_SCOPES = 4; + + /** + * Obtains the object value of the + * name variable in scope. The + * context parameter is interpreted differently + * depending on the value of scope, as follows: + * + *

    + * + *
  • if scope is {@link #GLOBAL_SCOPE}, the + * value of context is ignored. + * + *
  • if scope is {@link + * #SESSION_SCOPE}, the value of context is + * interpreted as the session identifier. + * + *
  • if scope is {@link #PAGE_SCOPE}, the value + * of context is interpreted as an identifier of the + * page. This could be the URL of the page or the path of the file + * name in the file system. + * + *
+ * + * @param name a String value + * @param scope an int value + * @param context a String value whose interpretation + * depends on scope + * @return a {@link XScriptObject} value + */ + XScriptObject get(String name, int scope, String context) + throws IllegalArgumentException; + + /** + * Search for the first occurence of the variable + * name. + * + *

The search happens first in the session scope + * identified by sessionContext. If no variable is + * found here, the search continues in the page scope identified by + * pageContext. If no variable is found here, it's + * finally searched in the global scope. + * + *

The XScriptObject value of the variable is + * returned if a variable is found in one of the scopes, otherwise + * an exception is thrown. + * + * @param name a String value + * @param sessionContext a String value + * @param pageContext a String value + * @return a XScriptObject value + * @exception IllegalArgumentException if an error occurs + */ + XScriptObject getFirst(String name, + String sessionContext, + String pageContext) + throws IllegalArgumentException; + + /** + * Defines or overwrites the value of variable + * name in scope. The context + * argument is interpreted as described in {@link #get(String, int, + * String)}. + * + * @param name a String value + * @param value a XScriptObject value + * @param scope an int value + * @param context a String value whose interpretation + * depends on scope + */ + void put(String name, XScriptObject value, int scope, String context) + throws IllegalArgumentException; + + /** + * Removes a variable previously declared in scope + * within context. Such a variable could be declared + * using the {@link #put(String, XScriptObject, int, String)} + * method. + * + * @param name a String value + * @param scope an int value + * @param context a String value + */ + void remove(String name, int scope, String context); + + /** + * Remove the first appearance of name in the all the + * currently accessible scopes. The search happens as described in + * {@link #getFirst(String,String,String)}. + * + * @param name a String value + * @param sessionContext a String value + * @param pageContext a String value + * @exception IllegalArgumentException if an error occurs + */ + void removeFirst(String name, String sessionContext, String pageContext) + throws IllegalArgumentException; } 1.6.2.2 +211 -224 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManagerImpl.java Index: XScriptManagerImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManagerImpl.java,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -r1.6.2.1 -r1.6.2.2 --- XScriptManagerImpl.java 14 Apr 2002 04:06:19 -0000 1.6.2.1 +++ XScriptManagerImpl.java 26 Jul 2002 04:40:49 -0000 1.6.2.2 @@ -50,20 +50,17 @@ */ package org.apache.cocoon.components.xscript; -import java.util.HashMap; - -import org.apache.avalon.framework.logger.AbstractLoggable; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.parameters.Parameterizable; -import org.apache.avalon.framework.parameters.ParameterException; - import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; +import org.apache.avalon.framework.logger.AbstractLoggable; +import org.apache.avalon.framework.parameters.ParameterException; +import org.apache.avalon.framework.parameters.Parameterizable; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.thread.ThreadSafe; -import org.apache.cocoon.components.xscript.XScriptObjectFromURL; +import java.util.HashMap; /** * The actual implementation of the XScriptManager interface. @@ -73,219 +70,209 @@ * @since August 4, 2001 */ public class XScriptManagerImpl - extends AbstractLoggable - implements XScriptManager, Composable, Component, Parameterizable, ThreadSafe -{ - /** - * The global scope. All the global variables are indexed in this - * space by their name. - */ - XScriptVariableScope globalScope = new XScriptVariableScope(); - - /** - * The session scope. The key in this hash table is the session - * identifier, which should be a String object. The - * value is an {@link XScriptVariableScope} instance which holds the - * variables in a session scope. - */ - HashMap sessionScope = new HashMap(); - - /** - * Page specific variables. The key in the hash map is an identifier - * for the page, usually the full path name to the page. The value - * is an {@link XScriptVariableScope} instance which holds the - * variables in a page scope. - */ - HashMap pageScope = new HashMap(); - - /** - * The ComponentManager instance. - */ - protected ComponentManager manager = null; - - public void compose(ComponentManager manager) throws ComponentException - { - this.manager = manager; - getLogger().debug("XScriptManager component initialized."); - } - - public void register(XScriptObject object) - { - try { - object.compose(manager); - } catch (ComponentException ex) { - } - } - - public void parameterize(Parameters params) throws ParameterException - { - String[] names = params.getNames(); - for (int i = 0; i < names.length; i++) { - String resourceString = params.getParameter(names[i]); - XScriptObject resource = new XScriptObjectFromURL(this, resourceString); - globalScope.put(names[i], resource); - } - } - - private IllegalArgumentException - createAccessException(String msg, String name, int scope, String context) - { - StringBuffer message = new StringBuffer("Cannot ").append(msg) - .append(" variable named '").append(name) - .append("' in "); - - if (scope == XScriptManager.GLOBAL_SCOPE) - message.append("global scope"); - else if (scope == XScriptManager.SESSION_SCOPE) - message.append("session scope"); - else if (scope == XScriptManager.PAGE_SCOPE) - message.append("page scope"); - else - message.append("unknown scope (").append(scope).append(")"); - - message.append(" with context '").append(context).append("'"); - return new IllegalArgumentException(message.toString()); - } - - public XScriptObject get(String name, int scope, String context) - throws IllegalArgumentException - { - if (scope == XScriptManager.GLOBAL_SCOPE) { - return globalScope.get(name); - } else if (scope == XScriptManager.SESSION_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context); - if (s != null) - return s.get(name); - } else if (scope == XScriptManager.PAGE_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context); - if (s != null) - return s.get(name); - } - - throw createAccessException("find", name, scope, context); - } - - public XScriptObject getFirst(String name, - String sessionContext, - String pageContext) - throws IllegalArgumentException - { - XScriptVariableScope scope; - - // Lookup in the session scope first. - scope = (XScriptVariableScope)sessionScope.get(sessionContext); - if (scope != null) { - synchronized(scope) { - if (scope.defines(name)) { - return scope.get(name); - } - } - } - - // No luck finding `name' in session scope, try in page scope. - scope = (XScriptVariableScope)pageScope.get(pageContext); - if (scope != null) { - synchronized(scope) { - if (scope.defines(name)) { - return scope.get(name); - } - } - } - - // No luck finding `name' in the page scope, try the global scope. - synchronized(globalScope) { - if (globalScope.defines(name)) { - return globalScope.get(name); - } - } - - // No variable `name' found, throw an exception. - throw new IllegalArgumentException("getFirst: no variable '" + name - + "' accessible from this scope!"); - } - - public void put(String name, XScriptObject value, int scope, String context) - { - if (scope == XScriptManager.GLOBAL_SCOPE) { - globalScope.put(name, value); - } else if (scope == XScriptManager.SESSION_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context); - if (s == null) { - s = new XScriptVariableScope(); - sessionScope.put(context, s); - } - s.put(name, value); - } else if (scope == XScriptManager.PAGE_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context); - if (s == null) { - s = new XScriptVariableScope(); - pageScope.put(context, s); - } - s.put(name, value); - } else { - throw createAccessException("create", name, scope, context); - } - } - - public void remove(String name, int scope, String context) - throws IllegalArgumentException - { - if (scope == XScriptManager.GLOBAL_SCOPE) { - globalScope.remove(name); - } else if (scope == XScriptManager.SESSION_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context); - if (s != null) { - s.remove(name); - } - } else if (scope == XScriptManager.PAGE_SCOPE) { - XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context); - if (s != null) { - s.remove(name); - } - } else { - throw createAccessException("remove", name, scope, context); - } - } - - public void removeFirst(String name, - String sessionContext, - String pageContext) - throws IllegalArgumentException - { - XScriptVariableScope scope; - - // Lookup in the session scope first. - scope = (XScriptVariableScope)sessionScope.get(sessionContext); - if (scope != null) { - synchronized(scope) { - if (scope.defines(name)) { - scope.remove(name); - return; - } - } - } - - // No luck finding `name' in session scope, try in page scope. - scope = (XScriptVariableScope)pageScope.get(pageContext); - if (scope != null) { - synchronized(scope) { - if (scope.defines(name)) { - scope.remove(name); - return; - } - } - } - - // No luck finding `name' in the page scope, try the global scope. - synchronized(globalScope) { - if (globalScope.defines(name)) { - globalScope.remove(name); - return; - } - } - - // No variable `name' found, throw an exception. - throw new IllegalArgumentException("removeFirst: no variable '" + name - + "' accessible from this scope!"); - } + extends AbstractLoggable + implements XScriptManager, Composable, Component, Parameterizable, ThreadSafe { + /** + * The global scope. All the global variables are indexed in this + * space by their name. + */ + XScriptVariableScope globalScope = new XScriptVariableScope(); + + /** + * The session scope. The key in this hash table is the session + * identifier, which should be a String object. The + * value is an {@link XScriptVariableScope} instance which holds the + * variables in a session scope. + */ + HashMap sessionScope = new HashMap(); + + /** + * Page specific variables. The key in the hash map is an identifier + * for the page, usually the full path name to the page. The value + * is an {@link XScriptVariableScope} instance which holds the + * variables in a page scope. + */ + HashMap pageScope = new HashMap(); + + /** + * The ComponentManager instance. + */ + protected ComponentManager manager = null; + + public void compose(ComponentManager manager) throws ComponentException { + this.manager = manager; + getLogger().debug("XScriptManager component initialized."); + } + + public void register(XScriptObject object) { + try { + object.compose(manager); + } catch (ComponentException ex) { + } + } + + public void parameterize(Parameters params) throws ParameterException { + String[] names = params.getNames(); + for (int i = 0; i < names.length; i++) { + String resourceString = params.getParameter(names[i]); + XScriptObject resource = new XScriptObjectFromURL(this, resourceString); + globalScope.put(names[i], resource); + } + } + + private IllegalArgumentException + createAccessException(String msg, String name, int scope, String context) { + StringBuffer message = new StringBuffer("Cannot ").append(msg) + .append(" variable named '").append(name) + .append("' in "); + + if (scope == XScriptManager.GLOBAL_SCOPE) + message.append("global scope"); + else if (scope == XScriptManager.SESSION_SCOPE) + message.append("session scope"); + else if (scope == XScriptManager.PAGE_SCOPE) + message.append("page scope"); + else + message.append("unknown scope (").append(scope).append(")"); + + message.append(" with context '").append(context).append("'"); + return new IllegalArgumentException(message.toString()); + } + + public XScriptObject get(String name, int scope, String context) + throws IllegalArgumentException { + if (scope == XScriptManager.GLOBAL_SCOPE) { + return globalScope.get(name); + } else if (scope == XScriptManager.SESSION_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) sessionScope.get(context); + if (s != null) + return s.get(name); + } else if (scope == XScriptManager.PAGE_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) pageScope.get(context); + if (s != null) + return s.get(name); + } + + throw createAccessException("find", name, scope, context); + } + + public XScriptObject getFirst(String name, + String sessionContext, + String pageContext) + throws IllegalArgumentException { + XScriptVariableScope scope; + + // Lookup in the session scope first. + scope = (XScriptVariableScope) sessionScope.get(sessionContext); + if (scope != null) { + synchronized (scope) { + if (scope.defines(name)) { + return scope.get(name); + } + } + } + + // No luck finding `name' in session scope, try in page scope. + scope = (XScriptVariableScope) pageScope.get(pageContext); + if (scope != null) { + synchronized (scope) { + if (scope.defines(name)) { + return scope.get(name); + } + } + } + + // No luck finding `name' in the page scope, try the global scope. + synchronized (globalScope) { + if (globalScope.defines(name)) { + return globalScope.get(name); + } + } + + // No variable `name' found, throw an exception. + throw new IllegalArgumentException("getFirst: no variable '" + name + + "' accessible from this scope!"); + } + + public void put(String name, XScriptObject value, int scope, String context) { + if (scope == XScriptManager.GLOBAL_SCOPE) { + globalScope.put(name, value); + } else if (scope == XScriptManager.SESSION_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) sessionScope.get(context); + if (s == null) { + s = new XScriptVariableScope(); + sessionScope.put(context, s); + } + s.put(name, value); + } else if (scope == XScriptManager.PAGE_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) pageScope.get(context); + if (s == null) { + s = new XScriptVariableScope(); + pageScope.put(context, s); + } + s.put(name, value); + } else { + throw createAccessException("create", name, scope, context); + } + } + + public void remove(String name, int scope, String context) + throws IllegalArgumentException { + if (scope == XScriptManager.GLOBAL_SCOPE) { + globalScope.remove(name); + } else if (scope == XScriptManager.SESSION_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) sessionScope.get(context); + if (s != null) { + s.remove(name); + } + } else if (scope == XScriptManager.PAGE_SCOPE) { + XScriptVariableScope s = (XScriptVariableScope) pageScope.get(context); + if (s != null) { + s.remove(name); + } + } else { + throw createAccessException("remove", name, scope, context); + } + } + + public void removeFirst(String name, + String sessionContext, + String pageContext) + throws IllegalArgumentException { + XScriptVariableScope scope; + + // Lookup in the session scope first. + scope = (XScriptVariableScope) sessionScope.get(sessionContext); + if (scope != null) { + synchronized (scope) { + if (scope.defines(name)) { + scope.remove(name); + return; + } + } + } + + // No luck finding `name' in session scope, try in page scope. + scope = (XScriptVariableScope) pageScope.get(pageContext); + if (scope != null) { + synchronized (scope) { + if (scope.defines(name)) { + scope.remove(name); + return; + } + } + } + + // No luck finding `name' in the page scope, try the global scope. + synchronized (globalScope) { + if (globalScope.defines(name)) { + globalScope.remove(name); + return; + } + } + + // No variable `name' found, throw an exception. + throw new IllegalArgumentException("removeFirst: no variable '" + name + + "' accessible from this scope!"); + } } 1.7.2.3 +121 -128 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObject.java Index: XScriptObject.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObject.java,v retrieving revision 1.7.2.2 retrieving revision 1.7.2.3 diff -u -r1.7.2.2 -r1.7.2.3 --- XScriptObject.java 27 Jun 2002 19:07:56 -0000 1.7.2.2 +++ XScriptObject.java 26 Jul 2002 04:40:49 -0000 1.7.2.3 @@ -50,23 +50,26 @@ */ package org.apache.cocoon.components.xscript; -import javax.xml.transform.stream.StreamResult; -import java.util.Date; -import java.io.IOException; -import java.io.CharArrayWriter; - -import org.xml.sax.SAXException; -import org.xml.sax.InputSource; -import org.xml.sax.ContentHandler; -import org.apache.cocoon.xml.EmbeddedXMLPipe; -import org.apache.cocoon.environment.Source; -import org.apache.cocoon.components.xslt.XSLTProcessor; -import org.apache.cocoon.ProcessingException; -import org.apache.avalon.excalibur.xml.Parser; -import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentException; +import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; +import org.apache.avalon.framework.parameters.Parameters; + +import org.apache.avalon.excalibur.xml.Parser; + +import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.components.xslt.XSLTProcessor; +import org.apache.cocoon.environment.Source; +import org.apache.cocoon.xml.EmbeddedXMLPipe; + +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.transform.stream.StreamResult; +import java.io.CharArrayWriter; +import java.io.IOException; +import java.util.Date; /** * XScriptObject is the root class implemented by all the @@ -77,116 +80,106 @@ * @version CVS $Id$ * @since August 4, 2001 */ -public abstract class XScriptObject implements Source, Composable -{ - /** - * The creation date of this XScriptObject. - */ - Date lastModifiedDate = new Date(); - - /** - * The XScriptManager object that's managing this - * XScriptObject value. - */ - XScriptManager xscriptManager; - - protected ComponentManager componentManager; - - /** - * Creates a new XScriptObject instance. - * - * @param manager a XScriptManager value - */ - public XScriptObject(XScriptManager manager) - { - this.xscriptManager = manager; - ((XScriptManagerImpl)this.xscriptManager).register(this); - } - - public void compose(ComponentManager manager) - throws ComponentException - { - this.componentManager = manager; - } - - /** - * Apply the XSLT stylesheet defined by the stylesheet - * variable to this instance. Return the result of the - * transformation as an XScriptObject. - * - * @param stylesheet a XScriptObject value - * @param params a Parameters value containing optional - * arguments to be passed to the XSLT processor. - * @return XScriptObject object containing the result - * of the XSLT processing. - * @exception IllegalArgumentException if an error occurs - * @exception ProcessingException if an error occurs - */ - public XScriptObject transform(XScriptObject stylesheet, Parameters params) - throws IllegalArgumentException, ProcessingException - { - try { - CharArrayWriter writer = new CharArrayWriter(); - StreamResult result = new StreamResult(writer); - - XSLTProcessor transformer - = (XSLTProcessor)componentManager.lookup(XSLTProcessor.ROLE); - - try { - transformer.transform(this, stylesheet, params, result); - } finally { - componentManager.release(transformer); - } - - return new XScriptObjectResult(xscriptManager, writer.toString()); - } - catch (ComponentException ex) { - throw new ProcessingException(ex); - } - } - - public void toEmbeddedSAX(ContentHandler handler) throws SAXException - { - EmbeddedXMLPipe newHandler = new EmbeddedXMLPipe(handler); - toSAX(newHandler); - } - - /* The Source interface methods. */ - - public void toSAX(ContentHandler handler) throws SAXException - { - Parser parser = null; - try { - parser = (Parser)componentManager.lookup(Parser.ROLE); - InputSource source = getInputSource(); - parser.parse(source, handler); - } catch (SAXException e) { - throw e; - } catch (Exception e) { - throw new SAXException(e); - } finally { - if (parser != null) { - componentManager.release(parser); - } - } - } - - public long getLastModified() - { - return lastModifiedDate.getTime(); - } - - public abstract long getContentLength(); - - public InputSource getInputSource() - throws ProcessingException, IOException - { - InputSource is = new InputSource(getInputStream()); - is.setSystemId(getSystemId()); - return is; - } - - public void recycle() - { - } +public abstract class XScriptObject implements Source, Composable { + /** + * The creation date of this XScriptObject. + */ + Date lastModifiedDate = new Date(); + + /** + * The XScriptManager object that's managing this + * XScriptObject value. + */ + XScriptManager xscriptManager; + + protected ComponentManager componentManager; + + /** + * Creates a new XScriptObject instance. + * + * @param manager a XScriptManager value + */ + public XScriptObject(XScriptManager manager) { + this.xscriptManager = manager; + ((XScriptManagerImpl) this.xscriptManager).register(this); + } + + public void compose(ComponentManager manager) + throws ComponentException { + this.componentManager = manager; + } + + /** + * Apply the XSLT stylesheet defined by the stylesheet + * variable to this instance. Return the result of the + * transformation as an XScriptObject. + * + * @param stylesheet a XScriptObject value + * @param params a Parameters value containing optional + * arguments to be passed to the XSLT processor. + * @return XScriptObject object containing the result + * of the XSLT processing. + * @exception IllegalArgumentException if an error occurs + * @exception ProcessingException if an error occurs + */ + public XScriptObject transform(XScriptObject stylesheet, Parameters params) + throws IllegalArgumentException, ProcessingException { + try { + CharArrayWriter writer = new CharArrayWriter(); + StreamResult result = new StreamResult(writer); + + XSLTProcessor transformer + = (XSLTProcessor) componentManager.lookup(XSLTProcessor.ROLE); + + try { + transformer.transform(this, stylesheet, params, result); + } finally { + componentManager.release(transformer); + } + + return new XScriptObjectResult(xscriptManager, writer.toString()); + } catch (ComponentException ex) { + throw new ProcessingException(ex); + } + } + + public void toEmbeddedSAX(ContentHandler handler) throws SAXException { + EmbeddedXMLPipe newHandler = new EmbeddedXMLPipe(handler); + toSAX(newHandler); + } + + /* The Source interface methods. */ + + public void toSAX(ContentHandler handler) throws SAXException { + Parser parser = null; + try { + parser = (Parser) componentManager.lookup(Parser.ROLE); + InputSource source = getInputSource(); + parser.parse(source, handler); + } catch (SAXException e) { + throw e; + } catch (Exception e) { + throw new SAXException(e); + } finally { + if (parser != null) { + componentManager.release(parser); + } + } + } + + public long getLastModified() { + return lastModifiedDate.getTime(); + } + + public abstract long getContentLength(); + + public InputSource getInputSource() + throws ProcessingException, IOException { + InputSource is = new InputSource(getInputStream()); + is.setSystemId(getSystemId()); + return is; + } + + public void recycle() { + } } 1.5.2.2 +65 -72 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectFromURL.java Index: XScriptObjectFromURL.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectFromURL.java,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -r1.5.2.1 -r1.5.2.2 --- XScriptObjectFromURL.java 14 Apr 2002 04:06:19 -0000 1.5.2.1 +++ XScriptObjectFromURL.java 26 Jul 2002 04:40:49 -0000 1.5.2.2 @@ -50,14 +50,15 @@ */ package org.apache.cocoon.components.xscript; -import java.net.URLConnection; -import java.net.URL; -import java.io.InputStream; -import java.io.IOException; +import org.apache.avalon.framework.component.ComponentException; -import org.apache.cocoon.components.url.URLFactory; import org.apache.cocoon.ProcessingException; -import org.apache.avalon.framework.component.ComponentException; +import org.apache.cocoon.components.url.URLFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; /** * An XScriptObject created from the contents of a URL. @@ -66,69 +67,61 @@ * @version CVS $Id$ * @since August 30, 2001 */ -public class XScriptObjectFromURL extends XScriptObject -{ - /** - * The content obtained from this URL becomes the content of this - * instance. - */ - String systemId; - - /** - * The content length. - */ - int contentLength; - - /** - * When was the content of the URL last modified. - */ - long lastModified; - - public XScriptObjectFromURL(XScriptManager manager, String systemId) - { - super(manager); - this.systemId = systemId; - } - - public InputStream getInputStream() - throws ProcessingException, IOException - { - try { - URLFactory urlFactory = (URLFactory)componentManager.lookup(URLFactory.ROLE); - URL url = urlFactory.getURL(systemId); - URLConnection conn = url.openConnection(); - InputStream is = conn.getInputStream(); - contentLength = conn.getContentLength(); - componentManager.release(urlFactory); - - return is; - } catch (ComponentException ex) { - throw new ProcessingException(ex); - } - } - - public long getContentLength() - { - return contentLength; - } - - public long getLastModified() - { - return lastModified; - } - - public String getSystemId() - { - // FIXME: generate a real system id to represent this object - return "xscript:url:" + systemId; - } - - public void recycle() - { - } - - public String toString() - { - return new StringBuffer("XScriptObjectFromURL(systemId = ").append(systemId).append(")").toString(); - } +public class XScriptObjectFromURL extends XScriptObject { + /** + * The content obtained from this URL becomes the content of this + * instance. + */ + String systemId; + + /** + * The content length. + */ + int contentLength; + + /** + * When was the content of the URL last modified. + */ + long lastModified; + + public XScriptObjectFromURL(XScriptManager manager, String systemId) { + super(manager); + this.systemId = systemId; + } + + public InputStream getInputStream() + throws ProcessingException, IOException { + try { + URLFactory urlFactory = (URLFactory) componentManager.lookup(URLFactory.ROLE); + URL url = urlFactory.getURL(systemId); + URLConnection conn = url.openConnection(); + InputStream is = conn.getInputStream(); + contentLength = conn.getContentLength(); + componentManager.release(urlFactory); + + return is; + } catch (ComponentException ex) { + throw new ProcessingException(ex); + } + } + + public long getContentLength() { + return contentLength; + } + + public long getLastModified() { + return lastModified; + } + + public String getSystemId() { + // FIXME: generate a real system id to represent this object + return "xscript:url:" + systemId; + } + + public void recycle() { + } + + public String toString() { + return new StringBuffer("XScriptObjectFromURL(systemId = ").append(systemId).append(")").toString(); + } } 1.4.2.3 +70 -86 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectInlineXML.java Index: XScriptObjectInlineXML.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectInlineXML.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -r1.4.2.2 -r1.4.2.3 --- XScriptObjectInlineXML.java 20 Jun 2002 04:28:10 -0000 1.4.2.2 +++ XScriptObjectInlineXML.java 26 Jul 2002 04:40:49 -0000 1.4.2.3 @@ -50,19 +50,15 @@ */ package org.apache.cocoon.components.xscript; -import java.util.Stack; -import java.io.StringReader; -import java.io.StringBufferInputStream; -import java.io.InputStream; -import java.io.IOException; +import org.apache.cocoon.ProcessingException; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.SAXException; -import org.xml.sax.InputSource; import org.xml.sax.ContentHandler; -import org.xml.sax.Attributes; +import org.xml.sax.InputSource; -import org.apache.cocoon.ProcessingException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringBufferInputStream; +import java.io.StringReader; /** * An XScriptObject created from an inline XML fragment. @@ -72,79 +68,67 @@ * @version CVS $Id$ * @since July 7, 2001 */ -public class XScriptObjectInlineXML extends XScriptObject -{ - StringBuffer stringBuffer; - StringBufferContentHandler streamHandler; - - public XScriptObjectInlineXML(XScriptManager manager) - { - super(manager); - stringBuffer = new StringBuffer(); - stringBuffer.append("\n\n"); - streamHandler = new StringBufferContentHandler(stringBuffer); - } - - public XScriptObjectInlineXML(XScriptManager manager, - StringBuffer stringBuffer) - { - super(manager); - this.stringBuffer = stringBuffer; - streamHandler = new StringBufferContentHandler(stringBuffer); - } - - public XScriptObjectInlineXML(XScriptManager manager, String string) - { - super(manager); - this.stringBuffer = new StringBuffer(string); - streamHandler = new StringBufferContentHandler(stringBuffer); - } - - public InputStream getInputStream() - throws ProcessingException, IOException - { - // FIXME(VG): This method should never be used because it - // incorrectly converts characters into bytes. - return new StringBufferInputStream(stringBuffer.toString()); - } - - public InputSource getInputSource() - throws ProcessingException, IOException - { - InputSource is = new InputSource(new StringReader(stringBuffer.toString())); - is.setSystemId(getSystemId()); - return is; - } - - public ContentHandler getContentHandler() - { - return streamHandler; - } - - public void setNextContentHandler(ContentHandler handler) - { - streamHandler.setNextContentHandler(handler); - } - - public String toString() - { - return stringBuffer.toString(); - } - - public long getContentLength() - { - return stringBuffer.length(); - } - - public String getContent() - { - return stringBuffer.toString(); - } - - public String getSystemId() - { - // FIXME: Implement a URI scheme to be able to refer to XScript - // variables by URI - return "xscript:inline:" + System.identityHashCode(this); - } +public class XScriptObjectInlineXML extends XScriptObject { + StringBuffer stringBuffer; + StringBufferContentHandler streamHandler; + + public XScriptObjectInlineXML(XScriptManager manager) { + super(manager); + stringBuffer = new StringBuffer(); + stringBuffer.append("\n\n"); + streamHandler = new StringBufferContentHandler(stringBuffer); + } + + public XScriptObjectInlineXML(XScriptManager manager, + StringBuffer stringBuffer) { + super(manager); + this.stringBuffer = stringBuffer; + streamHandler = new StringBufferContentHandler(stringBuffer); + } + + public XScriptObjectInlineXML(XScriptManager manager, String string) { + super(manager); + this.stringBuffer = new StringBuffer(string); + streamHandler = new StringBufferContentHandler(stringBuffer); + } + + public InputStream getInputStream() + throws ProcessingException, IOException { + // FIXME(VG): This method should never be used because it + // incorrectly converts characters into bytes. + return new StringBufferInputStream(stringBuffer.toString()); + } + + public InputSource getInputSource() + throws ProcessingException, IOException { + InputSource is = new InputSource(new StringReader(stringBuffer.toString())); + is.setSystemId(getSystemId()); + return is; + } + + public ContentHandler getContentHandler() { + return streamHandler; + } + + public void setNextContentHandler(ContentHandler handler) { + streamHandler.setNextContentHandler(handler); + } + + public String toString() { + return stringBuffer.toString(); + } + + public long getContentLength() { + return stringBuffer.length(); + } + + public String getContent() { + return stringBuffer.toString(); + } + + public String getSystemId() { + // FIXME: Implement a URI scheme to be able to refer to XScript + // variables by URI + return "xscript:inline:" + System.identityHashCode(this); + } } 1.4.2.1 +31 -40 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectResult.java Index: XScriptObjectResult.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObjectResult.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- XScriptObjectResult.java 22 Feb 2002 07:00:15 -0000 1.4 +++ XScriptObjectResult.java 26 Jul 2002 04:40:49 -0000 1.4.2.1 @@ -50,14 +50,11 @@ */ package org.apache.cocoon.components.xscript; +import org.apache.cocoon.ProcessingException; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import javax.xml.transform.Result; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.stream.StreamResult; -import org.apache.cocoon.ProcessingException; -import org.apache.cocoon.components.url.URLFactory; /** * An XScriptObject created from a JAXP @@ -67,38 +64,32 @@ * @version CVS $Id$ * @since August 30, 2001 */ -public class XScriptObjectResult extends XScriptObject -{ - /** - * The XML content of this object. - */ - String content; - - public XScriptObjectResult(XScriptManager manager, String content) - { - super(manager); - this.content = content; - } - - public InputStream getInputStream() - throws ProcessingException, IOException - { - return new ByteArrayInputStream(content.getBytes()); - } - - public long getContentLength() - { - return content.length(); - } - - public String getSystemId() - { - // FIXME: Return a real URL that identifies this object - return "file:/"; - } - - public String toString() - { - return "XScriptObjectResult: " + content; - } +public class XScriptObjectResult extends XScriptObject { + /** + * The XML content of this object. + */ + String content; + + public XScriptObjectResult(XScriptManager manager, String content) { + super(manager); + this.content = content; + } + + public InputStream getInputStream() + throws ProcessingException, IOException { + return new ByteArrayInputStream(content.getBytes()); + } + + public long getContentLength() { + return content.length(); + } + + public String getSystemId() { + // FIXME: Return a real URL that identifies this object + return "file:/"; + } + + public String toString() { + return "XScriptObjectResult: " + content; + } } 1.4.2.1 +43 -48 xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptVariableScope.java Index: XScriptVariableScope.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptVariableScope.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- XScriptVariableScope.java 22 Feb 2002 07:00:15 -0000 1.4 +++ XScriptVariableScope.java 26 Jul 2002 04:40:49 -0000 1.4.2.1 @@ -61,55 +61,50 @@ * @version CVS $Id$ * @since August 4, 2001 */ -public class XScriptVariableScope -{ - /** - * The variables store; each entry is String - * representing the name of the variable, with the corresponding - * value an {@link XScriptObject}. - */ - HashMap variables = new HashMap(); +public class XScriptVariableScope { + /** + * The variables store; each entry is String + * representing the name of the variable, with the corresponding + * value an {@link XScriptObject}. + */ + HashMap variables = new HashMap(); - /** - * Define a new variable or overwrite the value of an existing - * variable in this scope. - * - * @param name a String value - * @param value a {@link XScriptObject} value - */ - public synchronized void put(String name, XScriptObject value) - { - variables.put(name, value); - } + /** + * Define a new variable or overwrite the value of an existing + * variable in this scope. + * + * @param name a String value + * @param value a {@link XScriptObject} value + */ + public synchronized void put(String name, XScriptObject value) { + variables.put(name, value); + } - /** - * Obtains the value of the XScript name variable. - * - * @param name a String value - * @return a {@link XScriptObject} value - */ - public synchronized XScriptObject get(String name) - throws IllegalArgumentException - { - if (!variables.containsKey(name)) - throw new IllegalArgumentException("Cannot find variable '" - + name + "'!"); - return (XScriptObject)variables.get(name); - } + /** + * Obtains the value of the XScript name variable. + * + * @param name a String value + * @return a {@link XScriptObject} value + */ + public synchronized XScriptObject get(String name) + throws IllegalArgumentException { + if (!variables.containsKey(name)) + throw new IllegalArgumentException("Cannot find variable '" + + name + "'!"); + return (XScriptObject) variables.get(name); + } - /** - * Removes the XScript variable that's accessible via - * name. - * - * @param name a String value - */ - public synchronized void remove(String name) - { - variables.remove(name); - } + /** + * Removes the XScript variable that's accessible via + * name. + * + * @param name a String value + */ + public synchronized void remove(String name) { + variables.remove(name); + } - public synchronized boolean defines(String name) - { - return variables.containsKey(name); - } + public synchronized boolean defines(String name) { + return variables.containsKey(name); + } } ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org