You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2003/10/22 20:02:29 UTC
cvs commit: cocoon-2.2/src/java/org/apache/cocoon/generation AbstractGenerator.java AbstractServerPage.java DirectoryGenerator.java FileGenerator.java JXTemplateGenerator.java LinkStatusGenerator.java ServerPagesGenerator.java ServletGenerator.java StreamGenerator.java XPathDirectoryGenerator.java
bloritsch 2003/10/22 11:02:29
Modified: src/java/org/apache/cocoon/generation AbstractGenerator.java
AbstractServerPage.java DirectoryGenerator.java
FileGenerator.java JXTemplateGenerator.java
LinkStatusGenerator.java ServerPagesGenerator.java
ServletGenerator.java StreamGenerator.java
XPathDirectoryGenerator.java
Log:
Update the generators to be resettable/serviceable
Revision Changes Path
1.3 +6 -6 cocoon-2.2/src/java/org/apache/cocoon/generation/AbstractGenerator.java
Index: AbstractGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/AbstractGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractGenerator.java 3 Sep 2003 15:00:56 -0000 1.2
+++ AbstractGenerator.java 22 Oct 2003 18:02:29 -0000 1.3
@@ -63,13 +63,13 @@
* An abstract class that can be used to implement an own generator.
* If you need other components, use the {@link ServiceableGenerator}
* instead.
- *
+ *
* @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
* (Apache Software Foundation)
* @version CVS $Id$
*/
-public abstract class AbstractGenerator
- extends AbstractXMLProducer
+public abstract class AbstractGenerator
+ extends AbstractXMLProducer
implements Generator {
/** The current <code>SourceResolver</code>. */
@@ -96,8 +96,8 @@
/**
* Recycle the generator by removing references
*/
- public void recycle() {
- super.recycle();
+ public void reset() {
+ super.reset();
this.resolver = null;
this.objectModel = null;
this.source = null;
1.5 +3 -11 cocoon-2.2/src/java/org/apache/cocoon/generation/AbstractServerPage.java
Index: AbstractServerPage.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/AbstractServerPage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractServerPage.java 15 Oct 2003 18:03:53 -0000 1.4
+++ AbstractServerPage.java 22 Oct 2003 18:02:29 -0000 1.5
@@ -75,8 +75,8 @@
* @version CVS $Id$
*/
public abstract class AbstractServerPage
- extends ServletGenerator
- implements CompiledComponent, CacheableProcessingComponent, Recomposable {
+ extends ServletGenerator
+ implements CompiledComponent, CacheableProcessingComponent {
/**
* Code generators should produce a constructor
* block that initializes the generator's
@@ -96,14 +96,6 @@
protected long dateCreated = -1L;
/** The dependency file list */
protected File[] dependencies = null;
-
- /**
- * Recompose with the actual <code>ComponentManager</code> that should
- * be used.
- */
- public void recompose(ComponentManager manager) throws ComponentException {
- this.manager = manager;
- }
/**
* Determines whether this generator's source files have changed
1.10 +16 -16 cocoon-2.2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
Index: DirectoryGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DirectoryGenerator.java 25 Sep 2003 17:28:38 -0000 1.9
+++ DirectoryGenerator.java 22 Oct 2003 18:02:29 -0000 1.10
@@ -125,8 +125,8 @@
* (SMB GmbH) for Virbus AG
* @version CVS $Id$
*/
-public class DirectoryGenerator
- extends ServiceableGenerator
+public class DirectoryGenerator
+ extends ServiceableGenerator
implements CacheableProcessingComponent {
/** Constant for the file protocol. */
@@ -286,7 +286,7 @@
* is initially empty since the files that define it are not known before
* generation has occured. So the returned object is kept by the generator
* and filled with each of the files that are traversed.
- *
+ *
* @see DirectoryGenerator.DirValidity
*/
public SourceValidity getValidity() {
@@ -298,7 +298,7 @@
/**
* Generate XML data.
- *
+ *
* @throws SAXException if an error occurs while outputting the document
* @throws ProcessingException if the requsted URI isn't a directory on the local filesystem
*/
@@ -336,7 +336,7 @@
/**
* Creates a stack containing the ancestors of File up to specified directory.
- *
+ *
* @param path the File whose ancestors shall be retrieved
* @return a Stack containing the ancestors.
*/
@@ -360,7 +360,7 @@
/**
* Adds recursively the path from the directory matched by the root pattern
* down to the requested directory.
- *
+ *
* @param path the requested directory.
* @param ancestors the stack of the ancestors.
* @throws SAXException
@@ -380,7 +380,7 @@
* Adds a single node to the generated document. If the path is a
* directory, and depth is greater than zero, then recursive calls
* are made to add nodes for the directory's children.
- *
+ *
* @param path the file/directory to process
* @param depth how deep to scan the directory
* @throws SAXException if an error occurs while constructing nodes
@@ -461,7 +461,7 @@
/**
* Begins a named node and calls setNodeAttributes to set its attributes.
- *
+ *
* @param nodeName the name of the new node
* @param path the file/directory to use when setting attributes
* @throws SAXException if an error occurs while creating the node
@@ -478,7 +478,7 @@
* Sets the attributes for a given path. The default method sets attributes
* for the name of thefile/directory and for the last modification time
* of the path.
- *
+ *
* @param path the file/directory to use when setting attributes
* @throws SAXException if an error occurs while setting the attributes
*/
@@ -504,7 +504,7 @@
/**
* Ends the named node.
- *
+ *
* @param nodeName the name of the new node
* @throws SAXException if an error occurs while closing the node
*/
@@ -514,7 +514,7 @@
/**
* Determines if a given File is the defined root.
- *
+ *
* @param path the File to check
* @return true if the File is the root or the root pattern is not set,
* false otherwise.
@@ -525,7 +525,7 @@
/**
* Determines if a given File shall be visible.
- *
+ *
* @param path the File to check
* @return true if the File shall be visible or the include Pattern is <code>null</code>,
* false otherwise.
@@ -536,7 +536,7 @@
/**
* Determines if a given File shall be excluded from viewing.
- *
+ *
* @param path the File to check
* @return false if the given File shall not be excluded or the exclude Pattern is <code>null</code>,
* true otherwise.
@@ -548,7 +548,7 @@
/**
* Recycle resources
*/
- public void recycle() {
+ public void reset() {
this.cacheKeyParList = null;
this.attributes = null;
this.dateFormatter = null;
@@ -556,7 +556,7 @@
this.includeRE = null;
this.excludeRE = null;
this.validity = null;
- super.recycle();
+ super.reset();
}
/** Specific validity class, that holds all files that have been generated */
1.6 +3 -3 cocoon-2.2/src/java/org/apache/cocoon/generation/FileGenerator.java
Index: FileGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/FileGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileGenerator.java 18 Sep 2003 14:43:48 -0000 1.5
+++ FileGenerator.java 22 Oct 2003 18:02:29 -0000 1.6
@@ -84,12 +84,12 @@
* Recycle this component.
* All instance variables are set to <code>null</code>.
*/
- public void recycle() {
+ public void reset() {
if (null != this.inputSource) {
super.resolver.release(this.inputSource);
this.inputSource = null;
}
- super.recycle();
+ super.reset();
}
/**
1.13 +363 -363 cocoon-2.2/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
Index: JXTemplateGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JXTemplateGenerator.java 15 Oct 2003 14:18:40 -0000 1.12
+++ JXTemplateGenerator.java 22 Oct 2003 18:02:29 -0000 1.13
@@ -1,4 +1,4 @@
-/*
+/*
============================================================================
The Apache Software License, Version 1.1
@@ -104,12 +104,12 @@
import java.text.*;
/**
- * <p>(<em>JX</em> for <a href="http://jakarta.apache.org/commons/jxpath">Apache <em>JX</em>Path</a>
+ * <p>(<em>JX</em> for <a href="http://jakarta.apache.org/commons/jxpath">Apache <em>JX</em>Path</a>
* and <a href="http://jakarta.apache.org/commons/jexl">Apache <em>J</em>e<em>x</em>l</a>).</p>
* <p>Uses the namespace <code>http://apache.org/cocoon/templates/jx/1.0</code></p>
- * <p>Provides a generic page template with embedded JSTL and XPath
+ * <p>Provides a generic page template with embedded JSTL and XPath
* expression substitution to access data sent by Cocoon Flowscripts.</p>
- * The embedded expression language allows a page author to access an
+ * The embedded expression language allows a page author to access an
* object using a simplified syntax such as
*
* <p><pre>
@@ -118,10 +118,10 @@
*
* <p>Embedded JSTL expressions are contained in <code>${}</code>.</p>
* <p>Embedded XPath expressions are contained in <code>#{}</code>.</p>
- * <p>Note that since this generator uses
- * <a href="http://jakarta.apache.org/commons/jxpath">Apache JXPath</a>
- * and <a href="http://jakarta.apache.org/commons/jexl">Apache Jexl</a>, the
- * referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects from
+ * <p>Note that since this generator uses
+ * <a href="http://jakarta.apache.org/commons/jxpath">Apache JXPath</a>
+ * and <a href="http://jakarta.apache.org/commons/jexl">Apache Jexl</a>, the
+ * referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects from
* a Flowscript. In addition the following implicit objects are available as
* both XPath and JSTL variables:</p>
* <p>
@@ -143,15 +143,15 @@
* </dl>
* </p>
*
- * The current Web Continuation from the Flowscript
- * is also available as a variable named <code>continuation</code>. You would
+ * The current Web Continuation from the Flowscript
+ * is also available as a variable named <code>continuation</code>. You would
* typically access its <code>id</code>:
*
* <p><pre>
* <form action="${continuation.id}">
* </pre></p>
*
- * <p>You can also reach previous continuations by using the
+ * <p>You can also reach previous continuations by using the
* <code>getContinuation()</code> function:</p>
*
* <p><pre>
@@ -165,17 +165,17 @@
* </template>
* </pre></p>
*
- * <p>The <code>import</code> tag allows you to include another template
- * within the current template. The content of the imported template is
+ * <p>The <code>import</code> tag allows you to include another template
+ * within the current template. The content of the imported template is
* compiled and will be executed in place of the <code>import</code> tag:</p><pre>
* <import uri="URI" [context="Expression"]/>
- * </pre></p><p>The Cocoon source resolver is used to resolve <code>uri</code>.
- * If <code>context</code> is present, then its value is used as the context
- * for evaluating the imported template, otherwise the current context is
+ * </pre></p><p>The Cocoon source resolver is used to resolve <code>uri</code>.
+ * If <code>context</code> is present, then its value is used as the context
+ * for evaluating the imported template, otherwise the current context is
* used.</p>
- * <p>The <code>set</code> tag creates a local alias of an object. The
- * <code>var</code> attribute specifies the name of a variable to assign the
- * object to. The <code>value</code> attribute specifies the object (defaults
+ * <p>The <code>set</code> tag creates a local alias of an object. The
+ * <code>var</code> attribute specifies the name of a variable to assign the
+ * object to. The <code>value</code> attribute specifies the object (defaults
* to <code>body</code> if not present):</p>
*
* <pre>
@@ -184,10 +184,10 @@
* </set>
* </pre></p>
*
- * <p>If used within a <code>macro</code> definition (see below)
- * variables created by <code>set</code> are only visible within the body of
+ * <p>If used within a <code>macro</code> definition (see below)
+ * variables created by <code>set</code> are only visible within the body of
* the <code>macro</code>.</p>
- * <p>The <code>if</code> tag allows the conditional execution of its body
+ * <p>The <code>if</code> tag allows the conditional execution of its body
* according to value of a <code>test</code> attribute:</p>
*
* <p><pre>
@@ -196,11 +196,11 @@
* </if>
* </pre></p>
*
- * <p>The <code>choose</code> tag performs conditional block execution by the
- * embedded <code>when</code> sub tags. It renders the body of the first
- * <code>when</code> tag whose <code>test</code> condition evaluates to true.
+ * <p>The <code>choose</code> tag performs conditional block execution by the
+ * embedded <code>when</code> sub tags. It renders the body of the first
+ * <code>when</code> tag whose <code>test</code> condition evaluates to true.
* If none of the <code>test</code> conditions of nested <code>when</code> tags
- * evaluate to <code>true</code>, then the body of an <code>otherwise</code>
+ * evaluate to <code>true</code>, then the body of an <code>otherwise</code>
* tag is evaluated, if present:</p>
*
* <p><pre>
@@ -214,40 +214,40 @@
* </choose>
* </pre></p>
*
- * <p>The <code>out</code> tag evaluates an expression and outputs
+ * <p>The <code>out</code> tag evaluates an expression and outputs
* the result of the evaluation:</p>
*
* <p><pre>
* <out value="Expression"/>
* </pre></p>
*
- * <p>The <code>forEach</code> tag allows you to iterate over a collection
+ * <p>The <code>forEach</code> tag allows you to iterate over a collection
* of objects:<p>
*
* <p><pre>
- * <forEach [var="Name"] [items="Expression"]
+ * <forEach [var="Name"] [items="Expression"]
[begin="Number"] [end="Number"] [step="Number"]>
* body
* </forEach>
* </pre></p>
*
- * <p>The <code>items</code> attribute specifies the list of items to iterate
- * over. The <code>var</code> attribute specifies the name of a variable to
- * hold the current item. The <code>begin</code> attribute specifies the
- * element to start with (<code>0</code> = first item,
- * <code>1</code> = second item, ...).
- * If unspecified it defaults to <code>0</code>. The <code>end</code>
- * attribute specifies the item to end with (<code>0</code> = first item,
- * <code>1</code> = second item, ...). If unspecified it defaults to the last
+ * <p>The <code>items</code> attribute specifies the list of items to iterate
+ * over. The <code>var</code> attribute specifies the name of a variable to
+ * hold the current item. The <code>begin</code> attribute specifies the
+ * element to start with (<code>0</code> = first item,
+ * <code>1</code> = second item, ...).
+ * If unspecified it defaults to <code>0</code>. The <code>end</code>
+ * attribute specifies the item to end with (<code>0</code> = first item,
+ * <code>1</code> = second item, ...). If unspecified it defaults to the last
* item in the list. Every <code>step</code> items are
- * processed (defaults to <code>1</code> if <code>step</code> is absent).
- * Either <code>items</code> or both <code>begin</code> and <code>end</code>
+ * processed (defaults to <code>1</code> if <code>step</code> is absent).
+ * Either <code>items</code> or both <code>begin</code> and <code>end</code>
* must be present.<p>
*
*
*
* <p>
- * The <code>formatNumber</code> tag is used to display numeric data, including currencies and percentages, in a locale-specific manner. The <code>formatNumber</code>> action determines from the locale, for example, whether to use a period or a comma for delimiting the integer and decimal portions of a number. Here is its syntax:
+ * The <code>formatNumber</code> tag is used to display numeric data, including currencies and percentages, in a locale-specific manner. The <code>formatNumber</code>> action determines from the locale, for example, whether to use a period or a comma for delimiting the integer and decimal portions of a number. Here is its syntax:
* </p>
* <p>
* <formatNumber value="Expression"
@@ -259,10 +259,10 @@
* [var="Name"] [locale="Expression"]>
* </p>
*
- * <p>The <code>formatDate</code> tag provides facilities to format Date values:</p>
+ * <p>The <code>formatDate</code> tag provides facilities to format Date values:</p>
*<p>
- * <formatDate value="Expression" [dateStyle="Style"]
- [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
+ * <formatDate value="Expression" [dateStyle="Style"]
+ [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
[locale="Expression"]>
* </p>
*
@@ -283,17 +283,17 @@
* </c:macro>
* </pre></p>
*
- * <p>The tag being defined in this example is <code><d></code> and it
+ * <p>The tag being defined in this example is <code><d></code> and it
* can be used like any other tag:</p>
*
* <p><pre>
* <d/>
* </pre></p>
*
- * <p>However, when this tag is used it will be replaced with a row containing
+ * <p>However, when this tag is used it will be replaced with a row containing
* a single empty data cell.</p>
- * <p> When such a tag is used, the attributes and content of the tag become
- * available as variables in the body of the <code>macro</code>'s definition,
+ * <p> When such a tag is used, the attributes and content of the tag become
+ * available as variables in the body of the <code>macro</code>'s definition,
* for example:</p>
*
* <p><pre>
@@ -306,10 +306,10 @@
* </c:macro>
* </pre></p>
*
- * <p>The <code>parameter</code> tags in the macro definition define formal
- * parameters, which are replaced with the actual attribute values of the
- * tag when it is used. The content of the tag is also available as a special
- * variable <code>${content}</code>.</p><p>Assuming you had this code in your
+ * <p>The <code>parameter</code> tags in the macro definition define formal
+ * parameters, which are replaced with the actual attribute values of the
+ * tag when it is used. The content of the tag is also available as a special
+ * variable <code>${content}</code>.</p><p>Assuming you had this code in your
* flowscript:</p>
* <code>var greatlakes = ["Superior", "Michigan", "Huron", "Erie", "Ontario"];</code>
* </p><p><code> sendPage(uri, {greatlakes: greatlakes});</code>
@@ -321,7 +321,7 @@
* </table>
* </pre></p>
*
- * <p>When the <code>tablerows</code> tag is used in this situation the
+ * <p>When the <code>tablerows</code> tag is used in this situation the
* following output would be generated:
* </p>
*<p><pre>
@@ -336,7 +336,7 @@
*/
public class JXTemplateGenerator extends ServiceableGenerator {
- private static final JXPathContextFactory
+ private static final JXPathContextFactory
jxpathContextFactory = JXPathContextFactory.newInstance();
private static final char[] EMPTY_CHARS = "".toCharArray();
@@ -364,7 +364,7 @@
public void remove() {
}
};
-
+
private static final Locator NULL_LOCATOR = new LocatorImpl();
/**
@@ -372,22 +372,22 @@
* as well as Java Objects
*/
static class JSIntrospector extends UberspectImpl {
-
+
static class JSMethod implements VelMethod {
-
+
Scriptable scope;
String name;
-
+
public JSMethod(Scriptable scope, String name) {
this.scope = scope;
this.name = name;
}
-
+
public Object invoke(Object thisArg, Object[] args)
throws Exception {
Context cx = Context.enter();
try {
- Object result;
+ Object result;
Scriptable thisObj;
if (!(thisArg instanceof Scriptable)) {
thisObj = Context.toObject(thisArg, scope);
@@ -400,7 +400,7 @@
newArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
newArgs[i] = args[i];
- if (args[i] != null &&
+ if (args[i] != null &&
!(args[i] instanceof Number) &&
!(args[i] instanceof Boolean) &&
!(args[i] instanceof String) &&
@@ -409,12 +409,12 @@
}
}
}
- result = ScriptRuntime.call(cx, result, thisObj,
+ result = ScriptRuntime.call(cx, result, thisObj,
newArgs, scope);
if (result == Undefined.instance ||
result == Scriptable.NOT_FOUND) {
result = null;
-
+
} else {
if (!(result instanceof NativeJavaClass)) {
while (result instanceof Wrapper) {
@@ -429,31 +429,31 @@
Context.exit();
}
}
-
+
public boolean isCacheable() {
return false;
}
-
+
public String getMethodName() {
return name;
}
-
+
public Class getReturnType() {
return Object.class;
}
-
+
}
-
+
static class JSPropertyGet implements VelPropertyGet {
-
+
Scriptable scope;
String name;
-
+
public JSPropertyGet(Scriptable scope, String name) {
this.scope = scope;
this.name = name;
}
-
+
public Object invoke(Object thisArg) throws Exception {
Context.enter();
try {
@@ -464,10 +464,10 @@
thisObj = (Scriptable)thisArg;
}
Object result = ScriptableObject.getProperty(thisObj, name);
- if (result == Undefined.instance ||
+ if (result == Undefined.instance ||
result == Scriptable.NOT_FOUND) {
result = null;
- }
+ }
if (result instanceof Wrapper) {
if (!(result instanceof NativeJavaClass)) {
result = ((Wrapper)result).unwrap();
@@ -478,27 +478,27 @@
Context.exit();
}
}
-
+
public boolean isCacheable() {
return false;
}
-
+
public String getMethodName() {
return name;
}
-
+
}
-
+
static class JSPropertySet implements VelPropertySet {
-
+
Scriptable scope;
String name;
-
+
public JSPropertySet(Scriptable scope, String name) {
this.scope = scope;
this.name = name;
}
-
+
public Object invoke(Object thisArg, Object rhs) throws Exception {
Context.enter();
try {
@@ -509,7 +509,7 @@
} else {
thisObj = (Scriptable)thisArg;
}
- if (arg != null &&
+ if (arg != null &&
!(arg instanceof Number) &&
!(arg instanceof Boolean) &&
!(arg instanceof String) &&
@@ -522,30 +522,30 @@
Context.exit();
}
}
-
+
public boolean isCacheable() {
return false;
}
-
+
public String getMethodName() {
- return name;
+ return name;
}
}
-
+
static class NativeArrayIterator implements Iterator {
-
+
NativeArray arr;
int index;
-
+
public NativeArrayIterator(NativeArray arr) {
this.arr = arr;
this.index = 0;
}
-
+
public boolean hasNext() {
return index < (int)arr.jsGet_length();
}
-
+
public Object next() {
Context.enter();
try {
@@ -565,33 +565,33 @@
Context.exit();
}
}
-
+
public void remove() {
arr.delete(index);
}
}
-
+
static class ScriptableIterator implements Iterator {
-
+
Scriptable scope;
Object[] ids;
int index;
-
+
public ScriptableIterator(Scriptable scope) {
this.scope = scope;
this.ids = scope.getIds();
this.index = 0;
}
-
+
public boolean hasNext() {
return index < ids.length;
}
-
+
public Object next() {
Context.enter();
try {
- Object result =
- ScriptableObject.getProperty(scope,
+ Object result =
+ ScriptableObject.getProperty(scope,
ids[index++].toString());
if (result == Undefined.instance ||
result == Scriptable.NOT_FOUND) {
@@ -608,7 +608,7 @@
Context.exit();
}
}
-
+
public void remove() {
Context.enter();
try {
@@ -618,7 +618,7 @@
}
}
}
-
+
public Iterator getIterator(Object obj, Info i)
throws Exception {
if (!(obj instanceof Scriptable)) {
@@ -629,8 +629,8 @@
}
return new ScriptableIterator((Scriptable)obj);
}
-
- public VelMethod getMethod(Object obj, String methodName,
+
+ public VelMethod getMethod(Object obj, String methodName,
Object[] args, Info i)
throws Exception {
if (!(obj instanceof Scriptable)) {
@@ -638,8 +638,8 @@
}
return new JSMethod((Scriptable)obj, methodName);
}
-
- public VelPropertyGet getPropertyGet(Object obj, String identifier,
+
+ public VelPropertyGet getPropertyGet(Object obj, String identifier,
Info i)
throws Exception {
if (!(obj instanceof Scriptable)) {
@@ -647,8 +647,8 @@
}
return new JSPropertyGet((Scriptable)obj, identifier);
}
-
- public VelPropertySet getPropertySet(Object obj, String identifier,
+
+ public VelPropertySet getPropertySet(Object obj, String identifier,
Object arg, Info i)
throws Exception {
if (!(obj instanceof Scriptable)) {
@@ -658,7 +658,7 @@
}
}
- static class MyJexlContext
+ static class MyJexlContext
extends HashMap implements JexlContext {
public Map getVars() {
return this;
@@ -726,7 +726,7 @@
}
return localVariables.containsKey(varName);
}
-
+
public Object getVariable(String varName) {
if (varName.equals("continuation")) {
return kont;
@@ -745,11 +745,11 @@
}
return localVariables.get(varName);
}
-
+
public void declareVariable(String varName, Object value) {
localVariables.put(varName, value);
}
-
+
public void undeclareVariable(String varName) {
localVariables.remove(varName);
}
@@ -758,7 +758,7 @@
static {
// Hack: there's no _nice_ way to add my introspector to Jexl right now
try {
- Field field =
+ Field field =
org.apache.commons.jexl.util.Introspector.class.getDeclaredField("uberSpect");
field.setAccessible(true);
field.set(null, new JSIntrospector());
@@ -768,7 +768,7 @@
}
- final static String NS =
+ final static String NS =
"http://apache.org/cocoon/templates/jx/1.0";
final static String TEMPLATE = "template";
@@ -788,11 +788,11 @@
/**
* Compile a single Jexl expr (contained in ${}) or XPath expression
- * (contained in #{})
+ * (contained in #{})
*/
- private static Expression compileExpr(String expr, String errorPrefix,
- Locator location)
+ private static Expression compileExpr(String expr, String errorPrefix,
+ Locator location)
throws SAXParseException {
try {
return compileExpr(expr);
@@ -850,7 +850,7 @@
}
// Compile an integer expression (returns either a Compiled Expression
// or an Integer literal)
- private static Expression compileInt(String val, String msg, Locator location)
+ private static Expression compileInt(String val, String msg, Locator location)
throws SAXException {
Expression res = compileExpr(val, msg, location);
if (res == null) return null;
@@ -860,7 +860,7 @@
return res;
}
- private static Expression compileBoolean(String val, String msg, Locator location)
+ private static Expression compileBoolean(String val, String msg, Locator location)
throws SAXException {
Expression res = compileExpr(val, msg, location);
if (res == null) return null;
@@ -870,7 +870,7 @@
return res;
}
- private static Expression compile(final String variable, boolean xpath)
+ private static Expression compile(final String variable, boolean xpath)
throws Exception {
Object compiled;
if (xpath) {
@@ -882,7 +882,7 @@
}
static private Object getValue(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
if (expr == null) return null;
Object compiled = expr.compiledExpression;
@@ -891,7 +891,7 @@
CompiledExpression e = (CompiledExpression)compiled;
return e.getValue(jxpathContext);
} else if (compiled instanceof org.apache.commons.jexl.Expression) {
- org.apache.commons.jexl.Expression e =
+ org.apache.commons.jexl.Expression e =
(org.apache.commons.jexl.Expression)compiled;
return e.evaluate(jexlContext);
}
@@ -906,7 +906,7 @@
}
static private int getIntValue(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
Object res = getValue(expr, jexlContext, jxpathContext);
if (res instanceof Number) {
@@ -916,7 +916,7 @@
}
static private Number getNumberValue(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
Object res = getValue(expr, jexlContext, jxpathContext);
if (res instanceof Number) {
@@ -929,7 +929,7 @@
}
static private String getStringValue(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
Object res = getValue(expr, jexlContext, jxpathContext);
if (res != null) {
@@ -942,7 +942,7 @@
}
static private Boolean getBooleanValue(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
Object res = getValue(expr, jexlContext, jxpathContext);
if (res instanceof Boolean) {
@@ -953,7 +953,7 @@
// Hack: try to prevent JXPath from converting result to a String
private Object getNode(Expression expr, JexlContext jexlContext,
- JXPathContext jxpathContext)
+ JXPathContext jxpathContext)
throws Exception {
try {
Object compiled = expr.compiledExpression;
@@ -961,7 +961,7 @@
CompiledExpression e = (CompiledExpression)compiled;
return e.getPointer(jxpathContext, expr.raw).getNode();
} else if (compiled instanceof org.apache.commons.jexl.Expression) {
- org.apache.commons.jexl.Expression e =
+ org.apache.commons.jexl.Expression e =
(org.apache.commons.jexl.Expression)compiled;
return e.evaluate(jexlContext);
}
@@ -979,7 +979,7 @@
final Locator location;
Event next; // in document order
Event(Locator locator) {
- this.location =
+ this.location =
locator == null ? NULL_LOCATOR : new LocatorImpl(locator);
}
@@ -996,13 +996,13 @@
}
return result;
}
-
+
}
static class TextEvent extends Event {
- TextEvent(Locator location,
- char[] chars, int start, int length)
+ TextEvent(Locator location,
+ char[] chars, int start, int length)
throws SAXException {
super(location);
StringBuffer buf = new StringBuffer();
@@ -1023,16 +1023,16 @@
buf.append('\\');
} else {
buf.append((char)ch);
- }
+ }
} else if (c == '}') {
String str = buf.toString();
Object compiledExpression;
try {
if (xpath) {
- compiledExpression =
+ compiledExpression =
JXPathContext.compile(str);
} else {
- compiledExpression =
+ compiledExpression =
ExpressionFactory.createExpression(str);
}
} catch (Exception exc) {
@@ -1061,9 +1061,9 @@
xpath = c == '#';
inExpr = true;
if (buf.length() > 0) {
- char[] charArray =
+ char[] charArray =
new char[buf.length()];
-
+
buf.getChars(0, buf.length(),
charArray, 0);
substitutions.add(charArray);
@@ -1089,7 +1089,7 @@
ignored.printStackTrace();
}
if (buf.length() > 0) {
- char[] charArray =
+ char[] charArray =
new char[buf.length()];
buf.getChars(0, buf.length(), charArray, 0);
substitutions.add(charArray);
@@ -1102,8 +1102,8 @@
}
static class Characters extends TextEvent {
- Characters(Locator location,
- char[] chars, int start, int length)
+ Characters(Locator location,
+ char[] chars, int start, int length)
throws SAXException {
super(location, chars, start, length);
}
@@ -1125,7 +1125,7 @@
}
static class EndElement extends Event {
- EndElement(Locator location,
+ EndElement(Locator location,
StartElement startElement) {
super(location);
this.startElement = startElement;
@@ -1140,10 +1140,10 @@
}
final String prefix;
}
-
+
static class IgnorableWhitespace extends TextEvent {
- IgnorableWhitespace(Locator location,
- char[] chars, int start, int length)
+ IgnorableWhitespace(Locator location,
+ char[] chars, int start, int length)
throws SAXException {
super(location, chars, start, length);
}
@@ -1181,9 +1181,9 @@
final String raw;
final String type;
}
-
+
static class CopyAttribute extends AttributeEvent {
- CopyAttribute(String namespaceURI,
+ CopyAttribute(String namespaceURI,
String localName,
String raw,
String type, String value) {
@@ -1192,17 +1192,17 @@
}
final String value;
}
-
+
static class Subst {
}
-
+
static class Literal extends Subst {
Literal(String val) {
this.value = val;
}
final String value;
}
-
+
static class Expression extends Subst {
Expression(String raw, Object expr) {
this.raw = raw;
@@ -1226,7 +1226,7 @@
static class StartElement extends Event {
StartElement(Locator location, String namespaceURI,
String localName, String raw,
- Attributes attrs)
+ Attributes attrs)
throws SAXException {
super(location);
this.namespaceURI = namespaceURI;
@@ -1272,8 +1272,8 @@
throw new SAXParseException(err.getMessage(),
location,
null);
-
- }
+
+ }
substEvents.add(compiledExpression);
buf.setLength(0);
inExpr = false;
@@ -1310,7 +1310,7 @@
}
}
break;
- }
+ }
}
} catch (IOException ignored) {
ignored.printStackTrace();
@@ -1401,7 +1401,7 @@
}
static class StartDTD extends Event {
- StartDTD(Locator location, String name,
+ StartDTD(Locator location, String name,
String publicId, String systemId) {
super(location);
this.name = name;
@@ -1412,7 +1412,7 @@
final String publicId;
final String systemId;
}
-
+
static class StartEntity extends Event {
public StartEntity(Locator location, String name) {
super(location);
@@ -1429,9 +1429,9 @@
final StartElement startElement;
EndInstruction endInstruction;
}
-
+
static class EndInstruction extends Event {
- EndInstruction(Locator locator,
+ EndInstruction(Locator locator,
StartInstruction startInstruction) {
super(locator);
this.startInstruction = startInstruction;
@@ -1457,7 +1457,7 @@
final Expression end;
final Expression step;
}
-
+
static class StartIf extends StartInstruction {
StartIf(StartElement raw, Expression test) {
super(raw);
@@ -1499,7 +1499,7 @@
}
static class StartImport extends StartInstruction {
- StartImport(StartElement raw, AttributeEvent uri,
+ StartImport(StartElement raw, AttributeEvent uri,
Expression select) {
super(raw);
this.uri = uri;
@@ -1537,7 +1537,7 @@
if (!params) {
throw new SAXParseException("<parameter> not allowed here: \""+startParam.name +"\"", startParam.location, null);
}
- Object prev =
+ Object prev =
parameters.put(startParam.name, startParam);
if (prev != null) {
throw new SAXParseException("duplicate parameter: \""+startParam.name +"\"", location, null);
@@ -1633,25 +1633,25 @@
return ret;
}
- private static final String NUMBER = "number";
+ private static final String NUMBER = "number";
private static final String CURRENCY = "currency";
private static final String PERCENT = "percent";
static class StartFormatNumber extends StartInstruction {
- Expression value;
- Expression type;
- Expression pattern;
- Expression currencyCode;
- Expression currencySymbol;
- Expression isGroupingUsed;
- Expression maxIntegerDigits;
- Expression minIntegerDigits;
- Expression maxFractionDigits;
- Expression minFractionDigits;
+ Expression value;
+ Expression type;
+ Expression pattern;
+ Expression currencyCode;
+ Expression currencySymbol;
+ Expression isGroupingUsed;
+ Expression maxIntegerDigits;
+ Expression minIntegerDigits;
+ Expression maxFractionDigits;
+ Expression minFractionDigits;
Expression locale;
-
- Expression var;
+
+ Expression var;
private static Class currencyClass;
@@ -1665,33 +1665,33 @@
public StartFormatNumber(StartElement raw,
Expression var,
- Expression value,
- Expression type,
- Expression pattern,
- Expression currencyCode,
- Expression currencySymbol,
- Expression isGroupingUsed,
- Expression maxIntegerDigits,
- Expression minIntegerDigits,
- Expression maxFractionDigits,
+ Expression value,
+ Expression type,
+ Expression pattern,
+ Expression currencyCode,
+ Expression currencySymbol,
+ Expression isGroupingUsed,
+ Expression maxIntegerDigits,
+ Expression minIntegerDigits,
+ Expression maxFractionDigits,
Expression minFractionDigits,
Expression locale) {
super(raw);
- this.var = var;
- this.value = value;
- this.type = type;
- this.pattern = pattern;
- this.currencyCode = currencyCode;
- this.currencySymbol = currencySymbol;
- this.isGroupingUsed = isGroupingUsed;
- this.maxIntegerDigits = maxIntegerDigits;
- this.minIntegerDigits = minIntegerDigits;
- this.maxFractionDigits = maxFractionDigits;
- this.minFractionDigits = minFractionDigits;
+ this.var = var;
+ this.value = value;
+ this.type = type;
+ this.pattern = pattern;
+ this.currencyCode = currencyCode;
+ this.currencySymbol = currencySymbol;
+ this.isGroupingUsed = isGroupingUsed;
+ this.maxIntegerDigits = maxIntegerDigits;
+ this.minIntegerDigits = minIntegerDigits;
+ this.maxFractionDigits = maxFractionDigits;
+ this.minFractionDigits = minFractionDigits;
this.locale = locale;
}
- String format(JexlContext jexl, JXPathContext jxp)
+ String format(JexlContext jexl, JXPathContext jxp)
throws Exception {
// Determine formatting locale
String var = getStringValue(this.var, jexl, jxp);
@@ -1699,17 +1699,17 @@
String type = getStringValue(this.type, jexl, jxp);
String pattern = getStringValue(this.pattern, jexl, jxp);
String currencyCode = getStringValue(this.currencyCode, jexl, jxp);
- String currencySymbol = getStringValue(this.currencySymbol,
+ String currencySymbol = getStringValue(this.currencySymbol,
jexl, jxp);
- Boolean isGroupingUsed = getBooleanValue(this.isGroupingUsed,
+ Boolean isGroupingUsed = getBooleanValue(this.isGroupingUsed,
jexl, jxp);
- Number maxIntegerDigits = getNumberValue(this.maxIntegerDigits,
+ Number maxIntegerDigits = getNumberValue(this.maxIntegerDigits,
jexl, jxp);
- Number minIntegerDigits = getNumberValue(this.minIntegerDigits,
+ Number minIntegerDigits = getNumberValue(this.minIntegerDigits,
jexl, jxp);
- Number maxFractionDigits = getNumberValue(this.maxFractionDigits,
+ Number maxFractionDigits = getNumberValue(this.maxFractionDigits,
jexl, jxp);
- Number minFractionDigits = getNumberValue(this.minFractionDigits,
+ Number minFractionDigits = getNumberValue(this.minFractionDigits,
jexl, jxp);
String localeStr = getStringValue(this.locale,
jexl, jxp);
@@ -1721,7 +1721,7 @@
}
String formatted;
if (loc != null) {
- // Create formatter
+ // Create formatter
NumberFormat formatter = null;
if ((pattern != null) && !pattern.equals("")) {
// if 'pattern' is specified, 'type' is ignored
@@ -1757,9 +1757,9 @@
}
return formatted;
}
-
+
private NumberFormat createFormatter(Locale loc,
- String type)
+ String type)
throws Exception {
NumberFormat formatter = null;
if ((type == null) || NUMBER.equalsIgnoreCase(type)) {
@@ -1796,7 +1796,7 @@
if (minFractionDigits != null)
formatter.setMinimumFractionDigits(minFractionDigits.intValue());
}
-
+
/*
* Override the formatting locale's default currency symbol with the
* specified currency code (specified via the "currencyCode" attribute) or
@@ -1821,7 +1821,7 @@
* >=1.4 EUR --- Locale's currency symbol for Euro
*
* all --- \u20AC \u20AC
- *
+ *
* <1.4 EUR \u20AC \u20AC
* >=1.4 EUR \u20AC Locale's currency symbol for Euro
*/
@@ -1830,11 +1830,11 @@
String currencySymbol) throws Exception {
String code = null;
String symbol = null;
-
+
if ((currencyCode == null) && (currencySymbol == null)) {
return;
}
-
+
if ((currencyCode != null) && (currencySymbol != null)) {
if (currencyClass != null)
code = currencyCode;
@@ -1848,10 +1848,10 @@
else
symbol = currencyCode;
}
-
+
if (code != null) {
Object[] methodArgs = new Object[1];
-
+
/*
* java.util.Currency.getInstance()
*/
@@ -1860,7 +1860,7 @@
methodArgs[0] = code;
Object currency = m.invoke(null, methodArgs);
-
+
/*
* java.text.NumberFormat.setCurrency()
*/
@@ -1920,11 +1920,11 @@
this.locale = locale;
}
- String format(JexlContext jexl, JXPathContext jxp)
+ String format(JexlContext jexl, JXPathContext jxp)
throws Exception {
String var = getStringValue(this.var, jexl, jxp);
Object value = getValue(this.value, jexl, jxp);
- Object locVal = getValue(this.locale,
+ Object locVal = getValue(this.locale,
jexl, jxp);
String pattern = getStringValue(this.pattern,
jexl, jxp);
@@ -1973,7 +1973,7 @@
} else {
throw new IllegalArgumentException("Illegal timeZone value: \""+timeZone+"\"");
}
- }
+ }
if (tz != null) {
formatter.setTimeZone(tz);
}
@@ -1990,7 +1990,7 @@
private DateFormat createFormatter(Locale loc,
String type,
String dateStyle,
- String timeStyle)
+ String timeStyle)
throws Exception {
DateFormat formatter = null;
if ((type == null) || DATE.equalsIgnoreCase(type)) {
@@ -2079,7 +2079,7 @@
}
}
- public void characters(char[] ch, int start, int length)
+ public void characters(char[] ch, int start, int length)
throws SAXException {
if (charBuf == null) {
charBuf = new StringBuffer();
@@ -2101,14 +2101,14 @@
public void endElement(String namespaceURI,
String localName,
- String raw)
+ String raw)
throws SAXException {
Event start = (Event)stack.pop();
Event newEvent = null;
if (NS.equals(namespaceURI)) {
- StartInstruction startInstruction =
+ StartInstruction startInstruction =
(StartInstruction)start;
- EndInstruction endInstruction =
+ EndInstruction endInstruction =
new EndInstruction(locator, startInstruction);
newEvent = endInstruction;
if (start instanceof StartWhen) {
@@ -2124,14 +2124,14 @@
startChoose.firstChoice = startWhen;
}
} else if (start instanceof StartOtherwise) {
- StartOtherwise startOtherwise =
+ StartOtherwise startOtherwise =
(StartOtherwise)start;
StartChoose startChoose = (StartChoose)stack.peek();
startChoose.otherwise = startOtherwise;
- }
+ }
} else {
StartElement startElement = (StartElement)start;
- newEvent = startElement.endElement =
+ newEvent = startElement.endElement =
new EndElement(locator, startElement);
}
addEvent(newEvent);
@@ -2141,20 +2141,20 @@
}
}
-
+
public void endPrefixMapping(String prefix) throws SAXException {
- EndPrefixMapping endPrefixMapping =
+ EndPrefixMapping endPrefixMapping =
new EndPrefixMapping(locator, prefix);
addEvent(endPrefixMapping);
}
- public void ignorableWhitespace(char[] ch, int start, int length)
+ public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException {
Event ev = new IgnorableWhitespace(locator, ch, start, length);
addEvent(ev);
}
- public void processingInstruction(String target, String data)
+ public void processingInstruction(String target, String data)
throws SAXException {
Event pi = new ProcessingInstruction(locator, target, data);
addEvent(pi);
@@ -2173,16 +2173,16 @@
lastEvent = startEvent;
stack.push(lastEvent);
}
-
+
public void startElement(String namespaceURI,
String localName,
String qname,
- Attributes attrs)
+ Attributes attrs)
throws SAXException {
Event newEvent = null;
- StartElement startElement =
+ StartElement startElement =
new StartElement(locator, namespaceURI,
localName, qname, attrs);
if (NS.equals(namespaceURI)) {
@@ -2207,48 +2207,48 @@
Expression expr;
expr = compileExpr(items == null ? select : items,
null, locator);
- StartForEach startForEach =
- new StartForEach(startElement, expr,
+ StartForEach startForEach =
+ new StartForEach(startElement, expr,
var, begin, end, step);
newEvent = startForEach;
} else if (localName.equals(FORMAT_NUMBER)) {
- Expression value =
+ Expression value =
compileExpr(attrs.getValue("value"),
null, locator);;
- Expression type =
+ Expression type =
compileExpr(attrs.getValue("type"),
null, locator);
- Expression pattern =
+ Expression pattern =
compileExpr(attrs.getValue("pattern"),
null, locator);
- Expression currencyCode =
+ Expression currencyCode =
compileExpr(attrs.getValue("currencyCode"),
null, locator);
- Expression currencySymbol =
+ Expression currencySymbol =
compileExpr(attrs.getValue("currencySymbol"),
- null, locator);
- Expression isGroupingUsed =
- compileBoolean(attrs.getValue("isGroupingUsed"),
+ null, locator);
+ Expression isGroupingUsed =
+ compileBoolean(attrs.getValue("isGroupingUsed"),
null, locator);
- Expression maxIntegerDigits =
- compileInt(attrs.getValue("maxIntegerDigits"),
- null, locator);
- Expression minIntegerDigits =
- compileInt(attrs.getValue("minIntegerDigits"),
- null, locator);
- Expression maxFractionDigits =
- compileInt(attrs.getValue("maxFractionDigits"),
- null, locator);
- Expression minFractionDigits =
- compileInt(attrs.getValue("minFractionDigits"),
- null, locator);
+ Expression maxIntegerDigits =
+ compileInt(attrs.getValue("maxIntegerDigits"),
+ null, locator);
+ Expression minIntegerDigits =
+ compileInt(attrs.getValue("minIntegerDigits"),
+ null, locator);
+ Expression maxFractionDigits =
+ compileInt(attrs.getValue("maxFractionDigits"),
+ null, locator);
+ Expression minFractionDigits =
+ compileInt(attrs.getValue("minFractionDigits"),
+ null, locator);
Expression var =
- compileExpr(attrs.getValue("var"),
- null, locator);
+ compileExpr(attrs.getValue("var"),
+ null, locator);
Expression locale =
- compileExpr(attrs.getValue("locale"),
- null, locator);
- StartFormatNumber startFormatNumber =
+ compileExpr(attrs.getValue("locale"),
+ null, locator);
+ StartFormatNumber startFormatNumber =
new StartFormatNumber(startElement,
var,
value,
@@ -2265,30 +2265,30 @@
newEvent = startFormatNumber;
} else if (localName.equals(FORMAT_DATE)) {
Expression var =
- compileExpr(attrs.getValue("var"),
- null, locator);
- Expression value =
+ compileExpr(attrs.getValue("var"),
+ null, locator);
+ Expression value =
compileExpr(attrs.getValue("value"),
null, locator);
- Expression type =
+ Expression type =
compileExpr(attrs.getValue("type"),
null, locator);
- Expression pattern =
+ Expression pattern =
compileExpr(attrs.getValue("pattern"),
null, locator);
Expression timeZone =
- compileExpr(attrs.getValue("timeZone"),
- null, locator);
+ compileExpr(attrs.getValue("timeZone"),
+ null, locator);
Expression dateStyle =
- compileExpr(attrs.getValue("dateStyle"),
- null, locator);
+ compileExpr(attrs.getValue("dateStyle"),
+ null, locator);
Expression timeStyle =
- compileExpr(attrs.getValue("timeStyle"),
- null, locator);
+ compileExpr(attrs.getValue("timeStyle"),
+ null, locator);
Expression locale =
- compileExpr(attrs.getValue("locale"),
- null, locator);
- StartFormatDate startFormatDate =
+ compileExpr(attrs.getValue("locale"),
+ null, locator);
+ StartFormatDate startFormatDate =
new StartFormatDate(startElement,
var,
value,
@@ -2320,8 +2320,8 @@
if (value == null) {
throw new SAXParseException("out: \"value\" is required", locator, null);
}
- Expression expr = compileExpr(value,
- "out: \"value\": ",
+ Expression expr = compileExpr(value,
+ "out: \"value\": ",
locator);
newEvent = new StartOut(startElement, expr);
} else if (localName.equals(OTHERWISE)) {
@@ -2329,7 +2329,7 @@
!(stack.peek() instanceof StartChoose)) {
throw new SAXParseException("<otherwise> must be within <choose>", locator, null);
}
- StartOtherwise startOtherwise =
+ StartOtherwise startOtherwise =
new StartOtherwise(startElement);
newEvent = startOtherwise;
} else if (localName.equals(IF)) {
@@ -2337,9 +2337,9 @@
if (test == null) {
throw new SAXParseException("if: \"test\" is required", locator, null);
}
- Expression expr =
+ Expression expr =
compileExpr(test, "if: \"test\": ", locator);
- StartIf startIf =
+ StartIf startIf =
new StartIf(startElement, expr);
newEvent = startIf;
} else if (localName.equals(MACRO)) {
@@ -2355,8 +2355,8 @@
if (name == null) {
throw new SAXParseException("macro: \"name\" is required", locator, null);
}
- StartDefine startDefine =
- new StartDefine(startElement, namespace, name);
+ StartDefine startDefine =
+ new StartDefine(startElement, namespace, name);
newEvent = startDefine;
} else if (localName.equals(PARAMETER)) {
boolean syntaxErr = false;
@@ -2370,8 +2370,8 @@
if (name == null) {
throw new SAXParseException("parameter: \"name\" is required", locator, null);
}
- StartParameter startParameter =
- new StartParameter(startElement,
+ StartParameter startParameter =
+ new StartParameter(startElement,
name, optional, default_);
newEvent = startParameter;
}
@@ -2383,10 +2383,10 @@
String value = attrs.getValue("value");
Expression valueExpr = null;
if (value != null) {
- valueExpr =
+ valueExpr =
compileExpr(value, "set: \"value\":",
locator);
- }
+ }
StartSet startSet = new StartSet(startElement, var, valueExpr);
newEvent = startSet;
} else if (localName.equals(IMPORT)) {
@@ -2408,11 +2408,11 @@
String select = attrs.getValue("context");
Expression expr = null;
if (select != null) {
- expr =
+ expr =
compileExpr(select, "import: \"context\": ",
locator);
}
- StartImport startImport =
+ StartImport startImport =
new StartImport(startElement, uri, expr);
newEvent = startImport;
} else if (localName.equals(TEMPLATE)) {
@@ -2428,13 +2428,13 @@
stack.push(newEvent);
addEvent(newEvent);
}
-
- public void startPrefixMapping(String prefix, String uri)
+
+ public void startPrefixMapping(String prefix, String uri)
throws SAXException {
addEvent(new StartPrefixMapping(locator, prefix, uri));
}
- public void comment(char ch[], int start, int length)
+ public void comment(char ch[], int start, int length)
throws SAXException {
addEvent(new Comment(locator, ch, start, length));
}
@@ -2455,11 +2455,11 @@
addEvent(new StartCDATA(locator));
}
- public void startDTD(String name, String publicId, String systemId)
+ public void startDTD(String name, String publicId, String systemId)
throws SAXException {
addEvent(new StartDTD(locator, name, publicId, systemId));
}
-
+
public void startEntity(String name) throws SAXException {
addEvent(new StartEntity(locator, name));
}
@@ -2467,7 +2467,7 @@
/**
* Adapter that makes this generator usable as a transformer
- * (Note there is a performance penalty for this however:
+ * (Note there is a performance penalty for this however:
* you effectively recompile the template for every instance document)
*/
@@ -2475,7 +2475,7 @@
static class TemplateConsumer extends Parser implements XMLConsumer {
public TemplateConsumer(SourceResolver resolver, Map objectModel,
- String src, Parameters parameters)
+ String src, Parameters parameters)
throws ProcessingException, SAXException, IOException {
this.gen = new JXTemplateGenerator();
this.gen.setup(resolver, objectModel, null, parameters);
@@ -2498,8 +2498,8 @@
TemplateConsumer templateConsumer;
- public void recycle() {
- super.recycle();
+ public void reset() {
+ super.reset();
templateConsumer = null;
}
@@ -2532,16 +2532,16 @@
return globalJexlContext;
}
- public void recycle() {
+ public void reset() {
if ( this.resolver != null) {
- this.resolver.release(this.inputSource);
+ this.resolver.release(this.inputSource);
}
this.inputSource = null;
this.jxpathContext = null;
this.globalJexlContext = null;
this.variables = null;
this.definitions = null;
- super.recycle();
+ super.reset();
}
public void setup(SourceResolver resolver, Map objectModel,
@@ -2577,12 +2577,12 @@
objectModel);
this.definitions = new HashMap();
}
-
+
private void fillContext(Object contextObject, Map map) {
if (contextObject == null) return;
// Hack: I use jxpath to populate the context object's properties
// in the jexl context
- final JXPathBeanInfo bi =
+ final JXPathBeanInfo bi =
JXPathIntrospector.getBeanInfo(contextObject.getClass());
if (bi.isDynamic()) {
Class cl = bi.getDynamicPropertyHandlerClass();
@@ -2605,7 +2605,7 @@
try {
Method read = props[i].getReadMethod();
if (read != null) {
- map.put(props[i].getName(),
+ map.put(props[i].getName(),
read.invoke(contextObject, null));
}
} catch (Exception ignored) {
@@ -2623,7 +2623,7 @@
final Response response = ObjectModelHelper.getResponse(objectModel);
final org.apache.cocoon.environment.Context app =
ObjectModelHelper.getContext(objectModel);
-
+
this.variables = new MyVariables(contextObject,
kont,
request,
@@ -2637,13 +2637,13 @@
map = new HashMap();
fillContext(contextObject, map);
}
-
+
jxpathContext = jxpathContextFactory.newContext(null, contextObject);
jxpathContext.setVariables(variables);
globalJexlContext = new MyJexlContext();
globalJexlContext.setVars(map);
map = globalJexlContext.getVars();
-
+
if (contextObject != null) {
map.put("flowContext", contextObject);
// FIXME (VG): Is this required (what it's used for - examples)?
@@ -2661,17 +2661,17 @@
map.put("response", response);
map.put("context", app);
map.put("parameters", parameters);
-
+
final Object session = request.getSession(false);
if (session != null) {
map.put("session", session);
}
}
- public void generate()
+ public void generate()
throws IOException, SAXException, ProcessingException {
final String cacheKey = inputSource.getURI();
-
+
StartDocument startEvent;
synchronized (cache) {
startEvent = (StartDocument)cache.get(cacheKey);
@@ -2686,7 +2686,7 @@
}
}
execute(this.xmlConsumer,
- globalJexlContext, jxpathContext,
+ globalJexlContext, jxpathContext,
startEvent, null);
}
@@ -2696,7 +2696,7 @@
}
private void characters(JexlContext jexlContext,
- JXPathContext jxpathContext,
+ JXPathContext jxpathContext,
TextEvent event,
CharHandler handler) throws SAXException {
Iterator iter = event.substitutions.iterator();
@@ -2729,7 +2729,7 @@
}
private void executeRaw(final XMLConsumer consumer,
- Event startEvent, Event endEvent)
+ Event startEvent, Event endEvent)
throws SAXException {
Event ev = startEvent;
while (ev != endEvent) {
@@ -2740,7 +2740,7 @@
} else if (ev instanceof EndDocument) {
consumer.endDocument();
} else if (ev instanceof StartElement) {
- StartElement startElement =
+ StartElement startElement =
(StartElement)ev;
consumer.startElement(startElement.namespaceURI,
startElement.localName,
@@ -2753,7 +2753,7 @@
startElement.localName,
startElement.raw);
} else if (ev instanceof EndPrefixMapping) {
- EndPrefixMapping endPrefixMapping =
+ EndPrefixMapping endPrefixMapping =
(EndPrefixMapping)ev;
consumer.endPrefixMapping(endPrefixMapping.prefix);
} else if (ev instanceof IgnorableWhitespace) {
@@ -2772,9 +2772,9 @@
consumer.startDocument();
}
} else if (ev instanceof StartPrefixMapping) {
- StartPrefixMapping startPrefixMapping =
+ StartPrefixMapping startPrefixMapping =
(StartPrefixMapping)ev;
- consumer.startPrefixMapping(startPrefixMapping.prefix,
+ consumer.startPrefixMapping(startPrefixMapping.prefix,
startPrefixMapping.uri);
} else if (ev instanceof Comment) {
TextEvent text = (TextEvent)ev;
@@ -2803,7 +2803,7 @@
startElement.attributes);
} else if (ev instanceof EndInstruction) {
EndInstruction endInstruction = (EndInstruction)ev;
- StartInstruction startInstruction =
+ StartInstruction startInstruction =
endInstruction.startInstruction;
StartElement startElement = startInstruction.startElement;
consumer.endElement(startElement.namespaceURI,
@@ -2812,7 +2812,7 @@
}
ev = ev.next;
}
- }
+ }
private void executeDOM(final XMLConsumer consumer,
MyJexlContext jexlContext,
@@ -2832,14 +2832,14 @@
final XMLConsumer consumer,
MyJexlContext jexlContext,
JXPathContext jxpathContext,
- Event startEvent, Event endEvent)
+ Event startEvent, Event endEvent)
throws SAXException {
try {
execute(consumer, jexlContext,
jxpathContext, startEvent, endEvent);
} catch (SAXParseException exc) {
throw new SAXParseException(messagePrefix +": " +exc.getMessage(),
- location,
+ location,
exc);
}
}
@@ -2847,7 +2847,7 @@
private void execute(final XMLConsumer consumer,
MyJexlContext jexlContext,
JXPathContext jxpathContext,
- Event startEvent, Event endEvent)
+ Event startEvent, Event endEvent)
throws SAXException {
Event ev = startEvent;
while (ev != endEvent) {
@@ -2863,7 +2863,7 @@
} else {
Expression expr = (Expression)subst;
try {
- Object val =
+ Object val =
getNode(expr, jexlContext, jxpathContext);
if (val instanceof Node) {
executeDOM(consumer,
@@ -2916,17 +2916,17 @@
startElement.localName,
startElement.raw);
} else if (ev instanceof EndPrefixMapping) {
- EndPrefixMapping endPrefixMapping =
+ EndPrefixMapping endPrefixMapping =
(EndPrefixMapping)ev;
consumer.endPrefixMapping(endPrefixMapping.prefix);
} else if (ev instanceof IgnorableWhitespace) {
TextEvent text = (TextEvent)ev;
- characters(jexlContext,
- jxpathContext,
- text,
+ characters(jexlContext,
+ jxpathContext,
+ text,
new CharHandler() {
public void characters(char[] ch, int offset,
- int len)
+ int len)
throws SAXException {
consumer.ignorableWhitespace(ch, offset, len);
}
@@ -2978,9 +2978,9 @@
} else {
Expression expr = (Expression)items;
if (expr.compiledExpression instanceof CompiledExpression) {
- CompiledExpression compiledExpression =
+ CompiledExpression compiledExpression =
(CompiledExpression)expr.compiledExpression;
- Object val =
+ Object val =
compiledExpression.getPointer(jxpathContext,
expr.raw).getNode();
// FIXME: workaround for JXPath bug
@@ -2990,7 +2990,7 @@
iter = compiledExpression.iteratePointers(jxpathContext);
}
} else if (expr.compiledExpression instanceof org.apache.commons.jexl.Expression) {
- org.apache.commons.jexl.Expression e =
+ org.apache.commons.jexl.Expression e =
(org.apache.commons.jexl.Expression)expr.compiledExpression;
Object result = e.evaluate(jexlContext);
if (result != null) {
@@ -2998,7 +2998,7 @@
org.apache.commons.jexl.util.Introspector.getUberspect().getIterator(result, new Info(ev.location.getSystemId(),
ev.location.getLineNumber(),
ev.location.getColumnNumber()));
-
+
}
if (iter == null) {
iter = EMPTY_ITER;
@@ -3006,19 +3006,19 @@
} else {
// literal value
iter = new Iterator() {
-
+
Object val = items;
-
+
public boolean hasNext() {
return val != null;
}
-
+
public Object next() {
Object res = val;
val = null;
return res;
}
-
+
public void remove() {
}
};
@@ -3026,10 +3026,10 @@
}
begin = startForEach.begin == null ? 0 :
getIntValue(startForEach.begin, jexlContext, jxpathContext);
- end = startForEach.end == null ? Integer.MAX_VALUE :
- getIntValue(startForEach.end, jexlContext,
+ end = startForEach.end == null ? Integer.MAX_VALUE :
+ getIntValue(startForEach.end, jexlContext,
jxpathContext);
- step = startForEach.step == null ? 1 :
+ step = startForEach.step == null ? 1 :
getIntValue(startForEach.step, jexlContext,
jxpathContext);
} catch (Exception exc) {
@@ -3042,7 +3042,7 @@
null);
}
int i;
- MyJexlContext localJexlContext =
+ MyJexlContext localJexlContext =
new MyJexlContext(jexlContext);
for (i = 0; i < begin && iter.hasNext(); i++) {
iter.next();
@@ -3053,7 +3053,7 @@
value = iter.next();
if (value instanceof Pointer) {
Pointer ptr = (Pointer)value;
- localJXPathContext =
+ localJXPathContext =
jxpathContext.getRelativeContext(ptr);
try {
value = ptr.getNode();
@@ -3075,7 +3075,7 @@
localJXPathContext,
startForEach.next,
startForEach.endInstruction);
- for (int skip = step-1;
+ for (int skip = step-1;
skip > 0 && iter.hasNext(); --skip) {
iter.next();
}
@@ -3084,7 +3084,7 @@
continue;
} else if (ev instanceof StartChoose) {
StartChoose startChoose = (StartChoose)ev;
- StartWhen startWhen = startChoose.firstChoice;
+ StartWhen startWhen = startChoose.firstChoice;
for (;startWhen != null; startWhen = startWhen.nextChoice) {
Object val;
try {
@@ -3138,7 +3138,7 @@
"set",
EMPTY_ATTRS);
execute(builder, jexlContext, jxpathContext,
- startSet.next,
+ startSet.next,
startSet.endInstruction);
builder.endElement(NS,
"set",
@@ -3155,14 +3155,14 @@
}
value = nodeArr;
}
- jxpathContext.getVariables().declareVariable(startSet.var,
+ jxpathContext.getVariables().declareVariable(startSet.var,
value);
jexlContext.put(startSet.var, value);
ev = startSet.endInstruction.next;
continue;
} else if (ev instanceof StartElement) {
StartElement startElement = (StartElement)ev;
- StartDefine def =
+ StartDefine def =
(StartDefine)definitions.get(startElement.qname);
if (def != null) {
Map attributeMap = new HashMap();
@@ -3177,18 +3177,18 @@
CopyAttribute copy =
(CopyAttribute)attrEvent;
attributeValue = copy.value;
- } else if (attrEvent instanceof
+ } else if (attrEvent instanceof
SubstituteAttribute) {
SubstituteAttribute substEvent =
(SubstituteAttribute)attrEvent;
if (substEvent.substitutions.size() == 1 &&
- substEvent.substitutions.get(0) instanceof
+ substEvent.substitutions.get(0) instanceof
Expression) {
Expression expr = (Expression)
substEvent.substitutions.get(0);
Object val;
try {
- val =
+ val =
getNode(expr,
jexlContext,
jxpathContext);
@@ -3213,7 +3213,7 @@
Expression expr = (Expression)subst;
Object val;
try {
- val =
+ val =
getValue(expr,
jexlContext,
jxpathContext);
@@ -3241,19 +3241,19 @@
startElement.localName,
startElement.raw,
EMPTY_ATTRS);
- executeRaw(builder,
- startElement.next,
+ executeRaw(builder,
+ startElement.next,
startElement.endElement);
builder.endElement(startElement.namespaceURI,
startElement.localName,
startElement.raw);
builder.endDocument();
Node node = builder.getDocument().getDocumentElement();
- MyVariables vars =
+ MyVariables vars =
(MyVariables)jxpathContext.getVariables();
Map saveLocals = vars.localVariables;
vars.localVariables = new HashMap();
- MyJexlContext localJexlContext =
+ MyJexlContext localJexlContext =
new MyJexlContext(globalJexlContext);
// JXPath doesn't handle NodeList, so convert it to
// an array
@@ -3269,7 +3269,7 @@
while (iter.hasNext()) {
Map.Entry e = (Map.Entry)iter.next();
String key = (String)e.getKey();
- StartParameter startParam =
+ StartParameter startParam =
(StartParameter)e.getValue();
Object default_ = startParam.default_;
Object val = attributeMap.get(key);
@@ -3284,7 +3284,7 @@
localJXPathContext.setVariables(vars);
call(ev.location,
startElement.localName,
- consumer,
+ consumer,
localJexlContext, localJXPathContext,
def.body, def.endInstruction);
vars.localVariables = saveLocals;
@@ -3304,7 +3304,7 @@
copy.raw,
copy.type,
copy.value);
- } else if (attrEvent instanceof
+ } else if (attrEvent instanceof
SubstituteAttribute) {
StringBuffer buf = new StringBuffer();
SubstituteAttribute substEvent =
@@ -3319,14 +3319,14 @@
Expression expr = (Expression)subst;
Object val;
try {
- val =
+ val =
getValue(expr,
jexlContext,
jxpathContext);
} catch (Exception e) {
throw new SAXParseException(e.getMessage(),
ev.location,
- e);
+ e);
}
if (val == null) {
val = "";
@@ -3344,10 +3344,10 @@
consumer.startElement(startElement.namespaceURI,
startElement.localName,
startElement.raw,
- attrs);
-
+ attrs);
+
} else if (ev instanceof StartFormatNumber) {
- StartFormatNumber startFormatNumber =
+ StartFormatNumber startFormatNumber =
(StartFormatNumber)ev;
try {
String result =
@@ -3363,7 +3363,7 @@
e);
}
} else if (ev instanceof StartFormatDate) {
- StartFormatDate startFormatDate =
+ StartFormatDate startFormatDate =
(StartFormatDate)ev;
try {
String result =
@@ -3379,19 +3379,19 @@
e);
}
} else if (ev instanceof StartPrefixMapping) {
- StartPrefixMapping startPrefixMapping =
+ StartPrefixMapping startPrefixMapping =
(StartPrefixMapping)ev;
- consumer.startPrefixMapping(startPrefixMapping.prefix,
+ consumer.startPrefixMapping(startPrefixMapping.prefix,
startPrefixMapping.uri);
} else if (ev instanceof Comment) {
TextEvent text = (TextEvent)ev;
final StringBuffer buf = new StringBuffer();
- characters(jexlContext,
- jxpathContext,
- text,
+ characters(jexlContext,
+ jxpathContext,
+ text,
new CharHandler() {
public void characters(char[] ch, int offset,
- int len)
+ int len)
throws SAXException {
buf.append(ch, offset, len);
}
@@ -3480,7 +3480,7 @@
Expression expr = (Expression)subst;
Object val;
try {
- val =
+ val =
getValue(expr,
jexlContext,
jxpathContext);
@@ -3500,13 +3500,13 @@
}
}
uri = buf.toString();
-
+
}
Source input = null;
StartDocument doc;
try {
input = resolver.resolveURI(uri);
-
+
SourceValidity validity = null;
synchronized (cache) {
doc = (StartDocument)cache.get(input.getURI());
@@ -3557,7 +3557,7 @@
Object obj = getValue(startImport.select,
jexlContext,
jxpathContext);
- selectJXPath =
+ selectJXPath =
jxpathContextFactory.newContext(null, obj);
selectJXPath.setVariables(variables);
selectJexl = new MyJexlContext(globalJexlContext);
@@ -3572,7 +3572,7 @@
null);
}
}
- execute(consumer, selectJexl, selectJXPath, doc.next,
+ execute(consumer, selectJexl, selectJXPath, doc.next,
doc.endDocument);
ev = startImport.endInstruction.next;
continue;
1.5 +5 -5 cocoon-2.2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java
Index: LinkStatusGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/LinkStatusGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LinkStatusGenerator.java 3 Sep 2003 15:00:56 -0000 1.4
+++ LinkStatusGenerator.java 22 Oct 2003 18:02:29 -0000 1.5
@@ -50,7 +50,6 @@
*/
package org.apache.cocoon.generation;
-import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
@@ -62,6 +61,7 @@
import org.apache.cocoon.util.Tokenizer;
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
+import org.apache.excalibur.mpool.Resettable;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -87,7 +87,7 @@
* @author Bernhard Huber (huber@apache.org)
* @version CVS $Id$
*/
-public class LinkStatusGenerator extends ServiceableGenerator implements Recyclable, Configurable {
+public class LinkStatusGenerator extends ServiceableGenerator implements Resettable, Configurable {
/** The URI of the namespace of this generator. */
protected static final String URI =
"http://apache.org/cocoon/linkstatus/2.0";
@@ -679,8 +679,8 @@
return false;
}
- public void recycle() {
- super.recycle();
+ public void reset() {
+ super.reset();
this.attributes = null;
//this.excludeCrawlingURL = null;
1.6 +6 -6 cocoon-2.2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java
Index: ServerPagesGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServerPagesGenerator.java 15 Oct 2003 16:55:00 -0000 1.5
+++ ServerPagesGenerator.java 22 Oct 2003 18:02:29 -0000 1.6
@@ -289,7 +289,7 @@
/**
* Recycle the generator by removing references
*/
- public void recycle() {
+ public void reset() {
if (this.generator != null) {
this.programGenerator.release(this.generator);
this.generator = null;
@@ -299,10 +299,10 @@
this.inputSource = null;
}
if (this.completionPipe != null) {
- this.completionPipe.recycle();
+ this.completionPipe.reset();
this.completionPipe = null;
}
- super.recycle();
+ super.reset();
}
/**
@@ -474,9 +474,9 @@
}
}
- public void recycle() {
+ public void reset() {
this.eventStack.clear();
- super.recycle();
+ super.reset();
}
}
}
1.4 +3 -3 cocoon-2.2/src/java/org/apache/cocoon/generation/ServletGenerator.java
Index: ServletGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/ServletGenerator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServletGenerator.java 15 Oct 2003 16:55:01 -0000 1.3
+++ ServletGenerator.java 22 Oct 2003 18:02:29 -0000 1.4
@@ -87,8 +87,8 @@
/**
* Recycle the generator by removing references
*/
- public void recycle() {
- super.recycle();
+ public void reset() {
+ super.reset();
this.request = null;
this.response = null;
this.context = null;
1.6 +5 -5 cocoon-2.2/src/java/org/apache/cocoon/generation/StreamGenerator.java
Index: StreamGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/StreamGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StreamGenerator.java 24 Sep 2003 21:41:12 -0000 1.5
+++ StreamGenerator.java 22 Oct 2003 18:02:29 -0000 1.6
@@ -103,20 +103,20 @@
* Recycle this component.
* All instance variables are set to <code>null</code>.
*/
- public void recycle() {
- super.recycle();
+ public void reset() {
+ super.reset();
this.inputSource = null;
}
/**
* Generate XML data out of request InputStream.
*/
- public void generate()
+ public void generate()
throws IOException, SAXException, ProcessingException {
SAXParser parser = null;
int len = 0;
String contentType = null;
-
+
Request request = ObjectModelHelper.getRequest(this.objectModel);
try {
contentType = request.getContentType();
1.5 +3 -3 cocoon-2.2/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java
Index: XPathDirectoryGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/XPathDirectoryGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XPathDirectoryGenerator.java 23 Sep 2003 22:46:44 -0000 1.4
+++ XPathDirectoryGenerator.java 22 Oct 2003 18:02:29 -0000 1.5
@@ -243,11 +243,11 @@
/**
* Recycle resources
*/
- public void recycle() {
+ public void reset() {
this.xpath = null;
this.doc = null;
//this.parser = null;
//this.processor = null;
- super.recycle();
+ super.reset();
}
}