tcurdt 2003/01/12 08:31:20
Modified: src/blocks/precept/java/org/apache/cocoon/precept
ConfigurationHelper.java Constraint.java
Context.java Instance.java InstanceFactory.java
InstanceTransformer.java
InvalidXPathSyntaxException.java
NoSuchNodeException.java Preceptor.java
PreceptorViolationException.java
src/blocks/precept/java/org/apache/cocoon/precept/acting
AbstractMethodAction.java
AbstractPreceptorAction.java
PreceptorDemoAction.java
src/blocks/precept/java/org/apache/cocoon/precept/preceptors
AbstractPreceptor.java PreceptorBuilder.java
src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax
AbstractPreceptorNode.java
AttributePreceptorNode.java ConstraintFactory.java
ElementPreceptorNode.java PreceptorBuilderImpl.java
PreceptorImpl.java
src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints
AbstractConstraint.java ChoiceConstraint.java
RegexprConstraint.java
src/blocks/precept/java/org/apache/cocoon/precept/stores
AbstractInstance.java
src/blocks/precept/java/org/apache/cocoon/precept/stores/bean
InstanceImpl.java
src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test
CocoonInstallationBean.java SystemBean.java
UserBean.java
src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple
AttributeNode.java ElementNode.java
InstanceImpl.java Node.java
Log:
fixed the formatting due to a line ending mixup
Revision Changes Path
1.2 +78 -60
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/ConfigurationHelper.java
Index: ConfigurationHelper.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/ConfigurationHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConfigurationHelper.java 29 Oct 2002 15:48:32 -0000 1.1
+++ ConfigurationHelper.java 12 Jan 2003 16:31:18 -0000 1.2
@@ -1,76 +1,94 @@
/*
- * @version: Mar 26, 2002
-
- * @author Torsten Curdt <[EMAIL PROTECTED]>
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
+ used to endorse or promote products derived from this software without
+ prior written permission. For written permission, please contact
+ [EMAIL PROTECTED]
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation and was originally created by
+ Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
+ Software Foundation, please see <http://www.apache.org/>.
- */
+*/
package org.apache.cocoon.precept;
-
import org.apache.avalon.framework.configuration.Configuration;
+/*
+ * @version: Mar 26, 2002
+ * @author Torsten Curdt <[EMAIL PROTECTED]>
+ */
-public class ConfigurationHelper {
-
- public final static String toString( Configuration conf ) {
-
- String result = "<" + conf.getName();
-
-
-
- String[] attributes = conf.getAttributeNames();
-
- for(int i=0;i<attributes.length;i++) {
-
- try {
-
- result += " " + attributes[i] + "=\"" +
conf.getAttribute(attributes[i]) + "\"";
-
- }
-
- catch(Throwable t) {
-
- }
-
- }
-
-
-
- result += ">";
-
-
-
- try {
-
- result += conf.getValue();
-
- }
-
- catch(Throwable t) {
-
- }
-
-
-
- Configuration[] childs = conf.getChildren();
-
- for(int i=0;i<childs.length;i++) {
- Configuration child = childs[i];
+public class ConfigurationHelper {
- result += toString(child);
+ public final static String toString(Configuration conf) {
+ String result = "<" + conf.getName();
+ String[] attributes = conf.getAttributeNames();
+
+ for (int i = 0; i < attributes.length; i++) {
+ try {
+ result += " " + attributes[i] + "=\"" +
conf.getAttribute(attributes[i]) + "\"";
+ }
+ catch (Throwable t) {
+ }
+ }
+
+ result += ">";
+
+ try {
+ result += conf.getValue();
+ }
+ catch (Throwable t) {
+ }
+
+ Configuration[] childs = conf.getChildren();
+ for (int i = 0; i < childs.length; i++) {
+ Configuration child = childs[i];
+ result += toString(child);
+ }
+ return (result + "</" + conf.getName() + ">");
}
-
-
-
- return(result + "</" + conf.getName() + ">");
-
- }
-
}
-
1.3 +4 -65
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Constraint.java
Index: Constraint.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Constraint.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Constraint.java 7 Jan 2003 23:56:10 -0000 1.2
+++ Constraint.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,131 +1,70 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
-
-
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public interface Constraint {
+ public boolean isSatisfiedBy(Object value, Context context);
- public boolean isSatisfiedBy( Object value, Context context );
-
- public String getId();
-
- public String getType();
+ public String getId();
- public void toSAX(ContentHandler handler) throws SAXException;
+ public String getType();
+ public void toSAX(ContentHandler handler) throws SAXException;
}
1.3 +0 -59
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Context.java
Index: Context.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Context.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Context.java 7 Jan 2003 23:56:10 -0000 1.2
+++ Context.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,118 +1,59 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
package org.apache.cocoon.precept;
-
-
-
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class Context {
1.2 +11 -65
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Instance.java
Index: Instance.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Instance.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Instance.java 29 Oct 2002 15:48:32 -0000 1.1
+++ Instance.java 12 Jan 2003 16:31:18 -0000 1.2
@@ -1,105 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
import org.apache.avalon.framework.component.Component;
@@ -107,31 +55,29 @@
import org.xml.sax.SAXException;
-
import java.util.Collection;
/*
-
* @version: Mar 15, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public interface Instance extends Component {
- public String ROLE = "org.apache.cocoon.precept.Instance";
+ public String ROLE = "org.apache.cocoon.precept.Instance";
+
+ public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException;
+
+ public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException;
+ public Object getValue(String xpath) throws InvalidXPathSyntaxException,
NoSuchNodeException;
- public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException;
- public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException;
- public Object getValue(String xpath) throws InvalidXPathSyntaxException,
NoSuchNodeException;
+ public Collection getNodePaths();
- public Collection getNodePaths();
+ public void setPreceptor(Preceptor preceptor);
- public void setPreceptor( Preceptor preceptor );
- public Preceptor getPreceptor();
+ public Preceptor getPreceptor();
+ public void toSAX(ContentHandler handler, boolean constraints) throws
SAXException;
- public void toSAX( ContentHandler handler, boolean constraints) throws
SAXException;
- public long getLastModified();
+ public long getLastModified();
}
1.3 +73 -126
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InstanceFactory.java
Index: InstanceFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InstanceFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InstanceFactory.java 7 Jan 2003 23:56:10 -0000 1.2
+++ InstanceFactory.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,105 +1,55 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
package org.apache.cocoon.precept;
import java.util.HashMap;
@@ -118,105 +68,102 @@
import org.apache.cocoon.precept.preceptors.PreceptorBuilder;
/*
-
* @version: Mar 18, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class InstanceFactory extends AbstractLogEnabled implements
Component, Configurable, Composable, ThreadSafe {
- public final static String ROLE =
"org.apache.cocoon.precept.InstanceFactory";
+ public final static String ROLE =
"org.apache.cocoon.precept.InstanceFactory";
- private ComponentManager manager = null;
- private HashMap instanceConfigurationMap;
+ private ComponentManager manager = null;
+ private HashMap instanceConfigurationMap;
- public void configure(Configuration conf) throws ConfigurationException {
- instanceConfigurationMap = new HashMap();
- Configuration[] instances = conf.getChildren("instance");
+ public void configure(Configuration conf) throws ConfigurationException {
+ instanceConfigurationMap = new HashMap();
+ Configuration[] instances = conf.getChildren("instance");
- if (instances != null) {
- for (int p = 0; p < instances.length; p++) {
- Configuration instance = instances[p];
- String name = instance.getAttribute("name");
- getLogger().debug("registering instance [name=" +
String.valueOf(name) + ";impl=" + String.valueOf(instance.getAttribute("impl"))
+ "]");
- if (instanceConfigurationMap.containsKey(name)) {
+ if (instances != null) {
+ for (int p = 0; p < instances.length; p++) {
+ Configuration instance = instances[p];
+ String name = instance.getAttribute("name");
+ getLogger().debug("registering instance [name=" +
String.valueOf(name) + ";impl=" + String.valueOf(instance.getAttribute("impl"))
+ "]");
+ if (instanceConfigurationMap.containsKey(name)) {
- getLogger().error("instance [name=" + String.valueOf(name) + "]
appears more than once");
+ getLogger().error("instance [name=" +
String.valueOf(name) + "] appears more than once");
- throw new ConfigurationException("instance [name=" +
String.valueOf(name) + "] appears more than once");
+ throw new ConfigurationException("instance [name=" +
String.valueOf(name) + "] appears more than once");
- }
+ }
- instanceConfigurationMap.put(name, instance);
- }
+ instanceConfigurationMap.put(name, instance);
+ }
+ }
+ else {
+ getLogger().warn("no instances are configured");
+ }
}
- else {
- getLogger().warn("no instances are configured");
+
+ public void compose(ComponentManager manager) throws ComponentException {
+ this.manager = manager;
}
- }
- public void compose(ComponentManager manager) throws ComponentException {
- this.manager = manager;
- }
-
- public Instance createInstance( String name ) {
- getLogger().debug("creating instance [" + String.valueOf(name) + "]");
- Configuration instanceConf = (Configuration)
instanceConfigurationMap.get(name);
- ComponentSelector instanceSelector = null;
- Instance instance = null;
- try {
- instanceSelector = (ComponentSelector) manager.lookup(Instance.ROLE +
"Selector");
- instance = (Instance)
instanceSelector.select(instanceConf.getAttribute("impl"));
-
- Configuration builderConf = instanceConf.getChild("preceptor");
- if (builderConf != null) {
- ComponentSelector preceptorBuilderSelector = null;
- PreceptorBuilder preceptorBuilder = null;
+ public Instance createInstance(String name) {
+ getLogger().debug("creating instance [" + String.valueOf(name) +
"]");
+ Configuration instanceConf = (Configuration)
instanceConfigurationMap.get(name);
+ ComponentSelector instanceSelector = null;
+ Instance instance = null;
try {
- preceptorBuilderSelector = (ComponentSelector)
manager.lookup(PreceptorBuilder.ROLE + "Selector");
- preceptorBuilder = (PreceptorBuilder)
preceptorBuilderSelector.select(builderConf.getAttribute("impl"));
-
- String uri = builderConf.getAttribute("uri");
-
- getLogger().debug("building preceptor from [" +
String.valueOf(uri) + "]");
-
- //FIXME: use a resolver here
- Preceptor newPreceptor = preceptorBuilder.buildPreceptor(uri);
+ instanceSelector = (ComponentSelector)
manager.lookup(Instance.ROLE + "Selector");
+ instance = (Instance)
instanceSelector.select(instanceConf.getAttribute("impl"));
- instance.setPreceptor( newPreceptor );
+ Configuration builderConf = instanceConf.getChild("preceptor");
+ if (builderConf != null) {
+ ComponentSelector preceptorBuilderSelector = null;
+ PreceptorBuilder preceptorBuilder = null;
+ try {
+ preceptorBuilderSelector = (ComponentSelector)
manager.lookup(PreceptorBuilder.ROLE + "Selector");
+ preceptorBuilder = (PreceptorBuilder)
preceptorBuilderSelector.select(builderConf.getAttribute("impl"));
+
+ String uri = builderConf.getAttribute("uri");
+
+ getLogger().debug("building preceptor from [" +
String.valueOf(uri) + "]");
+
+ //FIXME: use a resolver here
+ Preceptor newPreceptor =
preceptorBuilder.buildPreceptor(uri);
+
+ instance.setPreceptor(newPreceptor);
+ }
+ catch (ComponentException e) {
+ if (preceptorBuilderSelector != null) {
+ getLogger().error("could not get preceptor builder",
e);
+ }
+ else {
+ getLogger().error("could not get preceptor builder
selector", e);
+ }
+ }
+ catch (Exception e) {
+ getLogger().error("", e);
+ e.printStackTrace(System.out);
+ }
+ finally {
+ manager.release(preceptorBuilder);
+ manager.release(preceptorBuilderSelector);
+ }
+ }
}
- catch(ComponentException e) {
- if(preceptorBuilderSelector != null) {
- getLogger().error("could not get preceptor builder",e);
- }
- else {
- getLogger().error("could not get preceptor builder selector",e);
- }
+ catch (ConfigurationException e) {
+ getLogger().error("", e);
}
- catch(Exception e) {
- getLogger().error("",e);
- e.printStackTrace(System.out);
+ catch (ComponentException e) {
+ getLogger().error("could not get instance selector", e);
}
finally {
- manager.release(preceptorBuilder);
- manager.release(preceptorBuilderSelector);
+ //manager.release(instance);
+ //should be released while session invalidation
+ manager.release(instanceSelector);
}
- }
- }
- catch(ConfigurationException e) {
- getLogger().error("",e);
- }
- catch(ComponentException e) {
- getLogger().error("could not get instance selector",e);
- }
- finally {
- //manager.release(instance);
- //should be released while session invalidation
- manager.release(instanceSelector);
+ return (instance);
}
- return(instance);
- }
}
1.3 +184 -443
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InstanceTransformer.java
Index: InstanceTransformer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InstanceTransformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InstanceTransformer.java 7 Jan 2003 23:56:10 -0000 1.2
+++ InstanceTransformer.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,105 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
import java.io.IOException;
@@ -128,418 +76,211 @@
/*
* @author Torsten Curdt <[EMAIL PROTECTED]>
*/
-public class InstanceTransformer extends AbstractTransformer {
- //implements Cacheable {
-
- public final static String NS = "http://www.dff.st/ns/desire/instance/1.0";
-
-
-
- public final static Attributes NOATTR = new AttributesImpl();
-
-
-
- public final static String TAG_INSERTINSTANCE = "insert-instance";
-
- public final static String TAG_INSERTINSTANCE_ATTR_ID = "id";
-
-
-
- public final static String TAG_INSTANCE = "instance";
-
- public final static String TAG_INSTANCE_ATTR_ID = "id";
-
-
-
- public final static String TAG_INSERTVIOLATIONS = "insert-violations";
-
-
-
- public final static String TAG_BUTTON = "button";
-
-
-
- public final static String TAG_LABEL = "label";
-
-
- public final static String TAG_OUTPUT = "output";
-
- public final static String TAG_TEXTBOX = "textbox";
-
- public final static String TAG_PASSWORD = "password";
-
- public final static String TAG_SELECTBOOLEAN = "selectBoolean";
-
- public final static String TAG_SELECTONE = "selectOne";
-
-
-
- public final static String TAG_SELECTMANY = "selectMany";
-
-
-
- public final static String TAG_COMMON_ATTR_REF = "ref";
-
- public final static String TAG_COMMON_ATTR_INSTANCE = "instance";
-
-
-
- private Request request;
-
- private Session session;
-
- private Instance defaultInstance;
-
- private Object value;
-
- private String prefix;
-
-
-
- public void setup(SourceResolver resolver, Map objectModel, String source,
Parameters parameters) throws ProcessingException, SAXException, IOException {
-
- request = ObjectModelHelper.getRequest(objectModel);
-
- if (request == null) {
+public class InstanceTransformer extends AbstractTransformer {
+ //implements Cacheable {
- getLogger().debug("no request object");
+ public final static String NS =
"http://www.dff.st/ns/desire/instance/1.0";
- throw new ProcessingException("no request object");
+ public final static Attributes NOATTR = new AttributesImpl();
+ public final static String TAG_INSERTINSTANCE = "insert-instance";
+ public final static String TAG_INSERTINSTANCE_ATTR_ID = "id";
+ public final static String TAG_INSTANCE = "instance";
+ public final static String TAG_INSTANCE_ATTR_ID = "id";
+ public final static String TAG_INSERTVIOLATIONS = "insert-violations";
+ public final static String TAG_BUTTON = "button";
+ public final static String TAG_LABEL = "label";
+ public final static String TAG_OUTPUT = "output";
+ public final static String TAG_TEXTBOX = "textbox";
+ public final static String TAG_PASSWORD = "password";
+ public final static String TAG_SELECTBOOLEAN = "selectBoolean";
+ public final static String TAG_SELECTONE = "selectOne";
+ public final static String TAG_SELECTMANY = "selectMany";
+ public final static String TAG_COMMON_ATTR_REF = "ref";
+ public final static String TAG_COMMON_ATTR_INSTANCE = "instance";
+
+
+ private Request request;
+ private Session session;
+ private Instance defaultInstance;
+ private Object value;
+ private String prefix;
+
+
+ public void setup(SourceResolver resolver, Map objectModel, String
source, Parameters parameters) throws ProcessingException, SAXException,
IOException {
+ request = ObjectModelHelper.getRequest(objectModel);
+
+ if (request == null) {
+ getLogger().debug("no request object");
+ throw new ProcessingException("no request object");
+ }
+ session = request.getSession(false);
+ defaultInstance = null;
+ prefix = null;
}
+ public void startElement(String uri, String name, String raw, Attributes
attributes) throws SAXException {
+ if (NS.equals(uri)) {
+ if (prefix == null) {
+ prefix = raw.substring(0, raw.length() - name.length() - 1);
+ getLogger().debug("found prefix [" + String.valueOf(prefix)
+ "] for namespace [" + NS + "]");
+ }
-
- session = request.getSession(false);
-
- defaultInstance = null;
-
- prefix = null;
-
- }
-
-
-
-
-
- public void startElement(String uri, String name, String raw, Attributes
attributes) throws SAXException {
-
- if (NS.equals(uri)) {
-
- if (prefix == null) {
-
- prefix = raw.substring(0, raw.length() - name.length() - 1);
-
- getLogger().debug("found prefix [" + String.valueOf(prefix) + "] for
namespace [" + NS + "]");
-
- }
-
-
-
- if (TAG_INSERTINSTANCE.equals(name)) {
-
- if (session != null) {
-
- String id = attributes.getValue(TAG_INSERTINSTANCE_ATTR_ID);
-
-
-
- getLogger().debug("inserting instance [id=" + String.valueOf(id) +
"]");
-
- Instance instance = (Instance) session.getAttribute(id);
-
- if (instance != null) {
-
- instance.toSAX(this, true);
-
- }
-
- else {
-
- getLogger().debug("could not find instance [id=" +
String.valueOf(id) + "]");
-
- }
-
+ if (TAG_INSERTINSTANCE.equals(name)) {
+ if (session != null) {
+ String id =
attributes.getValue(TAG_INSERTINSTANCE_ATTR_ID);
+ getLogger().debug("inserting instance [id=" +
String.valueOf(id) + "]");
+
+ Instance instance = (Instance) session.getAttribute(id);
+ if (instance != null) {
+ instance.toSAX(this, true);
+ }
+ else {
+ getLogger().debug("could not find instance [id=" +
String.valueOf(id) + "]");
+ }
+ }
+ else {
+ getLogger().debug("no session - no instance");
+ }
+ }
+ else if (TAG_INSERTVIOLATIONS.equals(name)) {
+ Collection violations = (Collection)
request.getAttribute(AbstractPreceptorAction.PRECEPTORVIOLATIONS);
+ if (violations != null) {
+ for (Iterator it = violations.iterator(); it.hasNext();)
{
+ Constraint constraint = (Constraint) it.next();
+ super.startElement(uri, "constraint", prefix + ":" +
"constraint", NOATTR);
+ String v = String.valueOf(constraint);
+ super.characters(v.toCharArray(), 0, v.length());
+ super.endElement(uri, "constraint", prefix + ":" +
"constraint");
+ }
+ }
+ }
+ else if (TAG_INSTANCE.equals(name)) {
+ if (session != null) {
+ String id = attributes.getValue(TAG_INSTANCE_ATTR_ID);
+ defaultInstance = (Instance) session.getAttribute(id);
+ if (defaultInstance != null) {
+ getLogger().debug("using default instance [id=" +
String.valueOf(id) + "]");
+ }
+ else {
+ getLogger().error("could not find instance [id=" +
String.valueOf(id) + "]");
+ }
+ }
+ }
+ else if (TAG_OUTPUT.equals(name) ||
+ TAG_TEXTBOX.equals(name) ||
+ TAG_PASSWORD.equals(name) ||
+ TAG_SELECTBOOLEAN.equals(name) ||
+ TAG_SELECTONE.equals(name)) {
+ String ref = attributes.getValue(TAG_COMMON_ATTR_REF);
+ String id = attributes.getValue(TAG_COMMON_ATTR_INSTANCE);
+
+ getLogger().debug("[" + String.valueOf(name) + "] getting
value from [" + String.valueOf(ref) + "]");
+
+ if (ref != null) {
+ Instance instance = defaultInstance;
+
+ if (id != null) {
+ if (session != null) {
+ instance = (Instance) session.getAttribute(id);
+ if (instance != null) {
+ getLogger().debug("using instance [id=" +
String.valueOf(id) + "]");
+ }
+ else {
+ getLogger().error("could not find instance
[id=" + String.valueOf(id) + "]");
+ }
+ }
+ }
+
+ super.startElement(uri, name, raw, attributes);
+
+ try {
+ value = instance.getValue(ref);
+
+ getLogger().debug("[" + String.valueOf(ref) + "] = "
+ String.valueOf(value));
+
+ super.startElement(uri, "value", prefix + ":" +
"value", NOATTR);
+ if (value != null) {
+ String v = String.valueOf(value);
+ super.characters(v.toCharArray(), 0, v.length());
+ }
+
+ super.endElement(uri, "value", prefix + ":" +
"value");
+
+ if (instance.getPreceptor() != null) {
+ Collection constraints =
instance.getPreceptor().getConstraintsFor(ref);
+ if (constraints != null) {
+ for (Iterator it = constraints.iterator();
it.hasNext();) {
+ Constraint constraint = (Constraint)
it.next();
+ constraint.toSAX(this);
+ }
+ }
+ }
+ }
+ catch (InvalidXPathSyntaxException e) {
+ throw new SAXException(e);
+ }
+ catch (NoSuchNodeException e) {
+ //throw new SAXException(e);
+ }
+ }
+ else {
+ throw new SAXException("[" + String.valueOf(name) + "]
needs an \"" + TAG_COMMON_ATTR_REF + "\" attribute");
+ }
+ }
+ else if (TAG_SELECTMANY.equals(name)) {
+ //NYI
+ throw new SAXException("NYI");
+ }
+ else if (TAG_BUTTON.equals(name)) {
+ //NYI
+ super.startElement(uri, name, raw, attributes);
+ }
+ else {
+ getLogger().error("unknown element [" + String.valueOf(name)
+ "]");
+ super.startElement(uri, name, raw, attributes);
+ }
}
-
else {
-
- getLogger().debug("no session - no instance");
-
+ super.startElement(uri, name, raw, attributes);
}
+ }
- }
-
- else if (TAG_INSERTVIOLATIONS.equals(name)) {
-
- Collection violations = (Collection)
request.getAttribute(AbstractPreceptorAction.PRECEPTORVIOLATIONS);
-
- if (violations != null) {
-
- for (Iterator it = violations.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- super.startElement(uri, "constraint", prefix + ":" +
"constraint", NOATTR);
-
- String v = String.valueOf(constraint);
-
- super.characters(v.toCharArray(), 0, v.length());
-
- super.endElement(uri, "constraint", prefix + ":" + "constraint");
-
- }
-
- }
-
- }
-
- else if (TAG_INSTANCE.equals(name)) {
-
- if (session != null) {
-
- String id = attributes.getValue(TAG_INSTANCE_ATTR_ID);
-
- defaultInstance = (Instance) session.getAttribute(id);
-
- if (defaultInstance != null) {
-
- getLogger().debug("using default instance [id=" +
String.valueOf(id) + "]");
-
- }
-
- else {
-
- getLogger().error("could not find instance [id=" +
String.valueOf(id) + "]");
-
- }
-
- }
-
- }
-
- else if (TAG_OUTPUT.equals(name) ||
-
- TAG_TEXTBOX.equals(name) ||
-
- TAG_PASSWORD.equals(name) ||
-
- TAG_SELECTBOOLEAN.equals(name) ||
-
- TAG_SELECTONE.equals(name)) {
-
- String ref = attributes.getValue(TAG_COMMON_ATTR_REF);
-
- String id = attributes.getValue(TAG_COMMON_ATTR_INSTANCE);
-
-
-
- getLogger().debug("[" + String.valueOf(name) + "] getting value from
[" + String.valueOf(ref) + "]");
-
-
-
- if (ref != null) {
-
- Instance instance = defaultInstance;
-
-
-
- if (id != null) {
-
- if (session != null) {
-
- instance = (Instance) session.getAttribute(id);
-
- if (instance != null) {
-
- getLogger().debug("using instance [id=" + String.valueOf(id)
+ "]");
-
- }
-
- else {
-
- getLogger().error("could not find instance [id=" +
String.valueOf(id) + "]");
-
- }
+ public void endElement(String uri, String name, String raw) throws
SAXException {
+ if (NS.equals(uri)) {
+ if (TAG_INSERTINSTANCE.equals(name)) {
}
-
- }
-
-
-
- super.startElement(uri, name, raw, attributes);
-
- try {
-
- value = instance.getValue(ref);
-
-
-
- getLogger().debug("[" + String.valueOf(ref) + "] = " +
String.valueOf(value));
-
-
-
- super.startElement(uri, "value", prefix + ":" + "value", NOATTR);
-
- if (value != null) {
-
- String v = String.valueOf(value);
-
- super.characters(v.toCharArray(),0,v.length());
-
+ else if (TAG_INSERTVIOLATIONS.equals(name)) {
}
-
- super.endElement(uri, "value", prefix + ":" + "value");
-
-
-
- if (instance.getPreceptor() != null) {
-
- Collection constraints =
instance.getPreceptor().getConstraintsFor(ref);
-
- if (constraints != null) {
-
- for (Iterator it = constraints.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- constraint.toSAX(this);
-
- }
-
- }
-
+ else if (TAG_INSTANCE.equals(name)) {
+ }
+ else if (TAG_OUTPUT.equals(name) ||
+ TAG_TEXTBOX.equals(name) ||
+ TAG_PASSWORD.equals(name) ||
+ TAG_SELECTBOOLEAN.equals(name) ||
+ TAG_SELECTONE.equals(name)) {
+ super.endElement(uri, name, raw);
+ }
+ else if (TAG_SELECTMANY.equals(name)) {
+ }
+ else if (TAG_BUTTON.equals(name)) {
+ super.endElement(uri, name, raw);
+ }
+ else {
+ getLogger().error("unknown element [" + String.valueOf(name)
+ "]");
+ super.endElement(uri, name, raw);
}
-
- }
-
- catch (InvalidXPathSyntaxException e) {
-
- throw new SAXException(e);
-
- }
-
- catch (NoSuchNodeException e) {
-
- //throw new SAXException(e);
-
- }
-
}
-
else {
-
- throw new SAXException("[" + String.valueOf(name) + "] needs an
\"" + TAG_COMMON_ATTR_REF + "\" attribute");
-
+ super.endElement(uri, name, raw);
}
-
- }
-
- else if (TAG_SELECTMANY.equals(name)) {
-
- //NYI
-
- throw new SAXException("NYI");
-
- }
-
- else if (TAG_BUTTON.equals(name)) {
-
- //NYI
-
- super.startElement(uri, name, raw, attributes);
-
- }
-
- else {
-
- getLogger().error("unknown element [" + String.valueOf(name) + "]");
-
- super.startElement(uri, name, raw, attributes);
-
- }
-
}
- else {
-
- super.startElement(uri, name, raw, attributes);
-
+ public void characters(char[] chars, int start, int len) throws
SAXException {
+ super.characters(chars, start, len);
}
-
- }
-
-
-
-
-
- public void endElement(String uri, String name, String raw) throws
SAXException {
-
- if (NS.equals(uri)) {
-
- if (TAG_INSERTINSTANCE.equals(name)) {
-
- }
-
- else if (TAG_INSERTVIOLATIONS.equals(name)) {
-
- }
-
- else if (TAG_INSTANCE.equals(name)) {
-
- }
-
- else if (TAG_OUTPUT.equals(name) ||
-
- TAG_TEXTBOX.equals(name) ||
-
- TAG_PASSWORD.equals(name) ||
-
- TAG_SELECTBOOLEAN.equals(name) ||
-
- TAG_SELECTONE.equals(name) ) {
-
- super.endElement(uri, name, raw);
-
- }
-
- else if (TAG_SELECTMANY.equals(name)) {
-
- }
-
- else if (TAG_BUTTON.equals(name)) {
-
- super.endElement(uri, name, raw);
-
- }
-
- else {
-
- getLogger().error("unknown element [" + String.valueOf(name) + "]");
-
- super.endElement(uri, name, raw);
-
- }
-
- }
-
- else {
-
- super.endElement(uri, name, raw);
-
- }
-
- }
-
-
-
- public void characters(char[] chars, int start, int len) throws
SAXException {
-
- super.characters(chars, start, len);
-
- }
/**
* Generate the unique key.
1.2 +7 -72
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InvalidXPathSyntaxException.java
Index: InvalidXPathSyntaxException.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/InvalidXPathSyntaxException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InvalidXPathSyntaxException.java 29 Oct 2002 15:48:32 -0000 1.1
+++ InvalidXPathSyntaxException.java 12 Jan 2003 16:31:18 -0000 1.2
@@ -1,136 +1,71 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
-
-
import org.apache.avalon.framework.CascadingException;
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class InvalidXPathSyntaxException extends CascadingException {
- public InvalidXPathSyntaxException(String s) {
-
- super(s);
-
- }
-
-
-
- public InvalidXPathSyntaxException(Throwable t) {
-
- super("",t);
-
- }
+ public InvalidXPathSyntaxException(String s) {
+ super(s);
+ }
+
+ public InvalidXPathSyntaxException(Throwable t) {
+ super("", t);
+ }
}
1.2 +6 -69
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/NoSuchNodeException.java
Index: NoSuchNodeException.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/NoSuchNodeException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NoSuchNodeException.java 29 Oct 2002 15:48:32 -0000 1.1
+++ NoSuchNodeException.java 12 Jan 2003 16:31:18 -0000 1.2
@@ -1,136 +1,73 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
-
import org.apache.avalon.framework.CascadingException;
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class NoSuchNodeException extends CascadingException {
- public NoSuchNodeException(String s) {
-
- super(s);
-
- }
-
-
-
- public NoSuchNodeException(Throwable t) {
+ public NoSuchNodeException(String s) {
+ super(s);
+ }
- super("",t);
- }
+ public NoSuchNodeException(Throwable t) {
+ super("", t);
+ }
}
1.3 +6 -68
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Preceptor.java
Index: Preceptor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/Preceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Preceptor.java 7 Jan 2003 23:56:10 -0000 1.2
+++ Preceptor.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,105 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
import java.util.Collection;
@@ -107,30 +55,20 @@
import org.apache.avalon.framework.component.Component;
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public interface Preceptor extends Component {
- public String ROLE = "org.apache.cocoon.precept.Preceptor";
-
-
- public Collection getConstraintsFor( String xpath ) throws
InvalidXPathSyntaxException, NoSuchNodeException;
-
-
- public boolean isValidNode( String xpath ) throws
InvalidXPathSyntaxException;
-
-
- public void buildInstance( Instance instance );
-
+ public String ROLE = "org.apache.cocoon.precept.Preceptor";
- public Collection validate(Instance instance, String xpath, Context
context) throws InvalidXPathSyntaxException, NoSuchNodeException;
+ public Collection getConstraintsFor(String xpath) throws
InvalidXPathSyntaxException, NoSuchNodeException;
- public Collection validate(Instance instance, Context context) throws
InvalidXPathSyntaxException;
+ public boolean isValidNode(String xpath) throws
InvalidXPathSyntaxException;
+ public void buildInstance(Instance instance);
+ public Collection validate(Instance instance, String xpath, Context
context) throws InvalidXPathSyntaxException, NoSuchNodeException;
+ public Collection validate(Instance instance, Context context) throws
InvalidXPathSyntaxException;
}
1.2 +6 -68
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/PreceptorViolationException.java
Index: PreceptorViolationException.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/PreceptorViolationException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreceptorViolationException.java 29 Oct 2002 15:48:32 -0000 1.1
+++ PreceptorViolationException.java 12 Jan 2003 16:31:18 -0000 1.2
@@ -1,136 +1,74 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept;
-
import org.apache.avalon.framework.CascadingException;
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class PreceptorViolationException extends CascadingException {
- public PreceptorViolationException(String s) {
-
- super(s);
-
- }
-
-
-
- public PreceptorViolationException(Throwable t) {
+ public PreceptorViolationException(String s) {
+ super(s);
+ }
- super("",t);
- }
+ public PreceptorViolationException(Throwable t) {
+ super("", t);
+ }
}
1.3 +3 -109
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/AbstractMethodAction.java
Index: AbstractMethodAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/AbstractMethodAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractMethodAction.java 29 Oct 2002 19:53:10 -0000 1.2
+++ AbstractMethodAction.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,104 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
package org.apache.cocoon.precept.acting;
@@ -128,92 +77,61 @@
/*
-
* @version: Feb 25, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public abstract class AbstractMethodAction extends
ConfigurableComposerAction {
-
private static final String ACTION_METHOD_PREFIX = "do";
-
private static final String ACTION_METHOD_PARAMETER = "method";
-
private static final String ACTION_METHOD_REQUEST_PARAMETER_PREFIX =
"cocoon-method-";
-
private HashMap methodIndex = null;
- public static final String extractMethod( Request request ) {
+ public static final String extractMethod(Request request) {
Enumeration parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
String parameterName = (String) parameterNames.nextElement();
if
(parameterName.startsWith(ACTION_METHOD_REQUEST_PARAMETER_PREFIX)) {
-
return(parameterName.substring(ACTION_METHOD_REQUEST_PARAMETER_PREFIX.length()));
+ return
(parameterName.substring(ACTION_METHOD_REQUEST_PARAMETER_PREFIX.length()));
}
}
- return(null);
+ return (null);
}
public void configure(Configuration conf) throws ConfigurationException {
-
super.configure(conf);
-
if (methodIndex == null) {
try {
-
Method[] methods = this.getClass().getMethods();
-
methodIndex = new HashMap();
-
int prefixLen = ACTION_METHOD_PREFIX.length();
for (int i = 0; i < methods.length; i++) {
-
String methodName = methods[i].getName();
-
if (methodName.startsWith(ACTION_METHOD_PREFIX)) {
-
String actionName = methodName.substring(prefixLen,
prefixLen + 1).toLowerCase() +
-
methodName.substring(prefixLen + 1);
-
methodIndex.put(actionName, methods[i]);
-
if (getLogger().isDebugEnabled()) {
-
getLogger().debug("registered method \"" +
methodName + "\" as action \"" + actionName + "\"");
-
}
-
}
-
}
-
}
-
catch (Exception e) {
-
throw new ConfigurationException("cannot get methods by
reflection", e);
-
}
-
}
-
}
-
public Map introspection(Redirector redirector, SourceResolver resolver,
Map objectModel, String source, Parameters parameters) throws Exception {
-
return (EMPTY_MAP);
-
}
@@ -227,51 +145,27 @@
}
if (actionMethod != null) {
-
Method method = (Method) methodIndex.get(actionMethod);
-
if (method != null) {
-
getLogger().debug("calling method [" +
String.valueOf(actionMethod) + "]");
-
return ((Map) method.invoke(this, new Object[]{redirector,
resolver, objectModel, source, parameters}));
-
}
-
else {
-
throw new Exception("action has no method \"" + actionMethod
+ "\"");
-
}
-
}
-
else {
-
Request request = ObjectModelHelper.getRequest(objectModel);
if (request != null &&
"GET".equalsIgnoreCase(request.getMethod())) {
-
// just the first view of the page
-
// call introspection
-
getLogger().debug("calling introspection");
-
return (introspection(redirector, resolver, objectModel,
source, parameters));
-
}
-
else {
-
getLogger().debug("already in flow - no introspection");
-
return (EMPTY_MAP);
-
}
-
}
-
}
-
}
-
1.3 +75 -214
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/AbstractPreceptorAction.java
Index: AbstractPreceptorAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/AbstractPreceptorAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractPreceptorAction.java 7 Jan 2003 23:56:10 -0000 1.2
+++ AbstractPreceptorAction.java 12 Jan 2003 16:31:18 -0000 1.3
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.acting;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -124,194 +71,108 @@
import org.apache.cocoon.precept.PreceptorViolationException;
-
/*
-
* @version: Feb 25, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public abstract class AbstractPreceptorAction extends AbstractMethodAction
implements ThreadSafe {
+ public final static String PRECEPTORVIOLATIONS = "preceptorViolations";
-
-
- public final static String PRECEPTORVIOLATIONS = "preceptorViolations";
-
-
-
- final protected Session createSession( Map objectModel ) {
-
- Request request = ObjectModelHelper.getRequest(objectModel);
-
- return(request.getSession(true));
-
- }
-
-
-
- final protected Instance getInstance( Map objectModel, String instanceId )
{
-
- Request request = ObjectModelHelper.getRequest(objectModel);
-
- Session session = request.getSession(false);
-
- return((Instance)session.getAttribute(instanceId));
-
- }
-
-
-
- final protected Instance createInstance(String id) throws
ComponentException {
-
- InstanceFactory factory = (InstanceFactory)
manager.lookup(InstanceFactory.ROLE);
-
- Instance instance = factory.createInstance(id);
-
- manager.release(factory);
-
- return(instance);
-
- }
-
-
-
- final protected void populate(Map objectModel, String instanceId, String
xpath) throws PreceptorViolationException, InvalidXPathSyntaxException {
-
- Request request = ObjectModelHelper.getRequest(objectModel);
-
- Session session = request.getSession(false);
-
- if (session != null) {
-
- Instance instance = (Instance)session.getAttribute(instanceId);
-
- if (instance != null) {
-
- String value = request.getParameter(xpath);
-
- //String[] values = request.getParameterValues(xpath);
-
-
-
- if (value == null) value = "false";
-
-
-
- getLogger().debug("populating into " + String.valueOf(xpath) + " = "
+ String.valueOf(value));
-
- instance.setValue(xpath,value);
-
- }
-
+ final protected Session createSession(Map objectModel) {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ return (request.getSession(true));
}
- }
-
-
-
- final protected void populate(Map objectModel, String instanceId, String[]
xpaths) throws PreceptorViolationException, InvalidXPathSyntaxException {
-
- for(int i=0; i < xpaths.length; i++) {
-
- populate(objectModel,instanceId,xpaths[i]);
+ final protected Instance getInstance(Map objectModel, String instanceId)
{
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ Session session = request.getSession(false);
+ return ((Instance) session.getAttribute(instanceId));
}
- }
-
-
-
- final protected Collection validate(Map objectModel, String instanceId)
throws InvalidXPathSyntaxException, NoSuchNodeException {
-
- Instance instance = getInstance(objectModel,instanceId);
-
- Preceptor preceptor = instance.getPreceptor();
-
- Collection violations = preceptor.validate(instance,null);
-
- return(violations);
-
- }
-
-
-
- final protected Collection validate(Map objectModel, String instanceId,
String xpath) throws InvalidXPathSyntaxException, NoSuchNodeException {
-
- Instance instance = getInstance(objectModel,instanceId);
-
- Preceptor preceptor = instance.getPreceptor();
-
- Collection violations = preceptor.validate(instance,xpath,null);
-
- return(violations);
-
- }
-
-
-
- final protected void pass(Map objectModel, Collection violations) {
-
- if (violations != null) {
-
- Request request = ObjectModelHelper.getRequest(objectModel);
-
- List currentViolations = (List)
request.getAttribute(PRECEPTORVIOLATIONS);
-
- if (currentViolations == null) {
-
- request.setAttribute(PRECEPTORVIOLATIONS, violations);
-
- }
-
- else {
-
- }
+ final protected Instance createInstance(String id) throws
ComponentException {
+ InstanceFactory factory = (InstanceFactory)
manager.lookup(InstanceFactory.ROLE);
+ Instance instance = factory.createInstance(id);
+ manager.release(factory);
+ return (instance);
}
- }
-
-
-
- final protected Collection validate(Map objectModel, String instanceId,
String[] xpaths) throws InvalidXPathSyntaxException, NoSuchNodeException {
-
- Instance instance = getInstance(objectModel,instanceId);
-
- Preceptor preceptor = instance.getPreceptor();
-
- ArrayList allErrors = null;
-
- for(int i=0; i < xpaths.length; i++) {
-
- Collection errors = preceptor.validate(instance,xpaths[i],null);
- if (errors != null) {
-
- if (allErrors == null) allErrors = new ArrayList(1);
-
- allErrors.addAll(errors);
-
- }
+ final protected void populate(Map objectModel, String instanceId, String
xpath) throws PreceptorViolationException, InvalidXPathSyntaxException {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ Session session = request.getSession(false);
+ if (session != null) {
+ Instance instance = (Instance) session.getAttribute(instanceId);
+ if (instance != null) {
+ String value = request.getParameter(xpath);
+ //String[] values = request.getParameterValues(xpath);
+
+ if (value == null) value = "false";
+
+ getLogger().debug("populating into " + String.valueOf(xpath)
+ " = " + String.valueOf(value));
+
+ instance.setValue(xpath, value);
+ }
+ }
+ }
+ final protected void populate(Map objectModel, String instanceId,
String[] xpaths) throws PreceptorViolationException,
InvalidXPathSyntaxException {
+ for (int i = 0; i < xpaths.length; i++) {
+ populate(objectModel, instanceId, xpaths[i]);
+ }
}
- return(allErrors);
- }
+ final protected Collection validate(Map objectModel, String instanceId)
throws InvalidXPathSyntaxException, NoSuchNodeException {
+ Instance instance = getInstance(objectModel, instanceId);
+ Preceptor preceptor = instance.getPreceptor();
+ Collection violations = preceptor.validate(instance, null);
+ return (violations);
+ }
+ final protected Collection validate(Map objectModel, String instanceId,
String xpath) throws InvalidXPathSyntaxException, NoSuchNodeException {
+ Instance instance = getInstance(objectModel, instanceId);
+ Preceptor preceptor = instance.getPreceptor();
+ Collection violations = preceptor.validate(instance, xpath, null);
+ return (violations);
+ }
- final protected Map page( String id ) {
- Map m = new HashMap(1);
+ final protected void pass(Map objectModel, Collection violations) {
+ if (violations != null) {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ List currentViolations = (List)
request.getAttribute(PRECEPTORVIOLATIONS);
+ if (currentViolations == null) {
+ request.setAttribute(PRECEPTORVIOLATIONS, violations);
+ }
+ else {
+ }
+ }
+ }
- m.put("page",id);
- return(m);
+ final protected Collection validate(Map objectModel, String instanceId,
String[] xpaths) throws InvalidXPathSyntaxException, NoSuchNodeException {
+ Instance instance = getInstance(objectModel, instanceId);
+ Preceptor preceptor = instance.getPreceptor();
+ ArrayList allErrors = null;
+ for (int i = 0; i < xpaths.length; i++) {
+ Collection errors = preceptor.validate(instance, xpaths[i],
null);
+ if (errors != null) {
+ if (allErrors == null) allErrors = new ArrayList(1);
+ allErrors.addAll(errors);
+ }
+ }
+ return (allErrors);
+ }
- }
+ final protected Map page(String id) {
+ Map m = new HashMap(1);
+ m.put("page", id);
+ return (m);
+ }
}
1.2 +122 -301
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/PreceptorDemoAction.java
Index: PreceptorDemoAction.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/acting/PreceptorDemoAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreceptorDemoAction.java 29 Oct 2002 15:48:33 -0000 1.1
+++ PreceptorDemoAction.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,376 +1,197 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-/*
-
- * @version: Feb 25, 2002
-
- * @author Torsten Curdt <[EMAIL PROTECTED]>
-
- */
-
package org.apache.cocoon.precept.acting;
-
import org.apache.cocoon.environment.*;
import org.apache.avalon.framework.parameters.Parameters;
-
import java.util.*;
-
import org.apache.cocoon.precept.Instance;
import org.apache.cocoon.precept.acting.AbstractPreceptorAction;
-
-
/*
-
+ * @version: Feb 25, 2002
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class PreceptorDemoAction extends AbstractPreceptorAction {
+ private final static String VIEW1 = "view1";
+ private final static String VIEW2 = "view2";
+ private final static String VIEW3 = "view3";
+ private final static String VIEW4 = "view4";
+ private final static String VIEW_THANKS = "thanks";
+ private final static String VIEW_ERROR = "error";
+
+ private final static String[] SET_PERSON = {
+ "cocoon-installation/user/firstname",
+ "cocoon-installation/user/lastname",
+ "cocoon-installation/user/email",
+ "cocoon-installation/user/age"
+ };
+
+ private final static String[] SET_INSTALLATION = {
+ "cocoon-installation/number",
+ "cocoon-installation/live-url",
+ "cocoon-installation/publish"
+ };
+
+ private final static String[] SET_SYSTEM = {
+ "cocoon-installation/system/os",
+ "cocoon-installation/system/processor",
+ "cocoon-installation/system/ram",
+ "cocoon-installation/system/servlet-engine",
+ "cocoon-installation/system/java-version"
+ };
+
+ public Map introspection(Redirector redirector, SourceResolver resolver,
Map objectModel, String src, Parameters par) throws Exception {
+ getLogger().debug("start of flow");
+
+ Session session = createSession(objectModel);
+ Instance instance = createInstance("feedback");
+
+ session.setAttribute("form-feedback", instance);
+ return (page(VIEW1));
+
+ }
+
+ public Map doPrev1(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ populate(objectModel, "form-feedback", SET_INSTALLATION);
+ return (page(VIEW1));
+
+ }
+
+ public Map doPrev2(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ populate(objectModel, "form-feedback", SET_SYSTEM);
+ return (page(VIEW2));
+
+ }
+
+ public Map doPrev3(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ return (page(VIEW3));
+ }
+
+
+ public Map doNext2(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ getLogger().debug("populating");
+ populate(objectModel, "form-feedback", SET_PERSON);
+
+ Collection errors = validate(objectModel, "form-feedback",
SET_PERSON);
+ if (errors != null) {
+ getLogger().debug("some constraints FAILED");
+ pass(objectModel, errors);
+ return (page(VIEW1));
+ }
+ else {
+ getLogger().debug("all constraints are ok");
+ return (page(VIEW2));
+ }
+ }
+
+ public Map doNext3(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ getLogger().debug("populating");
+ populate(objectModel, "form-feedback", SET_INSTALLATION);
+
+ Collection errors = validate(objectModel, "form-feedback",
SET_INSTALLATION);
+
+ if (errors != null) {
+ getLogger().debug("some constraints FAILED");
+ pass(objectModel, errors);
+ return (page(VIEW2));
+ }
+ else {
+ getLogger().debug("all constraints are ok");
+ return (page(VIEW3));
+ }
+ }
+
+ public Map doNext4(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ getLogger().debug("populating");
+ populate(objectModel, "form-feedback", SET_SYSTEM);
+
+ Collection errors = validate(objectModel, "form-feedback",
SET_SYSTEM);
+ if (errors != null) {
+ getLogger().debug("some constraints FAILED");
+ pass(objectModel, errors);
+ return (page(VIEW3));
+ }
+ else {
+ getLogger().debug("all constraints are ok");
+ return (page(VIEW4));
+ }
+ }
+
+ public Map doSubmit(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
+ getLogger().debug("submitting");
+ Collection errors = validate(objectModel, "form-feedback");
+ if (errors != null) {
+ getLogger().debug("some constraints FAILED");
+ pass(objectModel, errors);
+ return (page(VIEW_ERROR));
+ }
+ else {
+ getLogger().debug("instance is valid - submitting");
+
+ /*
+ * do whatever you want with the instance data
+ */
-
- private final static String VIEW1 = "view1";
-
- private final static String VIEW2 = "view2";
-
- private final static String VIEW3 = "view3";
-
- private final static String VIEW4 = "view4";
-
- private final static String VIEW_THANKS = "thanks";
-
- private final static String VIEW_ERROR = "error";
-
-
-
- private final static String[] SET_PERSON = {
-
- "cocoon-installation/user/firstname",
-
- "cocoon-installation/user/lastname",
-
- "cocoon-installation/user/email",
-
- "cocoon-installation/user/age"
-
- };
-
-
-
- private final static String[] SET_INSTALLATION = {
-
- "cocoon-installation/number",
-
- "cocoon-installation/live-url",
-
- "cocoon-installation/publish"
-
- };
-
-
-
- private final static String[] SET_SYSTEM = {
-
- "cocoon-installation/system/os",
-
- "cocoon-installation/system/processor",
-
- "cocoon-installation/system/ram",
-
- "cocoon-installation/system/servlet-engine",
-
- "cocoon-installation/system/java-version"
-
- };
-
-
-
-
-
- public Map introspection(Redirector redirector, SourceResolver resolver,
Map objectModel, String src, Parameters par) throws Exception {
-
- getLogger().debug("start of flow");
-
-
-
- Session session = createSession(objectModel);
-
- Instance instance = createInstance("feedback");
-
-
-
- session.setAttribute("form-feedback",instance);
-
- return(page(VIEW1));
-
- }
-
-
-
- public Map doPrev1(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- populate(objectModel, "form-feedback", SET_INSTALLATION );
-
- return (page(VIEW1));
-
- }
-
- public Map doPrev2(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- populate(objectModel, "form-feedback", SET_SYSTEM );
-
- return (page(VIEW2));
-
- }
-
- public Map doPrev3(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- return (page(VIEW3));
-
- }
-
-
-
- public Map doNext2(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- getLogger().debug("populating");
-
- populate(objectModel, "form-feedback", SET_PERSON );
-
-
-
- Collection errors = validate(objectModel, "form-feedback", SET_PERSON );
-
- if(errors != null) {
-
- getLogger().debug("some constraints FAILED");
-
- pass(objectModel,errors);
-
- return (page(VIEW1));
-
- }
-
- else {
-
- getLogger().debug("all constraints are ok");
-
- return (page(VIEW2));
-
- }
-
- }
-
-
-
- public Map doNext3(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- getLogger().debug("populating");
-
- populate(objectModel, "form-feedback", SET_INSTALLATION );
-
-
-
- Collection errors = validate(objectModel, "form-feedback",
SET_INSTALLATION );
-
- if(errors != null) {
-
- getLogger().debug("some constraints FAILED");
-
- pass(objectModel,errors);
-
- return (page(VIEW2));
-
+ return (page(VIEW_THANKS));
+ }
}
-
- else {
-
- getLogger().debug("all constraints are ok");
-
- return (page(VIEW3));
-
- }
-
- }
-
-
-
- public Map doNext4(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- getLogger().debug("populating");
-
- populate(objectModel, "form-feedback", SET_SYSTEM );
-
-
-
- Collection errors = validate(objectModel, "form-feedback", SET_SYSTEM );
-
- if(errors != null) {
-
- getLogger().debug("some constraints FAILED");
-
- pass(objectModel,errors);
-
- return (page(VIEW3));
-
- }
-
- else {
-
- getLogger().debug("all constraints are ok");
-
- return (page(VIEW4));
-
- }
-
- }
-
-
-
- public Map doSubmit(Redirector redirector, SourceResolver resolver, Map
objectModel, String src, Parameters par) throws Exception {
-
- getLogger().debug("submitting");
-
- Collection errors = validate(objectModel, "form-feedback");
-
- if (errors != null) {
-
- getLogger().debug("some constraints FAILED");
-
- pass(objectModel,errors);
-
- return (page(VIEW_ERROR));
-
- }
-
- else {
-
- getLogger().debug("instance is valid - submitting");
-
-
-
- /*
-
- * do whatever you want with the instance data
-
- */
-
-
-
- return (page(VIEW_THANKS));
-
- }
-
- }
-
}
-
1.3 +5 -61
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/AbstractPreceptor.java
Index: AbstractPreceptor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/AbstractPreceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractPreceptor.java 7 Jan 2003 23:56:10 -0000 1.2
+++ AbstractPreceptor.java 12 Jan 2003 16:31:19 -0000 1.3
@@ -1,105 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors;
import org.apache.avalon.framework.component.ComponentException;
@@ -110,18 +58,14 @@
import org.apache.cocoon.precept.Preceptor;
/*
-
* @version: Mar 18, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
-public abstract class AbstractPreceptor extends AbstractLogEnabled
implements Preceptor, Composable {
- protected ComponentManager manager;
-
+public abstract class AbstractPreceptor extends AbstractLogEnabled
implements Preceptor, Composable {
+ protected ComponentManager manager;
- public void compose(ComponentManager manager) throws ComponentException {
- this.manager = manager;
- }
+ public void compose(ComponentManager manager) throws ComponentException {
+ this.manager = manager;
+ }
}
1.3 +3 -2
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/PreceptorBuilder.java
Index: PreceptorBuilder.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/PreceptorBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PreceptorBuilder.java 7 Jan 2003 23:56:10 -0000 1.2
+++ PreceptorBuilder.java 12 Jan 2003 16:31:19 -0000 1.3
@@ -58,9 +58,10 @@
* @version: Mar 20, 2002
* @author Torsten Curdt <[EMAIL PROTECTED]>
*/
+
public interface PreceptorBuilder extends Component {
- public String ROLE = "org.apache.cocoon.precept.PreceptorBuilder";
+ public String ROLE = "org.apache.cocoon.precept.PreceptorBuilder";
- public Preceptor buildPreceptor( String uri ) throws Exception;
+ public Preceptor buildPreceptor(String uri) throws Exception;
}
1.2 +38 -149
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/AbstractPreceptorNode.java
Index: AbstractPreceptorNode.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/AbstractPreceptorNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractPreceptorNode.java 29 Oct 2002 15:48:33 -0000 1.1
+++ AbstractPreceptorNode.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,230 +1,119 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
-
-
import org.apache.cocoon.precept.Preceptor;
import org.apache.cocoon.precept.Constraint;
-
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
-
-
/*
-
* @version: Feb 22, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public abstract class AbstractPreceptorNode {
- protected String name;
-
- protected List constraints;
-
- protected ElementPreceptorNode parent;
-
- protected Preceptor preceptor;
-
-
-
-
-
- public String getName() {
-
- return(this.name);
-
- }
-
-
-
- public ElementPreceptorNode getParent() {
-
- return(this.parent);
-
- }
-
-
-
- public List validate(Object value) {
-
- if (constraints != null) {
-
- for (Iterator it = constraints.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- }
-
- return(null);
+ protected String name;
+ protected List constraints;
+ protected ElementPreceptorNode parent;
+ protected Preceptor preceptor;
+ public String getName() {
+ return (this.name);
}
- else {
-
- return(null);
-
+ public ElementPreceptorNode getParent() {
+ return (this.parent);
}
- }
-
-
-
- public List getConstraints() {
-
- return(constraints);
-
- }
-
-
-
- public AbstractPreceptorNode addConstraints(List constraints) {
-
- if (constraints != null) {
-
- if (this.constraints == null) {
-
- this.constraints = new ArrayList(constraints.size());
-
- }
-
- this.constraints.addAll(constraints);
-
+ public List validate(Object value) {
+ if (constraints != null) {
+ for (Iterator it = constraints.iterator(); it.hasNext();) {
+ Constraint constraint = (Constraint) it.next();
+ }
+ return (null);
+ }
+ else {
+ return (null);
+ }
}
- return(this);
-
- }
-
-
-
- public AbstractPreceptorNode addConstraint(Constraint constraint) {
-
- if (constraint != null) {
-
- if (this.constraints == null){
-
- this.constraints = new ArrayList(1);
-
- }
-
- this.constraints.add(constraint);
-
+ public List getConstraints() {
+ return (constraints);
}
- return(this);
-
- }
+ public AbstractPreceptorNode addConstraints(List constraints) {
+ if (constraints != null) {
+ if (this.constraints == null) {
+ this.constraints = new ArrayList(constraints.size());
+ }
+ this.constraints.addAll(constraints);
+ }
+ return (this);
+ }
+ public AbstractPreceptorNode addConstraint(Constraint constraint) {
+ if (constraint != null) {
+ if (this.constraints == null) {
+ this.constraints = new ArrayList(1);
+ }
+ this.constraints.add(constraint);
+ }
+ return (this);
+ }
}
-
1.3 +20 -122
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/AttributePreceptorNode.java
Index: AttributePreceptorNode.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/AttributePreceptorNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AttributePreceptorNode.java 7 Jan 2003 23:56:10 -0000 1.2
+++ AttributePreceptorNode.java 12 Jan 2003 16:31:19 -0000 1.3
@@ -1,211 +1,109 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
-
import java.util.Iterator;
import org.apache.cocoon.precept.Constraint;
import org.apache.cocoon.precept.Preceptor;
-
/*
-
* @version: Feb 22, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
-
public class AttributePreceptorNode extends AbstractPreceptorNode {
- private boolean required;
-
- //private StringBuffer valueObject;
-
-
-
- public AttributePreceptorNode( Preceptor preceptor, ElementPreceptorNode
parent, String name, boolean required ) {
-
- this.name = name;
-
- this.required = required;
-
- this.parent = parent;
-
- this.preceptor = preceptor;
-
- }
-
-
-
- public boolean isRequired() {
-
- return(required);
-
- }
-
-
-
- public void toStringBuffer( StringBuffer sb, int depth) {
-
- sb.append(" ").append(name).append("=");
-
-
-
- if (constraints != null) {
-
- for (Iterator it = constraints.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- sb.append("{").append(constraint.getType()).append("}");
-
- }
+ private boolean required;
+ //private StringBuffer valueObject;
+ public AttributePreceptorNode(Preceptor preceptor, ElementPreceptorNode
parent, String name, boolean required) {
+ this.name = name;
+ this.required = required;
+ this.parent = parent;
+ this.preceptor = preceptor;
}
+ public boolean isRequired() {
+ return (required);
+ }
+ public void toStringBuffer(StringBuffer sb, int depth) {
+ sb.append(" ").append(name).append("=");
- sb.append("[").append( (required)?"required":"optional" ).append("]");
-
- }
-
+ if (constraints != null) {
+ for (Iterator it = constraints.iterator(); it.hasNext();) {
+ Constraint constraint = (Constraint) it.next();
+ sb.append("{").append(constraint.getType()).append("}");
+ }
+ }
+ sb.append("[").append((required) ? "required" :
"optional").append("]");
+ }
/*
-
public StringBuffer setValue( String value ) {
-
if (valueObject == null){
-
valueObject = new StringBuffer(value);
-
}
-
else {
-
valueObject.setLength(0);
-
valueObject.append(value);
-
}
-
return(valueObject);
-
}
-
-
public StringBuffer getValue() {
-
return(valueObject);
-
}
-
*/
-
}
-
1.2 +7 -72
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/ConstraintFactory.java
Index: ConstraintFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/ConstraintFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConstraintFactory.java 29 Oct 2002 15:48:33 -0000 1.1
+++ ConstraintFactory.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
-
import org.apache.cocoon.precept.Constraint;
import
org.apache.cocoon.precept.preceptors.easyrelax.constraints.ChoiceConstraint;
@@ -113,32 +60,20 @@
import org.apache.avalon.framework.configuration.Configuration;
-
/*
-
* @version: Mar 21, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class ConstraintFactory {
- public Constraint createConstraintInstance(String type, String name,
Object context, Configuration conf) {
-
- if ("choice".equals(type)) {
-
- return(new ChoiceConstraint());
-
- }
-
- else {
-
- return(new RegexprConstraint());
-
+ public Constraint createConstraintInstance(String type, String name,
Object context, Configuration conf) {
+ if ("choice".equals(type)) {
+ return (new ChoiceConstraint());
+ }
+ else {
+ return (new RegexprConstraint());
+ }
}
-
- }
-
}
1.2 +92 -307
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/ElementPreceptorNode.java
Index: ElementPreceptorNode.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/ElementPreceptorNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElementPreceptorNode.java 29 Oct 2002 15:48:33 -0000 1.1
+++ ElementPreceptorNode.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,448 +1,233 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
-
-
-
import org.apache.cocoon.precept.Preceptor;
import org.apache.cocoon.precept.Constraint;
-
import java.util.*;
-
-
/*
-
* @version: Feb 22, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class ElementPreceptorNode extends AbstractPreceptorNode {
- public final static int UNBOUND = -1;
-
+ public final static int UNBOUND = -1;
- private Map childs;
-
- private Map attributes;
-
+ private Map childs;
+ private Map attributes;
// private List values;
+ private int minOcc;
+ private int maxOcc;
- private int minOcc;
-
- private int maxOcc;
-
-
-
- public ElementPreceptorNode( Preceptor preceptor, ElementPreceptorNode
parent, String name, int minOcc, int maxOcc) {
-
- this.name = name;
-
- this.minOcc = minOcc;
-
- this.maxOcc = maxOcc;
-
- this.parent = parent;
-
- this.preceptor = preceptor;
-
-
-
- }
-
-
-
- public AttributePreceptorNode addAttribute( String name, boolean required,
List constraints ) {
-
- if (attributes == null) attributes = new HashMap();
-
- AttributePreceptorNode a = new AttributePreceptorNode( preceptor, this,
name, required );
-
- a.addConstraints(constraints);
-
- attributes.put(name,a);
-
- return(a);
-
- }
-
-
-
- public ElementPreceptorNode addElement( String name, int min, int max,
List constraints ) {
-
- if (childs == null) childs = new HashMap();
-
- ElementPreceptorNode e = new ElementPreceptorNode( preceptor, this,
name, min, max);
-
- e.addConstraints(constraints);
-
- childs.put(name,e);
-
- return(e);
-
- }
-
-
-
- public ElementPreceptorNode getChild( String name ) {
-
- if (childs != null) {
-
- return((ElementPreceptorNode)childs.get(name));
-
+ public ElementPreceptorNode(Preceptor preceptor, ElementPreceptorNode
parent, String name, int minOcc, int maxOcc) {
+ this.name = name;
+ this.minOcc = minOcc;
+ this.maxOcc = maxOcc;
+ this.parent = parent;
+ this.preceptor = preceptor;
}
- else {
-
- return(null);
+ public AttributePreceptorNode addAttribute(String name, boolean
required, List constraints) {
+ if (attributes == null) attributes = new HashMap();
+ AttributePreceptorNode a = new AttributePreceptorNode(preceptor,
this, name, required);
+ a.addConstraints(constraints);
+ attributes.put(name, a);
+ return (a);
}
- }
-
-
-
- public Collection getChildElements() {
-
- if (childs != null) {
-
- return(childs.values());
+ public ElementPreceptorNode addElement(String name, int min, int max,
List constraints) {
+ if (childs == null) childs = new HashMap();
+ ElementPreceptorNode e = new ElementPreceptorNode(preceptor, this,
name, min, max);
+ e.addConstraints(constraints);
+ childs.put(name, e);
+ return (e);
}
- else {
-
- return(null);
+ public ElementPreceptorNode getChild(String name) {
+ if (childs != null) {
+ return ((ElementPreceptorNode) childs.get(name));
+ }
+ else {
+ return (null);
+ }
}
- }
-
-
-
- public AttributePreceptorNode getAttribute( String name ) {
-
- if (attributes != null) {
-
- return((AttributePreceptorNode)attributes.get(name));
+ public Collection getChildElements() {
+ if (childs != null) {
+ return (childs.values());
+ }
+ else {
+ return (null);
+ }
}
- else {
-
- return(null);
+ public AttributePreceptorNode getAttribute(String name) {
+ if (attributes != null) {
+ return ((AttributePreceptorNode) attributes.get(name));
+ }
+ else {
+ return (null);
+ }
}
- }
-
-
-
- public Collection getAttributes() {
-
- if (attributes != null) {
-
- return(attributes.values());
+ public Collection getAttributes() {
+ if (attributes != null) {
+ return (attributes.values());
+ }
+ else {
+ return (null);
+ }
}
- else {
-
- return(null);
-
+ public int getMinOcc() {
+ return (this.minOcc);
}
- }
-
-
-
- public int getMinOcc() {
-
- return(this.minOcc);
-
- }
-
-
-
- public int getMaxOcc() {
-
- return(this.maxOcc);
-
- }
-
-
+ public int getMaxOcc() {
+ return (this.maxOcc);
+ }
/*
public StringBuffer setValue(int i, String value) throws
PreceptorViolationException {
-
if (values == null) values = new ArrayList(1);
-
-
if (i <= values.size()) {
-
// already there
-
StringBuffer valueObject = (StringBuffer) values.get(i-1);
-
valueObject.setLength(0);
-
valueObject.append(value);
-
return(valueObject);
-
}
-
else {
-
// create a slot
-
if (i > maxOcc) {
-
// restricted
-
throw new PreceptorViolationException( String.valueOf(name) + " is
out of bound");
-
}
-
else {
-
StringBuffer valueObject = new StringBuffer(value);
-
values.add(valueObject);
-
return(valueObject);
-
}
-
}
-
}
-
-
public StringBuffer getValue(int i) {
-
if (values != null && i <= values.size()) {
-
// is there
-
return((StringBuffer)values.get(i-1));
-
}
-
else {
-
return(null);
-
}
-
}
-
-
public int valueCount() {
-
if (values != null) {
-
return(values.size());
-
}
-
else {
-
return(0);
-
}
-
}
-
*/
-
-
- public void toStringBuffer( StringBuffer sb, ElementPreceptorNode e, int
depth) {
-
- StringBuffer ident = new StringBuffer();
-
- for(int i=0;i<depth*3;i++) ident.append(" ");
-
-
-
- sb.append("\n").append(ident).append("<").append(e.getName());
-
-
sb.append("[").append(e.getMinOcc()).append(",").append(e.getMaxOcc()).append("]");
-
-
-
- Collection attributes = e.getAttributes();
-
- if (attributes != null) {
-
- for (Iterator it = attributes.iterator(); it.hasNext();) {
-
- AttributePreceptorNode attr = (AttributePreceptorNode) it.next();
-
- attr.toStringBuffer(sb,depth);
-
- }
-
+ public void toStringBuffer(StringBuffer sb, ElementPreceptorNode e, int
depth) {
+ StringBuffer ident = new StringBuffer();
+ for (int i = 0; i < depth * 3; i++) ident.append(" ");
+
+ sb.append("\n").append(ident).append("<").append(e.getName());
+
sb.append("[").append(e.getMinOcc()).append(",").append(e.getMaxOcc()).append("]");
+
+ Collection attributes = e.getAttributes();
+ if (attributes != null) {
+ for (Iterator it = attributes.iterator(); it.hasNext();) {
+ AttributePreceptorNode attr = (AttributePreceptorNode)
it.next();
+ attr.toStringBuffer(sb, depth);
+ }
+ }
+
+ sb.append(">");
+
+ if (e.getConstraints() != null) {
+ for (Iterator it = e.getConstraints().iterator(); it.hasNext();)
{
+ Constraint constraint = (Constraint) it.next();
+ sb.append("{").append(constraint.getType()).append("}");
+ }
+ }
+ else {
+ sb.append("{*}");
+ }
+
+ Collection childs = e.getChildElements();
+ if (childs != null) {
+ for (Iterator it = childs.iterator(); it.hasNext();) {
+ ElementPreceptorNode child = (ElementPreceptorNode)
it.next();
+ toStringBuffer(sb, child, depth + 1);
+ }
+ }
+ sb.append("</").append(e.getName()).append(">");
}
-
-
-
- sb.append(">");
-
-
-
- if (e.getConstraints() != null) {
-
- for (Iterator it = e.getConstraints().iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- sb.append("{").append(constraint.getType()).append("}");
-
- }
-
- }
-
- else {
-
- sb.append("{*}");
-
- }
-
-
-
- Collection childs = e.getChildElements();
-
- if (childs != null) {
-
- for (Iterator it = childs.iterator(); it.hasNext();) {
-
- ElementPreceptorNode child = (ElementPreceptorNode) it.next();
-
- toStringBuffer(sb, child, depth + 1);
-
- }
-
- }
-
- sb.append("</").append(e.getName()).append(">");
-
- }
-
-
-
-}
-
+}
\ No newline at end of file
1.2 +0 -54
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/PreceptorBuilderImpl.java
Index: PreceptorBuilderImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/PreceptorBuilderImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreceptorBuilderImpl.java 29 Oct 2002 15:48:33 -0000 1.1
+++ PreceptorBuilderImpl.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,104 +1,53 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
import org.apache.avalon.excalibur.pool.Poolable;
@@ -127,11 +76,8 @@
/*
-
* @version: Feb 23, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class PreceptorBuilderImpl extends AbstractXMLConsumer implements
PreceptorBuilder, Composable, Disposable, Poolable {
1.2 +140 -364
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/PreceptorImpl.java
Index: PreceptorImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/PreceptorImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreceptorImpl.java 29 Oct 2002 15:48:33 -0000 1.1
+++ PreceptorImpl.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,456 +1,232 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax;
-
import org.apache.cocoon.precept.*;
import org.apache.cocoon.precept.preceptors.AbstractPreceptor;
-
import java.util.*;
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
-
-
public class PreceptorImpl extends AbstractPreceptor {
+ HashMap index = new HashMap();
- HashMap index = new HashMap();
-
-
-
- public Collection validate(Instance instance, String xpath, Context
context) throws InvalidXPathSyntaxException, NoSuchNodeException {
-
- Collection violations = null;
-
- Collection constraints = (Collection) getConstraintsFor(xpath);
-
- if (constraints != null) {
-
- Object value = instance.getValue(xpath);
-
- for (Iterator it = constraints.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
-
- if (!constraint.isSatisfiedBy(value, context)) {
-
- if (violations == null) {
-
- violations = new HashSet();
-
- }
-
- violations.add(constraint);
+ public Collection validate(Instance instance, String xpath, Context
context) throws InvalidXPathSyntaxException, NoSuchNodeException {
+ Collection violations = null;
+ Collection constraints = (Collection) getConstraintsFor(xpath);
+ if (constraints != null) {
+ Object value = instance.getValue(xpath);
+ for (Iterator it = constraints.iterator(); it.hasNext();) {
+ Constraint constraint = (Constraint) it.next();
+ if (!constraint.isSatisfiedBy(value, context)) {
+ if (violations == null) {
+ violations = new HashSet();
+ }
+ violations.add(constraint);
+ }
+ }
+ return (violations);
}
-
- }
-
- return (violations);
-
- }
-
- else {
-
- return (null);
-
- }
-
- }
-
-
-
- public Collection validate(Instance instance, Context context) throws
InvalidXPathSyntaxException {
-
- Collection allViolations = null;
-
- Collection xpaths = instance.getNodePaths();
-
- for (Iterator it = xpaths.iterator(); it.hasNext();) {
-
- String xpath = (String) it.next();
-
- try {
-
- Collection violations = validate(instance, xpath, context);
-
- if (violations != null) {
-
- if (allViolations == null) {
-
- allViolations = new HashSet();
-
- }
-
- allViolations.addAll(violations);
-
+ else {
+ return (null);
}
-
- }
-
- catch (NoSuchNodeException e) {
-
- getLogger().error("hm.. the instance just told us about the nodes!");
-
- }
-
}
- return (allViolations);
-
- }
-
-
-
- public Collection getConstraintsFor(String xpath) throws
NoSuchNodeException {
-
- AbstractPreceptorNode node = (AbstractPreceptorNode) index.get(xpath);
-
- if (node != null) {
-
- List constraints = node.getConstraints();
-
- if (constraints != null) {
-
- getLogger().debug(constraints.size() + " constraints for [" +
String.valueOf(xpath) + "]");
-
- return (constraints);
-
- }
-
- else {
-
- getLogger().debug("no constraints for [" + String.valueOf(xpath) +
"]");
-
- return (null);
-
- }
-
- }
-
- else {
-
- throw new NoSuchNodeException(xpath);
-
+ public Collection validate(Instance instance, Context context) throws
InvalidXPathSyntaxException {
+ Collection allViolations = null;
+ Collection xpaths = instance.getNodePaths();
+ for (Iterator it = xpaths.iterator(); it.hasNext();) {
+ String xpath = (String) it.next();
+ try {
+ Collection violations = validate(instance, xpath, context);
+ if (violations != null) {
+ if (allViolations == null) {
+ allViolations = new HashSet();
+ }
+ allViolations.addAll(violations);
+ }
+ }
+ catch (NoSuchNodeException e) {
+ getLogger().error("hm.. the instance just told us about the
nodes!");
+ }
+ }
+ return (allViolations);
}
- }
-
-
-
- public void buildInstance(Instance instance) {
-
- try {
-
- for (Iterator it = index.keySet().iterator(); it.hasNext();) {
-
- String xpath = (String) it.next();
-
+ public Collection getConstraintsFor(String xpath) throws
NoSuchNodeException {
AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(xpath);
-
- if (node instanceof ElementPreceptorNode) {
-
- for (int i = 0; i < ((ElementPreceptorNode) node).getMinOcc();
i++) {
-
- String s = xpath;
-
- if (i != 0) {
-
- s += "[" + (i + 1) + "]";
-
+ if (node != null) {
+ List constraints = node.getConstraints();
+ if (constraints != null) {
+ getLogger().debug(constraints.size() + " constraints for ["
+ String.valueOf(xpath) + "]");
+ return (constraints);
+ }
+ else {
+ getLogger().debug("no constraints for [" +
String.valueOf(xpath) + "]");
+ return (null);
}
-
- getLogger().debug("building node [" + String.valueOf(s) + "]");
-
- instance.setValue(s, "");
-
- }
-
}
-
else {
-
- getLogger().debug("building node [" + String.valueOf(xpath) + "]");
-
- instance.setValue(xpath, "");
-
+ throw new NoSuchNodeException(xpath);
}
-
- }
-
- }
-
- catch (InvalidXPathSyntaxException e) {
-
- getLogger().error("hm.. the preceptor should know how to build the
instance!");
-
}
- catch (PreceptorViolationException e) {
-
- getLogger().error("hm.. the preceptor should know how to build the
instance!");
-
- }
-
- }
-
-
-
- public boolean isValidNode(String xpath) throws
InvalidXPathSyntaxException {
-
- StringBuffer currentPath = new StringBuffer();
-
- StringTokenizer tok = new StringTokenizer(xpath, "/", false);
-
- boolean first = true;
-
- while (tok.hasMoreTokens()) {
-
- String level = tok.nextToken();
-
- if (!first) {
-
- currentPath.append("/");
-
- }
-
- else {
-
- first = false;
-
- }
-
-
-
- if (level.startsWith("@")) {
-
- currentPath.append(level);
-
- AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(currentPath.toString());
-
- if (node != null) {
-
- getLogger().debug("found attribute node [" +
String.valueOf(currentPath) + "] in index");
-
- return (true);
-
+ public void buildInstance(Instance instance) {
+ try {
+ for (Iterator it = index.keySet().iterator(); it.hasNext();) {
+ String xpath = (String) it.next();
+ AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(xpath);
+ if (node instanceof ElementPreceptorNode) {
+ for (int i = 0; i < ((ElementPreceptorNode)
node).getMinOcc(); i++) {
+ String s = xpath;
+ if (i != 0) {
+ s += "[" + (i + 1) + "]";
+ }
+ getLogger().debug("building node [" +
String.valueOf(s) + "]");
+ instance.setValue(s, "");
+ }
+ }
+ else {
+ getLogger().debug("building node [" +
String.valueOf(xpath) + "]");
+ instance.setValue(xpath, "");
+ }
+ }
}
-
- else {
-
- getLogger().debug("could not find attribute [" +
String.valueOf(currentPath) + "] in index");
-
- return (false);
-
+ catch (InvalidXPathSyntaxException e) {
+ getLogger().error("hm.. the preceptor should know how to build
the instance!");
}
+ catch (PreceptorViolationException e) {
+ getLogger().error("hm.. the preceptor should know how to build
the instance!");
+ }
+ }
- }
-
- else {
-
- String levelName;
-
- int levelInt = 1;
-
- int open = level.indexOf("[");
-
- if (open > 0) {
-
- int close = level.indexOf("]", open);
-
- if (close > 0) {
-
- try {
-
- levelInt = Integer.parseInt(level.substring(open + 1, close));
-
- levelName = level.substring(0, open);
-
+ public boolean isValidNode(String xpath) throws
InvalidXPathSyntaxException {
+ StringBuffer currentPath = new StringBuffer();
+ StringTokenizer tok = new StringTokenizer(xpath, "/", false);
+ boolean first = true;
+ while (tok.hasMoreTokens()) {
+ String level = tok.nextToken();
+ if (!first) {
+ currentPath.append("/");
}
-
- catch (NumberFormatException e) {
-
- getLogger().debug("invalid syntax [" + String.valueOf(level) +
"]");
-
- throw new InvalidXPathSyntaxException(level);
-
+ else {
+ first = false;
}
- }
-
- else {
-
- getLogger().debug("invalid syntax [" + String.valueOf(level) +
"]");
-
- throw new InvalidXPathSyntaxException(level);
-
- }
-
- }
-
- else {
-
- levelName = level;
-
- }
-
-
-
- currentPath.append(levelName);
-
- AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(currentPath.toString());
-
- if (node != null) {
-
- getLogger().debug("found node [" + String.valueOf(currentPath) +
"] in index");
-
-
-
- if (node instanceof ElementPreceptorNode) {
-
- if (((ElementPreceptorNode) node).getMaxOcc() !=
ElementPreceptorNode.UNBOUND && levelInt > ((ElementPreceptorNode)
node).getMaxOcc()) {
-
- getLogger().debug(String.valueOf(levelName) + "[" + levelInt +
"] exceeds maximal occurrences [" + ((ElementPreceptorNode) node).getMaxOcc() +
"]");
-
- return (false);
-
+ if (level.startsWith("@")) {
+ currentPath.append(level);
+ AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(currentPath.toString());
+ if (node != null) {
+ getLogger().debug("found attribute node [" +
String.valueOf(currentPath) + "] in index");
+ return (true);
+ }
+ else {
+ getLogger().debug("could not find attribute [" +
String.valueOf(currentPath) + "] in index");
+ return (false);
+ }
+ }
+ else {
+ String levelName;
+ int levelInt = 1;
+ int open = level.indexOf("[");
+ if (open > 0) {
+ int close = level.indexOf("]", open);
+ if (close > 0) {
+ try {
+ levelInt = Integer.parseInt(level.substring(open
+ 1, close));
+ levelName = level.substring(0, open);
+ }
+ catch (NumberFormatException e) {
+ getLogger().debug("invalid syntax [" +
String.valueOf(level) + "]");
+ throw new InvalidXPathSyntaxException(level);
+ }
+ }
+ else {
+ getLogger().debug("invalid syntax [" +
String.valueOf(level) + "]");
+ throw new InvalidXPathSyntaxException(level);
+ }
+ }
+ else {
+ levelName = level;
+ }
+
+ currentPath.append(levelName);
+ AbstractPreceptorNode node = (AbstractPreceptorNode)
index.get(currentPath.toString());
+ if (node != null) {
+ getLogger().debug("found node [" +
String.valueOf(currentPath) + "] in index");
+
+ if (node instanceof ElementPreceptorNode) {
+ if (((ElementPreceptorNode) node).getMaxOcc() !=
ElementPreceptorNode.UNBOUND && levelInt > ((ElementPreceptorNode)
node).getMaxOcc()) {
+ getLogger().debug(String.valueOf(levelName) +
"[" + levelInt + "] exceeds maximal occurrences [" + ((ElementPreceptorNode)
node).getMaxOcc() + "]");
+ return (false);
+ }
+ }
+
+ if (!tok.hasMoreTokens()) return (true);
+ }
+ else {
+ getLogger().debug("could not find [" +
String.valueOf(currentPath) + "] in index");
+ return (false);
+ }
}
-
- }
-
-
-
- if (!tok.hasMoreTokens()) return (true);
-
- }
-
- else {
-
- getLogger().debug("could not find [" + String.valueOf(currentPath)
+ "] in index");
-
- return (false);
-
}
-
- }
-
+ return (false);
}
-
- return (false);
-
- }
-
}
-
1.2 +1 -60
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/AbstractConstraint.java
Index: AbstractConstraint.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/AbstractConstraint.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractConstraint.java 29 Oct 2002 15:48:33 -0000 1.1
+++ AbstractConstraint.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax.constraints;
-
import org.apache.cocoon.precept.Constraint;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -111,18 +58,12 @@
import org.apache.avalon.framework.component.Component;
-
/*
-
* @version: Mar 21, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public abstract class AbstractConstraint extends AbstractLogEnabled
implements Constraint, Component {
-
- protected String id = null;
-
+ protected String id = null;
}
1.3 +51 -171
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/ChoiceConstraint.java
Index: ChoiceConstraint.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/ChoiceConstraint.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ChoiceConstraint.java 7 Jan 2003 23:56:10 -0000 1.2
+++ ChoiceConstraint.java 12 Jan 2003 16:31:19 -0000 1.3
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.preceptors.easyrelax.constraints;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -122,140 +69,73 @@
import org.xml.sax.helpers.AttributesImpl;
-
/*
-
* @version: Mar 21, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class ChoiceConstraint extends AbstractConstraint implements
Configurable, SingleThreaded {
- public Collection validValues = new ArrayList();
-
- public Map validValuesDescription = new HashMap();
-
-
-
- public void configure(Configuration configuration) throws
ConfigurationException {
-
- id = configuration.getAttribute("name");
-
-
-
- getLogger().debug("configuring constraint [" + String.valueOf(id) + "]");
+ public Collection validValues = new ArrayList();
+ public Map validValuesDescription = new HashMap();
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ id = configuration.getAttribute("name");
+ getLogger().debug("configuring constraint [" + String.valueOf(id) +
"]");
- if (validValues.size() == 0) {
-
- Configuration[] choices = configuration.getChildren("choice");
-
- for(int i=0;i<choices.length;i++) {
-
- Configuration choice = choices[i];
-
- String value = choice.getAttribute("value");
-
- String valueDescription = choice.getValue();
-
-
-
- getLogger().debug("registered choice [" + String.valueOf(value) + "]
= [" + String.valueOf(valueDescription) + "]");
-
-
-
- validValues.add(value);
-
- validValuesDescription.put(value,valueDescription);
-
- }
-
+ if (validValues.size() == 0) {
+ Configuration[] choices = configuration.getChildren("choice");
+ for (int i = 0; i < choices.length; i++) {
+ Configuration choice = choices[i];
+ String value = choice.getAttribute("value");
+ String valueDescription = choice.getValue();
+
+ getLogger().debug("registered choice [" +
String.valueOf(value) + "] = [" + String.valueOf(valueDescription) + "]");
+
+ validValues.add(value);
+ validValuesDescription.put(value, valueDescription);
+ }
+ }
}
- }
-
-
-
- public boolean isSatisfiedBy(Object value, Context context ) {
-
- boolean isValid = validValues.contains(value);
-
- System.out.println("checking choice [" + String.valueOf(value) + "]
contains [" + String.valueOf(validValues) + "] is " + isValid);
-
- getLogger().debug("checking choice [" + String.valueOf(value) + "]
contains [" + String.valueOf(validValues) + "] is " + isValid);
-
- return(isValid);
-
- }
-
-
-
- public String getId() {
-
- return(id);
-
- }
-
-
-
- public String getType() {
-
- return("choice");
-
- }
-
-
-
- public String toString() {
-
- return( String.valueOf(getType()) + "[" + String.valueOf(getId()) + "]
-> [" + String.valueOf(validValues) + "]");
-
- }
-
-
-
- public void toSAX(ContentHandler handler) throws SAXException {
-
- AttributesImpl attributes = new AttributesImpl();
-
- attributes.addAttribute("","type","type","CDATA",getType());
-
- attributes.addAttribute("","name","name","CDATA",id);
-
-
-
- handler.startElement("","constraint","constraint",attributes);
-
- for (Iterator it = validValues.iterator(); it.hasNext();) {
-
- String value = (String) it.next();
-
- String description = (String) validValuesDescription.get(value);
-
-
-
- AttributesImpl choiceAttributes = new AttributesImpl();
-
- choiceAttributes.addAttribute("","value","value","CDATA",value);
-
-
-
- handler.startElement("","choice","choice",choiceAttributes);
-
- handler.characters(description.toCharArray(),0,description.length());
-
- handler.endElement("","choice","choice");
-
+ public boolean isSatisfiedBy(Object value, Context context) {
+ boolean isValid = validValues.contains(value);
+ System.out.println("checking choice [" + String.valueOf(value) + "]
contains [" + String.valueOf(validValues) + "] is " + isValid);
+ getLogger().debug("checking choice [" + String.valueOf(value) + "]
contains [" + String.valueOf(validValues) + "] is " + isValid);
+ return (isValid);
}
- handler.endElement("","constraint","constraint");
+ public String getId() {
+ return (id);
+ }
- }
+ public String getType() {
+ return ("choice");
+ }
+ public String toString() {
+ return (String.valueOf(getType()) + "[" + String.valueOf(getId()) +
"] -> [" + String.valueOf(validValues) + "]");
+ }
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute("", "type", "type", "CDATA", getType());
+ attributes.addAttribute("", "name", "name", "CDATA", id);
+
+ handler.startElement("", "constraint", "constraint", attributes);
+ for (Iterator it = validValues.iterator(); it.hasNext();) {
+ String value = (String) it.next();
+ String description = (String) validValuesDescription.get(value);
+
+ AttributesImpl choiceAttributes = new AttributesImpl();
+ choiceAttributes.addAttribute("", "value", "value", "CDATA",
value);
+
+ handler.startElement("", "choice", "choice", choiceAttributes);
+ handler.characters(description.toCharArray(), 0,
description.length());
+ handler.endElement("", "choice", "choice");
+ }
+ handler.endElement("", "constraint", "constraint");
+ }
}
-
1.3 +14 -21
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/RegexprConstraint.java
Index: RegexprConstraint.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/preceptors/easyrelax/constraints/RegexprConstraint.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RegexprConstraint.java 7 Jan 2003 23:56:10 -0000 1.2
+++ RegexprConstraint.java 12 Jan 2003 16:31:19 -0000 1.3
@@ -61,42 +61,39 @@
import org.apache.regexp.RESyntaxException;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
+
/*
* @version: Mar 21, 2002
* @author Torsten Curdt <[EMAIL PROTECTED]>
*/
-public class RegexprConstraint extends AbstractConstraint implements
Configurable, SingleThreaded
-{
+
+public class RegexprConstraint extends AbstractConstraint implements
Configurable, SingleThreaded {
private String expressionString;
private RE expression;
- public void configure(Configuration configuration) throws
ConfigurationException
- {
+ public void configure(Configuration configuration) throws
ConfigurationException {
id = configuration.getAttribute("name");
expressionString = configuration.getValue();
getLogger().debug("expression [" + String.valueOf(expressionString)
+ "]");
- try
- {
+ try {
expression = new RE(expressionString);
}
- catch (RESyntaxException e)
- {
+ catch (RESyntaxException e) {
throw new ConfigurationException("", e);
}
}
- public boolean isSatisfiedBy(Object value, Context context)
- {
+ public boolean isSatisfiedBy(Object value, Context context) {
boolean isValid = expression.match(String.valueOf(value));
System.out.println(
- "checking regexpr ["
+ "checking regexpr ["
+ String.valueOf(value)
+ "] matches ["
+ String.valueOf(expressionString)
+ "] is "
+ isValid);
getLogger().debug(
- "checking regexpr ["
+ "checking regexpr ["
+ String.valueOf(value)
+ "] matches ["
+ String.valueOf(expressionString)
@@ -105,20 +102,17 @@
return (isValid);
}
- public String getId()
- {
+ public String getId() {
return (id);
}
- public String getType()
- {
+ public String getType() {
return ("regexpr");
}
- public String toString()
- {
+ public String toString() {
return (
- String.valueOf(getType())
+ String.valueOf(getType())
+ "["
+ String.valueOf(getId())
+ "] -> ["
@@ -126,7 +120,6 @@
+ "]");
}
- public void toSAX(ContentHandler handler) throws SAXException
- {
+ public void toSAX(ContentHandler handler) throws SAXException {
}
}
1.2 +14 -86
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/AbstractInstance.java
Index: AbstractInstance.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/AbstractInstance.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractInstance.java 29 Oct 2002 15:48:34 -0000 1.1
+++ AbstractInstance.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores;
-
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.component.Composable;
@@ -117,55 +64,36 @@
import org.apache.cocoon.precept.Instance;
-
import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionBindingEvent;
-
/*
-
* @version: Mar 18, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
-public abstract class AbstractInstance extends AbstractLogEnabled
- implements Instance, Composable, Disposable, HttpSessionBindingListener {
-
- protected ComponentManager manager;
-
-
-
- public void compose(ComponentManager manager) throws ComponentException {
-
- this.manager = manager;
-
- }
-
-
-
- public void valueBound(HttpSessionBindingEvent event) {
-
- }
-
-
-
- public void valueUnbound(HttpSessionBindingEvent event) {
-
- getLogger().debug("releasing instance in session");
+public abstract class AbstractInstance extends AbstractLogEnabled
+ implements Instance, Composable, Disposable,
HttpSessionBindingListener {
- manager.release(this);
+ protected ComponentManager manager;
- }
+ public void compose(ComponentManager manager) throws ComponentException {
+ this.manager = manager;
+ }
+ public void valueBound(HttpSessionBindingEvent event) {
+ }
- public void dispose() {
- }
+ public void valueUnbound(HttpSessionBindingEvent event) {
+ getLogger().debug("releasing instance in session");
+ manager.release(this);
+ }
+ public void dispose() {
+ }
}
1.2 +90 -257
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/InstanceImpl.java
Index: InstanceImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/InstanceImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InstanceImpl.java 29 Oct 2002 15:48:34 -0000 1.1
+++ InstanceImpl.java 12 Jan 2003 16:31:19 -0000 1.2
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.bean;
-
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.configuration.Configurable;
@@ -137,236 +84,122 @@
import org.apache.cocoon.precept.stores.AbstractInstance;
-
import java.util.Collection;
-
/*
-
* @version: Mar 15, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class InstanceImpl extends AbstractInstance implements Configurable {
- private Preceptor preceptor;
-
- private Mapping mapping;
-
- private Object bean;
-
- private JXPathContext beanContext;
-
-
-
- public void setBean(Object bean) {
-
- this.bean = bean;
-
- this.beanContext = JXPathContext.newContext(bean);
-
- }
-
-
-
- public void configure(Configuration configuration) throws
ConfigurationException {
-
- Configuration clazzConf = configuration.getChild("class");
-
- if (clazzConf != null) {
-
- ClassLoaderManager clazzLoader = null;
-
- try {
-
- String clazzName = clazzConf.getValue();
-
- String mappingURI = clazzConf.getAttribute("mapping");
-
-
-
- if (mappingURI != null) {
-
- mapping = new Mapping();
-
- // resolve
-
- //mapping.loadMapping(getFile(resolver,mappingURI));
-
- getLogger().debug("bean class = [" + String.valueOf(clazzName) +
"] mapping [" + String.valueOf(mappingURI) + "]");
-
+ private Preceptor preceptor;
+ private Mapping mapping;
+ private Object bean;
+ private JXPathContext beanContext;
+
+ public void setBean(Object bean) {
+ this.bean = bean;
+ this.beanContext = JXPathContext.newContext(bean);
+ }
+
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ Configuration clazzConf = configuration.getChild("class");
+ if (clazzConf != null) {
+ ClassLoaderManager clazzLoader = null;
+ try {
+ String clazzName = clazzConf.getValue();
+ String mappingURI = clazzConf.getAttribute("mapping");
+
+ if (mappingURI != null) {
+ mapping = new Mapping();
+ // resolve
+ //mapping.loadMapping(getFile(resolver,mappingURI));
+ getLogger().debug("bean class = [" +
String.valueOf(clazzName) + "] mapping [" + String.valueOf(mappingURI) + "]");
+ }
+ else {
+ getLogger().debug("bean class = [" +
String.valueOf(clazzName) + "] using default mapping");
+ }
+
+ clazzLoader = (ClassLoaderManager)
manager.lookup(ClassLoaderManager.ROLE);
+ Class clazz = clazzLoader.loadClass(clazzName);
+ setBean(clazz.newInstance());
+ }
+ catch (ComponentException e) {
+ throw new ConfigurationException("", e);
+ }
+ catch (ClassNotFoundException e) {
+ throw new ConfigurationException("", e);
+ }
+ catch (InstantiationException e) {
+ throw new ConfigurationException("", e);
+ }
+ catch (IllegalAccessException e) {
+ throw new ConfigurationException("", e);
+ }
+ finally {
+ manager.release(clazzLoader);
+ }
}
-
- else {
-
- getLogger().debug("bean class = [" + String.valueOf(clazzName) +
"] using default mapping");
-
- }
-
-
-
- clazzLoader = (ClassLoaderManager)
manager.lookup(ClassLoaderManager.ROLE);
-
- Class clazz = clazzLoader.loadClass(clazzName);
-
- setBean(clazz.newInstance());
-
- }
-
- catch (ComponentException e) {
-
- throw new ConfigurationException("", e);
-
- }
-
- catch (ClassNotFoundException e) {
-
- throw new ConfigurationException("", e);
-
- }
-
- catch (InstantiationException e) {
-
- throw new ConfigurationException("", e);
-
- }
-
- catch (IllegalAccessException e) {
-
- throw new ConfigurationException("", e);
-
- }
-
- finally {
-
- manager.release(clazzLoader);
-
- }
-
}
- }
-
-
-
- public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException {
-
- setValue(xpath, value, null);
-
- }
-
-
-
- public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException {
-
- try {
-
- beanContext.setValue(xpath, value);
-
+ public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException {
+ setValue(xpath, value, null);
}
- catch (Exception e) {
-
- throw new PreceptorViolationException(e);
-
+ public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException {
+ try {
+ beanContext.setValue(xpath, value);
+ }
+ catch (Exception e) {
+ throw new PreceptorViolationException(e);
+ }
}
- }
-
-
-
- public Object getValue(String xpath) throws InvalidXPathSyntaxException {
-
- try {
-
- return (beanContext.getValue(xpath));
-
+ public Object getValue(String xpath) throws InvalidXPathSyntaxException {
+ try {
+ return (beanContext.getValue(xpath));
+ }
+ catch (Exception e) {
+ throw new InvalidXPathSyntaxException(e);
+ }
}
- catch (Exception e) {
-
- throw new InvalidXPathSyntaxException(e);
-
+ public void setPreceptor(Preceptor preceptor) {
+ this.preceptor = preceptor;
+ preceptor.buildInstance(this);
}
- }
-
-
-
- public void setPreceptor(Preceptor preceptor) {
-
- this.preceptor = preceptor;
-
- preceptor.buildInstance(this);
-
- }
-
-
-
- public Preceptor getPreceptor() {
-
- return (preceptor);
-
- }
-
-
-
- public long getLastModified() {
-
- //NYI
-
- return 0;
-
- }
-
-
-
- public void toSAX(ContentHandler handler, boolean withConstraints) throws
SAXException {
-
- try {
-
- Marshaller marshaller = new Marshaller(new
DocumentHandlerAdapter(handler));
-
- if (mapping != null) {
-
- marshaller.setMapping(mapping);
-
- }
-
- marshaller.marshal(bean);
-
+ public Preceptor getPreceptor() {
+ return (preceptor);
}
- catch (ValidationException e) {
-
- throw new SAXException(e);
-
+ public long getLastModified() {
+ //NYI
+ return 0;
}
- catch (MappingException e) {
-
- throw new SAXException(e);
-
+ public void toSAX(ContentHandler handler, boolean withConstraints)
throws SAXException {
+ try {
+ Marshaller marshaller = new Marshaller(new
DocumentHandlerAdapter(handler));
+ if (mapping != null) {
+ marshaller.setMapping(mapping);
+ }
+ marshaller.marshal(bean);
+ }
+ catch (ValidationException e) {
+ throw new SAXException(e);
+ }
+ catch (MappingException e) {
+ throw new SAXException(e);
+ }
+ catch (MarshalException e) {
+ throw new SAXException(e);
+ }
}
- catch (MarshalException e) {
-
- throw new SAXException(e);
-
+ public Collection getNodePaths() {
+ return null;
}
-
- }
-
-
-
- public Collection getNodePaths() {
-
- return null;
-
- }
-
}
-
1.2 +50 -158
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/CocoonInstallationBean.java
Index: CocoonInstallationBean.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/CocoonInstallationBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CocoonInstallationBean.java 29 Oct 2002 15:48:34 -0000 1.1
+++ CocoonInstallationBean.java 12 Jan 2003 16:31:20 -0000 1.2
@@ -1,220 +1,112 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.bean.test;
-
/*
-
* @version: Mar 20, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class CocoonInstallationBean {
- private UserBean user;
-
- private SystemBean system;
-
- private int number;
-
- private String live_url;
-
- private boolean publish;
-
-
-
- public CocoonInstallationBean() {
-
- user = new UserBean();
-
- system = new SystemBean();
-
- }
-
-
-
- public UserBean getUser() {
-
- return user;
-
- }
-
-
-
- public void setUser(UserBean user) {
-
- this.user = user;
-
- }
-
-
-
- public SystemBean getSystem() {
-
- return system;
-
- }
-
-
-
- public void setSystem(SystemBean system) {
-
- this.system = system;
-
- }
-
-
-
- public int getNumber() {
-
- return number;
-
- }
-
-
-
- public void setNumber(int number) {
-
- this.number = number;
-
- }
-
-
-
- public String getLive_url() {
-
- return live_url;
-
- }
-
-
-
- public void setLive_url(String live_url) {
-
- this.live_url = live_url;
-
- }
-
-
-
- public boolean isPublish() {
-
- return publish;
-
- }
-
-
-
- public void setPublish(boolean publish) {
-
- this.publish = publish;
-
- }
-
-
+ private UserBean user;
+ private SystemBean system;
+ private int number;
+ private String live_url;
+ private boolean publish;
+
+ public CocoonInstallationBean() {
+ user = new UserBean();
+ system = new SystemBean();
+ }
+
+ public UserBean getUser() {
+ return user;
+ }
+
+ public void setUser(UserBean user) {
+ this.user = user;
+ }
+
+ public SystemBean getSystem() {
+ return system;
+ }
+
+ public void setSystem(SystemBean system) {
+ this.system = system;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getLive_url() {
+ return live_url;
+ }
+
+ public void setLive_url(String live_url) {
+ this.live_url = live_url;
+ }
+
+ public boolean isPublish() {
+ return publish;
+ }
+
+ public void setPublish(boolean publish) {
+ this.publish = publish;
+ }
}
-
1.2 +48 -153
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/SystemBean.java
Index: SystemBean.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/SystemBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SystemBean.java 29 Oct 2002 15:48:34 -0000 1.1
+++ SystemBean.java 12 Jan 2003 16:31:20 -0000 1.2
@@ -1,214 +1,109 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.bean.test;
-
/*
-
* @version: Mar 20, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class SystemBean {
- private String os;
-
- private String processor;
-
- private int ram;
-
- private String servlet_engine;
-
- private String java_version;
-
-
-
- public SystemBean() {
-
- }
-
-
-
- public String getOs() {
-
- return os;
-
- }
-
-
-
- public void setOs(String os) {
-
- this.os = os;
-
- }
-
-
-
- public String getProcessor() {
-
- return processor;
-
- }
-
-
-
- public void setProcessor(String processor) {
-
- this.processor = processor;
-
- }
-
-
-
- public int getRam() {
-
- return ram;
-
- }
-
-
-
- public void setRam(int ram) {
-
- this.ram = ram;
-
- }
-
-
-
- public String getServlet_engine() {
-
- return servlet_engine;
-
- }
-
-
-
- public void setServlet_engine(String servlet_engine) {
-
- this.servlet_engine = servlet_engine;
-
- }
-
-
-
- public String getJava_version() {
-
- return java_version;
-
- }
-
-
-
- public void setJava_version(String java_version) {
-
- this.java_version = java_version;
-
- }
-
+ private String os;
+ private String processor;
+ private int ram;
+ private String servlet_engine;
+ private String java_version;
+
+ public SystemBean() {
+ }
+
+ public String getOs() {
+ return os;
+ }
+
+ public void setOs(String os) {
+ this.os = os;
+ }
+
+ public String getProcessor() {
+ return processor;
+ }
+
+ public void setProcessor(String processor) {
+ this.processor = processor;
+ }
+
+ public int getRam() {
+ return ram;
+ }
+
+ public void setRam(int ram) {
+ this.ram = ram;
+ }
+
+ public String getServlet_engine() {
+ return servlet_engine;
+ }
+
+ public void setServlet_engine(String servlet_engine) {
+ this.servlet_engine = servlet_engine;
+ }
+
+ public String getJava_version() {
+ return java_version;
+ }
+
+ public void setJava_version(String java_version) {
+ this.java_version = java_version;
+ }
}
-
1.2 +30 -117
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/UserBean.java
Index: UserBean.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/bean/test/UserBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UserBean.java 29 Oct 2002 15:48:34 -0000 1.1
+++ UserBean.java 12 Jan 2003 16:31:20 -0000 1.2
@@ -1,178 +1,91 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.bean.test;
-
/*
-
* @version: Mar 20, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class UserBean {
- private String firstname;
-
- private String lastname;
-
- private String email;
-
-
-
- public UserBean() {
-
- }
-
-
-
- public String getFirstname() {
-
- return firstname;
-
- }
-
-
-
- public void setFirstname(String firstname) {
-
- this.firstname = firstname;
-
- }
-
-
-
- public String getLastname() {
-
- return lastname;
-
- }
-
-
-
- public void setLastname(String lastname) {
-
- this.lastname = lastname;
-
- }
-
-
-
- public String getEmail() {
-
- return email;
-
- }
-
-
-
- public void setEmail(String email) {
-
- this.email = email;
-
- }
-
+ private String firstname;
+ private String lastname;
+ private String email;
+
+ public UserBean() {
+ }
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
}
-
1.3 +8 -62
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/AttributeNode.java
Index: AttributeNode.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/AttributeNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AttributeNode.java 7 Jan 2003 23:56:11 -0000 1.2
+++ AttributeNode.java 12 Jan 2003 16:31:20 -0000 1.3
@@ -1,124 +1,70 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
package org.apache.cocoon.precept.stores.dom.simple;
import java.util.Collection;
/*
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class AttributeNode extends Node {
- public AttributeNode( String name, Collection constraints) {
- super(name,constraints);
- }
-
- public void toStringBuffer( StringBuffer sb, int depth) {
- sb.append(" ").append(name).append("=");
-
- sb.append("\"").append(String.valueOf(getValue())).append("\"");
-
- }
+ public AttributeNode(String name, Collection constraints) {
+ super(name, constraints);
+ }
+
+ public void toStringBuffer(StringBuffer sb, int depth) {
+ sb.append(" ").append(name).append("=");
+ sb.append("\"").append(String.valueOf(getValue())).append("\"");
+ }
}
1.2 +73 -222
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/ElementNode.java
Index: ElementNode.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/ElementNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ElementNode.java 29 Oct 2002 15:48:34 -0000 1.1
+++ ElementNode.java 12 Jan 2003 16:31:20 -0000 1.2
@@ -1,109 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.dom.simple;
-
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -115,207 +62,111 @@
import org.apache.cocoon.precept.Constraint;
-
import java.util.*;
-
/*
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class ElementNode extends Node {
- private final static Attributes NOATTR = new AttributesImpl();
-
-
-
- private ArrayList childs;
-
- private ArrayList attributes;
-
- private HashMap attributeIndex;
-
-
-
-
-
- public ElementNode(String name, Collection constraints) {
-
- super(name, constraints);
-
- }
-
-
-
- public void addAttribute(Node node) {
-
- if (attributes == null) attributes = new ArrayList();
-
- if (attributeIndex == null) attributeIndex = new HashMap();
-
- attributes.add(node);
-
- attributeIndex.put(node.getValue(), node);
-
- }
-
- //public Node getAttribute( String name ) {
- //}
-
- public List getAttributes() {
+ private final static Attributes NOATTR = new AttributesImpl();
- return (attributes);
+ private ArrayList childs;
+ private ArrayList attributes;
+ private HashMap attributeIndex;
- }
-
-
-
-
-
- public void addChild(Node node) {
-
- if (childs == null) childs = new ArrayList();
-
- childs.add(node);
-
- }
-
-
-
- public List getChilds() {
-
- return (childs);
-
- }
-
- //public List getChilds( String name ) {
- //}
-
- public void toStringBuffer(StringBuffer sb, ElementNode e, int depth) {
-
- StringBuffer ident = new StringBuffer();
-
- for (int i = 0; i < depth * 3; i++) ident.append(" ");
-
-
-
- sb.append("\n").append(ident).append("<").append(e.getName());
-
-
-
-
-
- Collection attributes = e.getAttributes();
-
- if (attributes != null) {
-
- for (Iterator it = attributes.iterator(); it.hasNext();) {
-
- AttributeNode attr = (AttributeNode) it.next();
-
- attr.toStringBuffer(sb, depth);
-
- }
+ public ElementNode(String name, Collection constraints) {
+ super(name, constraints);
}
-
-
- sb.append(">").append("\n").append(ident).append(" ");
-
-
-
- sb.append(String.valueOf(e.getValue()));
-
-
-
- Collection childs = e.getChilds();
-
- if (childs != null) {
-
- for (Iterator it = childs.iterator(); it.hasNext();) {
-
- ElementNode child = (ElementNode) it.next();
-
- toStringBuffer(sb, child, depth + 1);
-
- }
-
+ public void addAttribute(Node node) {
+ if (attributes == null) attributes = new ArrayList();
+ if (attributeIndex == null) attributeIndex = new HashMap();
+ attributes.add(node);
+ attributeIndex.put(node.getValue(), node);
}
- sb.append("\n").append(ident);
-
- sb.append("</").append(e.getName()).append(">");
-
- }
-
-
-
-
-
- public void toSAX(ContentHandler handler, ElementNode e, boolean
withConstraints) throws SAXException {
-
-
-
- handler.startElement("", e.getName(), e.getName(), NOATTR);
-
-
-
- if (e.getValue() != null)
handler.characters(e.getValue().toString().toCharArray(), 0,
e.getValue().length());
-
-
-
- if (withConstraints) {
-
- Collection constraints = e.getConstraints();
-
- if (constraints != null) {
-
- for (Iterator it = constraints.iterator(); it.hasNext();) {
-
- Constraint constraint = (Constraint) it.next();
+ //public Node getAttribute( String name ) {
+ //}
+ public List getAttributes() {
+ return (attributes);
+ }
+ public void addChild(Node node) {
+ if (childs == null) childs = new ArrayList();
+ childs.add(node);
+ }
- handler.startElement("", "constraint", "constraint", NOATTR);
+ public List getChilds() {
+ return (childs);
+ }
- String s = String.valueOf(constraint.getId()) +
+ //public List getChilds( String name ) {
+ //}
+ public void toStringBuffer(StringBuffer sb, ElementNode e, int depth) {
+ StringBuffer ident = new StringBuffer();
+ for (int i = 0; i < depth * 3; i++) ident.append(" ");
+
+ sb.append("\n").append(ident).append("<").append(e.getName());
- " of type " + String.valueOf(constraint.getType()) +
- " is " + constraint.isSatisfiedBy(e.getValue(), null);
+ Collection attributes = e.getAttributes();
+ if (attributes != null) {
+ for (Iterator it = attributes.iterator(); it.hasNext();) {
+ AttributeNode attr = (AttributeNode) it.next();
+ attr.toStringBuffer(sb, depth);
+ }
+ }
- handler.characters(s.toString().toCharArray(), 0, s.length());
+ sb.append(">").append("\n").append(ident).append(" ");
- handler.endElement("", "constraint", "constraint");
+ sb.append(String.valueOf(e.getValue()));
+ Collection childs = e.getChilds();
+ if (childs != null) {
+ for (Iterator it = childs.iterator(); it.hasNext();) {
+ ElementNode child = (ElementNode) it.next();
+ toStringBuffer(sb, child, depth + 1);
+ }
}
-
- }
-
+ sb.append("\n").append(ident);
+ sb.append("</").append(e.getName()).append(">");
}
+ public void toSAX(ContentHandler handler, ElementNode e, boolean
withConstraints) throws SAXException {
- Collection childs = e.getChilds();
-
- if (childs != null) {
-
- for (Iterator it = childs.iterator(); it.hasNext();) {
+ handler.startElement("", e.getName(), e.getName(), NOATTR);
- ElementNode child = (ElementNode) it.next();
+ if (e.getValue() != null)
handler.characters(e.getValue().toString().toCharArray(), 0,
e.getValue().length());
- toSAX(handler, child, withConstraints);
-
- }
+ if (withConstraints) {
+ Collection constraints = e.getConstraints();
+ if (constraints != null) {
+ for (Iterator it = constraints.iterator(); it.hasNext();) {
+ Constraint constraint = (Constraint) it.next();
+
+ handler.startElement("", "constraint", "constraint",
NOATTR);
+ String s = String.valueOf(constraint.getId()) +
+ " of type " +
String.valueOf(constraint.getType()) +
+ " is " + constraint.isSatisfiedBy(e.getValue(),
null);
+ handler.characters(s.toString().toCharArray(), 0,
s.length());
+ handler.endElement("", "constraint", "constraint");
+ }
+ }
+ }
+ Collection childs = e.getChilds();
+ if (childs != null) {
+ for (Iterator it = childs.iterator(); it.hasNext();) {
+ ElementNode child = (ElementNode) it.next();
+ toSAX(handler, child, withConstraints);
+ }
+ }
+ handler.endElement("", getName(), e.getName());
}
-
- handler.endElement("", getName(), e.getName());
-
- }
-
}
1.3 +127 -346
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/InstanceImpl.java
Index: InstanceImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/InstanceImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InstanceImpl.java 7 Jan 2003 23:56:11 -0000 1.2
+++ InstanceImpl.java 12 Jan 2003 16:31:20 -0000 1.3
@@ -1,111 +1,56 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.dom.simple;
-
-
-
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -121,333 +66,169 @@
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public class InstanceImpl extends AbstractInstance {
- private HashMap index = new HashMap();
-
- private Preceptor preceptor;
-
- private ElementNode root;
-
-
-
- public void setPreceptor(Preceptor preceptor) {
-
- this.preceptor = preceptor;
-
- preceptor.buildInstance(this);
-
- }
-
-
-
- private Node createNode(String xpath) throws InvalidXPathSyntaxException {
-
- try {
-
- StringBuffer currentPath = new StringBuffer();
-
- StringTokenizer tok = new StringTokenizer(xpath, "/", false);
-
- Node currentParent = root;
-
- boolean first = true;
-
- while (tok.hasMoreTokens()) {
-
- String level = tok.nextToken();
-
- if (!first) {
-
- currentPath.append("/");
-
+ private HashMap index = new HashMap();
+ private Preceptor preceptor;
+ private ElementNode root;
+
+ public void setPreceptor(Preceptor preceptor) {
+ this.preceptor = preceptor;
+ preceptor.buildInstance(this);
+ }
+
+ private Node createNode(String xpath) throws InvalidXPathSyntaxException
{
+ try {
+ StringBuffer currentPath = new StringBuffer();
+ StringTokenizer tok = new StringTokenizer(xpath, "/", false);
+ Node currentParent = root;
+ boolean first = true;
+ while (tok.hasMoreTokens()) {
+ String level = tok.nextToken();
+ if (!first) {
+ currentPath.append("/");
+ }
+ else {
+ first = false;
+ }
+ if (level.endsWith("[1]")) {
+ level = level.substring(0, level.length() - 3);
+ }
+ currentPath.append(level);
+ Node node = (Node) index.get(currentPath.toString());
+ if (node != null) {
+ getLogger().debug("found node [" +
String.valueOf(currentPath) + "] in index");
+ currentParent = node;
+ }
+ else {
+ if (currentParent != null) {
+ if (level.startsWith("@")) {
+ if (level.indexOf("[") >= 0 ||
level.indexOf("]") >= 0) {
+ throw new InvalidXPathSyntaxException(level);
+ }
+ if (preceptor != null) {
+ node = new AttributeNode(level.substring(1),
preceptor.getConstraintsFor(currentPath.toString()));
+ }
+ else {
+ node = new AttributeNode(level.substring(1),
null);
+ }
+ getLogger().debug("creating attribute [" +
String.valueOf(currentPath) + "]");
+ ((ElementNode) currentParent).addAttribute(node);
+ index.put(currentPath.toString(), node);
+ return (node);
+ }
+ else {
+ if (preceptor != null) {
+ node = new ElementNode(level,
preceptor.getConstraintsFor(currentPath.toString()));
+ }
+ else {
+ node = new ElementNode(level, null);
+ }
+ getLogger().debug("creating node [" +
String.valueOf(currentPath) + "]");
+ ((ElementNode) currentParent).addChild(node);
+ index.put(currentPath.toString(), node);
+ }
+ }
+ else {
+ getLogger().debug("creating root node [" +
String.valueOf(currentPath) + "]");
+ if (preceptor != null) {
+ node = root = new ElementNode(level,
preceptor.getConstraintsFor(currentPath.toString()));
+ }
+ else {
+ node = root = new ElementNode(level, null);
+ }
+ index.put(currentPath.toString(), node);
+ }
+ }
+ currentParent = node;
+ }
+ return (currentParent);
}
-
- else {
-
- first = false;
-
+ catch (NoSuchNodeException e) {
+ getLogger().error("hm.. this should not happen!");
+ return (null);
}
+ }
- if (level.endsWith("[1]")) {
-
- level = level.substring(0, level.length() - 3);
-
+ private Node lookupNode(String xpath) {
+ Node node = (Node) index.get(xpath);
+ if (node == null) {
+ node = (Node) index.get(xpath + "[1]");
}
+ return (node);
+ }
- currentPath.append(level);
+ public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException {
+ setValue(xpath, value, null);
+ }
- Node node = (Node) index.get(currentPath.toString());
+ public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException {
+ Node node = lookupNode(xpath);
if (node != null) {
-
- getLogger().debug("found node [" + String.valueOf(currentPath) +
"] in index");
-
- currentParent = node;
-
+ node.setValue((String) value);
}
-
else {
-
- if (currentParent != null) {
-
- if (level.startsWith("@")) {
-
- if (level.indexOf("[") >= 0 || level.indexOf("]") >= 0) {
-
- throw new InvalidXPathSyntaxException(level);
-
- }
-
- if (preceptor != null) {
-
- node = new AttributeNode(level.substring(1),
preceptor.getConstraintsFor(currentPath.toString()));
-
- }
-
- else {
-
- node = new AttributeNode(level.substring(1), null);
-
- }
-
- getLogger().debug("creating attribute [" +
String.valueOf(currentPath) + "]");
-
- ((ElementNode) currentParent).addAttribute(node);
-
- index.put(currentPath.toString(), node);
-
- return (node);
-
- }
-
- else {
-
- if (preceptor != null) {
-
- node = new ElementNode(level,
preceptor.getConstraintsFor(currentPath.toString()));
-
- }
-
- else {
-
- node = new ElementNode(level, null);
-
- }
-
- getLogger().debug("creating node [" +
String.valueOf(currentPath) + "]");
-
- ((ElementNode) currentParent).addChild(node);
-
- index.put(currentPath.toString(), node);
-
- }
-
- }
-
- else {
-
- getLogger().debug("creating root node [" +
String.valueOf(currentPath) + "]");
-
if (preceptor != null) {
-
- node = root = new ElementNode(level,
preceptor.getConstraintsFor(currentPath.toString()));
-
+ getLogger().debug("checking preceptor for [" +
String.valueOf(xpath) + "]");
+ if (preceptor.isValidNode(xpath)) {
+ node = createNode(xpath);
+ node.setValue((String) value);
+ }
+ else {
+ throw new PreceptorViolationException("[" +
String.valueOf(xpath) + "] is prohibited by preceptor");
+ }
}
-
else {
-
- node = root = new ElementNode(level, null);
-
+ getLogger().debug("no preceptor");
+ node = createNode(xpath);
+ node.setValue((String) value);
}
-
- index.put(currentPath.toString(), node);
-
- }
-
}
-
- currentParent = node;
-
- }
-
- return (currentParent);
-
}
- catch (NoSuchNodeException e) {
-
- getLogger().error("hm.. this should not happen!");
-
- return (null);
-
- }
-
- }
-
-
-
- private Node lookupNode( String xpath ) {
-
- Node node = (Node) index.get(xpath);
-
- if (node == null) {
-
- node = (Node) index.get(xpath + "[1]");
-
- }
-
- return(node);
-
- }
-
-
-
- public void setValue(String xpath, Object value) throws
PreceptorViolationException, InvalidXPathSyntaxException {
-
- setValue(xpath, value, null);
-
- }
-
-
-
- public void setValue(String xpath, Object value, Context context) throws
PreceptorViolationException, InvalidXPathSyntaxException {
-
- Node node = lookupNode(xpath);
-
-
-
- if (node != null) {
-
- node.setValue((String) value);
-
- }
-
- else {
-
- if (preceptor != null) {
-
- getLogger().debug("checking preceptor for [" + String.valueOf(xpath)
+ "]");
-
- if (preceptor.isValidNode(xpath)) {
-
- node = createNode(xpath);
-
- node.setValue((String) value);
-
+ public Object getValue(String xpath) throws InvalidXPathSyntaxException,
NoSuchNodeException {
+ Node node = lookupNode(xpath);
+ if (node != null) {
+ return (node.getValue());
}
-
else {
-
- throw new PreceptorViolationException("[" + String.valueOf(xpath)
+ "] is prohibited by preceptor");
-
+ throw new NoSuchNodeException(xpath);
}
-
- }
-
- else {
-
- getLogger().debug("no preceptor");
-
- node = createNode(xpath);
-
- node.setValue((String) value);
-
- }
-
}
- }
-
-
-
- public Object getValue(String xpath) throws InvalidXPathSyntaxException,
NoSuchNodeException {
-
- Node node = lookupNode(xpath);
-
- if (node != null) {
-
- return (node.getValue());
-
+ public Preceptor getPreceptor() {
+ return (preceptor);
}
- else {
-
- throw new NoSuchNodeException(xpath);
-
+ public long getLastModified() {
+ //NYI
+ return 0;
}
- }
-
-
-
- public Preceptor getPreceptor() {
-
- return (preceptor);
-
- }
-
-
-
- public long getLastModified() {
-
- //NYI
-
- return 0;
-
- }
-
-
-
- public void toSAX(ContentHandler handler, boolean constraints) throws
SAXException {
-
- if (root != null) {
-
- root.toSAX(handler, root, constraints);
-
+ public void toSAX(ContentHandler handler, boolean constraints) throws
SAXException {
+ if (root != null) {
+ root.toSAX(handler, root, constraints);
+ }
}
- }
-
-
-
- public String toString() {
-
- if (root != null) {
-
- StringBuffer sb = new StringBuffer();
-
- root.toStringBuffer(sb, root, 0);
-
- return (sb.toString());
-
+ public String toString() {
+ if (root != null) {
+ StringBuffer sb = new StringBuffer();
+ root.toStringBuffer(sb, root, 0);
+ return (sb.toString());
+ }
+ else {
+ return ("");
+ }
}
- else {
-
- return ("");
-
+ public Collection getNodePaths() {
+ return (Collections.unmodifiableCollection(index.keySet()));
}
-
- }
-
-
-
- public Collection getNodePaths() {
-
- return( Collections.unmodifiableCollection( index.keySet() ));
-
- }
-
}
-
1.3 +24 -89
xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/Node.java
Index: Node.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/blocks/precept/java/org/apache/cocoon/precept/stores/dom/simple/Node.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Node.java 7 Jan 2003 23:56:11 -0000 1.2
+++ Node.java 12 Jan 2003 16:31:20 -0000 1.3
@@ -1,152 +1,87 @@
/*
-
-
============================================================================
-
The Apache Software License, Version 1.1
-
============================================================================
-
-
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
-
-
Redistribution and use in source and binary forms, with or without modifica-
-
tion, are permitted provided that the following conditions are met:
-
-
1. Redistributions of source code must retain the above copyright notice,
-
this list of conditions and the following disclaimer.
-
-
2. Redistributions in binary form must reproduce the above copyright notice,
-
this list of conditions and the following disclaimer in the documentation
-
and/or other materials provided with the distribution.
-
-
3. The end-user documentation included with the redistribution, if any, must
-
include the following acknowledgment: "This product includes software
-
developed by the Apache Software Foundation (http://www.apache.org/)."
-
Alternately, this acknowledgment may appear in the software itself, if
-
and wherever such third-party acknowledgments normally appear.
-
-
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
-
used to endorse or promote products derived from this software without
-
prior written permission. For written permission, please contact
-
[EMAIL PROTECTED]
-
-
5. Products derived from this software may not be called "Apache", nor may
-
"Apache" appear in their name, without prior written permission of the
-
Apache Software Foundation.
-
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
This software consists of voluntary contributions made by many individuals
-
on behalf of the Apache Software Foundation and was originally created by
-
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
-
Software Foundation, please see <http://www.apache.org/>.
-
-
*/
-
-
-
package org.apache.cocoon.precept.stores.dom.simple;
-
-
import java.util.Collection;
-
-
/*
-
* @version: Mar 14, 2002
-
* @author Torsten Curdt <[EMAIL PROTECTED]>
-
*/
public abstract class Node {
-
- protected String name;
- protected String value;
- protected Collection constraints;
-
-
- public Node( String name, Collection constraints) {
- this.name = name;
- this.constraints = constraints;
- }
-
- public String getName() {
- return(name);
- }
-
- public String getValue() {
-
- return(value);
-
- }
-
-
- public void setValue( String value ) {
- this.value = value;
-
- }
-
- public Collection getConstraints() {
- return(constraints);
- }
+ protected String name;
+ protected String value;
+ protected Collection constraints;
+
+ public Node(String name, Collection constraints) {
+ this.name = name;
+ this.constraints = constraints;
+ }
+
+ public String getName() {
+ return (name);
+ }
+
+ public String getValue() {
+ return (value);
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public Collection getConstraints() {
+ return (constraints);
+ }
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]