removing stale RC1 branch
git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/cocoon-2.2@605704 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/pom.xml b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/pom.xml
deleted file mode 100644
index cd81c22..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/pom.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <artifactId>cocoon-core-modules</artifactId>
- <groupId>org.apache.cocoon</groupId>
- <version>4</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cocoon-pipeline-impl</artifactId>
- <version>1.0.0-RC2-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Cocoon Pipeline Implementation</name>
- <description>
- Several implementations of the ProcessingPipeline interface together with
- needed classes and components. Abstract classes for making it easier to
- write sitemap components.
- </description>
-
- <url>http://cocoon.apache.org/${docs.m.pipeline-impl.relPath}</url>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <connection>scm:svn:https://svn.apache.org/repos/asf/cocoon/branches/cocoon-2.2/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/cocoon/branches/cocoon-2.2/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1</developerConnection>
- <url>https://svn.apache.org/repos/asf/cocoon/branches/cocoon-2.2/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1</url>
- </scm>
-
- <properties>
- <docs.name>${project.name}</docs.name>
- <docs.version>${docs.m.pipeline-impl.version}</docs.version>
- </properties>
-
- <distributionManagement>
- <site>
- <id>website</id>
- <url>${docs.deploymentBaseUrl}/${docs.m.pipeline-impl.relPath}</url>
- </site>
- </distributionManagement>
-
- <dependencies>
- <!-- Cocoon -->
- <dependency>
- <groupId>org.apache.cocoon</groupId>
- <artifactId>cocoon-pipeline-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cocoon</groupId>
- <artifactId>cocoon-configuration-api</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cocoon</groupId>
- <artifactId>cocoon-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.cocoon</groupId>
- <artifactId>cocoon-xml-api</artifactId>
- </dependency>
- <!-- Excalibur -->
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-pool-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-sourceresolve</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.avalon.framework</groupId>
- <artifactId>avalon-framework-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.components</groupId>
- <artifactId>excalibur-store</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.excalibur.containerkit</groupId>
- <artifactId>excalibur-instrument-api</artifactId>
- </dependency>
- <!-- Commons -->
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
- <dependency>
- <groupId>jakarta-regexp</groupId>
- <artifactId>jakarta-regexp</artifactId>
- </dependency>
- <!-- Spring Framework -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </dependency>
- <dependency>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <!-- Test Dependencies -->
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/changes/changes.xml b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/changes/changes.xml
deleted file mode 100644
index 368848c..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/changes/changes.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<!--+
- | Find usage details at http://maven.apache.org/plugins/maven-changes-plugin/usage.html
- |
- | @version $Id$
- +-->
-<document>
- <body>
- <release version="1.0.0-M1-SNAPSHOT" date="2007-00-00" description="unreleased">
-
- </release>
- </body>
-</document>
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/CachingOutputStream.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/CachingOutputStream.java
deleted file mode 100644
index bfe499b..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/CachingOutputStream.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.caching;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * This is an {@link OutputStream} which forwards all received bytes to another
- * output stream and in addition caches all bytes, thus acting like a
- * TeeOutputStream.
- *
- * @version $Id$
- */
-public final class CachingOutputStream
-extends OutputStream {
-
- private OutputStream receiver;
-
- /** The buffer for the compile xml byte stream. */
- private byte buf[];
-
- /** The number of valid bytes in the buffer. */
- private int bufCount;
-
- public CachingOutputStream(OutputStream os) {
- this.receiver = os;
- this.buf = new byte[1024];
- this.bufCount = 0;
- }
-
- public byte[] getContent() {
- byte newbuf[] = new byte[this.bufCount];
- System.arraycopy(this.buf, 0, newbuf, 0, this.bufCount);
- return newbuf;
- }
-
- public void write(int b) throws IOException {
- this.receiver.write(b);
- int newcount = this.bufCount + 1;
- if (newcount > this.buf.length) {
- byte newbuf[] = new byte[Math.max(this.buf.length << 1, newcount)];
- System.arraycopy(this.buf, 0, newbuf, 0, this.bufCount);
- this.buf = newbuf;
- }
- this.buf[this.bufCount] = (byte)b;
- this.bufCount = newcount;
- }
-
- public void write( byte b[] ) throws IOException {
- this.write(b, 0, b.length);
- }
-
- public void write(byte b[], int off, int len) throws IOException {
- this.receiver.write(b, off, len);
- if (len == 0) return;
- int newcount = this.bufCount + (len-off);
- if (newcount > this.buf.length) {
- byte newbuf[] = new byte[Math.max(this.buf.length << 1, newcount)];
- System.arraycopy(this.buf, 0, newbuf, 0, this.bufCount);
- this.buf = newbuf;
- }
- System.arraycopy(b, off, this.buf, this.bufCount, len);
- this.bufCount = newcount;
- }
-
- public void flush() throws IOException {
- this.receiver.flush();
- }
-
- public void close() throws IOException {
- this.receiver.close();
- }
-
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/ComponentCacheKey.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/ComponentCacheKey.java
deleted file mode 100644
index 0821fd4..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/ComponentCacheKey.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.caching;
-
-import java.io.Serializable;
-/**
- * This is the cache key for one sitemap component.
- * It consists of three parts:<br/>
- * a.) The component type (generator, transformer etc.)<br/>
- * b.) The component identifier - a unique handle for the sitemap
- * component<br/>
- * c.) The cache key - a key, generated by the component, which
- * is unique inside the components space.
- *
- * @version $Id$
- */
-public final class ComponentCacheKey
- implements Serializable {
-
- public static final int ComponentType_Generator = 1;
- public static final int ComponentType_Transformer = 3;
- public static final int ComponentType_Serializer = 5;
- public static final int ComponentType_Reader = 7;
-
- // Converts Generator / Transformer / Serializer / Reader constants above
- // into string.
- private static final String[] COMPONENTS = { "X", "G", "X", "T", "X", "S", "X", "R" };
-
- /** The component type */
- private final int type;
- /** The component identifier */
- private final String identifier;
- /** The unique key */
- private final Serializable key;
- /** the hash code */
- private final int hashCode;
- /** cachePoint */
- private final boolean cachePoint;
-
- /**
- * Constructor
- */
- public ComponentCacheKey(int componentType,
- String componentIdentifier,
- Serializable cacheKey) {
- this(componentType, componentIdentifier, cacheKey, false);
- }
-
- /**
- * alternate cachepoint Constructor
- */
- public ComponentCacheKey(int componentType,
- String componentIdentifier,
- Serializable cacheKey,
- boolean cachePoint) {
- this.type = componentType;
- this.identifier = componentIdentifier;
- this.key = cacheKey;
- /** cachePoint */
- this.cachePoint = cachePoint;
- this.hashCode = this.type +
- (this.identifier.length() << 3) +
- this.key.hashCode();
- }
-
- /**
- * Compare
- */
- public boolean equals(Object object) {
- if (object instanceof ComponentCacheKey) {
- ComponentCacheKey ccp = (ComponentCacheKey)object;
- if (this.type == ccp.type
- && this.identifier.equals(ccp.identifier)
- && this.key.equals(ccp.key)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * HashCode
- */
- public int hashCode() {
- return this.hashCode;
- }
-
- private String toString;
-
- /**
- * toString
- * The FilesystemStore uses toString!
- */
- public String toString() {
- if (this.toString == null) {
- toString = COMPONENTS[this.type] + '-' + this.identifier + '-' + this.key.toString();
- }
- return toString;
- }
-
- /**
- * Check if we are a cachepoint
- */
- public boolean isCachePoint() {
- return cachePoint;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/IdentifierCacheKey.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/IdentifierCacheKey.java
deleted file mode 100644
index 06a13dd..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/IdentifierCacheKey.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.caching;
-
-import java.io.Serializable;
-
-/**
- * This is a "simple" cache key that does not consider the components used in the
- * pipeline. It simply consists of a key (unique identifier for the request) and
- * a boolean value that defines if the key is for a complete pipeline call or
- * for an internal pipeline call.
- *
- * @version $Id$
- * @since 2.1.1
- */
-public class IdentifierCacheKey implements Serializable {
-
- /** The key. Must not be null. */
- protected final String key;
-
- /** True if this is an external pipeline call. */
- protected final boolean external;
-
- /** Caches toString() value. */
- protected transient String toString;
-
- /**
- * @param key Not null key value
- * @param external True if key represents external pipeline call
- */
- public IdentifierCacheKey(String key, boolean external) {
- this.key = key;
- this.external = external;
- }
-
- /**
- * The cache key
- */
- public String getKey() {
- return this.key;
- }
-
- /**
- * Compare
- */
- public boolean equals(Object object) {
- if (object instanceof IdentifierCacheKey) {
- IdentifierCacheKey pck = (IdentifierCacheKey) object;
- if (external != pck.external) {
- return false;
- }
- return this.key.equals(pck.key);
- }
- return false;
- }
-
- /**
- * Generate a hash code
- */
- public int hashCode() {
- return key.hashCode() + (external ? Boolean.TRUE : Boolean.FALSE).hashCode();
- }
-
- /**
- * toString
- * The FilesystemStore uses toString!
- */
- public String toString() {
- if (this.toString == null) {
- this.toString = "IK:" + external + ':' + key;
- }
- return toString;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/PipelineCacheKey.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/PipelineCacheKey.java
deleted file mode 100644
index acbaf42..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/PipelineCacheKey.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.caching;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This is the cache key for one pipeline (or the first part of a pipeline).
- * It consists of one or more {@link ComponentCacheKey}s.
- *
- * @version $Id$
- */
-public final class PipelineCacheKey
- implements Serializable {
-
- /** The keys */
- private final List keys;
-
- /** the hash code */
- private int hashCode;
-
- /**
- * Constructor
- */
- public PipelineCacheKey() {
- this.keys = new ArrayList(6);
- }
-
- /**
- * Constructor
- */
- public PipelineCacheKey(int size) {
- this.keys = new ArrayList(size);
- }
-
- /**
- * Add a key
- */
- public void addKey(ComponentCacheKey key) {
- this.keys.add(key);
- this.hashCode = 0;
- this.toString = null;
- }
-
- /**
- * Remove the last key
- */
- public void removeLastKey() {
- this.keys.remove(this.keys.size()-1);
- this.hashCode = 0;
- this.toString = null;
- }
-
- /**
- * Remove unitl cachepoint (including cachePoint)
- */
- public void removeUntilCachePoint() {
- this.hashCode = 0;
- this.toString = null;
- int keyCount = this.keys.size();
-
- while (keyCount > 0) {
- if (((ComponentCacheKey)this.keys.get(keyCount-1)).isCachePoint()) {
- this.keys.remove(keyCount-1);
- return;
- }
- this.keys.remove(keyCount-1);
- keyCount--;
- }
- }
-
- /**
- * Return the number of keys
- */
- public int size() {
- return this.keys.size();
- }
-
- /**
- * Compare
- */
- public boolean equals(Object object) {
- if (object instanceof PipelineCacheKey) {
- PipelineCacheKey pck = (PipelineCacheKey)object;
- final int len = this.keys.size();
- if (pck.keys.size() == len) {
- boolean cont = true;
- int i = 0;
- while (i < len && cont) {
- cont = this.keys.get(i).equals(pck.keys.get(i));
- i++;
- }
- return cont;
- }
- }
- return false;
- }
-
- /**
- * Generate a hash code
- */
- public int hashCode() {
- if (this.hashCode == 0) {
- final int len = this.keys.size();
- for(int i=0; i < len; i++) {
- this.hashCode += this.keys.get(i).hashCode();
- }
- if (len % 2 == 0) this.hashCode++;
- }
- return this.hashCode;
- }
-
- /**
- * Clone the object (but not the component keys)
- */
- public PipelineCacheKey copy() {
- final int len = this.keys.size();
- PipelineCacheKey pck = new PipelineCacheKey(len);
- for(int i=0; i < len; i++) {
- pck.keys.add(this.keys.get(i));
- }
- return pck;
- }
-
- private String toString;
-
- /**
- * toString
- * The FilesystemStore uses toString!
- */
- public String toString() {
- if (this.toString == null) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("PK");
- final int len = this.keys.size();
- for(int i=0; i < len; i++) {
- buffer.append('_').append(this.keys.get(i).toString());
- }
- this.toString = buffer.toString();
- }
- return toString;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java
deleted file mode 100644
index b851ba0..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/caching/impl/CacheImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.caching.impl;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.Cache;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.excalibur.store.Store;
-
-/**
- * This is the Cocoon cache. This component is responsible for storing
- * and retrieving cached responses. It can be used to monitor the cache
- * or the investigate which responses are cached etc.
- * This component will grow!
- *
- * @since 2.1
- * @version $Id$
- */
-public class CacheImpl implements Cache {
-
- private Log logger = LogFactory.getLog(getClass());
-
- /** The store containing the cached responses */
- protected Store store;
-
- /**
- * Store a cached response
- * @param key the key used by the caching algorithm to identify the
- * request
- * @param response the cached response
- */
- public void store(Serializable key,
- CachedResponse response)
- throws ProcessingException {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Caching new response for " + key);
- }
- try {
- this.store.store(key, response);
- } catch (IOException e) {
- throw new ProcessingException("Unable to cache response.", e);
- }
- }
-
- /**
- * Get a cached response.
- * If it is not available <code>null</code> is returned.
- * @param key the key used by the caching algorithm to identify the
- * request
- */
- public CachedResponse get(Serializable key) {
- final CachedResponse r = (CachedResponse) this.store.get(key);
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Cache " + (r == null ? "MISS" : "HIT") + " for " + key);
- }
- return r;
- }
-
- /**
- * Remove a cached response.
- * If it is not available no operation is performed.
- * @param key the key used by the caching algorithm to identify the
- * request
- */
- public void remove(Serializable key) {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Removing cached response for " + key);
- }
- this.store.remove(key);
- }
-
- /**
- * clear cache of all cached responses
- */
- public void clear() {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Clearing cache");
- }
- // FIXME this clears the whole store!
- this.store.clear();
- }
-
- /**
- * See if a response is cached under this key
- */
- public boolean containsKey(Serializable key) {
- return this.store.containsKey(key);
- }
-
- /**
- * Set the Store implementation
- */
- public void setStore(Store store) {
- this.store = store;
- }
-
- protected Log getLogger() {
- return this.logger;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
deleted file mode 100644
index 601f675..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
+++ /dev/null
@@ -1,928 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-import org.apache.avalon.excalibur.pool.Recyclable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.ConnectionResetException;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Response;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.generation.Generator;
-import org.apache.cocoon.reading.Reader;
-import org.apache.cocoon.serialization.Serializer;
-import org.apache.cocoon.sitemap.DisposableSitemapComponent;
-import org.apache.cocoon.sitemap.SitemapErrorHandler;
-import org.apache.cocoon.sitemap.SitemapModelComponent;
-import org.apache.cocoon.transformation.Transformer;
-import org.apache.cocoon.util.location.Locatable;
-import org.apache.cocoon.util.location.Location;
-import org.apache.cocoon.xml.SaxBuffer;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLProducer;
-import org.apache.excalibur.source.SourceValidity;
-import org.xml.sax.SAXException;
-
-/**
- * This is the base for all implementations of a <code>ProcessingPipeline</code>.
- * It is advisable to inherit from this base class instead of doing a complete
- * own implementation!
- *
- * @since 2.1
- * @version $Id$
- */
-public abstract class AbstractProcessingPipeline
- extends AbstractLogEnabled
- implements ProcessingPipeline, Parameterizable, Recyclable, Serviceable {
-
- // Generator stuff
- protected Generator generator;
- protected Parameters generatorParam;
- protected String generatorSource;
-
- // Transformer stuff
- protected ArrayList transformers = new ArrayList();
- protected ArrayList transformerParams = new ArrayList();
- protected ArrayList transformerSources = new ArrayList();
-
- // Serializer stuff
- protected Serializer serializer;
- protected Parameters serializerParam;
- protected String serializerSource;
- protected String serializerMimeType;
-
- // Reader stuff
- protected Reader reader;
- protected Parameters readerParam;
- protected String readerSource;
- protected String readerMimeType;
-
- // Error handler stuff
- private SitemapErrorHandler errorHandler;
- private ProcessingPipeline errorPipeline;
-
- /** True when pipeline has been prepared. */
- private boolean prepared;
-
- /**
- * This is the last component in the pipeline, either the serializer
- * or a custom XML consumer in case of internal processing.
- */
- protected XMLConsumer lastConsumer;
-
- /** The component manager set with compose() */
- protected ServiceManager manager;
-
- /** The component manager set with compose() and recompose() */
- protected ServiceManager newManager;
-
- /** The configuration */
- protected Parameters configuration;
-
- /** Configured Expires value */
- protected long configuredExpires;
-
- /** Configured Output Buffer Size */
- protected int configuredOutputBufferSize;
-
- /** The parameters */
- protected Parameters parameters;
-
- /** Expires value */
- protected long expires;
-
- /** Output Buffer Size */
- protected int outputBufferSize;
-
- /** The current SourceResolver */
- protected SourceResolver sourceResolver;
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service (ServiceManager aManager)
- throws ServiceException {
- this.manager = aManager;
- this.newManager = aManager;
- }
-
- /**
- * Set the processor's service manager
- */
- public void setProcessorManager (ServiceManager manager) {
- this.newManager = manager;
- }
-
- /**
- * Parameterizable Interface - Configuration
- */
- public void parameterize(Parameters params)
- throws ParameterException {
- this.configuration = params;
- final String expiresValue = params.getParameter("expires", null);
- if (expiresValue != null) {
- this.configuredExpires = parseExpires(expiresValue);
- }
- this.configuredOutputBufferSize = params.getParameterAsInteger("outputBufferSize", -1);
- }
-
- /**
- * Setup this component
- */
- public void setup(Parameters params) {
- this.parameters = params;
- final String expiresValue = params.getParameter("expires", null);
- if (expiresValue != null) {
- this.expires = parseExpires(expiresValue);
- } else {
- this.expires = this.configuredExpires;
- }
- this.outputBufferSize = params.getParameterAsInteger("outputBufferSize",
- this.configuredOutputBufferSize);
- }
-
- /**
- * Informs pipeline we have come across a branch point.
- * Default behaviour is do nothing.
- */
- public void informBranchPoint() {
- // this can be overwritten in subclasses
- }
-
- /**
- * Get the generator - used for content aggregation
- */
- public Generator getGenerator() {
- return this.generator;
- }
-
- /**
- * Set the generator that will be used as the initial step in the pipeline.
- * The generator role is given : the actual <code>Generator</code> is fetched
- * from the latest <code>ServiceManager</code>.
- *
- * @param role the generator role in the component manager.
- * @param source the source where to produce XML from, or <code>null</code> if no
- * source is given.
- * @param param the parameters for the generator.
- * @throws ProcessingException if the generator couldn't be obtained.
- */
- public void setGenerator(String role, String source, Parameters param, Parameters hintParam)
- throws ProcessingException {
- if (this.generator != null) {
- throw new ProcessingException ("Generator already set. Cannot set generator '" + role + "'",
- getLocation(param));
- }
- if (this.reader != null) {
- throw new ProcessingException ("Reader already set. Cannot set generator '" + role + "'",
- getLocation(param));
- }
- try {
- this.generator = (Generator) this.newManager.lookup(Generator.ROLE + '/' + role);
- } catch (ServiceException ce) {
- throw ProcessingException.throwLocated("Lookup of generator '" + role + "' failed", ce, getLocation(param));
- }
- this.generatorSource = source;
- this.generatorParam = param;
- }
-
- /**
- * Add a transformer at the end of the pipeline.
- * The transformer role is given : the actual <code>Transformer</code> is fetched
- * from the latest <code>ServiceManager</code>.
- *
- * @param role the transformer role in the component manager.
- * @param source the source used to setup the transformer (e.g. XSL file), or
- * <code>null</code> if no source is given.
- * @param param the parameters for the transfomer.
- * @throws ProcessingException if the generator couldn't be obtained.
- */
- public void addTransformer(String role, String source, Parameters param, Parameters hintParam)
- throws ProcessingException {
- if (this.reader != null) {
- // Should normally never happen as setting a reader starts pipeline processing
- throw new ProcessingException ("Reader already set. Cannot add transformer '" + role + "'",
- getLocation(param));
- }
- if (this.generator == null) {
- throw new ProcessingException ("Must set a generator before adding transformer '" + role + "'",
- getLocation(param));
- }
- try {
- this.transformers.add(this.newManager.lookup(Transformer.ROLE + '/' + role));
- } catch (ServiceException ce) {
- throw ProcessingException.throwLocated("Lookup of transformer '"+role+"' failed", ce, getLocation(param));
- }
- this.transformerSources.add(source);
- this.transformerParams.add(param);
- }
-
- /**
- * Set the serializer for this pipeline
- * @param mimeType Can be null
- */
- public void setSerializer(String role, String source, Parameters param, Parameters hintParam, String mimeType)
- throws ProcessingException {
- if (this.serializer != null) {
- // Should normally not happen as adding a serializer starts pipeline processing
- throw new ProcessingException ("Serializer already set. Cannot set serializer '" + role + "'",
- getLocation(param));
- }
- if (this.reader != null) {
- // Should normally never happen as setting a reader starts pipeline processing
- throw new ProcessingException ("Reader already set. Cannot set serializer '" + role + "'",
- getLocation(param));
- }
- if (this.generator == null) {
- throw new ProcessingException ("Must set a generator before setting serializer '" + role + "'",
- getLocation(param));
- }
-
- try {
- this.serializer = (Serializer)this.newManager.lookup(Serializer.ROLE + '/' + role);
- } catch (ServiceException ce) {
- throw ProcessingException.throwLocated("Lookup of serializer '" + role + "' failed", ce, getLocation(param));
- }
- this.serializerSource = source;
- this.serializerParam = param;
- this.serializerMimeType = mimeType;
- this.lastConsumer = this.serializer;
- }
-
- /**
- * Set the reader for this pipeline
- * @param mimeType Can be null
- */
- public void setReader(String role, String source, Parameters param, String mimeType)
- throws ProcessingException {
- if (this.reader != null) {
- // Should normally never happen as setting a reader starts pipeline processing
- throw new ProcessingException ("Reader already set. Cannot set reader '" + role + "'",
- getLocation(param));
- }
- if (this.generator != null) {
- // Should normally never happen as setting a reader starts pipeline processing
- throw new ProcessingException ("Generator already set. Cannot use reader '" + role + "'",
- getLocation(param));
- }
-
- try {
- this.reader = (Reader)this.newManager.lookup(Reader.ROLE + '/' + role);
- } catch (ServiceException ce) {
- throw ProcessingException.throwLocated("Lookup of reader '"+role+"' failed", ce, getLocation(param));
- }
- this.readerSource = source;
- this.readerParam = param;
- this.readerMimeType = mimeType;
- }
-
- /**
- * Sets error handler for this pipeline.
- * Used for handling errors in the internal pipelines.
- * @param errorHandler error handler
- */
- public void setErrorHandler(SitemapErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- /**
- * Sanity check
- * @return true if the pipeline is 'sane', false otherwise.
- */
- protected boolean checkPipeline() {
- if (this.generator == null && this.reader == null) {
- return false;
- }
-
- if (this.generator != null && this.serializer == null) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Setup pipeline components.
- */
- protected void setupPipeline(Environment environment)
- throws ProcessingException {
- try {
- // setup the generator
- this.generator.setup(
- this.sourceResolver,
- environment.getObjectModel(),
- generatorSource,
- generatorParam
- );
-
- Iterator transformerItt = this.transformers.iterator();
- Iterator transformerSourceItt = this.transformerSources.iterator();
- Iterator transformerParamItt = this.transformerParams.iterator();
-
- while (transformerItt.hasNext()) {
- Transformer trans = (Transformer)transformerItt.next();
- trans.setup(this.sourceResolver,
- environment.getObjectModel(),
- (String)transformerSourceItt.next(),
- (Parameters)transformerParamItt.next()
- );
- }
-
- if (this.serializer instanceof SitemapModelComponent) {
- ((SitemapModelComponent)this.serializer).setup(
- this.sourceResolver,
- environment.getObjectModel(),
- this.serializerSource,
- this.serializerParam
- );
- }
- } catch (Exception e) {
- handleException(e);
- }
- }
-
- /**
- * Connect the next component
- */
- protected void connect(Environment environment,
- XMLProducer producer,
- XMLConsumer consumer)
- throws ProcessingException {
- // Connect next component.
- producer.setConsumer(consumer);
- }
-
- /**
- * Connect the XML pipeline.
- */
- protected void connectPipeline(Environment environment)
- throws ProcessingException {
- XMLProducer prev = this.generator;
-
- Iterator itt = this.transformers.iterator();
- while (itt.hasNext()) {
- Transformer next = (Transformer) itt.next();
- connect(environment, prev, next);
- prev = next;
- }
-
- // insert the serializer
- connect(environment, prev, this.lastConsumer);
- }
-
- /**
- * Process the given <code>Environment</code>, producing the output.
- */
- public boolean process(Environment environment)
- throws ProcessingException {
- if (!this.prepared) {
- preparePipeline(environment);
- }
-
- // See if we need to set an "Expires:" header
- if (this.expires != 0) {
- Response res = ObjectModelHelper.getResponse(environment.getObjectModel());
- res.setDateHeader("Expires", System.currentTimeMillis() + expires);
- res.setHeader("Cache-Control", "max-age=" + expires/1000 + ", public");
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Setting a new Expires object for this resource");
- }
- environment.getObjectModel().put(ObjectModelHelper.EXPIRES_OBJECT,
- new Long(expires + System.currentTimeMillis()));
- }
-
- if (this.reader != null) {
- if (checkIfModified(environment, this.reader.getLastModified())) {
- return true;
- }
-
- return processReader(environment);
- } else {
- // If this is an internal request, lastConsumer was reset!
- if (this.lastConsumer == null) {
- this.lastConsumer = this.serializer;
- }
-
- connectPipeline(environment);
- return processXMLPipeline(environment);
- }
- }
-
- /**
- * Prepare the pipeline
- */
- protected void preparePipeline(Environment environment)
- throws ProcessingException {
- // Look up the source resolver as late as possible as setProcessorManager might
- // have changed the service manager
- try {
- this.sourceResolver = (SourceResolver) this.newManager.lookup(SourceResolver.ROLE);
- } catch (ServiceException e) {
- throw new ProcessingException("Couldn't find a source resolver", e);
- }
- if (!checkPipeline()) {
- throw new ProcessingException("Attempted to process incomplete pipeline.");
- }
-
- if (this.prepared) {
- throw new ProcessingException("Duplicate preparePipeline call caught.");
- }
-
- if (this.reader != null) {
- setupReader(environment);
- } else {
- setupPipeline(environment);
- }
- this.prepared = true;
- }
-
- /**
- * Prepare an internal processing.
- * @param environment The current environment.
- * @throws ProcessingException
- */
- public void prepareInternal(Environment environment)
- throws ProcessingException {
- this.lastConsumer = null;
- try {
- preparePipeline(environment);
- } catch (ProcessingException e) {
- prepareInternalErrorHandler(environment, e);
- }
- }
-
- /**
- * If prepareInternal fails, prepare internal error handler.
- */
- protected void prepareInternalErrorHandler(Environment environment, ProcessingException ex)
- throws ProcessingException {
- if (this.errorHandler != null) {
- try {
- this.errorPipeline = this.errorHandler.prepareErrorPipeline(ex);
- if (this.errorPipeline != null) {
- this.errorPipeline.prepareInternal(environment);
- return;
- }
- } catch (ProcessingException e) {
- // Log the original exception
- getLogger().error("Failed to process error handler for exception", ex);
- throw e;
- } catch (Exception e) {
- getLogger().error("Failed to process error handler for exception", ex);
- throw new ProcessingException("Failed to handle exception <" + ex.getMessage() + ">", e);
- }
- } else {
- // propagate exception if we have no error handler
- throw ex;
- }
- }
-
- /**
- * @return true if error happened during internal pipeline prepare call.
- */
- protected boolean isInternalError() {
- return this.errorPipeline != null;
- }
-
- /**
- * Process the SAX event pipeline
- */
- protected boolean processXMLPipeline(Environment environment)
- throws ProcessingException {
-
- setMimeTypeForSerializer(environment);
- try {
- if (this.lastConsumer == null) {
- // internal processing
- this.generator.generate();
- } else {
- if (this.serializer.shouldSetContentLength()) {
- // set the output stream
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- this.serializer.setOutputStream(os);
-
- // execute the pipeline:
- this.generator.generate();
- environment.setContentLength(os.size());
- os.writeTo(environment.getOutputStream(0));
- } else {
- // set the output stream
- this.serializer.setOutputStream(environment.getOutputStream(this.outputBufferSize));
- // execute the pipeline:
- this.generator.generate();
- }
- }
- } catch (Exception e) {
- handleException(e);
- }
-
- return true;
- }
-
- /**
- * Setup the reader
- */
- protected void setupReader(Environment environment)
- throws ProcessingException {
- try {
- this.reader.setup(this.sourceResolver,environment.getObjectModel(),readerSource,readerParam);
-
- // set the expires parameter on the pipeline if the reader is configured with one
- if (readerParam.isParameter("expires")) {
- // should this checking be done somewhere else??
- this.expires = readerParam.getParameterAsLong("expires");
- }
- } catch (Exception e){
- handleException(e);
- }
- }
-
- /**
- * Set the mime-type for a reader
- * @param environment The current environment
- */
- protected void setMimeTypeForReader(Environment environment) {
- // Set the mime-type
- // the behaviour has changed from 2.1.x to 2.2 according to bug #10277:
- // MIME type declared in the sitemap (instance or declaration, in this order)
- // Ask the Reader for a MIME type:
- // A *.doc reader could peek into the file
- // and return either text/plain or application/vnd.msword or
- // the reader can use MIME type declared in WEB-INF/web.xml or
- // by the server.
- if ( this.readerMimeType != null ) {
- // there was a mime-type defined on map:read in the sitemap
- environment.setContentType(this.readerMimeType);
- } else {
- final String mimeType = this.reader.getMimeType();
- if (mimeType != null) {
- environment.setContentType(mimeType);
- }
- // If no mimeType available, leave to to upstream proxy
- // or browser to deduce content-type from URL extension.
- }
- }
-
- /**
- * Set the mime-type for a serializer
- * @param environment The current environment
- */
- protected void setMimeTypeForSerializer(Environment environment)
- throws ProcessingException {
- if (this.lastConsumer == null) {
- // internal processing: text/xml
- environment.setContentType("text/xml");
- } else {
- // Set the mime-type
- // the behaviour has changed from 2.1.x to 2.2 according to bug #10277
- if (serializerMimeType != null) {
- // there was a serializer defined in the sitemap
- environment.setContentType(serializerMimeType);
- } else {
- // ask to the component itself
- String mimeType = this.serializer.getMimeType();
- if (mimeType != null) {
- environment.setContentType (mimeType);
- } else {
- // No mimeType available
- String message = "Unable to determine MIME type for " +
- environment.getURIPrefix() + "/" + environment.getURI();
- throw new ProcessingException(message);
- }
- }
- }
- }
-
- protected boolean checkIfModified(Environment environment,
- long lastModified)
- throws ProcessingException {
- // has the read resource been modified?
- if(!environment.isResponseModified(lastModified)) {
- // environment supports this, so we are finished
- environment.setResponseIsNotModified();
- return true;
- }
- return false;
- }
-
- /**
- * Process the pipeline using a reader.
- * @throws ProcessingException if
- */
- protected boolean processReader(Environment environment)
- throws ProcessingException {
- try {
- this.setMimeTypeForReader(environment);
- if (this.reader.shouldSetContentLength()) {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- this.reader.setOutputStream(os);
- this.reader.generate();
- environment.setContentLength(os.size());
- os.writeTo(environment.getOutputStream(0));
- } else {
- this.reader.setOutputStream(environment.getOutputStream(this.outputBufferSize));
- this.reader.generate();
- }
- } catch (Exception e) {
- handleException(e);
- }
-
- return true;
- }
-
- /**
- * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
- */
- public void recycle() {
- this.prepared = false;
-
- // Release reader.
- if (this.reader != null) {
- if ( this.reader instanceof DisposableSitemapComponent ) {
- ((DisposableSitemapComponent)this.reader).dispose();
- }
- this.newManager.release(this.reader);
- this.reader = null;
- this.readerParam = null;
- }
-
- // Release generator.
- if (this.generator != null) {
- if ( this.generator instanceof DisposableSitemapComponent ) {
- ((DisposableSitemapComponent)this.generator).dispose();
- }
- this.newManager.release(this.generator);
- this.generator = null;
- this.generatorParam = null;
- }
-
- // Release transformers
- int size = this.transformers.size();
- for (int i = 0; i < size; i++) {
- if ( this.transformers.get(i) instanceof DisposableSitemapComponent ) {
- ((DisposableSitemapComponent)this.transformers.get(i)).dispose();
- }
- this.newManager.release(this.transformers.get(i));
- }
- this.transformers.clear();
- this.transformerParams.clear();
- this.transformerSources.clear();
-
- // Release serializer
- if (this.serializer != null) {
- if ( this.serializer instanceof DisposableSitemapComponent ) {
- ((DisposableSitemapComponent)this.serializer).dispose();
- }
- this.newManager.release(this.serializer);
- this.serializerParam = null;
- }
-
- // Release source resolver
- if (this.sourceResolver != null) {
- this.newManager.release(this.sourceResolver);
- }
- this.serializer = null;
- this.parameters = null;
- this.sourceResolver = null;
- this.lastConsumer = null;
-
- // Release error handler
- this.errorHandler = null;
-
- // Release error pipeline
- // This is not done by using release in the creating container as release
- // is a noop for the Avalon life style in the Spring container
- this.errorPipeline = null;
- }
-
- /**
- * Process the given <code>Environment</code>, but do not use the
- * serializer. Instead all SAX events are streamed to the XMLConsumer.
- */
- public boolean process(Environment environment, XMLConsumer consumer)
- throws ProcessingException {
- if (this.reader != null) {
- throw new ProcessingException("Streaming of an internal pipeline is not possible with a reader.");
- }
-
- // Exception happened during setup and was handled
- if (this.errorPipeline != null) {
- return this.errorPipeline.process(environment, consumer);
- }
-
- // Have to buffer events if error handler is specified.
- SaxBuffer buffer = null;
- this.lastConsumer = this.errorHandler == null? consumer: (buffer = new SaxBuffer());
- try {
- connectPipeline(environment);
- return processXMLPipeline(environment);
- } catch (ProcessingException e) {
- buffer = null;
- return processErrorHandler(environment, e, consumer);
- } finally {
- if (buffer != null) {
- try {
- buffer.toSAX(consumer);
- } catch (SAXException e) {
- throw new ProcessingException("Failed to execute pipeline.", e);
- }
- }
- }
- }
-
- protected boolean processErrorHandler(Environment environment, ProcessingException e, XMLConsumer consumer)
- throws ProcessingException {
- if (this.errorHandler != null) {
- try {
- this.errorPipeline = this.errorHandler.prepareErrorPipeline(e);
- if (this.errorPipeline != null) {
- this.errorPipeline.prepareInternal(environment);
- return this.errorPipeline.process(environment, consumer);
- }
- } catch (Exception ignored) {
- getLogger().debug("Exception in error handler", ignored);
- }
- }
-
- throw e;
- }
-
- /**
- * Return valid validity objects for the event pipeline
- * If the "event pipeline" (= the complete pipeline without the
- * serializer) is cacheable and valid, return all validity objects.
- * Otherwise return <code>null</code>
- */
- public SourceValidity getValidityForEventPipeline() {
- return null;
- }
-
- /**
- * Return the key for the event pipeline
- * If the "event pipeline" (= the complete pipeline without the
- * serializer) is cacheable and valid, return a key.
- * Otherwise return <code>null</code>
- */
- public String getKeyForEventPipeline() {
- return null;
- }
-
-
- /**
- * Parse the expires parameter
- */
- private long parseExpires(String expire) {
- StringTokenizer tokens = new StringTokenizer(expire);
-
- // get <base>
- String current = tokens.nextToken();
- if (current.equals("modification")) {
- getLogger().warn("the \"modification\" keyword is not yet" +
- " implemented. Assuming \"now\" as the base attribute");
- current = "now";
- }
-
- if (!current.equals("now") && !current.equals("access")) {
- getLogger().error("bad <base> attribute, Expires header will not be set");
- return -1;
- }
-
- long number = 0;
- long modifier = 0;
- long expires = 0;
-
- while (tokens.hasMoreTokens()) {
- current = tokens.nextToken();
-
- // get rid of the optional <plus> keyword
- if (current.equals("plus")) {
- current = tokens.nextToken();
- }
-
- // We're expecting a sequence of <number> and <modification> here
- // get <number> first
- try {
- number = Long.parseLong(current);
- } catch (NumberFormatException nfe) {
- getLogger().error("state violation: a number was expected here");
- return -1;
- }
-
- // now get <modifier>
- try {
- current = tokens.nextToken();
- } catch (NoSuchElementException nsee) {
- getLogger().error("State violation: expecting a modifier" +
- " but no one found: Expires header will not be set");
- }
- if (current.equals("years")) {
- modifier = 365L * 24L * 60L * 60L * 1000L;
- } else if (current.equals("months")) {
- modifier = 30L * 24L * 60L * 60L * 1000L;
- } else if (current.equals("weeks")) {
- modifier = 7L * 24L * 60L * 60L * 1000L;
- } else if (current.equals("days")) {
- modifier = 24L * 60L * 60L * 1000L;
- } else if (current.equals("hours")) {
- modifier = 60L * 60L * 1000L;
- } else if (current.equals("minutes")) {
- modifier = 60L * 1000L;
- } else if (current.equals("seconds")) {
- modifier = 1000L;
- } else {
- getLogger().error("Bad modifier (" + current +
- "): ignoring expires configuration");
- return -1;
- }
- expires += number * modifier;
- }
-
- return expires;
- }
-
- protected Location getLocation(Parameters param) {
- Location location = null;
- if (param instanceof Locatable) {
- location = ((Locatable)param).getLocation();
- }
- if (location == null) {
- location = Location.UNKNOWN;
- }
- return location;
- }
-
- /**
- * Handles exception which can happen during pipeline processing.
- * If this not a connection reset, then all locations for pipeline components are
- * added to the exception.
- *
- * @throws ConnectionResetException if connection reset detected
- * @throws ProcessingException in all other cases
- */
- protected void handleException(Exception e) throws ProcessingException {
- // Check if the client aborted the connection
- if (e instanceof SocketException) {
- if (e.getMessage().indexOf("reset") > -1
- || e.getMessage().indexOf("aborted") > -1
- || e.getMessage().indexOf("Broken pipe") > -1
- || e.getMessage().indexOf("connection abort") > -1) {
- throw new ConnectionResetException("Connection reset by peer", e);
- }
- } else if (e instanceof IOException) {
- // Tomcat5 wraps SocketException into ClientAbortException which extends IOException.
- if (e.getClass().getName().endsWith("ClientAbortException")) {
- throw new ConnectionResetException("Connection reset by peer", e);
- }
- } else if (e instanceof ConnectionResetException) {
- // Exception comes up from a deeper pipeline
- throw (ConnectionResetException)e;
- }
-
- // Not a connection reset: add all location information
- if (this.reader == null) {
- // Add all locations in reverse order
- ArrayList locations = new ArrayList(this.transformers.size() + 2);
- locations.add(getLocation(this.serializerParam));
- for (int i = this.transformerParams.size() - 1; i >= 0; i--) {
- locations.add(getLocation((Parameters)this.transformerParams.get(i)));
- }
- locations.add(getLocation(this.generatorParam));
-
- throw ProcessingException.throwLocated("Failed to process pipeline", e, locations);
-
- } else {
- // Add reader location
- throw ProcessingException.throwLocated("Failed to process reader", e, getLocation(this.readerParam));
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
deleted file mode 100644
index 932f5f0..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
+++ /dev/null
@@ -1,1066 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.CacheableProcessingComponent;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.cocoon.caching.CachingOutputStream;
-import org.apache.cocoon.caching.ComponentCacheKey;
-import org.apache.cocoon.caching.PipelineCacheKey;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.transformation.Transformer;
-import org.apache.cocoon.util.HashUtil;
-import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.source.impl.validity.AggregatedValidity;
-import org.apache.excalibur.source.impl.validity.DeferredValidity;
-import org.apache.excalibur.source.impl.validity.NOPValidity;
-import org.apache.excalibur.store.Store;
-
-/**
- * This is the base class for all caching pipeline implementations
- * that check different pipeline components.
- *
- * @since 2.1
- * @version $Id$
- */
-public abstract class AbstractCachingProcessingPipeline extends BaseCachingProcessingPipeline {
-
- public static final String PIPELOCK_PREFIX = "PIPELOCK:";
-
- /** The role name of the generator */
- protected String generatorRole;
-
- /** The role names of the transfomrers */
- protected ArrayList transformerRoles = new ArrayList();
-
- /** The role name of the serializer */
- protected String serializerRole;
-
- /** The role name of the reader */
- protected String readerRole;
-
- /** The cached response */
- protected CachedResponse cachedResponse;
-
- /** The index indicating the first transformer getting input from the cache */
- protected int firstProcessedTransformerIndex;
-
- /** Complete response is cached */
- protected boolean completeResponseIsCached;
-
-
- /** This key indicates the response that is fetched from the cache */
- protected PipelineCacheKey fromCacheKey;
-
- /** This key indicates the response that will get into the cache */
- protected PipelineCacheKey toCacheKey;
-
- /** The source validities used for caching */
- protected SourceValidity[] toCacheSourceValidities;
-
- /** The index indicating to the first transformer which is not cacheable */
- protected int firstNotCacheableTransformerIndex;
-
- /** Cache complete response */
- protected boolean cacheCompleteResponse;
-
- protected Store transientStore = null;
-
- /** Abstract method defined in subclasses
- * @return <u>complete</u> cached response or <code>null</code><br>
- * See issue COCOON-2009 for discussion*/
- protected abstract CachedResponse cacheResults(Environment environment,
- OutputStream os)
- throws Exception;
-
- /** Abstract method defined in subclasses */
- protected abstract ComponentCacheKey newComponentCacheKey(int type,
- String role,
- Serializable key);
-
- /** Abstract method defined in subclasses */
- protected abstract void connectCachingPipeline(Environment environment)
- throws ProcessingException;
-
- /**
- * Parameterizable Interface - Configuration
- */
- public void parameterize(Parameters params)
- throws ParameterException {
- super.parameterize(params);
-
- String storeRole = params.getParameter("store-role",Store.TRANSIENT_STORE);
-
- try {
- transientStore = (Store) manager.lookup(storeRole);
- } catch (ServiceException e) {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Could not look up transient store, synchronizing requests will not work!",e);
- }
- }
- }
-
- /**
- * Set the generator.
- */
- public void setGenerator (String role, String source, Parameters param,
- Parameters hintParam)
- throws ProcessingException {
- super.setGenerator(role, source, param, hintParam);
- this.generatorRole = role;
- }
-
- /**
- * Add a transformer.
- */
- public void addTransformer (String role, String source, Parameters param,
- Parameters hintParam) throws ProcessingException {
- super.addTransformer(role, source, param, hintParam);
- this.transformerRoles.add(role);
- }
-
- /**
- * Set the serializer.
- */
- public void setSerializer (String role, String source, Parameters param,
- Parameters hintParam, String mimeType) throws ProcessingException {
- super.setSerializer(role, source, param, hintParam, mimeType);
- this.serializerRole = role;
- }
-
- /**
- * Set the Reader.
- */
- public void setReader (String role, String source, Parameters param,
- String mimeType)
- throws ProcessingException {
- super.setReader(role, source, param, mimeType);
- this.readerRole = role;
- }
-
- protected boolean waitForLock(Object key) {
- if(transientStore != null) {
- Object lock = null;
- synchronized(transientStore) {
- String lockKey = PIPELOCK_PREFIX+key;
- if(transientStore.containsKey(lockKey)) {
- // cache content is currently being generated, wait for other thread
- lock = transientStore.get(lockKey);
- }
- }
- // Avoid deadlock with self (see JIRA COCOON-1985).
- if(lock != null && lock != Thread.currentThread()) {
- try {
- // become owner of monitor
- synchronized(lock) {
- lock.wait();
- }
- } catch (InterruptedException e) {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Got interrupted waiting for other pipeline to finish processing, retrying...",e);
- }
- return false;
- }
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Other pipeline finished processing, retrying to get cached response.");
- }
- return false;
- }
- }
- return true;
- }
-
- /**
- * makes the lock (instantiates a new object and puts it into the store)
- */
- protected boolean generateLock(Object key) {
- boolean succeeded = true;
-
- if( transientStore != null && key != null ) {
- String lockKey = PIPELOCK_PREFIX+key;
- synchronized(transientStore) {
- if(transientStore.containsKey(lockKey)) {
- succeeded = false;
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Lock already present in the store!");
- }
- } else {
- Object lock = Thread.currentThread();
- try {
- transientStore.store(lockKey, lock);
- } catch (IOException e) {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Could not put lock in the store!",e);
- }
- succeeded = false;
- }
- }
- }
- }
-
- return succeeded;
- }
-
- /**
- * releases the lock (notifies it and removes it from the store)
- */
- protected boolean releaseLock(Object key) {
- boolean succeeded = true;
-
- if( transientStore != null && key != null ) {
- String lockKey = PIPELOCK_PREFIX+key;
- Object lock = null;
- synchronized(transientStore) {
- if(!transientStore.containsKey(lockKey)) {
- succeeded = false;
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Lock not present in the store!");
- }
- } else {
- try {
- lock = transientStore.get(lockKey);
- transientStore.remove(lockKey);
- } catch (Exception e) {
- if(getLogger().isDebugEnabled()) {
- getLogger().debug("Could not get lock from the store!",e);
- }
- succeeded = false;
- }
- }
- }
- if(succeeded && lock != null) {
- // become monitor owner
- synchronized(lock) {
- lock.notifyAll();
- }
- }
- }
-
- return succeeded;
- }
-
- /**
- * Process the given <code>Environment</code>, producing the output.
- */
- protected boolean processXMLPipeline(Environment environment)
- throws ProcessingException {
- if (this.toCacheKey == null && this.cachedResponse == null) {
- return super.processXMLPipeline(environment);
- }
-
- if (this.cachedResponse != null && this.completeResponseIsCached) {
-
- // Allow for 304 (not modified) responses in dynamic content
- if (checkIfModified(environment, this.cachedResponse.getLastModified())) {
- return true;
- }
-
- // Set mime-type
- if (this.cachedResponse.getContentType() != null) {
- environment.setContentType(this.cachedResponse.getContentType());
- } else {
- setMimeTypeForSerializer(environment);
- }
-
- // Write response out
- try {
- final OutputStream outputStream = environment.getOutputStream(0);
- final byte[] content = this.cachedResponse.getResponse();
- if (content.length > 0) {
- environment.setContentLength(content.length);
- outputStream.write(content);
- }
- } catch (Exception e) {
- handleException(e);
- }
- } else {
- setMimeTypeForSerializer(environment);
- if (getLogger().isDebugEnabled() && this.toCacheKey != null) {
- getLogger().debug("processXMLPipeline: caching content for further" +
- " requests of '" + environment.getURI() +
- "' using key " + this.toCacheKey);
- }
-
- generateLock(this.toCacheKey);
-
- try {
- OutputStream os = null;
-
- if (this.cacheCompleteResponse && this.toCacheKey != null) {
- os = new CachingOutputStream(environment.getOutputStream(this.outputBufferSize));
- }
-
- if (super.serializer != super.lastConsumer) {
- if (os == null) {
- os = environment.getOutputStream(this.outputBufferSize);
- }
-
- // internal processing
- if (this.xmlDeserializer != null) {
- this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
- } else {
- this.generator.generate();
- }
-
- } else {
- if (this.serializer.shouldSetContentLength()) {
- if (os == null) {
- os = environment.getOutputStream(0);
- }
-
- // Set the output stream
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- this.serializer.setOutputStream(baos);
-
- // Execute the pipeline
- if (this.xmlDeserializer != null) {
- this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
- } else {
- this.generator.generate();
- }
-
- environment.setContentLength(baos.size());
- baos.writeTo(os);
- } else {
- if (os == null) {
- os = environment.getOutputStream(this.outputBufferSize);
- }
-
- // Set the output stream
- this.serializer.setOutputStream(os);
-
- // Execute the pipeline
- if (this.xmlDeserializer != null) {
- this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
- } else {
- this.generator.generate();
- }
- }
- }
-
- //
- // Now that we have processed the pipeline,
- // we do the actual caching
- //
- CachedResponse completeCachedResponse = cacheResults(environment,os);
-
- if (completeCachedResponse != null) {
- //Dirty work-around for setting Last-Modified header as there is no appoporiate method
- //org.apache.cocoon.environment.http.HttpEnvironment.isResponseModified will set it and the result of
- //the actual check is neither meaningful nor important here
- environment.isResponseModified(completeCachedResponse.getLastModified());
- }
-
- } catch (Exception e) {
- handleException(e);
- } finally {
- releaseLock(this.toCacheKey);
- }
-
- //Request has been succesfully processed, set approporiate status code
- environment.setStatus(HttpServletResponse.SC_OK);
- return true;
- }
-
- return true;
- }
-
- /**
- * The components of the pipeline are checked if they are Cacheable.
- */
- protected void generateCachingKey(Environment environment)
- throws ProcessingException {
-
- this.toCacheKey = null;
-
- this.firstNotCacheableTransformerIndex = 0;
- this.cacheCompleteResponse = false;
-
- // first step is to generate the key:
- // All pipeline components starting with the generator
- // are tested if they are either a CacheableProcessingComponent
- // or Cacheable (deprecated). The returned keys are chained together
- // to build a unique key of the request
-
- // is the generator cacheable?
- Serializable key = null;
- if (super.generator instanceof CacheableProcessingComponent) {
- key = ((CacheableProcessingComponent)super.generator).getKey();
- }
-
- if (key != null) {
- this.toCacheKey = new PipelineCacheKey();
- this.toCacheKey.addKey(
- this.newComponentCacheKey(
- ComponentCacheKey.ComponentType_Generator,
- this.generatorRole, key));
-
- // now testing transformers
- final int transformerSize = super.transformers.size();
- boolean continueTest = true;
-
- while (this.firstNotCacheableTransformerIndex < transformerSize && continueTest) {
- final Transformer trans =
- (Transformer) super.transformers.get(this.firstNotCacheableTransformerIndex);
- key = null;
- if (trans instanceof CacheableProcessingComponent) {
- key = ((CacheableProcessingComponent)trans).getKey();
- }
- if (key != null) {
- this.toCacheKey.addKey(
- this.newComponentCacheKey(
- ComponentCacheKey.ComponentType_Transformer,
- (String)this.transformerRoles.get(
- this.firstNotCacheableTransformerIndex),
- key));
-
- this.firstNotCacheableTransformerIndex++;
- } else {
- continueTest = false;
- }
- }
- // all transformers are cacheable => pipeline is cacheable
- // test serializer if this is not an internal request
- if (this.firstNotCacheableTransformerIndex == transformerSize
- && super.serializer == this.lastConsumer) {
-
- key = null;
- if (super.serializer instanceof CacheableProcessingComponent) {
- key = ((CacheableProcessingComponent)this.serializer).getKey();
- }
- if (key != null) {
- this.toCacheKey.addKey(
- this.newComponentCacheKey(
- ComponentCacheKey.ComponentType_Serializer,
- this.serializerRole,
- key));
- this.cacheCompleteResponse = true;
- }
- }
- }
- }
-
- /**
- * Generate validity objects for the new response
- */
- protected void setupValidities() throws ProcessingException {
-
- if (this.toCacheKey != null) {
- // only update validity objects if we cannot use
- // a cached response or when the cached response does
- // cache less than now is cacheable
- if (this.fromCacheKey == null
- || this.fromCacheKey.size() < this.toCacheKey.size()) {
-
- this.toCacheSourceValidities =
- new SourceValidity[this.toCacheKey.size()];
-
- int len = this.toCacheSourceValidities.length;
- int i = 0;
- while (i < len) {
- final SourceValidity validity = getValidityForInternalPipeline(i);
-
- if (validity == null) {
- if (i > 0
- && (this.fromCacheKey == null
- || i > this.fromCacheKey.size())) {
- // shorten key
- for (int m=i; m < this.toCacheSourceValidities.length; m++) {
- this.toCacheKey.removeLastKey();
- if (!this.cacheCompleteResponse) {
- this.firstNotCacheableTransformerIndex--;
- }
- this.cacheCompleteResponse = false;
- }
- SourceValidity[] copy = new SourceValidity[i];
- System.arraycopy(this.toCacheSourceValidities, 0, copy, 0, copy.length);
- this.toCacheSourceValidities = copy;
- len = this.toCacheSourceValidities.length;
- } else {
- // caching is not possible!
- this.toCacheKey = null;
- this.toCacheSourceValidities = null;
- this.cacheCompleteResponse = false;
- len = 0;
- }
- } else {
- this.toCacheSourceValidities[i] = validity;
- }
- i++;
- }
- } else {
- // we don't have to cache
- this.toCacheKey = null;
- this.cacheCompleteResponse = false;
- }
- }
- }
-
- /**
- * Calculate the key that can be used to get something from the cache, and
- * handle expires properly.
- */
- protected void validatePipeline(Environment environment)
- throws ProcessingException {
- this.completeResponseIsCached = this.cacheCompleteResponse;
- this.fromCacheKey = this.toCacheKey.copy();
- this.firstProcessedTransformerIndex = this.firstNotCacheableTransformerIndex;
-
- boolean finished = false;
- while (this.fromCacheKey != null && !finished) {
- finished = true;
-
- final CachedResponse response = this.cache.get(this.fromCacheKey);
-
- // now test validity
- if (response != null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Found cached response for '" + environment.getURI() +
- "' using key: " + this.fromCacheKey);
- }
-
- boolean responseIsValid = true;
- boolean responseIsUsable = true;
-
- // See if we have an explicit "expires" setting. If so,
- // and if it's still fresh, we're done.
- Long responseExpires = response.getExpires();
-
- if (responseExpires != null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Expires time found for " + environment.getURI());
- }
-
- if (responseExpires.longValue() > System.currentTimeMillis()) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Expires time still fresh for " + environment.getURI() +
- ", ignoring all other cache settings. This entry expires on "+
- new Date(responseExpires.longValue()));
- }
- this.cachedResponse = response;
- return;
- } else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Expires time has expired for " + environment.getURI() +
- ", regenerating content.");
- }
-
- // If an expires parameter was provided, use it. If this parameter is not available
- // it means that the sitemap was modified, and the old expires value is not valid
- // anymore.
- if (expires != 0) {
- if (this.getLogger().isDebugEnabled())
- this.getLogger().debug("Refreshing expires informations");
- response.setExpires(new Long(expires + System.currentTimeMillis()));
- } else {
- if (this.getLogger().isDebugEnabled())
- this.getLogger().debug("No expires defined anymore for this object, setting it to no expires");
- response.setExpires(null);
- }
- }
- } else {
- // The response had no expires informations. See if it needs to be set (i.e. because the configuration has changed)
- if (expires != 0) {
- if (this.getLogger().isDebugEnabled())
- this.getLogger().debug("Setting a new expires object for this resource");
- response.setExpires(new Long(expires + System.currentTimeMillis()));
- }
- }
-
- SourceValidity[] fromCacheValidityObjects = response.getValidityObjects();
-
- int i = 0;
- while (responseIsValid && i < fromCacheValidityObjects.length) {
- boolean isValid = false;
-
- // BH Check if validities[i] is null, may happen
- // if exception was thrown due to malformed content
- SourceValidity validity = fromCacheValidityObjects[i];
- int valid = validity == null ? SourceValidity.INVALID : validity.isValid();
- if (valid == SourceValidity.UNKNOWN) {
- // Don't know if valid, make second test
- validity = getValidityForInternalPipeline(i);
- if (validity != null) {
- valid = fromCacheValidityObjects[i].isValid(validity);
- if (valid == SourceValidity.UNKNOWN) {
- validity = null;
- } else {
- isValid = (valid == SourceValidity.VALID);
- }
- }
- } else {
- isValid = (valid == SourceValidity.VALID);
- }
-
- if (!isValid) {
- responseIsValid = false;
- // update validity
- if (validity == null) {
- responseIsUsable = false;
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("validatePipeline: responseIsUsable is false, valid=" +
- valid + " at index " + i);
- }
- } else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("validatePipeline: responseIsValid is false due to " +
- validity);
- }
- }
- } else {
- i++;
- }
- }
-
- if (responseIsValid) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("validatePipeline: using valid cached content for '" +
- environment.getURI() + "'.");
- }
-
- // we are valid, ok that's it
- this.cachedResponse = response;
- this.toCacheSourceValidities = fromCacheValidityObjects;
- } else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("validatePipeline: cached content is invalid for '" +
- environment.getURI() + "'.");
- }
- // we are not valid!
-
- if (!responseIsUsable) {
- // we could not compare, because we got no
- // validity object, so shorten pipeline key
- if (i > 0) {
- int deleteCount = fromCacheValidityObjects.length - i;
- if (i > 0 && i <= firstNotCacheableTransformerIndex + 1) {
- this.firstNotCacheableTransformerIndex = i-1;
- }
- for(int x=0; x < deleteCount; x++) {
- this.toCacheKey.removeLastKey();
- }
- finished = false;
- } else {
- this.toCacheKey = null;
- }
- this.cacheCompleteResponse = false;
- } else {
- // the entry is invalid, remove it
- this.cache.remove(this.fromCacheKey);
- }
-
- // try a shorter key
- if (i > 0) {
- this.fromCacheKey.removeLastKey();
- if (!this.completeResponseIsCached) {
- this.firstProcessedTransformerIndex--;
- }
- } else {
- this.fromCacheKey = null;
- }
- finished = false;
- this.completeResponseIsCached = false;
- }
- } else {
-
- // check if there might be one being generated
- if(!waitForLock(this.fromCacheKey)) {
- finished = false;
- continue;
- }
-
- // no cached response found
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug(
- "Cached response not found for '" + environment.getURI() +
- "' using key: " + this.fromCacheKey
- );
- }
-
- finished = setupFromCacheKey();
- this.completeResponseIsCached = false;
- }
- }
-
- }
-
- boolean setupFromCacheKey() {
- // stop on longest key for smart caching
- this.fromCacheKey = null;
- return true;
- }
-
- /**
- * Setup the evenet pipeline.
- * The components of the pipeline are checked if they are
- * Cacheable.
- */
- protected void setupPipeline(Environment environment)
- throws ProcessingException {
- super.setupPipeline(environment);
-
- // Generate the key to fill the cache
- generateCachingKey(environment);
-
- // Test the cache for a valid response
- if (this.toCacheKey != null) {
- validatePipeline(environment);
- }
-
- setupValidities();
- }
-
- /**
- * Connect the pipeline.
- */
- protected void connectPipeline(Environment environment)
- throws ProcessingException {
- if (this.toCacheKey == null && this.cachedResponse == null) {
- super.connectPipeline(environment);
- return;
- } else if (this.completeResponseIsCached) {
- // do nothing
- return;
- } else {
- this.connectCachingPipeline(environment);
- }
- }
-
- /** Process the pipeline using a reader.
- * @throws ProcessingException if an error occurs
- */
- protected boolean processReader(Environment environment)
- throws ProcessingException {
- try {
- boolean usedCache = false;
- OutputStream outputStream = null;
- SourceValidity readerValidity = null;
- PipelineCacheKey pcKey = null;
-
- // test if reader is cacheable
- Serializable readerKey = null;
- if (super.reader instanceof CacheableProcessingComponent) {
- readerKey = ((CacheableProcessingComponent)super.reader).getKey();
- }
-
- boolean finished = false;
-
- if (readerKey != null) {
- // response is cacheable, build the key
- pcKey = new PipelineCacheKey();
- pcKey.addKey(new ComponentCacheKey(ComponentCacheKey.ComponentType_Reader,
- this.readerRole,
- readerKey)
- );
-
- while(!finished) {
- finished = true;
- // now we have the key to get the cached object
- CachedResponse cachedObject = this.cache.get(pcKey);
- if (cachedObject != null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Found cached response for '" +
- environment.getURI() + "' using key: " + pcKey);
- }
-
- SourceValidity[] validities = cachedObject.getValidityObjects();
- if (validities == null || validities.length != 1) {
- // to avoid getting here again and again, we delete it
- this.cache.remove(pcKey);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Cached response for '" + environment.getURI() +
- "' using key: " + pcKey + " is invalid.");
- }
- this.cachedResponse = null;
- } else {
- SourceValidity cachedValidity = validities[0];
- boolean isValid = false;
- int valid = cachedValidity.isValid();
- if (valid == SourceValidity.UNKNOWN) {
- // get reader validity and compare
- readerValidity = ((CacheableProcessingComponent) super.reader).getValidity();
- if (readerValidity != null) {
- valid = cachedValidity.isValid(readerValidity);
- if (valid == SourceValidity.UNKNOWN) {
- readerValidity = null;
- } else {
- isValid = (valid == SourceValidity.VALID);
- }
- }
- } else {
- isValid = (valid == SourceValidity.VALID);
- }
-
- if (isValid) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("processReader: using valid cached content for '" +
- environment.getURI() + "'.");
- }
- byte[] response = cachedObject.getResponse();
- if (response.length > 0) {
- usedCache = true;
- if (cachedObject.getContentType() != null) {
- environment.setContentType(cachedObject.getContentType());
- } else {
- setMimeTypeForReader(environment);
- }
- outputStream = environment.getOutputStream(0);
- environment.setContentLength(response.length);
- outputStream.write(response);
- }
- } else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("processReader: cached content is invalid for '" +
- environment.getURI() + "'.");
- }
- // remove invalid cached object
- this.cache.remove(pcKey);
- }
- }
- } else {
- // check if something is being generated right now
- if(!waitForLock(pcKey)) {
- finished = false;
- continue;
- }
- }
- }
- }
-
- if (!usedCache) {
- // make sure lock will be released
- try {
- if (pcKey != null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("processReader: caching content for further requests of '" +
- environment.getURI() + "'.");
- }
- generateLock(pcKey);
-
- if (readerValidity == null) {
- readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
- }
-
- if (readerValidity != null) {
- outputStream = environment.getOutputStream(this.outputBufferSize);
- outputStream = new CachingOutputStream(outputStream);
- }
- }
-
- setMimeTypeForReader(environment);
- if (this.reader.shouldSetContentLength()) {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- this.reader.setOutputStream(os);
- this.reader.generate();
- environment.setContentLength(os.size());
- if (outputStream == null) {
- outputStream = environment.getOutputStream(0);
- }
- os.writeTo(outputStream);
- } else {
- if (outputStream == null) {
- outputStream = environment.getOutputStream(this.outputBufferSize);
- }
- this.reader.setOutputStream(outputStream);
- this.reader.generate();
- }
-
- // store the response
- if (pcKey != null && readerValidity != null) {
- final CachedResponse res = new CachedResponse(new SourceValidity[] {readerValidity},
- ((CachingOutputStream)outputStream).getContent());
- res.setContentType(environment.getContentType());
- this.cache.store(pcKey, res);
- }
-
- } finally {
- if (pcKey != null) {
- releaseLock(pcKey);
- }
- }
-
- }
- } catch (Exception e) {
- handleException(e);
- }
-
- //Request has been succesfully processed, set approporiate status code
- environment.setStatus(HttpServletResponse.SC_OK);
- return true;
- }
-
-
- /**
- * Return valid validity objects for the event pipeline.
- *
- * If the event pipeline (the complete pipeline without the
- * serializer) is cacheable and valid, return all validity objects.
- *
- * Otherwise, return <code>null</code>.
- */
- public SourceValidity getValidityForEventPipeline() {
- if (isInternalError()) {
- return null;
- }
-
- if (this.cachedResponse != null) {
- if (!this.cacheCompleteResponse &&
- this.firstNotCacheableTransformerIndex < super.transformers.size()) {
- // Cache contains only partial pipeline.
- return null;
- }
-
- if (this.toCacheSourceValidities != null) {
- // This means that the pipeline is valid based on the validities
- // of the individual components
- final AggregatedValidity validity = new AggregatedValidity();
- for (int i=0; i < this.toCacheSourceValidities.length; i++) {
- validity.add(this.toCacheSourceValidities[i]);
- }
-
- return validity;
- }
-
- // This means that the pipeline is valid because it has not yet expired
- return NOPValidity.SHARED_INSTANCE;
- } else {
- int vals = 0;
-
- if (null != this.toCacheKey
- && !this.cacheCompleteResponse
- && this.firstNotCacheableTransformerIndex == super.transformers.size()) {
- vals = this.toCacheKey.size();
- } else if (null != this.fromCacheKey
- && !this.completeResponseIsCached
- && this.firstProcessedTransformerIndex == super.transformers.size()) {
- vals = this.fromCacheKey.size();
- }
-
- if (vals > 0) {
- final AggregatedValidity validity = new AggregatedValidity();
- for (int i = 0; i < vals; i++) {
- validity.add(getValidityForInternalPipeline(i));
- }
-
- return validity;
- }
-
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getKeyForEventPipeline()
- */
- public String getKeyForEventPipeline() {
- if (isInternalError()) {
- return null;
- }
-
- if (null != this.toCacheKey
- && !this.cacheCompleteResponse
- && this.firstNotCacheableTransformerIndex == super.transformers.size()) {
- return String.valueOf(HashUtil.hash(this.toCacheKey.toString()));
- }
- if (null != this.fromCacheKey
- && !this.completeResponseIsCached
- && this.firstProcessedTransformerIndex == super.transformers.size()) {
- return String.valueOf(HashUtil.hash(this.fromCacheKey.toString()));
- }
-
- return null;
- }
-
- SourceValidity getValidityForInternalPipeline(int index) {
- final SourceValidity validity;
-
- // if debugging try to tell why something is not cacheable
- final boolean debug = this.getLogger().isDebugEnabled();
- String msg = null;
- if(debug) msg = "getValidityForInternalPipeline(" + index + "): ";
-
- if (index == 0) {
- // test generator
- validity = ((CacheableProcessingComponent)super.generator).getValidity();
- if(debug) msg += "generator: using getValidity";
- } else if (index <= firstNotCacheableTransformerIndex) {
- // test transformer
- final Transformer trans = (Transformer)super.transformers.get(index-1);
- validity = ((CacheableProcessingComponent)trans).getValidity();
- if(debug) msg += "transformer: using getValidity";
- } else {
- // test serializer
- validity = ((CacheableProcessingComponent)super.serializer).getValidity();
- if(debug) msg += "serializer: using getValidity";
- }
-
- if(debug) {
- msg += ", validity==" + validity;
- this.getLogger().debug(msg);
- }
- return validity;
- }
-
- /**
- * Recyclable Interface
- */
- public void recycle() {
- this.generatorRole = null;
- this.transformerRoles.clear();
- this.serializerRole = null;
- this.readerRole = null;
-
- this.fromCacheKey = null;
- this.cachedResponse = null;
-
- this.toCacheKey = null;
- this.toCacheSourceValidities = null;
-
- super.recycle();
- }
-}
-
-final class DeferredPipelineValidity implements DeferredValidity {
-
- private final AbstractCachingProcessingPipeline pipeline;
- private final int index;
-
- public DeferredPipelineValidity(AbstractCachingProcessingPipeline pipeline, int index) {
- this.pipeline = pipeline;
- this.index = index;
- }
-
- /**
- * @see org.apache.excalibur.source.impl.validity.DeferredValidity#getValidity()
- */
- public SourceValidity getValidity() {
- return pipeline.getValidityForInternalPipeline(this.index);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java
deleted file mode 100644
index 22c477c..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/BaseCachingProcessingPipeline.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.cocoon.caching.Cache;
-import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline;
-import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
-import org.apache.cocoon.components.sax.XMLByteStreamInterpreter;
-
-/**
- * This is the base class for all caching pipeline implementations.
- * The pipeline can be configured with the {@link Cache} to use
- * by specifying the <code>cache-role</code> parameter.
- *
- * @since 2.1
- * @version $Id$
- */
-public abstract class BaseCachingProcessingPipeline extends AbstractProcessingPipeline
- implements Disposable {
-
- /** This is the Cache holding cached responses */
- protected Cache cache;
-
- /** The deserializer */
- protected XMLByteStreamInterpreter xmlDeserializer;
-
- /** The serializer */
- protected XMLByteStreamCompiler xmlSerializer;
-
- /**
- * Parameterizable Interface - Configuration
- */
- public void parameterize(Parameters params)
- throws ParameterException {
- super.parameterize(params);
-
- String cacheRole = params.getParameter("cache-role", Cache.ROLE);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Using cache " + cacheRole);
- }
-
- try {
- this.cache = (Cache) this.manager.lookup(cacheRole);
- } catch (ServiceException ce) {
- throw new ParameterException("Unable to lookup cache: " + cacheRole, ce);
- }
- }
-
- /**
- * Recyclable Interface
- */
- public void recycle() {
- this.xmlDeserializer = null;
- this.xmlSerializer = null;
-
- super.recycle();
- }
-
- /**
- * Disposable Interface
- */
- public void dispose() {
- if (null != this.manager) {
- this.manager.release(this.cache);
- }
- this.cache = null;
- this.manager = null;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
deleted file mode 100644
index 6782cbc..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.cocoon.caching.CachingOutputStream;
-import org.apache.cocoon.caching.ComponentCacheKey;
-import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
-import org.apache.cocoon.components.sax.XMLByteStreamInterpreter;
-import org.apache.cocoon.components.sax.XMLTeePipe;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLProducer;
-import org.apache.excalibur.source.SourceValidity;
-
-/**
- * The CachingPointProcessingPipeline
- *
- * @since 2.1
- * @version $Id$
- */
-public class CachingPointProcessingPipeline
- extends AbstractCachingProcessingPipeline {
-
- protected ArrayList isCachePoint = new ArrayList();
- protected ArrayList xmlSerializerArray = new ArrayList();
- protected boolean nextIsCachePoint = false;
- protected String autoCachingPointSwitch;
- protected boolean autoCachingPoint = true;
-
-
- /**
- * The <code>CachingPointProcessingPipeline</code> is configurable.
- * The autoCachingPoint algorithm can be switced on/off
- * in the sitemap.xmap
- */
- public void parameterize(Parameters config) throws ParameterException {
- super.parameterize(config);
- this.autoCachingPointSwitch = config.getParameter("autoCachingPoint", null);
-
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("Auto caching-point is set to = '" + this.autoCachingPointSwitch + "'");
- }
-
- // Default is that auto caching-point is on
- if (this.autoCachingPointSwitch == null){
- this.autoCachingPoint=true;
- return;
- }
-
- if (this.autoCachingPointSwitch.toLowerCase().equals("on")) {
- this.autoCachingPoint=true;
- } else {
- this.autoCachingPoint=false;
- }
- }
-
- /**
- * Set the generator.
- */
- public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
- throws ProcessingException {
- super.setGenerator(role, source, param, hintParam);
-
- // check the hint param for a "caching-point" hint
- String pipelinehint = null;
- try {
- pipelinehint = hintParam.getParameter("caching-point", null);
-
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("generator caching-point pipeline-hint is set to: " + pipelinehint);
- }
- } catch (Exception ex) {
- if (this.getLogger().isWarnEnabled()) {
- getLogger().warn("caching-point hint Exception, pipeline-hint ignored: " + ex);
- }
- }
-
- // if this generator is manually set to "caching-point" (via pipeline-hint)
- // then ensure the next component is caching.
- if ( "true".equals(pipelinehint)) {
- this.nextIsCachePoint=true;
- }
- }
-
-
- /**
- * Add a transformer.
- */
- public void addTransformer (String role, String source, Parameters param, Parameters hintParam)
- throws ProcessingException {
- super.addTransformer(role, source, param, hintParam);
-
- // check the hint param for a "caching-point" hint
- String pipelinehint = null;
- try {
- pipelinehint = hintParam.getParameter("caching-point", null);
-
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("transformer caching-point pipeline-hint is set to: " + pipelinehint);
- }
- } catch (Exception ex) {
- if (this.getLogger().isWarnEnabled()) {
- getLogger().warn("caching-point hint Exception, pipeline-hint ignored: " + ex);
- }
- }
-
- // add caching point flag
- // default value is false
- this.isCachePoint.add(Boolean.valueOf(this.nextIsCachePoint));
- this.nextIsCachePoint = false;
-
- // if this transformer is manually set to "caching-point" (via pipeline-hint)
- // then ensure the next component is caching.
- if ( "true".equals(pipelinehint)) {
- this.nextIsCachePoint=true;
- }
- }
-
-
- /**
- * Determine if the given branch-point
- * is a caching-point
- *
- * Please Note: this method is used by auto caching-point
- * and is of no consequence when auto caching-point is switched off
- */
- public void informBranchPoint() {
-
- if (this.generator == null) {
- return;
- }
- if (!this.autoCachingPoint) {
- return;
- }
-
- this.nextIsCachePoint = true;
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Informed Pipeline of branch point");
- }
- }
-
- /**
- * Cache longest cacheable path plus cache points.
- */
- protected CachedResponse cacheResults(Environment environment, OutputStream os) throws Exception {
- CachedResponse completeCachedResponse = null;
-
- if (this.toCacheKey != null) {
- if ( this.cacheCompleteResponse ) {
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Cached: caching complete response; pSisze"
- + this.toCacheKey.size() + " Key " + this.toCacheKey);
- }
- CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
- ((CachingOutputStream)os).getContent());
- response.setContentType(environment.getContentType());
- this.cache.store(this.toCacheKey.copy(),
- response);
- completeCachedResponse = response;
- //
- // Scan back along the pipelineCacheKey for
- // for any cachepoint(s)
- //
- this.toCacheKey.removeUntilCachePoint();
-
- //
- // adjust the validities object
- // to reflect the new length of the pipeline cache key.
- //
- // REVISIT: Is it enough to simply reduce the length of the validities array?
- //
- if (this.toCacheKey.size()>0) {
- SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()];
- System.arraycopy(this.toCacheSourceValidities, 0,
- copy, 0, copy.length);
- this.toCacheSourceValidities = copy;
- }
- }
-
- if (this.toCacheKey.size()>0) {
- ListIterator itt = this.xmlSerializerArray.listIterator(this.xmlSerializerArray.size());
- while (itt.hasPrevious()) {
- XMLByteStreamCompiler serializer = (XMLByteStreamCompiler) itt.previous();
- CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
- (byte[])serializer.getSAXFragment());
- this.cache.store(this.toCacheKey.copy(),
- response);
-
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("Caching results for the following key: "
- + this.toCacheKey);
- }
-
- //
- // Check for further cachepoints
- //
- toCacheKey.removeUntilCachePoint();
- if (this.toCacheKey.size()==0)
- // no cachePoint found in key
- break;
-
- //
- // re-calculate validities array
- //
- SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()];
- System.arraycopy(this.toCacheSourceValidities, 0,
- copy, 0, copy.length);
- this.toCacheSourceValidities = copy;
- } //end serializer loop
-
- }
- }
- return completeCachedResponse;
- }
-
- /**
- * Create a new ComponentCachekey
- * ComponentCacheKeys can be flagged as cachepoints
- */
- protected ComponentCacheKey newComponentCacheKey(int type, String role,Serializable key) {
- boolean cachePoint = false;
-
- if (type == ComponentCacheKey.ComponentType_Transformer) {
- cachePoint =
- ((Boolean)this.isCachePoint.get(this.firstNotCacheableTransformerIndex)).booleanValue();
- } else if (type == ComponentCacheKey.ComponentType_Serializer) {
- cachePoint = this.nextIsCachePoint;
- }
-
- return new ComponentCacheKey(type, role, key, cachePoint);
- }
-
-
- /**
- * Connect the caching point pipeline.
- */
- protected void connectCachingPipeline(Environment environment)
- throws ProcessingException {
- XMLByteStreamCompiler localXMLSerializer = null;
- XMLByteStreamCompiler cachePointXMLSerializer = null;
- if (!this.cacheCompleteResponse) {
- this.xmlSerializer = new XMLByteStreamCompiler();
- localXMLSerializer = this.xmlSerializer;
- }
-
- if (this.cachedResponse == null) {
- XMLProducer prev = super.generator;
- XMLConsumer next;
-
- int cacheableTransformerCount = this.firstNotCacheableTransformerIndex;
- int currentTransformerIndex = 0; //start with the first transformer
-
- Iterator itt = this.transformers.iterator();
- while ( itt.hasNext() ) {
- next = (XMLConsumer) itt.next();
-
- // if we have cacheable transformers,
- // check the tranformers for cachepoints
- if (cacheableTransformerCount > 0) {
- if ( (this.isCachePoint.get(currentTransformerIndex) != null) &&
- ((Boolean)this.isCachePoint.get(currentTransformerIndex)).booleanValue()) {
-
- cachePointXMLSerializer = new XMLByteStreamCompiler();
- next = new XMLTeePipe(next, cachePointXMLSerializer);
- this.xmlSerializerArray.add(cachePointXMLSerializer);
- }
- }
-
-
- // Serializer is not cacheable,
- // but we have the longest cacheable key. Do default longest key caching
- if (localXMLSerializer != null) {
- if (cacheableTransformerCount == 0) {
- next = new XMLTeePipe(next, localXMLSerializer);
- this.xmlSerializerArray.add(localXMLSerializer);
- localXMLSerializer = null;
- } else {
- cacheableTransformerCount--;
- }
- }
- this.connect(environment, prev, next);
- prev = (XMLProducer) next;
-
- currentTransformerIndex++;
- }
- next = super.lastConsumer;
-
-
- // if the serializer is not cacheable, but all the transformers are:
- // (this is default longest key caching)
- if (localXMLSerializer != null) {
- next = new XMLTeePipe(next, localXMLSerializer);
- this.xmlSerializerArray.add(localXMLSerializer);
- localXMLSerializer = null;
- }
-
- // else if the serializer is cacheable and has cocoon views
- else if ((currentTransformerIndex == this.firstNotCacheableTransformerIndex) &&
- this.nextIsCachePoint) {
- cachePointXMLSerializer = new XMLByteStreamCompiler();
- next = new XMLTeePipe(next, cachePointXMLSerializer);
- this.xmlSerializerArray.add(cachePointXMLSerializer);
- }
- this.connect(environment, prev, next);
-
- } else {
- // Here the first part of the pipeline has been retrived from cache
- // we now check if any part of the rest of the pipeline can be cached
- this.xmlDeserializer = new XMLByteStreamInterpreter();
- // connect the pipeline:
- XMLProducer prev = xmlDeserializer;
- XMLConsumer next;
- int cacheableTransformerCount = 0;
- Iterator itt = this.transformers.iterator();
- while ( itt.hasNext() ) {
- next = (XMLConsumer) itt.next();
-
- if (cacheableTransformerCount >= this.firstProcessedTransformerIndex) {
-
- // if we have cacheable transformers left,
- // then check the tranformers for cachepoints
- if (cacheableTransformerCount < this.firstNotCacheableTransformerIndex) {
- if ( !(prev instanceof XMLByteStreamInterpreter) &&
- (this.isCachePoint.get(cacheableTransformerCount) != null) &&
- ((Boolean)this.isCachePoint.get(cacheableTransformerCount)).booleanValue()) {
- cachePointXMLSerializer = new XMLByteStreamCompiler();
- next = new XMLTeePipe(next, cachePointXMLSerializer);
- this.xmlSerializerArray.add(cachePointXMLSerializer);
- }
- }
-
- // Serializer is not cacheable,
- // but we have the longest cacheable key. Do default longest key caching
- if (localXMLSerializer != null && !(prev instanceof XMLByteStreamInterpreter)
- && cacheableTransformerCount == this.firstNotCacheableTransformerIndex) {
- next = new XMLTeePipe(next, localXMLSerializer);
- this.xmlSerializerArray.add(localXMLSerializer);
- localXMLSerializer = null;
- }
- this.connect(environment, prev, next);
- prev = (XMLProducer)next;
- }
- cacheableTransformerCount++;
- }
- next = super.lastConsumer;
-
- //*all* the transformers are cacheable, but the serializer is not!! this is longest key
- if (localXMLSerializer != null && !(prev instanceof XMLByteStreamInterpreter)) {
- next = new XMLTeePipe(next, localXMLSerializer);
- this.xmlSerializerArray.add(localXMLSerializer);
- localXMLSerializer = null;
- } else if (this.nextIsCachePoint && !(prev instanceof XMLByteStreamInterpreter) &&
- cacheableTransformerCount == this.firstNotCacheableTransformerIndex) {
- // else the serializer is cacheable but has views
- cachePointXMLSerializer = new XMLByteStreamCompiler();
- next = new XMLTeePipe(next, cachePointXMLSerializer);
- this.xmlSerializerArray.add(cachePointXMLSerializer);
- }
- this.connect(environment, prev, next);
- }
- }
-
-
- /**
- * Recyclable Interface
- */
- public void recycle() {
- super.recycle();
-
- Iterator itt = this.xmlSerializerArray.iterator();
- while (itt.hasNext()) {
- this.manager.release(itt.next());
- }
-
- this.isCachePoint.clear();
- this.xmlSerializerArray.clear();
- this.nextIsCachePoint = false;
- this.autoCachingPointSwitch=null;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
deleted file mode 100644
index 0cafaab..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Iterator;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.cocoon.caching.CachingOutputStream;
-import org.apache.cocoon.caching.ComponentCacheKey;
-import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
-import org.apache.cocoon.components.sax.XMLByteStreamInterpreter;
-import org.apache.cocoon.components.sax.XMLTeePipe;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLProducer;
-
-/**
- * The CachingProcessingPipeline
- *
- * @since 2.1
- * @version $Id$
- */
-public class CachingProcessingPipeline extends AbstractCachingProcessingPipeline {
-
- /**
- * Cache longest cacheable key
- */
- protected CachedResponse cacheResults(Environment environment, OutputStream os) throws Exception {
- if (this.toCacheKey != null) {
- // See if there is an expires object for this resource.
- Long expiresObj = (Long) environment.getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT);
-
- CachedResponse response;
- if (this.cacheCompleteResponse) {
- response = new CachedResponse(this.toCacheSourceValidities,
- ((CachingOutputStream) os).getContent(),
- expiresObj);
- response.setContentType(environment.getContentType());
- } else {
- response = new CachedResponse(this.toCacheSourceValidities,
- (byte[]) this.xmlSerializer.getSAXFragment(),
- expiresObj);
- }
-
- this.cache.store(this.toCacheKey, response);
- return response;
- }
- return null;
- }
-
- /**
- * Create a new cache key
- */
- protected ComponentCacheKey newComponentCacheKey(int type, String role,Serializable key) {
- return new ComponentCacheKey(type, role, key);
- }
-
- /**
- * Connect the pipeline.
- */
- protected void connectCachingPipeline(Environment environment)
- throws ProcessingException {
- XMLByteStreamCompiler localXMLSerializer = null;
- if (!this.cacheCompleteResponse) {
- this.xmlSerializer = new XMLByteStreamCompiler();
- localXMLSerializer = this.xmlSerializer;
- }
-
- if (this.cachedResponse == null) {
- XMLProducer prev = super.generator;
- XMLConsumer next;
-
- int cacheableTransformerCount = this.firstNotCacheableTransformerIndex;
-
- Iterator itt = this.transformers.iterator();
- while (itt.hasNext()) {
- next = (XMLConsumer) itt.next();
- if (localXMLSerializer != null) {
- if (cacheableTransformerCount == 0) {
- next = new XMLTeePipe(next, localXMLSerializer);
- localXMLSerializer = null;
- } else {
- cacheableTransformerCount--;
- }
- }
- connect(environment, prev, next);
- prev = (XMLProducer) next;
- }
-
- next = super.lastConsumer;
- if (localXMLSerializer != null) {
- next = new XMLTeePipe(next, localXMLSerializer);
- localXMLSerializer = null;
- }
- connect(environment, prev, next);
- } else {
- this.xmlDeserializer = new XMLByteStreamInterpreter();
-
- // connect the pipeline:
- XMLProducer prev = xmlDeserializer;
- XMLConsumer next;
- int cacheableTransformerCount = 0;
- Iterator itt = this.transformers.iterator();
- while (itt.hasNext()) {
- next = (XMLConsumer) itt.next();
- if (cacheableTransformerCount >= this.firstProcessedTransformerIndex) {
- if (localXMLSerializer != null
- && cacheableTransformerCount == this.firstNotCacheableTransformerIndex) {
- next = new XMLTeePipe(next, localXMLSerializer);
- localXMLSerializer = null;
- }
- connect(environment, prev, next);
- prev = (XMLProducer) next;
- }
- cacheableTransformerCount++;
- }
-
- next = super.lastConsumer;
- if (localXMLSerializer != null) {
- next = new XMLTeePipe(next, localXMLSerializer);
- localXMLSerializer = null;
- }
- connect(environment, prev, next);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
deleted file mode 100644
index 21d88dc..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameters;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.cocoon.caching.CachingOutputStream;
-import org.apache.cocoon.caching.IdentifierCacheKey;
-import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
-import org.apache.cocoon.components.sax.XMLByteStreamInterpreter;
-import org.apache.cocoon.components.sax.XMLTeePipe;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Response;
-import org.apache.cocoon.xml.XMLConsumer;
-
-import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.source.impl.validity.ExpiresValidity;
-import org.apache.excalibur.source.impl.validity.NOPValidity;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * This pipeline implementation caches the complete content for a defined
- * period of time (expires).
- *
- * <map:pipe name="expires" src="org.apache.cocoon.components.pipeline.impl.ExpiresCachingProcessingPipeline">
- * <parameter name="cache-expires" value="180"/> <!-- Expires in secondes -->
- * </map:pipe>
- *
- * The cache-expires parameter controls the period of time for caching the content. A positive
- * value is a value in seconds, a value of zero means no caching and a negative value means
- * indefinite caching. In this case, you should use an external mechanism to invalidate the
- * cache entry.
- *
- * @since 2.1
- * @version $Id$
- */
-public class ExpiresCachingProcessingPipeline
- extends BaseCachingProcessingPipeline {
-
- /** This key can be used to put a key in the object model */
- public static final String CACHE_KEY_KEY = ExpiresCachingProcessingPipeline.class.getName() + "/CacheKey";
-
- /** This key can be used to put an expires information in the object model */
- public static final String CACHE_EXPIRES_KEY = ExpiresCachingProcessingPipeline.class.getName() + "/Expires";
-
- /** The source validity */
- protected SourceValidity cacheValidity;
-
- /** The key used for caching */
- protected IdentifierCacheKey cacheKey;
-
- /** The expires information. */
- protected long cacheExpires;
-
- /** Default value for expiration */
- protected long defaultCacheExpires = 3600; // 1 hour
-
- /** The cached response */
- protected CachedResponse cachedResponse;
-
- public void parameterize(Parameters params)
- throws ParameterException {
- super.parameterize(params);
-
- this.defaultCacheExpires = params.getParameterAsLong("cache-expires", this.defaultCacheExpires);
- }
-
- /**
- * Process the given <code>Environment</code>, producing the output.
- */
- protected boolean processXMLPipeline(Environment environment)
- throws ProcessingException {
- try {
- if (this.cachedResponse != null) {
- byte[] content = cachedResponse.getResponse();
-
- if ( this.serializer == this.lastConsumer ) {
- if ( cachedResponse.getContentType() != null ) {
- environment.setContentType(cachedResponse.getContentType());
- } else {
- this.setMimeTypeForSerializer(environment);
- }
- final OutputStream outputStream = environment.getOutputStream(0);
- if (content.length > 0) {
- environment.setContentLength(content.length);
- outputStream.write(content);
- }
- } else {
- this.setMimeTypeForSerializer(environment);
- this.xmlDeserializer.setConsumer( this.lastConsumer );
- this.xmlDeserializer.deserialize( content );
- }
-
- } else {
-
- // generate new response
-
- if ( this.cacheExpires == 0 ) {
- return super.processXMLPipeline( environment );
- }
-
- this.setMimeTypeForSerializer(environment);
- byte[] cachedData;
- if ( this.serializer == this.lastConsumer ) {
-
- if (this.serializer.shouldSetContentLength()) {
- OutputStream os = environment.getOutputStream(this.outputBufferSize);
-
- // set the output stream
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- this.serializer.setOutputStream(baos);
-
- this.generator.generate();
-
- cachedData = baos.toByteArray();
- environment.setContentLength(cachedData.length);
- os.write(cachedData);
- } else {
- CachingOutputStream os = new CachingOutputStream( environment.getOutputStream(this.outputBufferSize) );
- // set the output stream
- this.serializer.setOutputStream( os );
- this.generator.generate();
-
- cachedData = os.getContent();
- }
-
- } else {
- this.generator.generate();
- cachedData = (byte[])this.xmlSerializer.getSAXFragment();
- }
-
- //
- // Now that we have processed the pipeline,
- // we do the actual caching
- //
- if (this.cacheValidity != null) {
- cachedResponse = new CachedResponse(this.cacheValidity,
- cachedData);
- cachedResponse.setContentType(environment.getContentType());
- this.cache.store(this.cacheKey, cachedResponse);
- }
- }
- } catch (Exception e) {
- handleException(e);
- }
-
- //Request has been succesfully processed, set approporiate status code
- environment.setStatus(HttpServletResponse.SC_OK);
- return true;
- }
-
- /**
- * Connect the XML pipeline.
- */
- protected void connectPipeline(Environment environment)
- throws ProcessingException {
- if ( this.lastConsumer != this.serializer ) {
- // internal
- if ( this.cachedResponse == null) {
- // if we cache, we need an xml serializer
- if ( this.cacheExpires != 0) {
- final XMLConsumer old = this.lastConsumer;
- this.xmlSerializer = new XMLByteStreamCompiler();
- this.lastConsumer = new XMLTeePipe(this.lastConsumer, this.xmlSerializer);
-
- super.connectPipeline( environment );
-
- this.lastConsumer = old;
- } else {
- super.connectPipeline( environment );
- }
- } else {
- // we use the cache, so we need an xml deserializer
- this.xmlDeserializer = new XMLByteStreamInterpreter();
- }
- } else {
- // external: we only need to connect if we don't use a cached response
- if ( this.cachedResponse == null) {
- super.connectPipeline( environment );
- }
- }
- }
-
- /**
- * Prepare the pipeline
- */
- protected void preparePipeline(Environment environment)
- throws ProcessingException {
- // get the key and the expires info
- // we must do this before we call super.preparePipeline,
- // otherwise internal pipelines are instantiated and
- // get a copy of the object model with our info!
- final Map objectModel = environment.getObjectModel();
- String key = (String)objectModel.get(CACHE_KEY_KEY);
- if ( key == null ) {
- key = this.parameters.getParameter("cache-key", null);
- if ( key == null ) {
- key = environment.getURIPrefix()+environment.getURI();
- }
- } else {
- objectModel.remove(CACHE_KEY_KEY);
- }
- String expiresValue = (String)objectModel.get(CACHE_EXPIRES_KEY);
- if ( expiresValue == null ) {
- this.cacheExpires = this.parameters.getParameterAsLong("cache-expires", this.defaultCacheExpires);
- } else {
- this.cacheExpires = Long.valueOf(expiresValue).longValue();
- objectModel.remove(CACHE_EXPIRES_KEY);
- }
-
- // prepare the pipeline
- super.preparePipeline( environment );
-
- // and now prepare the caching information
- this.cacheKey = new IdentifierCacheKey(key,
- this.serializer == this.lastConsumer);
- if ( this.cacheExpires > 0) {
- this.cacheValidity = new ExpiresValidity(this.cacheExpires*1000);
- } else if ( this.cacheExpires < 0 ) {
- this.cacheValidity = NOPValidity.SHARED_INSTANCE;
- }
- final boolean purge = this.parameters.getParameterAsBoolean("purge-cache", false);
-
- this.cachedResponse = this.cache.get(this.cacheKey);
- if ( this.cachedResponse != null ) {
- final SourceValidity sv = cachedResponse.getValidityObjects()[0];
- if ( purge
- || (this.cacheExpires != -1 && sv.isValid() != SourceValidity.VALID) ) {
- this.cache.remove( this.cacheKey );
- this.cachedResponse = null;
- }
- }
- if ( this.cacheExpires > 0
- && (this.reader != null || this.lastConsumer == this.serializer )) {
- Response res = ObjectModelHelper.getResponse(environment.getObjectModel());
- res.setDateHeader("Expires", System.currentTimeMillis() + (this.cacheExpires*1000));
- res.setHeader("Cache-Control", "max-age=" + this.cacheExpires + ", public");
- }
- }
-
- /**
- * Return valid validity objects for the event pipeline
- * If the "event pipeline" (= the complete pipeline without the
- * serializer) is cacheable and valid, return all validity objects.
- * Otherwise return <code>null</code>
- */
- public SourceValidity getValidityForEventPipeline() {
- return this.cacheValidity;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getKeyForEventPipeline()
- */
- public String getKeyForEventPipeline() {
- if (this.cacheKey != null && this.cacheValidity != null) {
- return this.cacheKey.toString();
- }
- return null;
- }
-
- /**
- * Recyclable Interface
- */
- public void recycle() {
- this.cacheKey = null;
- this.cacheExpires = 0;
- this.cachedResponse = null;
- super.recycle();
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.components.pipeline.AbstractProcessingPipeline#processReader(org.apache.cocoon.environment.Environment)
- */
- protected boolean processReader(Environment environment)
- throws ProcessingException {
- try {
- if (this.cachedResponse != null) {
- if ( cachedResponse.getContentType() != null ) {
- environment.setContentType(cachedResponse.getContentType());
- } else {
- this.setMimeTypeForReader(environment);
- }
-
- final byte[] content = cachedResponse.getResponse();
- environment.setContentLength(content.length);
-
- final OutputStream os = environment.getOutputStream(0);
- os.write(content);
-
- } else {
- // generate new response
-
- if ( this.cacheExpires == 0 ) {
- return super.processReader( environment );
- }
-
- byte[] cachedData;
-
- this.setMimeTypeForReader(environment);
- if (this.reader.shouldSetContentLength()) {
- final OutputStream os = environment.getOutputStream(this.outputBufferSize);
-
- // set the output stream
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- this.reader.setOutputStream(baos);
-
- this.reader.generate();
-
- cachedData = baos.toByteArray();
- environment.setContentLength(cachedData.length);
- os.write(cachedData);
- } else {
- final CachingOutputStream os = new CachingOutputStream( environment.getOutputStream(this.outputBufferSize) );
- // set the output stream
- this.reader.setOutputStream( os );
- this.reader.generate();
-
- cachedData = os.getContent();
- }
-
- //
- // Now that we have processed the pipeline,
- // we do the actual caching
- //
- if (this.cacheValidity != null) {
- cachedResponse = new CachedResponse(this.cacheValidity,
- cachedData);
- cachedResponse.setContentType(environment.getContentType());
- this.cache.store(this.cacheKey, cachedResponse);
- }
- }
- } catch (Exception e) {
- handleException(e);
- }
-
- //Request has been succesfully processed, set approporiate status code
- environment.setStatus(HttpServletResponse.SC_OK);
- return true;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/NonCachingProcessingPipeline.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/NonCachingProcessingPipeline.java
deleted file mode 100644
index f62b475..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/NonCachingProcessingPipeline.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline;
-
-/**
- * Thi is the implementation of the non caching processing pipeline
- *
- * @version $Id$
- */
-public class NonCachingProcessingPipeline
- extends AbstractProcessingPipeline {
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/PipelineComponentInfo.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/PipelineComponentInfo.java
deleted file mode 100644
index ed15006..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/pipeline/impl/PipelineComponentInfo.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.pipeline.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.cocoon.generation.Generator;
-import org.apache.cocoon.reading.Reader;
-import org.apache.cocoon.serialization.Serializer;
-import org.apache.cocoon.transformation.Transformer;
-
-/**
- * Holds informations defined in <map:components> such as default hint, labels and mime-types
- * that are needed when building a processor and to manage inheritance when building child processors.
- * <p>
- * In previous versions of the sitemap engine, these informations where store in specialized
- * extensions of ComponentSelector (<code>SitemapComponentSelector</code> and
- * <code>OutputComponentSelector</code>), which led to a strong dependency on the chosen component
- * container implementation. This is now a regular component that also "listens" to modifications
- * of the service manager when it is built.
- *
- * @version $Id: ProcessorComponentInfo.java 490762 2006-12-28 17:03:53Z danielf $
- */
-public class PipelineComponentInfo {
-
- /** The role to lookup this component. */
- public static final String ROLE = PipelineComponentInfo.class.getName();
-
- protected static final String GENERATOR_PREFIX = Generator.ROLE + "/";
- protected static final String TRANSFORMER_PREFIX = Transformer.ROLE + "/";
- protected static final String SERIALIZER_PREFIX = Serializer.ROLE + "/";
- protected static final String READER_PREFIX = Reader.ROLE + "/";
-
- /** Component info for the parent processor */
- protected PipelineComponentInfo parent;
-
- /** Lock that prevents further modification */
- protected boolean locked = false;
-
- /**
- * Component-related data (see methods below for key names). We use a single Map
- * to reduce memory usage, as each kind of data has a limited number of entries.
- */
- private Map data;
-
- public PipelineComponentInfo(PipelineComponentInfo parent) {
- this.parent = parent;
- }
-
- /**
- * Grabs on the fly the sitemap-related information on generators, transformers,
- * serializers and readers when they're declared in the <code>ServiceManager</code>.
- * <p>
- * This method is triggered when a component is added on a <code>CocoonServiceManager</code>.
- *
- * @param role the component's role
- * @param clazz the component's class
- * @param config the component's configuration
- */
- public void componentAdded(String role, String clazz, Configuration config) {
- if (role.startsWith(GENERATOR_PREFIX)) {
- setupLabelAndPipelineHint(role, config);
-
- } else if (role.startsWith(TRANSFORMER_PREFIX)) {
- setupLabelAndPipelineHint(role, config);
-
- } else if (role.startsWith(SERIALIZER_PREFIX)) {
- setupLabelAndPipelineHint(role, config);
- setupMimeType(role, config);
-
- } else if (role.startsWith(READER_PREFIX)) {
- setupMimeType(role, config);
- }
- }
-
- protected void setupLabelAndPipelineHint(String role, Configuration config) {
-
- // Labels
- String label = config.getAttribute("label", null);
- if (label != null) {
- StringTokenizer st = new StringTokenizer(label, " ,", false);
- String[] labels = new String[st.countTokens()];
- for (int tokenIdx = 0; tokenIdx < labels.length; tokenIdx++) {
- labels[tokenIdx] = st.nextToken();
- }
- setLabels(role, labels);
- } else {
- // Set no labels, overriding those defined in the parent sitemap, if any
- setLabels(role, null);
- }
-
- // Pipeline hints
- String pipelineHint = config.getAttribute("hint", null);
- setPipelineHint(role, pipelineHint);
- }
-
- protected void setupMimeType(String role, Configuration config) {
- setMimeType(role, config.getAttribute("mime-type", null));
- }
-
- /** Store some data, creating the storage map if needed */
- private void setData(String key, Object value) {
- if (locked) throw new IllegalStateException("ProcessorComponentInfo is locked");
- if (this.data == null) this.data = new HashMap();
- this.data.put(key, value);
- }
-
- /** Get some data, asking the parent if needed */
- private Object getData(String key) {
- // Need to check containsKey as the default hint may be unspecified (i.e. no "default" attribute)
- if (this.data != null && this.data.containsKey(key)) {
- return this.data.get(key);
- } else if (this.parent != null) {
- // Ask parent
- return this.parent.getData(key);
- } else {
- return null;
- }
- }
-
- /**
- * Lock this component info object at the end of processor building to prevent
- * any further changes.
- */
- public void lock() {
- this.locked = true;
- }
-
- public void setDefaultType(String role, String hint) {
- setData("defaultType/" + role, hint);
- }
-
- public String getDefaultType(String role) {
- return (String)getData("defaultType/" + role);
- }
-
- public void setPipelineHint(String role, String hint) {
- setData("pipelineHint/" + role, hint);
- }
-
- public String getPipelineHint(String role, String type) {
- return (String)getData("pipelineHint/" + role + "/" + type);
- }
-
- public void setMimeType(String role, String mimeType) {
- setData("mimeType/" + role, mimeType);
- }
-
- public String getMimeType(String role, String type) {
- return (String)getData("mimeType/" + role + "/" + type);
- }
-
- public void setLabels(String role, String[] labels) {
- setData("labels/" + role, labels);
- }
-
- public String[] getLabels(String role, String type) {
- return (String[])getData("labels/" + role + "/" + type);
- }
-
- public boolean hasLabel(String role, String type, String label) {
- String[] labels = this.getLabels(role, type);
- if (labels != null) {
- for (int i = 0; i < labels.length; i++) {
- if (labels[i].equals(label))
- return true;
- }
- }
- return false;
- }
-
- public Map getData() {
- return this.data;
- }
-
- public void setData(Map map) {
- this.data = map;
- }
-
- public void addData(Map map) {
- if (this.data == null)
- this.data = map;
- else
- this.data.putAll(map);
- }
-}
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
deleted file mode 100644
index a53375a..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamCompiler.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import java.util.HashMap;
-
-import org.apache.cocoon.xml.XMLConsumer;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- * This a simple xml compiler which outputs a byte array.
- * If you want to reuse this instance, make sure to call {@link #recycle()}
- * inbetween two compilation tasks.
- *
- * @version $Id: XMLByteStreamCompiler.java 439255 2006-09-01 10:00:00Z giacomo $
- */
-public abstract class AbstractXMLByteStreamCompiler implements XMLConsumer, XMLByteStreamConstants {
-
- private HashMap map;
- private int mapCount;
- private boolean hasProlog = false;
-
- protected AbstractXMLByteStreamCompiler() {
- this.map = new HashMap();
- this.initOutput();
- }
-
- private void initOutput() {
- this.mapCount = 0;
- this.map.clear();
- this.hasProlog = false;
- }
-
- public void recycle() {
- this.initOutput();
- }
-
- public void startDocument() throws SAXException {
- if(!hasProlog)
- writeProlog();
- this.writeEvent(START_DOCUMENT);
- }
-
- public void endDocument() throws SAXException {
- this.writeEvent(END_DOCUMENT);
- }
-
- public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException {
- if(!hasProlog)
- writeProlog();
- this.writeEvent(START_PREFIX_MAPPING);
- this.writeString(prefix);
- this.writeString(uri);
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- this.writeEvent(END_PREFIX_MAPPING);
- this.writeString(prefix);
- }
-
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
- int length = atts.getLength();
- this.writeEvent(START_ELEMENT);
- this.writeAttributes(length);
- for (int i = 0; i < length; i++) {
- this.writeString(atts.getURI(i));
- this.writeString(atts.getLocalName(i));
- this.writeString(atts.getQName(i));
- this.writeString(atts.getType(i));
- this.writeString(atts.getValue(i));
- }
- this.writeString((namespaceURI == null ? "" : namespaceURI));
- this.writeString(localName);
- this.writeString(qName);
- }
-
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
- this.writeEvent(END_ELEMENT);
- this.writeString((namespaceURI == null ? "" : namespaceURI));
- this.writeString(localName);
- this.writeString(qName);
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- this.writeEvent(CHARACTERS);
- this.writeChars(ch, start, length);
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- if(!hasProlog)
- writeProlog();
- this.writeEvent(IGNORABLE_WHITESPACE);
- this.writeChars(ch, start, length);
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- this.writeEvent(PROCESSING_INSTRUCTION);
- this.writeString(target);
- this.writeString(data);
- }
-
- public void setDocumentLocator(Locator locator) {
- try {
- if(!hasProlog)
- writeProlog();
- this.writeEvent(LOCATOR);
- String publicId = locator.getPublicId();
- String systemId = locator.getSystemId();
- this.writeString(publicId!=null?publicId:"");
- this.writeString(systemId!=null?systemId:"");
- this.write(locator.getLineNumber());
- this.write(locator.getColumnNumber());
- } catch (Exception e) {
- throw new DocumentLocatorException("Error while handling locator", e);
- }
- }
-
- public void skippedEntity(java.lang.String name) throws SAXException {
- this.writeEvent(SKIPPED_ENTITY);
- this.writeString(name);
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void startDTD(String name, String publicId, String systemId) throws SAXException {
- this.writeEvent(START_DTD);
- this.writeString(name);
- this.writeString(publicId!=null?publicId:"");
- this.writeString(systemId!=null?systemId:"");
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void endDTD() throws SAXException {
- this.writeEvent(END_DTD);
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void startEntity(String name) throws SAXException {
- this.writeEvent(START_ENTITY);
- this.writeString(name);
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void endEntity(String name) throws SAXException {
- this.writeEvent(END_ENTITY);
- this.writeString(name);
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void startCDATA() throws SAXException {
- this.writeEvent(START_CDATA);
- }
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void endCDATA() throws SAXException {
- this.writeEvent(END_CDATA);
- }
-
-
- /**
- * SAX Event Handling: LexicalHandler
- */
- public void comment(char ary[], int start, int length) throws SAXException {
- try {
- this.writeEvent(COMMENT);
- this.writeChars(ary, start, length);
- } catch (Exception e) {
- throw new SAXException(e);
- }
- }
-
- public final void writeEvent( final int event) throws SAXException {
- this.write(event);
- }
-
- public final void writeAttributes( final int attributes) throws SAXException {
- if (attributes > 0xFFFF) throw new SAXException("Too many attributes");
- this.write((attributes >>> 8) & 0xFF);
- this.write((attributes >>> 0) & 0xFF);
- }
-
- public final void writeString( final String str) throws SAXException {
- Integer index = (Integer) map.get(str);
- if (index == null) {
- map.put(str, new Integer(mapCount++));
- int length = str.length();
- this.writeChars(str.toCharArray(), 0, length);
- }
- else {
- int i = index.intValue();
-
- if (i > 0xFFFF) throw new SAXException("Index too large");
-
- this.write(((i >>> 8) & 0xFF) | 0x80);
- this.write((i >>> 0) & 0xFF);
- }
- }
-
- public final void writeChars( final char[] ch, final int start, final int length) throws SAXException {
- int utflen = 0;
- int c;
-
- for (int i = 0; i < length; i++) {
- c = ch[i + start];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- }
- else if (c > 0x07FF) {
- utflen += 3;
- }
- else {
- utflen += 2;
- }
- }
-
- if (utflen >= 0x00007FFF) {
- write((byte)0x7F);
- write((byte)0xFF);
- write((byte) ((utflen >>> 24) & 0xFF));
- write((byte) ((utflen >>> 16) & 0xFF));
- write((byte) ((utflen >>> 8) & 0xFF));
- write((byte) ((utflen >>> 0) & 0xFF));
- }
- else {
- write((byte) ((utflen >>> 8) & 0xFF));
- write((byte) ((utflen >>> 0) & 0xFF));
- }
-
- for (int i = 0; i < length; i++) {
- c = ch[i + start];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- write((byte) c);
- }
- else if (c > 0x07FF) {
- write((byte) (0xE0 | ((c >> 12) & 0x0F)));
- write((byte) (0x80 | ((c >> 6) & 0x3F)));
- write((byte) (0x80 | ((c >> 0) & 0x3F)));
- }
- else {
- write((byte) (0xC0 | ((c >> 6) & 0x1F)));
- write((byte) (0x80 | ((c >> 0) & 0x3F)));
- }
- }
-
-
-/*
- if (length == 0) return;
-
- assure( (int) (buf.length + length * utfRatioAverage) );
-
- int utflentotal = 0;
-
- bufCount += 2;
- int bufStart = bufCount;
-
- for (int i = 0; i < length; i++) {
- int c = ch[i + start];
- int l = bufCount-bufStart;
-
- if (l+3 >= 0x7FFF) {
- buf[bufStart-2] = (byte) ((l >>> 8) & 0xFF);
- buf[bufStart-1] = (byte) ((l >>> 0) & 0xFF);
- utflentotal += l;
- bufCount += 2;
- bufStart = bufCount;
- }
-
- if ((c >= 0x0001) && (c <= 0x007F)) {
- assure(bufCount+1);
- buf[bufCount++] = (byte)c;
- }
- else if (c > 0x07FF) {
- assure(bufCount+3);
- buf[bufCount++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
- buf[bufCount++] = (byte) (0x80 | ((c >> 6) & 0x3F));
- buf[bufCount++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- else {
- assure(bufCount+2);
- buf[bufCount++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
- buf[bufCount++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- }
-
- int l = bufCount-bufStart;
- buf[bufStart-2] = (byte) ((l >>> 8) & 0xFF);
- buf[bufStart-1] = (byte) ((l >>> 0) & 0xFF);
- utflentotal += l;
-
- utfRatioAverage = (utfRatioAverage + (utflentotal / length) / 2);
-*/
- }
-
-/* JH (2003-11-20): seems to be never used
-
- private void write( final byte[] b ) {
- int newcount = this.bufCount + b.length;
- assure(newcount);
- System.arraycopy(b, 0, this.buf, this.bufCount, b.length);
- this.bufCount = newcount;
- }
-*/
-
- abstract protected void write( final int b ) throws SAXException;
-
- private void writeProlog() throws SAXException
- {
- write((byte)'C');
- write((byte)'X');
- write((byte)'M');
- write((byte)'L');
- write((byte)1);
- write((byte)0);
- hasProlog = true;
- }
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
deleted file mode 100644
index ae3cb44..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/AbstractXMLByteStreamInterpreter.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import java.util.ArrayList;
-
-import org.apache.cocoon.xml.DefaultLexicalHandler;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLProducer;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * This a simple xml compiler which takes a byte array as input.
- * If you want to reuse this interpreter make sure to call first {@link #recycle()}
- * and then set the new consumer for the sax events.
- *
- * @version $Id: XMLByteStreamInterpreter.java 439255 2006-09-01 10:00:00Z giacomo $
- */
-public abstract class AbstractXMLByteStreamInterpreter implements XMLProducer, XMLByteStreamConstants {
-
- private ArrayList list = new ArrayList();
-
- protected static final ContentHandler EMPTY_CONTENT_HANDLER = new DefaultHandler();
-
- /** The <code>ContentHandler</code> receiving SAX events. */
- protected ContentHandler contentHandler = EMPTY_CONTENT_HANDLER;
-
- /** The <code>LexicalHandler</code> receiving SAX events. */
- protected LexicalHandler lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
-
- /**
- * Set the <code>XMLConsumer</code> that will receive XML data.
- * <br>
- * This method will simply call <code>setContentHandler(consumer)</code>
- * and <code>setLexicalHandler(consumer)</code>.
- */
- public void setConsumer(XMLConsumer consumer) {
- setContentHandler(consumer);
- setLexicalHandler(consumer);
- }
-
- /**
- * Set the <code>ContentHandler</code> that will receive XML data.
- * <br>
- * Subclasses may retrieve this <code>ContentHandler</code> instance
- * accessing the protected <code>super.contentHandler</code> field.
- */
- public void setContentHandler(ContentHandler handler) {
- this.contentHandler = handler;
- }
-
- /**
- * Set the <code>LexicalHandler</code> that will receive XML data.
- * <br>
- * Subclasses may retrieve this <code>LexicalHandler</code> instance
- * accessing the protected <code>super.lexicalHandler</code> field.
- */
- public void setLexicalHandler(LexicalHandler handler) {
- this.lexicalHandler = handler;
- }
-
- public void recycle() {
- this.contentHandler = EMPTY_CONTENT_HANDLER;
- this.lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
- this.list.clear();
- }
-
- /**
- * This method needs to be used by sub classes to start the parsing of the byte stream
- *
- * @throws SAXException
- */
- protected void parse() throws SAXException {
- this.list.clear();
- this.checkProlog();
- int event = -1;
- int lastEvent = -1;
- while ( ( event = readEvent() ) != -1 ) {
- lastEvent = event;
- switch (event) {
- case START_DOCUMENT:
- contentHandler.startDocument();
- break;
- case END_DOCUMENT:
- contentHandler.endDocument();
- break;
- case START_PREFIX_MAPPING:
- contentHandler.startPrefixMapping(this.readString(), this.readString());
- break;
- case END_PREFIX_MAPPING:
- contentHandler.endPrefixMapping(this.readString());
- break;
- case START_ELEMENT:
- int attributes = this.readAttributes();
- AttributesImpl atts = new AttributesImpl();
- for (int i = 0; i < attributes; i++) {
- atts.addAttribute(this.readString(), this.readString(), this.readString(), this.readString(), this.readString());
- }
- contentHandler.startElement(this.readString(), this.readString(), this.readString(), atts);
- break;
- case END_ELEMENT:
- contentHandler.endElement(this.readString(), this.readString(), this.readString());
- break;
- case CHARACTERS:
- char[] chars = this.readChars();
- int len = chars.length;
- while (len > 0 && chars[len-1]==0) len--;
- if (len > 0) contentHandler.characters(chars, 0, len);
- break;
- case IGNORABLE_WHITESPACE:
- char[] spaces = this.readChars();
- len = spaces.length;
- while (len > 0 && spaces[len-1]==0) len--;
- if (len > 0) contentHandler.characters(spaces, 0, len);
- break;
- case PROCESSING_INSTRUCTION:
- contentHandler.processingInstruction(this.readString(), this.readString());
- break;
- case COMMENT:
- chars = this.readChars();
- len = chars.length;
- while (len > 0 && chars[len-1]==0) len--;
- if (len > 0) lexicalHandler.comment(chars, 0, len);
- break;
- case LOCATOR:
- {
- String publicId = this.readString();
- String systemId = this.readString();
- int lineNumber = this.read();
- int columnNumber = this.read();
- org.xml.sax.helpers.LocatorImpl locator = new org.xml.sax.helpers.LocatorImpl();
- locator.setPublicId(publicId);
- locator.setSystemId(systemId);
- locator.setLineNumber(lineNumber);
- locator.setColumnNumber(columnNumber);
- contentHandler.setDocumentLocator(locator);
- }
- break;
- case START_DTD:
- lexicalHandler.startDTD(this.readString(),
- this.readString(),
- this.readString());
- break;
- case END_DTD:
- lexicalHandler.endDTD();
- break;
- case START_CDATA:
- lexicalHandler.startCDATA();
- break;
- case END_CDATA:
- lexicalHandler.endCDATA();
- break;
- case SKIPPED_ENTITY:
- contentHandler.skippedEntity( this.readString() );
- break;
- case START_ENTITY:
- lexicalHandler.startEntity( this.readString() );
- break;
- case END_ENTITY:
- lexicalHandler.endEntity( this.readString() );
- break;
- default:
- throw new SAXException ("parsing error: event not supported: " + event);
- }
- }
- if( lastEvent != END_DOCUMENT )
- {
- throw new SAXException ("parsing error: premature end of stream (lastEvent was " + lastEvent + ")." );
- }
- }
-
- protected int readEvent() throws SAXException {
- return this.read();
- }
-
- private int readAttributes() throws SAXException {
- int ch1 = this.read();
- int ch2 = this.read();
- return ((ch1 << 8) + (ch2 << 0));
- }
-
- private String readString() throws SAXException {
- int length = this.readWord();
- int index = length & 0x00007FFF;
- if (length >= 0x00008000) {
- return (String) list.get(index);
- }
- else {
- if (length == 0x00007FFF) {
- length = this.readLong();
- }
- char[] chars = this.readChars(length);
- int len = chars.length;
- if (len > 0) {
- while (chars[len-1]==0) len--;
- }
- String str;
- if (len == 0) {
- str = "";
- } else {
- str = new String(chars, 0, len);
- }
- list.add(str);
- return str;
- }
- }
-
- /**
- * The returned char array might contain any number of zero bytes
- * at the end
- */
- private char[] readChars() throws SAXException {
- int length = this.readWord();
- if (length == 0x00007FFF) {
- length = this.readLong();
- }
- return this.readChars(length);
- }
-
- protected abstract int read() throws SAXException;
- protected abstract int read(byte[] b) throws SAXException;
-
- /**
- * The returned char array might contain any number of zero bytes
- * at the end
- */
- private char[] readChars(int len) throws SAXException {
- char[] str = new char[len];
- byte[] bytearr = new byte[len];
- int c, char2, char3;
- int count = 0;
- int i = 0;
-
- this.readBytes(bytearr);
-
- while (count < len) {
- c = bytearr[count] & 0xff;
- switch (c >> 4) {
- case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
- // 0xxxxxxx
- count++;
- str[i++] = (char) c;
- break;
- case 12: case 13:
- // 110x xxxx 10xx xxxx
- count += 2;
- char2 = bytearr[count-1];
- str[i++] = (char) (((c & 0x1F) << 6) | (char2 & 0x3F));
- break;
- case 14:
- // 1110 xxxx 10xx xxxx 10xx xxxx
- count += 3;
- char2 = bytearr[count-2];
- char3 = bytearr[count-1];
- str[i++] = ((char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
- break;
- default:
- // 10xx xxxx, 1111 xxxx
- throw new SAXException("UTFDataFormatException");
- }
- }
-
- return str;
- }
-
- private void readBytes(byte[] b) throws SAXException {
- final int bytesRead = this.read( b );
- if (bytesRead < b.length ) {
- throw new SAXException("End of is reached.");
- }
- }
-
- private int readWord() throws SAXException {
- int ch1 = this.read();
- int ch2 = this.read();
- return ((ch1 << 8) + (ch2 << 0));
- }
-
- private int readLong() throws SAXException {
- int ch1 = this.read();
- int ch2 = this.read();
- int ch3 = this.read();
- int ch4 = this.read();
- return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
- }
-
- private void checkProlog() throws SAXException {
- int valid = 0;
- int ch = 0;
- if ((ch = this.read()) == 'C') valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- if ((ch = this.read()) == 'X') valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- if ((ch = this.read()) == 'M') valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- if ((ch = this.read()) == 'L') valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- if ((ch = this.read()) == 1) valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- if ((ch = this.read()) == 0) valid++;
- else throw new SAXException("Unrecognized file format (." + valid + "," + ch + ")");
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/DocumentLocatorException.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/DocumentLocatorException.java
deleted file mode 100644
index 0ac9114..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/DocumentLocatorException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.apache.avalon.framework.CascadingRuntimeException;
-
-public final class DocumentLocatorException extends CascadingRuntimeException
-{
- public DocumentLocatorException(String message)
- {
- super(message, null);
- }
-
- public DocumentLocatorException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java
deleted file mode 100644
index 9ae0137..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamCompiler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-
-/**
- * This a simple xml compiler which outputs a byte array.
- * If you want to reuse this instance, make sure to call {@link #recycle()}
- * inbetween two compilation tasks.
- *
- * @version $Id$
- */
-public final class XMLByteStreamCompiler extends AbstractXMLByteStreamCompiler {
-
- /** The buffer for the compile xml byte stream. */
- private byte buf[];
-
- /** The number of valid bytes in the buffer. */
- private int bufCount;
-
- private int bufCountAverage;
-
-
- public XMLByteStreamCompiler() {
- super();
- this.bufCountAverage = 2000;
- this.initOutput();
- }
-
- private void initOutput() {
- this.buf = new byte[bufCountAverage];
- this.bufCount = 0;
- }
-
- public void recycle() {
- bufCountAverage = (bufCountAverage + bufCount) / 2;
- initOutput();
- super.recycle();
- }
-
-
- public Object getSAXFragment() {
- if (this.bufCount == 0) { // no event arrived yet
- return null;
- }
- byte newbuf[] = new byte[this.bufCount];
- System.arraycopy(this.buf, 0, newbuf, 0, this.bufCount);
- return newbuf;
- }
-
- protected void write( final int b ) {
- int newcount = this.bufCount + 1;
- assure(newcount);
- this.buf[this.bufCount] = (byte)b;
- this.bufCount = newcount;
- }
-
- private void assure( final int size ) {
- if (size > this.buf.length) {
- byte newbuf[] = new byte[Math.max(this.buf.length << 1, size)];
- System.arraycopy(this.buf, 0, newbuf, 0, this.bufCount);
- this.buf = newbuf;
- }
- }
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamConstants.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamConstants.java
deleted file mode 100644
index f3b678b..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-/**
- * The common constants for SAX byte streaming
- *
- * @version CVS $Id$
- */
-public interface XMLByteStreamConstants {
-
- int START_DOCUMENT = 0;
- int END_DOCUMENT = 1;
- int START_PREFIX_MAPPING = 2;
- int END_PREFIX_MAPPING = 3;
- int START_ELEMENT = 4;
- int END_ELEMENT = 5;
- int CHARACTERS = 6;
- int IGNORABLE_WHITESPACE = 7;
- int PROCESSING_INSTRUCTION = 8;
- int COMMENT = 9;
- int LOCATOR = 10;
- int START_DTD = 11;
- int END_DTD = 12;
- int START_CDATA = 13;
- int END_CDATA = 14;
- int SKIPPED_ENTITY = 15;
- int START_ENTITY = 16;
- int END_ENTITY = 17;
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamFragment.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamFragment.java
deleted file mode 100644
index f6506f3..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamFragment.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.apache.cocoon.xml.AbstractSAXFragment;
-import org.apache.cocoon.xml.EmbeddedXMLPipe;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * An XMLByteStream wrapped by an XMLFragment implementation. This allows to
- * store SAX events and insert them in an XSP result using <xsp:expr>.
- *
- * @version $Id$
- */
-public class XMLByteStreamFragment extends AbstractSAXFragment {
-
- /** The XML byte stream */
- private Object xmlBytes;
-
- /**
- * Creates a new <code>XMLByteStreamFragment</code> defined by the given
- * XML byte stream.
- *
- * @param bytes the XML byte stream representing the document fragment
- */
- public XMLByteStreamFragment(Object bytes) {
- this.xmlBytes = bytes;
- }
-
- /**
- * Output the fragment. If the fragment is a document, start/endDocument
- * events are discarded.
- */
- public void toSAX(ContentHandler ch) throws SAXException {
- // Stream bytes and discard start/endDocument
- XMLByteStreamInterpreter deserializer = new XMLByteStreamInterpreter();
- deserializer.setContentHandler(new EmbeddedXMLPipe(ch));
- deserializer.deserialize(this.xmlBytes);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamInterpreter.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamInterpreter.java
deleted file mode 100644
index d644c3e..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLByteStreamInterpreter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.xml.sax.SAXException;
-
-/**
- * This a simple xml compiler which takes a byte array as input.
- * If you want to reuse this interpreter make sure to call first {@link #recycle()}
- * and then set the new consumer for the sax events.
- *
- * @version $Id$
- */
-public final class XMLByteStreamInterpreter extends AbstractXMLByteStreamInterpreter {
-
- private byte[] input;
- private int currentPos;
-
- public void recycle() {
- this.input = null;
- super.recycle();
- }
-
- public void deserialize(Object saxFragment) throws SAXException {
- if (!(saxFragment instanceof byte[])) {
- throw new SAXException("XMLDeserializer needs byte array for deserialization.");
- }
- this.input = (byte[])saxFragment;
- this.currentPos = 0;
- super.parse();
- }
-
- protected int read() throws SAXException {
- if (currentPos >= input.length)
- return -1;
- return input[currentPos++] & 0xff;
- }
-
- protected int read(byte[] b) throws SAXException {
- final int bytesRead = (this.currentPos + b.length > this.input.length ? this.input.length - this.currentPos : b.length);
- System.arraycopy(this.input, this.currentPos, b, 0, bytesRead);
- this.currentPos += bytesRead;
- return bytesRead;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
deleted file mode 100644
index 504da6c..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLInputStreamInterpreter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.apache.cocoon.components.sax.AbstractXMLByteStreamInterpreter;
-
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * This class interpreter compiled SAX event from an InputStream.
- * If you want to reuse this interpreter make sure to call first {@link #recycle()}
- * and then set the new consumer for the sax events before restarting with the {@link #deserialize(InputStream)} method.
- *
- * @version $Id: XMLInputStreamInterpreter.java 366211 2006-01-05 16:02:33Z cziegeler $
- */
-public final class XMLInputStreamInterpreter
- extends AbstractXMLByteStreamInterpreter {
-
- private InputStream is;
-
- public void deserialize(final InputStream inputStream)
- throws SAXException {
- this.is = inputStream;
- super.parse();
- }
-
- public void recycle() {
- this.is = null;
- super.recycle();
- }
-
- protected int read()
- throws SAXException {
- try {
- return is.read();
- } catch(final IOException e) {
- throw new SAXException(e);
- }
- }
-
- protected int read(final byte[] b)
- throws SAXException {
- try {
- return is.read(b);
- } catch(final IOException e) {
- throw new SAXException(e);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
deleted file mode 100644
index af9225b..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLOutputStreamCompiler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.apache.cocoon.components.sax.AbstractXMLByteStreamCompiler;
-
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-
-/**
- * This class compiles SAX events to an OutputStream.
- * If you want to reuse this instance, make sure to call {@link #recycle(OutputStream)} to set a new OutputStream
- * and reset the class inbetween two compilation tasks.
- *
- * @version $Id: XMLOutputStreamCompiler.java 366211 2006-01-05 16:02:33Z cziegeler $
- */
-public final class XMLOutputStreamCompiler
- extends AbstractXMLByteStreamCompiler {
-
- /** The buffer for the compile xml byte stream. */
- private OutputStream os;
-
- public XMLOutputStreamCompiler(final OutputStream out)
- throws IOException {
- super();
- this.recycle(out);
- }
-
- public void recycle(final OutputStream out) {
- this.os = out;
- super.recycle();
- }
-
- public void recycle() {
- this.recycle(this.os);
- }
-
- protected void write(final int b)
- throws SAXException {
- try {
- this.os.write((byte)b);
- } catch(final IOException e) {
- throw new SAXException(e);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLTeePipe.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLTeePipe.java
deleted file mode 100644
index ca577b2..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/sax/XMLTeePipe.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLPipe;
-import org.apache.cocoon.xml.XMLProducer;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- * This is a simple Tee Component.
- * The incoming events are forwarded to two other components.
- *
- * @version $Id$
- */
-public class XMLTeePipe implements XMLPipe {
-
- private XMLConsumer firstConsumer;
- private XMLConsumer secondConsumer;
-
- /**
- * Create a new XMLTeePipe with two consumers
- */
- public XMLTeePipe(XMLConsumer firstPipe,
- XMLConsumer secondConsumer) {
- this.firstConsumer = firstPipe;
- this.secondConsumer = secondConsumer;
- }
-
- /**
- * Set the <code>XMLConsumer</code> that will receive XML data.
- */
- public void setConsumer(XMLConsumer consumer) {
- ((XMLProducer) this.firstConsumer).setConsumer(consumer);
- }
-
- /**
- * Reset consumers.
- */
- public void recycle() {
- this.firstConsumer = null;
- this.secondConsumer = null;
- }
-
- //
- // XMLPipe interface
- //
-
- public void startDocument() throws SAXException {
- this.firstConsumer.startDocument();
- this.secondConsumer.startDocument();
- }
-
- public void endDocument() throws SAXException {
- this.firstConsumer.endDocument();
- this.secondConsumer.endDocument();
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- this.firstConsumer.startPrefixMapping(prefix, uri);
- this.secondConsumer.startPrefixMapping(prefix, uri);
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- this.firstConsumer.endPrefixMapping(prefix);
- this.secondConsumer.endPrefixMapping(prefix);
- }
-
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
- throws SAXException {
- this.firstConsumer.startElement(namespaceURI, localName, qName, atts);
- this.secondConsumer.startElement(namespaceURI, localName, qName, atts);
- }
-
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException {
- this.firstConsumer.endElement(namespaceURI, localName, qName);
- this.secondConsumer.endElement(namespaceURI, localName, qName);
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- this.firstConsumer.characters(ch, start, length);
- this.secondConsumer.characters(ch, start, length);
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- this.firstConsumer.ignorableWhitespace(ch, start, length);
- this.secondConsumer.ignorableWhitespace(ch, start, length);
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- this.firstConsumer.processingInstruction(target, data);
- this.secondConsumer.processingInstruction(target, data);
- }
-
- public void setDocumentLocator(Locator locator) {
- this.firstConsumer.setDocumentLocator(locator);
- this.secondConsumer.setDocumentLocator(locator);
- }
-
- public void skippedEntity(String name) throws SAXException {
- this.firstConsumer.skippedEntity(name);
- this.secondConsumer.skippedEntity(name);
- }
-
- public void startDTD(String name, String public_id, String system_id)
- throws SAXException {
- this.firstConsumer.startDTD(name, public_id, system_id);
- this.secondConsumer.startDTD(name, public_id, system_id);
- }
-
- public void endDTD() throws SAXException {
- this.firstConsumer.endDTD();
- this.secondConsumer.endDTD();
- }
-
- public void startEntity(String name) throws SAXException {
- this.firstConsumer.startEntity(name);
- this.secondConsumer.startEntity(name);
- }
-
- public void endEntity(String name) throws SAXException {
- this.firstConsumer.endEntity(name);
- this.secondConsumer.endEntity(name);
- }
-
- public void startCDATA() throws SAXException {
- this.firstConsumer.startCDATA();
- this.secondConsumer.startCDATA();
- }
-
- public void endCDATA() throws SAXException {
- this.firstConsumer.endCDATA();
- this.secondConsumer.endCDATA();
- }
-
- public void comment(char ary[], int start, int length)
- throws SAXException {
- this.firstConsumer.comment(ary, start, length);
- this.secondConsumer.comment(ary, start, length);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/URLRewriter.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/URLRewriter.java
deleted file mode 100644
index da8e5a7..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/URLRewriter.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.source;
-
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.xml.XMLConsumer;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * This is an <code>XMLConsumer</code> which rewrites the stream according
- * to the configuration. The configuration can have the following
- * parameters:
- *
- * <ul>
- * <li><code>rewriteURLMode</code>: The mode to rewrite the urls. Currently,
- * values <code>none</code> and <code>cocoon</code> are supported.
- * <li><code>baseURL</code>: The current URL to rewrite.
- * <li><code>cocoonURL</code>: The url all links are resolved to.
- * <li><code>urlParameterName</code>: The parameter name to use for
- * links (all links are then "cocoonURL?urlParameterName=LINK").
- * </ul>
- *
- * <p>URLRewriter rewrites only href, src, background, and action attributes.
- *
- * @version $Id$
- */
-public final class URLRewriter implements XMLConsumer {
-
- public static final String PARAMETER_MODE = "rewriteURLMode";
- public static final String MODE_NONE = "none";
- public static final String MODE_COCOON = "cocoon";
- public static final String PARAMETER_PARAMETER_NAME = "urlParameterName";
- public static final String PARAMETER_URL = "baseURL";
- public static final String PARAMETER_COCOON_URL = "cocoonURL";
-
- /** The <code>ContentHandler</code> */
- private ContentHandler contentHandler;
- /** The <code>LexicalHandler</code> */
- private LexicalHandler lexicalHandler;
-
- /**
- * The mode:
- * 0: no rewriting
- * 1: cocoon
- */
- private int mode;
-
- /** The base url */
- private String baseUrl;
- /** The cocoon url */
- private String cocoonUrl;
-
- /**
- * Create a new rewriter
- */
- public URLRewriter(Parameters configuration,
- ContentHandler contentHandler,
- LexicalHandler lexicalHandler)
- throws ProcessingException {
- try {
- this.contentHandler = contentHandler;
- this.lexicalHandler = lexicalHandler;
- this.mode = 0;
- if (configuration != null &&
- MODE_COCOON.equalsIgnoreCase(configuration.getParameter(PARAMETER_MODE, null))) {
- this.mode = 1;
- this.baseUrl = configuration.getParameter(PARAMETER_URL);
- this.cocoonUrl = configuration.getParameter(PARAMETER_COCOON_URL) +
- '?' + configuration.getParameter(PARAMETER_PARAMETER_NAME) + '=';
- }
- } catch (org.apache.avalon.framework.parameters.ParameterException local) {
- throw new ProcessingException("URLRewriter: configuration exception.", local);
- }
- }
-
- /**
- * Create a new rewriter
- */
- public URLRewriter(Parameters configuration,
- ContentHandler contentHandler)
- throws ProcessingException {
- this(configuration, contentHandler,
- (contentHandler instanceof LexicalHandler ? (LexicalHandler)contentHandler : null));
- }
-
- /**
- * SAX Event Handling
- */
- public void setDocumentLocator(Locator locator) {
- contentHandler.setDocumentLocator(locator);
- }
-
- /**
- * SAX Event Handling
- */
- public void startDocument()
- throws SAXException {
- contentHandler.startDocument();
- }
-
- /**
- * SAX Event Handling
- */
- public void endDocument()
- throws SAXException {
- contentHandler.endDocument();
- }
-
- /**
- * SAX Event Handling
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- contentHandler.startPrefixMapping(prefix,uri);
- }
-
- /**
- * SAX Event Handling
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- contentHandler.endPrefixMapping(prefix);
- }
-
- /**
- * SAX Event Handling
- */
- public void startElement(String namespace, String name, String raw,
- Attributes attr)
- throws SAXException {
- if (this.mode == 1) {
- String attrname;
- AttributesImpl newattr = null;
- String value;
-
- for(int i = 0; i < attr.getLength(); i++) {
- attrname = attr.getLocalName(i);
- if (attrname.equals("href") == true ||
- attrname.equals("action") == true) {
- if (newattr == null) {
- newattr = new AttributesImpl(attr);
- }
- value = attr.getValue(i);
- if (value.indexOf(':') == -1) {
- try {
- URL baseURL = new URL(new URL(this.baseUrl), value);
- value = baseURL.toExternalForm();
- } catch (MalformedURLException local) {
- value = attr.getValue(i);
- }
- }
- newattr.setValue(i, this.cocoonUrl + value);
- } else if (attrname.equals("src") == true ||
- attrname.equals("background") == true) {
- if (newattr == null) {
- newattr = new AttributesImpl(attr);
- }
- value = attr.getValue(i);
- if (value.indexOf(':') == -1) {
- try {
- URL baseURL = new URL(new URL(this.baseUrl), value);
- value = baseURL.toExternalForm();
- } catch (MalformedURLException local) {
- value = attr.getValue(i);
- }
- }
- newattr.setValue(i, value);
- }
- }
- if (newattr != null) {
- contentHandler.startElement(namespace, name, raw, newattr);
- return;
- }
- }
- contentHandler.startElement(namespace, name, raw, attr);
- }
-
- /**
- * SAX Event Handling
- */
- public void endElement(String namespace, String name, String raw)
- throws SAXException {
- contentHandler.endElement(namespace, name, raw);
- }
-
- /**
- * SAX Event Handling
- */
- public void characters(char ary[], int start, int length)
- throws SAXException {
- contentHandler.characters(ary, start, length);
- }
-
- /**
- * SAX Event Handling
- */
- public void ignorableWhitespace(char ary[], int start, int length)
- throws SAXException {
- contentHandler.ignorableWhitespace(ary, start, length);
- }
-
- /**
- * SAX Event Handling
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- contentHandler.processingInstruction(target, data);
- }
-
- /**
- * SAX Event Handling
- */
- public void skippedEntity(String name)
- throws SAXException {
- contentHandler.skippedEntity(name);
- }
-
- /**
- * SAX Event Handling
- */
- public void startDTD(String name, String public_id, String system_id)
- throws SAXException {
- if (lexicalHandler != null) lexicalHandler.startDTD(name, public_id, system_id);
- }
-
- /**
- * SAX Event Handling
- */
- public void endDTD() throws SAXException {
- if (lexicalHandler != null) lexicalHandler.endDTD();
- }
-
- /**
- * SAX Event Handling
- */
- public void startEntity(String name) throws SAXException {
- if (lexicalHandler != null) lexicalHandler.startEntity(name);
- }
-
- /**
- * SAX Event Handling
- */
- public void endEntity(String name) throws SAXException {
- if (lexicalHandler != null) lexicalHandler.endEntity(name);
- }
-
- /**
- * SAX Event Handling
- */
- public void startCDATA() throws SAXException {
- if (lexicalHandler != null) lexicalHandler.startCDATA();
- }
-
- /**
- * SAX Event Handling
- */
- public void endCDATA() throws SAXException {
- if (lexicalHandler != null) lexicalHandler.endCDATA();
- }
-
-
- /**
- * SAX Event Handling
- */
- public void comment(char ary[], int start, int length)
- throws SAXException {
- if (this.lexicalHandler != null) {
- lexicalHandler.comment(ary, start, length);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java
deleted file mode 100644
index 7c1ebbb..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.source.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.source.impl.validity.AbstractAggregatedValidity;
-
-/**
- * <p>An aggregated {@link SourceValidity} for multiple sources.</p>
- *
- * @version $Id$
- */
-public class MultiSourceValidity extends AbstractAggregatedValidity {
-
- /** <p>When validity expiration is performed.</p> */
- private long expiry;
-
- /** <p>The delay from <b>now</b> used to calculate the expiration time.</p> */
- private long delay;
-
- /** <p>An ordered list of URIs which should be checked.</p> */
- private List uris = new ArrayList();
-
- /** <p>Is this instance is closed (accepts modifications or is validable)? */
- private boolean isClosed = false;
-
- /** <p>The {@link SourceResolver} to use (transient not to be serialized). */
- private transient SourceResolver resolver;
-
- /**
- * <p>The delay value indicating to check always.</p>
- */
- public static final int CHECK_ALWAYS = -1;
-
- /**
- * <p>Create a new {@link MultiSourceValidity} instance.</p>
- *
- * <p>If the number of milliseconds is less than <b>zero</b>, or it's sum with
- * the number of <b>now</b> milliseconds is greater than the biggest long
- * representable, the expiration date will be set to {@link Long#MAX_VALUE}
- * milliseconds from the epoch.</p>
- *
- * @param resolver the {@link SourceResolver} used to access the sources.
- * @param delay the number of milliseconds from <b>now</b> defining for how long
- * this instance will be valid.
- */
- public MultiSourceValidity(SourceResolver resolver, long delay) {
- /* Calculate the initial expiration time and calculate the delay */
- this.resolver = resolver;
- this.expiry = System.currentTimeMillis() + delay;
- this.delay = delay;
- }
-
- /**
- * <p>Add a {@link Source} to the list of {@link Source}s monitored by this
- * instance.</p>
- *
- * @param src a <b>non-null</b> {@link Source}.
- */
- public void addSource(Source src) {
- if (this.uris != null) {
- SourceValidity validity = src.getValidity();
- if (validity == null) {
- /* The source has no validity: this will be always be invalid. */
- this.uris = null;
- } else {
- /* Add the validity and URI to the list */
- super.add(validity);
- this.uris.add(src.getURI());
- }
- }
- }
-
- /**
- * <p>Close this instance, or in other words declare that no other sources will
- * be added to this {@link MultiSourceValidity} and that checkings can be now
- * performed.</p>
- */
- public void close() {
- this.isClosed = true;
- this.resolver = null;
- }
-
- /**
- * <p>Check the validity of this {@link SourceValidity} instance.</p>
- *
- * @see SourceValidity#isValid()
- */
- public int isValid() {
- if (System.currentTimeMillis() <= expiry) {
- /* Validity not expired, so, don't even check */
- return SourceValidity.VALID;
- }
-
- /* Re-calculate the expiry time based on the current time */
- expiry = System.currentTimeMillis() + delay;
-
- if (uris == null || !isClosed) {
- /* We have not been closed (yet) or we were forced to be invalid */
- return SourceValidity.INVALID;
- } else {
- /* Compute the status of all the sources listed in this instance */
- return computeStatus(null);
- }
- }
-
- /**
- * <p>Check the validity of this instance comparing it with a (recently acquired)
- * new {@link SourceValidity} object.</p>
- *
- * @see SourceValidity#isValid(SourceValidity)
- */
- public int isValid(SourceValidity newValidity) {
- if (uris == null || !isClosed) {
- /* We have not been closed (yet) or we were forced to be invalid */
- return SourceValidity.INVALID;
- }
-
- /* Perform a simple class check and compute the validity of the sources */
- if (newValidity instanceof MultiSourceValidity) {
- return computeStatus(((MultiSourceValidity)newValidity).resolver);
- } else {
- /* The supplied validity is not an instance of ourselves, forget it */
- return SourceValidity.INVALID;
- }
- }
-
- /**
- * <p>Compute the status of this instance by checking every source.</p>
- *
- * @param resolver The {@link SourceResolver} to use to access sources.
- * @return {@link SourceValidity.VALID}, {@link SourceValidity.INVALID} or
- * {@link SourceValidity.UNKNOWN} depending on the status.
- */
- private int computeStatus(SourceResolver resolver) {
- /* Get the validities and analyse them one by one */
- List validities = super.getValidities();
- for (int i = 0; i < validities.size(); i++) {
-
- /* Check the validity status */
- SourceValidity validity = (SourceValidity) validities.get(i);
- switch (validity.isValid()) {
-
- /* The current source is valid: just continue to next source */
- case SourceValidity.VALID:
- break;
-
- /* The current source is invalid: stop examining */
- case SourceValidity.INVALID:
- return SourceValidity.INVALID;
-
- /* The source validity is not known: check with the new source */
- case SourceValidity.UNKNOWN:
- /* We have no resolver: definitely don't know */
- if (resolver == null) {
- return SourceValidity.UNKNOWN;
- }
-
- /* Check the new source by asking to the resolver */
- Source newSrc = null;
- int newValidity = SourceValidity.INVALID;
- try {
- newSrc = resolver.resolveURI((String) this.uris.get(i));
- newValidity = validity.isValid(newSrc.getValidity());
- } catch(IOException ioe) {
- /* Swallow the IOException, but set the new validity */
- newValidity = SourceValidity.INVALID;
- } finally {
- /* Make sure that the source is released */
- if (newSrc != null) {
- resolver.release(newSrc);
- }
- }
-
- /* If the source is still valid, go to the next one */
- if (newValidity == SourceValidity.VALID) {
- break;
- }
-
- /* The source is not valid (or unknown), we invalidate the lot */
- return SourceValidity.INVALID;
-
- /* We got something _really_ odd out tof the validity, dunno. */
- default:
- return SourceValidity.INVALID;
- }
- }
-
- /* All items checked successfully */
- return SourceValidity.VALID;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/util/SourceUtil.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/util/SourceUtil.java
deleted file mode 100644
index dd0b6bf..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/components/source/util/SourceUtil.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.source.util;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.components.source.URLRewriter;
-import org.apache.cocoon.util.NetUtils;
-import org.apache.cocoon.xml.IncludeXMLConsumer;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceException;
-import org.apache.excalibur.source.SourceNotFoundException;
-import org.apache.excalibur.source.SourceParameters;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.cocoon.core.xml.SAXParser;
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.apache.excalibur.xmlizer.XMLizer;
-import org.apache.regexp.RE;
-import org.apache.regexp.RECompiler;
-import org.apache.regexp.REProgram;
-import org.apache.regexp.RESyntaxException;
-import org.w3c.dom.Document;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * This class contains some utility methods for the source resolving.
- *
- * @version $Id$
- */
-public abstract class SourceUtil {
-
- protected static REProgram uripattern;
-
- static {
- try {
- uripattern = new RECompiler().compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$");
- } catch (RESyntaxException e) {
- // Should not happen
- throw new RuntimeException("Error parsing regular expression.", e);
- }
- }
-
- /**
- * Generates SAX events from the given source with possible URL rewriting.
- *
- * <p><b>NOTE</b>: If the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually
- * directly implement the LexicalHandler interface!</p>
- *
- * @param source the data
- * @throws ProcessingException if no suitable converter is found
- */
- static public void toSAX(ServiceManager manager,
- Source source,
- ContentHandler handler,
- Parameters typeParameters,
- boolean filterDocumentEvent)
- throws SAXException, IOException, ProcessingException {
- // Test for url rewriting
- if (typeParameters != null
- && typeParameters.getParameter(URLRewriter.PARAMETER_MODE, null) != null) {
- handler = new URLRewriter(typeParameters, handler);
- }
-
- String mimeTypeHint = null;
- if (typeParameters != null) {
- mimeTypeHint = typeParameters.getParameter("mime-type", mimeTypeHint);
- }
- if (filterDocumentEvent) {
- IncludeXMLConsumer filter = new IncludeXMLConsumer(handler);
- toSAX(manager, source, mimeTypeHint, filter);
- } else {
- toSAX(manager, source, mimeTypeHint, handler);
- }
- }
-
- /**
- * Generates SAX events from the XMLizable and handle SAXException.
- *
- * @param source the data
- */
- public static void toSAX(XMLizable source, ContentHandler handler) throws SAXException, IOException, ProcessingException {
- try {
- source.toSAX(handler);
- } catch (SAXException e) {
- // Unwrap ProcessingException, IOException, and extreme cases of SAXExceptions.
- // Handle SourceException.
- // See also handleSAXException
- final Exception cause = e.getException();
- if (cause != null) {
- if (cause instanceof SourceException) {
- throw handle((SourceException) cause);
- }
- if (cause instanceof ProcessingException) {
- throw (ProcessingException) cause;
- }
- if (cause instanceof IOException) {
- throw (IOException) cause;
- }
- if (cause instanceof SAXException) {
- throw (SAXException) cause;
- }
- }
-
- // Throw original SAX exception
- throw e;
- }
- }
-
- /**
- * Generates SAX events from the given source.
- *
- * <p><b>NOTE</b>: If the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually
- * directly implement the LexicalHandler interface!</p>
- *
- * @param source the data
- * @throws ProcessingException if no suitable converter is found
- */
- static public void toSAX(ServiceManager manager,
- Source source,
- ContentHandler handler)
- throws SAXException, IOException, ProcessingException {
- toSAX(manager, source, null, handler);
- }
-
- /**
- * Generates SAX events from the given source by using XMLizer.
- *
- * <p><b>NOTE</b>: If the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually
- * directly implement the LexicalHandler interface!</p>
- *
- * @param source the data
- * @throws ProcessingException if no suitable converter is found
- */
- public static void toSAX(ServiceManager manager,
- Source source,
- String mimeTypeHint,
- ContentHandler handler)
- throws SAXException, IOException, ProcessingException {
- if (source instanceof XMLizable) {
- toSAX((XMLizable) source, handler);
- } else {
- String mimeType = source.getMimeType();
- if (null == mimeType) {
- mimeType = mimeTypeHint;
- }
-
- XMLizer xmlizer = null;
- try {
- xmlizer = (XMLizer) manager.lookup(XMLizer.ROLE);
- xmlizer.toSAX(source.getInputStream(),
- mimeType,
- source.getURI(),
- handler);
- } catch (SourceException e) {
- throw SourceUtil.handle(e);
- } catch (ServiceException e) {
- throw new ProcessingException("Exception during streaming source.", e);
- } finally {
- manager.release(xmlizer);
- }
- }
- }
-
- /**
- * Generates character SAX events from the given source.
- *
- * @param source The data
- * @param encoding The character encoding of the data
- */
- public static void toCharacters(Source source, String encoding, ContentHandler handler) throws SAXException, IOException, ProcessingException {
- try {
- Reader r = encoding == null?
- new InputStreamReader(source.getInputStream()):
- new InputStreamReader(source.getInputStream(), encoding);
-
- int len;
- char[] chr = new char[4096];
- try {
- while ((len = r.read(chr)) > 0) {
- handler.characters(chr, 0, len);
- }
- } finally {
- r.close();
- }
- } catch (SAXException e) {
- handleSAXException(source.getURI(), e);
- }
- }
-
- /**
- * Generates SAX events from the given source by parsing it.
- *
- * <p><b>NOTE</b>: If the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually
- * directly implement the LexicalHandler interface!</p>
- *
- * @param source the data
- * @throws ProcessingException if no suitable converter is found
- * @deprecated use {@link #parse(SAXParser, Source, ContentHandler)} instead
- */
- public static void parse(ServiceManager manager, Source source, ContentHandler handler) throws SAXException, IOException, ProcessingException {
- if (source instanceof XMLizable) {
- toSAX((XMLizable) source, handler);
- } else {
- org.apache.excalibur.xml.sax.SAXParser parser = null;
- try {
- parser = (org.apache.excalibur.xml.sax.SAXParser) manager.lookup(org.apache.excalibur.xml.sax.SAXParser.ROLE);
- parser.parse(getInputSource(source), handler);
- } catch (SourceException e) {
- throw SourceUtil.handle(e);
- } catch (ServiceException e) {
- throw new ProcessingException("Exception during parsing source.", e);
- } finally {
- manager.release(parser);
- }
- }
- }
-
- /**
- * Generates SAX events from the given source by parsing it.
- *
- * <p><b>NOTE</b>: If the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually
- * directly implement the LexicalHandler interface!</p>
- *
- * @param source the data
- * @throws ProcessingException if error during processing source data occurs
- */
- public static void parse(SAXParser parser, Source source, ContentHandler handler) throws SAXException, IOException, ProcessingException {
- if (source instanceof XMLizable) {
- toSAX((XMLizable) source, handler);
- } else {
- try {
- parser.parse(getInputSource(source), handler);
- } catch (SourceException e) {
- throw SourceUtil.handle(e);
- }
- }
- }
-
-
- /**
- * Generates a DOM from the given source
- * @param source The data
- *
- * @return Created DOM document.
- *
- * @throws IOException If a io exception occurs.
- * @throws ProcessingException if no suitable converter is found
- * @throws SAXException If a SAX exception occurs.
- */
- public static Document toDOM(ServiceManager manager, Source source) throws SAXException, IOException, ProcessingException {
- DOMBuilder builder = new DOMBuilder();
-
- toSAX(manager, source, null, builder);
-
- Document document = builder.getDocument();
- if (document == null) {
- throw new ProcessingException("Could not build DOM for '" +
- source.getURI() + "'");
- }
-
- return document;
- }
-
- /**
- * Generates a DOM from the given source
- * @param source The data
- *
- * @return Created DOM document.
- *
- * @throws IOException If a io exception occurs.
- * @throws ProcessingException if no suitable converter is found
- * @throws SAXException If a SAX exception occurs.
- */
- public static Document toDOM(ServiceManager manager, String mimeTypeHint, Source source) throws SAXException, IOException, ProcessingException {
- DOMBuilder builder = new DOMBuilder();
-
- toSAX(manager, source, mimeTypeHint, builder);
-
- Document document = builder.getDocument();
- if (document == null) {
- throw new ProcessingException("Could not build DOM for '" +
- source.getURI() + "'");
- }
-
- return document;
- }
-
- /**
- * Make a ProcessingException from a SourceException.
- * If the exception is a SourceNotFoundException then a
- * ResourceNotFoundException is thrown.
- *
- * @param se Source exception
- * @return Created processing exception.
- */
- public static ProcessingException handle(SourceException se) {
- if (se instanceof SourceNotFoundException) {
- return new ResourceNotFoundException("Resource not found.", se);
- }
- return new ProcessingException("Exception during source resolving.",
- se);
- }
-
- /**
- * Make a ProcessingException from a SourceException.
- * If the exception is a SourceNotFoundException then a
- * ResourceNotFoundException is thrown.
- *
- * @param message Additional exception message.
- * @param se Source exception.
- * @return Created processing exception.
- */
- public static ProcessingException handle(String message, SourceException se) {
- if (se instanceof SourceNotFoundException) {
- return new ResourceNotFoundException(message, se);
- }
- return new ProcessingException(message, se);
- }
-
- /**
- * Handle SAXException catched in Generator's generate method.
- *
- * @param source Generator's source
- * @param e SAXException happened in the generator's generate method.
- */
- public static void handleSAXException(String source, SAXException e) throws ProcessingException, IOException, SAXException {
- final Exception cause = e.getException();
- if (cause != null) {
- // Unwrap ProcessingException, IOException, and extreme cases of SAXExceptions.
- // Handle SourceException.
- // See also toSax(XMLizable, ContentHandler)
- if (cause instanceof SourceException) {
- throw handle((SourceException) cause);
- }
- if (cause instanceof ProcessingException) {
- throw (ProcessingException) cause;
- }
- if (cause instanceof IOException) {
- throw (IOException) cause;
- }
- if (cause instanceof SAXException) {
- throw (SAXException) cause;
- }
- throw new ProcessingException("Could not read resource " +
- source, cause);
- }
- throw e;
- }
-
- /**
- * Get an InputSource object
- *
- * @param source Source.
- *
- * @return Input stream of the source.
- *
- * @throws IOException If a io exception occurs.
- * @throws ProcessingException If an exception occurs during
- * processing.
- */
- public static InputSource getInputSource(Source source) throws IOException, ProcessingException {
- try {
- final InputSource newObject = new InputSource(source.getInputStream());
-
- newObject.setSystemId(source.getURI());
- return newObject;
- } catch (SourceException se) {
- throw handle(se);
- }
- }
-
- /**
- * Get a <code>Source</code> object
- *
- * @param uri URI of the source.
- * @param typeParameters Type of Source query. Currently, only
- * <code>method</code> parameter (value typically <code>GET</code> or
- * <code>POST</code>) is recognized. May be <code>null</code>.
- * @param resourceParameters Parameters of the source. May be <code>null</code>
- * @param resolver Resolver for the source.
- *
- * @return The resolved source.
- *
- * @throws IOException If a io exception occurs.
- * @throws SAXException If a SAX exception occurs.
- * @throws SourceException If the source an exception throws.
- */
- public static Source getSource(String uri, Parameters typeParameters, SourceParameters resourceParameters, SourceResolver resolver) throws IOException, SAXException, SourceException {
-
- // first step: encode parameters which are already appended to the url
- int queryPos = uri.indexOf('?');
- if (queryPos != -1) {
- String queryString = uri.substring(queryPos+1);
- SourceParameters queries = new SourceParameters(queryString);
-
- if (queries.hasParameters()) {
- StringBuffer buffer = new StringBuffer(uri.substring(0, queryPos));
- char separator = '?';
-
- Iterator i = queries.getParameterNames();
- while (i.hasNext()) {
- String current = (String) i.next();
- Iterator values = queries.getParameterValues(current);
- while (values.hasNext()) {
- buffer.append(separator)
- .append(current)
- .append('=')
- .append(NetUtils.encode((String) values.next(), "utf-8"));
- separator = '&';
- }
- }
- uri = buffer.toString();
- }
- }
-
- String method = ((typeParameters!=null)
- ? typeParameters.getParameter("method", "GET")
- : "GET");
- if (method.equalsIgnoreCase("POST") &&
- (resourceParameters == null ||
- !resourceParameters.hasParameters())) {
- method = "GET";
- }
-
- if (uri.startsWith("cocoon:") && resourceParameters != null &&
- resourceParameters.hasParameters()) {
- int pos = uri.indexOf(";jsessionid=");
-
- StringBuffer buf;
- if (pos == -1) {
- buf = new StringBuffer(uri);
- } else {
- buf = new StringBuffer(uri.substring(0, pos));
- }
- buf.append(((uri.indexOf('?') == -1) ? '?' : '&'));
- buf.append(resourceParameters.getEncodedQueryString());
- uri = buf.toString();
- }
-
- Map resolverParameters = new HashMap();
- resolverParameters.put(SourceResolver.METHOD, method);
- if (typeParameters != null) {
- String encoding = typeParameters.getParameter("encoding",
- System.getProperty("file.encoding", "ISO-8859-1"));
- if (encoding != null && !"".equals(encoding)) {
- resolverParameters.put(SourceResolver.URI_ENCODING, encoding);
- }
- }
- resolverParameters.put(SourceResolver.URI_PARAMETERS,
- resourceParameters);
-
- return resolver.resolveURI(uri, null, resolverParameters);
- }
-
- /**
- * Return the scheme of a URI. Just as there are many different methods
- * of access to resources, there are a variety of schemes for identifying
- * such resources.
- * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>).
- *
- * @param uri Uniform resource identifier.
- *
- * @return Scheme of the URI.
- */
- public static String getScheme(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(2);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
- /**
- * Return the authority of a URI. This authority is
- * typically defined by an Internet-based server or a scheme-specific
- * registry of naming authorities
- * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>).
- *
- * @param uri Uniform resource identifier.
- *
- * @return Scheme of the URI.
- */
- public static String getAuthority(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(4);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
- /**
- * Return the path of a URI. The path contains data, specific to the
- * authority (or the scheme if there is no authority component),
- * identifying the resource within the scope of that scheme and authority
- * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>).
- *
- * @param uri Uniform resource identifier.
- *
- * @return Path of the URI.
- */
- public static String getPath(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(5);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
- /**
- * Return the path of a URI, if the URI can't contains a authority.
- * This implementation differ to the RFC 2396.
- *
- * @param uri Uniform resource identifier.
- *
- * @return Path of the URI.
- */
- public static String getPathWithoutAuthority(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(4) + re.getParen(5);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
- /**
- * Return the query of a URI. The query is a string of information to
- * be interpreted by the resource
- * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>).
- *
- * @param uri Uniform resource identifier.
- *
- * @return Query of the URI.
- */
- public static String getQuery(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(7);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
- /**
- * Return the fragment of a URI. When a URI reference is used to perform
- * a retrieval action on the identified resource, the optional fragment
- * identifier, consists of additional reference information to be
- * interpreted by the user agent after the retrieval action has been
- * successfully completed
- * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>).
- *
- * @param uri Uniform resource identifier.
- *
- * @return Fragment of the URI.
- */
- public static String getFragment(String uri) {
- RE re = new RE(uripattern);
- if (re.match(uri)) {
- return re.getParen(9);
- } else {
- throw new IllegalArgumentException("'" + uri +
- "' is not a correct URI");
- }
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoFactoryBean.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoFactoryBean.java
deleted file mode 100644
index 72f2c59..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoFactoryBean.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.core.container.spring.pipeline;
-
-import java.util.Map;
-
-import org.apache.cocoon.components.pipeline.impl.PipelineComponentInfo;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.HierarchicalBeanFactory;
-
-/**
- * This spring factory bean adds the processor component info to the bean factory.
- *
- * @since 2.2
- * @version $Id: ProcessorComponentInfoFactoryBean.java 448473 2006-09-21 06:22:51Z crossley $
- */
-public class PipelineComponentInfoFactoryBean
- implements FactoryBean, BeanFactoryAware {
-
- /** The bean factory. */
- protected BeanFactory beanFactory;
-
- protected Map data;
-
- protected PipelineComponentInfo info;
-
- /**
- * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
- */
- public void setBeanFactory(BeanFactory factory) throws BeansException {
- this.beanFactory = factory;
- }
-
- protected void init()
- throws Exception {
- PipelineComponentInfo parent = null;
- if ( this.beanFactory instanceof HierarchicalBeanFactory ) {
- BeanFactory parentFactory = ((HierarchicalBeanFactory)this.beanFactory).getParentBeanFactory();
- if ( parentFactory != null && parentFactory.containsBean(PipelineComponentInfo.ROLE) ) {
- parent = (PipelineComponentInfo)parentFactory.getBean(PipelineComponentInfo.ROLE);
- }
- }
- this.info = new PipelineComponentInfo(parent);
- if ( this.data != null ) {
- info.setData(data);
- }
- }
-
- /**
- * @see org.springframework.beans.factory.FactoryBean#getObject()
- */
- public Object getObject() throws Exception {
- return this.info;
- }
-
- /**
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- public Class getObjectType() {
- return PipelineComponentInfo.class;
- }
-
- /**
- * @see org.springframework.beans.factory.FactoryBean#isSingleton()
- */
- public boolean isSingleton() {
- return true;
- }
-
- public Map getData() {
- return data;
- }
-
- public void setData(Map data) {
- this.data = data;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializer.java
deleted file mode 100644
index 80be7d2..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.core.container.spring.pipeline;
-
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.cocoon.components.pipeline.impl.PipelineComponentInfo;
-
-
-/**
- * @version $Id$
- * @since 2.2
- */
-public class PipelineComponentInfoInitializer {
- private PipelineComponentInfo info;
- private String componentName;
- private String mimeType;
- private String label;
- private String hint;
- private Map data;
-
- public void init() {
- if (this.mimeType != null)
- this.info.setMimeType(this.componentName, this.mimeType);
- if (this.label != null) {
- StringTokenizer st = new StringTokenizer(this.label, " ,", false);
- String[] labels = new String[st.countTokens()];
- for (int tokenIdx = 0; tokenIdx < labels.length; tokenIdx++) {
- labels[tokenIdx] = st.nextToken();
- }
- this.info.setLabels(this.componentName, labels);
- }
- if (this.hint != null)
- this.info.setPipelineHint(this.componentName, this.hint);
- if (this.data != null)
- this.info.addData(data);
- }
-
- /**
- * @param info
- */
- public void setInfo(PipelineComponentInfo info) {
- this.info = info;
- }
-
- /**
- * @param componentName
- */
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
- /**
- * @param hint
- */
- public void setHint(String hint) {
- this.hint = hint;
- }
- /**
- * @param label
- */
- public void setLabel(String label) {
- this.label = label;
- }
- /**
- * @param mimeType
- */
- public void setMimeType(String mimeType) {
- this.mimeType = mimeType;
- }
-
- /**
- * @param data the data to set
- */
- public void setData(Map data) {
- this.data = data;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java
deleted file mode 100644
index e16cddd..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.core.container.spring.pipeline;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.cocoon.components.pipeline.impl.PipelineComponentInfo;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @version $Id$
- * @since 2.2
- */
-public class PipelineComponentInfoInitializerDecorator implements
- BeanDefinitionDecorator {
-
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- /* (non-Javadoc)
- * @see org.springframework.beans.factory.xml.BeanDefinitionDecorator#decorate(org.w3c.dom.Node, org.springframework.beans.factory.config.BeanDefinitionHolder, org.springframework.beans.factory.xml.ParserContext)
- */
- public BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder holder, ParserContext ctx) {
- registerPipelineComponentInfo(ctx);
- String initializerBeanName = registerPipelineComponentInfoInitializer(source, holder, ctx);
- createDependencyOnPipelineComponentInfoInitializer(holder, initializerBeanName);
- return holder;
- }
-
- private void registerPipelineComponentInfo(ParserContext ctx) {
- if (!ctx.getRegistry().containsBeanDefinition(PipelineComponentInfo.ROLE)) {
- BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoFactoryBean.class);
- defBuilder.setSingleton(true);
- defBuilder.setLazyInit(false);
- defBuilder.setInitMethodName("init");
- ctx.getRegistry().registerBeanDefinition(PipelineComponentInfo.ROLE, defBuilder.getBeanDefinition());
- }
- }
-
- private String registerPipelineComponentInfoInitializer(Node source, BeanDefinitionHolder holder, ParserContext ctx) {
- String componentName = holder.getBeanName();
- String mimeType = ((Element)source).hasAttribute("mime-type") ? ((Element)source).getAttribute("mime-type") : null;
- String label = ((Element)source).hasAttribute("label") ? ((Element)source).getAttribute("label") : null;
- String hint = ((Element)source).hasAttribute("hint") ? ((Element)source).getAttribute("hint") : null;
-
- BeanDefinitionBuilder initializer = BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoInitializer.class);
- initializer.addPropertyReference("info", PipelineComponentInfo.ROLE);
- initializer.addPropertyValue("componentName", componentName);
- if (mimeType != null)
- initializer.addPropertyValue("mimeType", mimeType);
- if (label != null)
- initializer.addPropertyValue("label", label);
- if (hint != null)
- initializer.addPropertyValue("hint", hint);
- initializer.setInitMethodName("init");
-
- String beanName = componentName + "/info";
- ctx.getRegistry().registerBeanDefinition(beanName, initializer.getBeanDefinition());
-
- return beanName;
- }
-
- private void createDependencyOnPipelineComponentInfoInitializer(BeanDefinitionHolder holder, String initializerBeanName) {
- AbstractBeanDefinition definition = ((AbstractBeanDefinition) holder.getBeanDefinition());
- String[] dependsOn = definition.getDependsOn();
- if (dependsOn == null) {
- dependsOn = new String[]{initializerBeanName};
- } else {
- List dependencies = new ArrayList(Arrays.asList(dependsOn));
- dependencies.add(initializerBeanName);
- dependsOn = (String[]) dependencies.toArray(EMPTY_STRING_ARRAY);
- }
- definition.setDependsOn(dependsOn);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineNamespaceHandler.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineNamespaceHandler.java
deleted file mode 100644
index 5fc257b..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineNamespaceHandler.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.core.container.spring.pipeline;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-/**
- * Spring namespace handler for the cocoon pipeline namespace.
- * Currently this namespace defines the following elements
- * (in the namespace "http://cocoon.apache.org/schema/pipeline"):
- * "component" : with optional attributes "mime-type", "label" and "hint".
- *
- * @version $Id$
- * @since 2.2
- */
-public class PipelineNamespaceHandler extends NamespaceHandlerSupport {
-
- /* (non-Javadoc)
- * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
- */
- public void init() {
- this.registerBeanDefinitionDecorator("component", new PipelineComponentInfoInitializerDecorator());
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java
deleted file mode 100644
index c3ea86f..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/AbstractEnvironment.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.util.BufferedOutputStream;
-import org.apache.commons.collections.iterators.IteratorEnumeration;
-
-/**
- * Base class for any environment
- *
- * @version $Id$
- */
-public abstract class AbstractEnvironment
- extends AbstractLogEnabled
- implements Environment {
-
- /** The current uri in progress */
- protected String uri;
-
- /** The prefix */
- protected String prefix = "";
-
- /** The View requested */
- protected String view;
-
- /** The Action requested */
- protected String action;
-
- /** The object model */
- protected Map objectModel = new HashMap();
-
- /** The attributes */
- private Map attributes = new HashMap();
-
- /** The secure Output Stream */
- protected BufferedOutputStream secureOutputStream;
-
- /** The real output stream */
- protected OutputStream outputStream;
-
- /**
- * Constructs the abstract environment
- */
- public AbstractEnvironment(String uri, String view) {
- this(uri, view, null);
- }
-
- /**
- * Constructs the abstract environment
- */
- public AbstractEnvironment(String uri, String view, String action) {
- this.uri = uri;
- this.view = view;
- this.action = action;
- }
-
- /**
- * Allow implementations to set view later than in super() constructor.
- * View can be set only once, and should be set in implementation's constructor.
- */
- protected void setView(String view) {
- if (this.view != null) {
- throw new IllegalStateException("View was already set on this environment");
- }
- this.view = view;
- }
-
- /**
- * Allow implementations to set action later than in super() constructor
- * Action can be set only once, and should be set in implementation's constructor.
- */
- protected void setAction(String action) {
- if (this.action != null) {
- throw new IllegalStateException("Action was already set on this environment");
- }
- this.action = action;
- }
-
- /**
- * Helper method to extract the view name from the request.
- */
- protected static String extractView(Request request) {
- return request.getParameter(Constants.VIEW_PARAM);
- }
-
- /**
- * Helper method to extract the action name from the request.
- */
- protected static String extractAction(Request req) {
- String action = req.getParameter(Constants.ACTION_PARAM);
- if (action != null) {
- /* TC: still support the deprecated syntax */
- return action;
- }
- for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ) {
- String name = (String)e.nextElement();
- if (name.startsWith(Constants.ACTION_PARAM_PREFIX)) {
- if (name.endsWith(".x") || name.endsWith(".y")) {
- return name.substring(Constants.ACTION_PARAM_PREFIX.length(),name.length()-2);
- }
- return name.substring(Constants.ACTION_PARAM_PREFIX.length());
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getURI()
- */
- public String getURI() {
- return this.uri;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getURIPrefix()
- */
- public String getURIPrefix() {
- return this.prefix;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#setURI(java.lang.String)
- */
- public void setURI(String prefix, String value) {
- this.prefix = prefix;
- this.uri = value;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getView()
- */
- public String getView() {
- return this.view;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getAction()
- */
- public String getAction() {
- return this.action;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#setStatus(int)
- */
- public void setStatus(int statusCode) {
- // for subclasses
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getObjectModel()
- */
- public Map getObjectModel() {
- return this.objectModel;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#isResponseModified(long)
- */
- public boolean isResponseModified(long lastModified) {
- return true; // always modified
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#setResponseIsNotModified()
- */
- public void setResponseIsNotModified() {
- // does nothing
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getAttribute(java.lang.String)
- */
- public Object getAttribute(String name) {
- return this.attributes.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#setAttribute(java.lang.String, java.lang.Object)
- */
- public void setAttribute(String name, Object value) {
- this.attributes.put(name, value);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#removeAttribute(java.lang.String)
- */
- public void removeAttribute(String name) {
- this.attributes.remove(name);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getAttributeNames()
- */
- public Enumeration getAttributeNames() {
- return new IteratorEnumeration(this.attributes.keySet().iterator());
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#getOutputStream(int)
- */
- public OutputStream getOutputStream(int bufferSize)
- throws IOException {
-
- // This method could be called several times during request processing
- // with differing values of bufferSize and should handle this situation
- // correctly.
-
- if (bufferSize == -1) {
- if (this.secureOutputStream == null) {
- this.secureOutputStream = new BufferedOutputStream(this.outputStream);
- }
- return this.secureOutputStream;
- } else if (bufferSize == 0) {
- // Discard secure output stream if it was created before.
- if (this.secureOutputStream != null) {
- this.secureOutputStream = null;
- }
- return this.outputStream;
- } else {
- // FIXME Triple buffering, anyone?
- this.outputStream = new java.io.BufferedOutputStream(this.outputStream, bufferSize);
- return this.outputStream;
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#tryResetResponse()
- */
- public boolean tryResetResponse()
- throws IOException {
- if (this.secureOutputStream != null) {
- this.secureOutputStream.clearBuffer();
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#commitResponse()
- */
- public void commitResponse()
- throws IOException {
- if (this.secureOutputStream != null) {
- this.setContentLength(this.secureOutputStream.getCount());
- this.secureOutputStream.realFlush();
- } else if ( this.outputStream != null ){
- this.outputStream.flush();
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#startingProcessing()
- */
- public void startingProcessing() {
- // do nothing here
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#finishingProcessing()
- */
- public void finishingProcessing() {
- // do nothing here
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Environment#isInternRedirect()
- */
- public boolean isInternalRedirect() {
- return false;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
deleted file mode 100644
index 86d4e05..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment;
-
-import java.io.IOException;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.cocoon.ProcessingException;
-
-/**
- * A base class for <code>Redirector</code>s that handle forward redirects, i.e. internal
- * redirects using the "cocoon:" pseudo-protocol.
- * <p>
- * Concrete subclasses have to define the <code>cocoonRedirect()</code> method.
- *
- * @version $Id$
- */
-public abstract class ForwardRedirector
-extends AbstractLogEnabled
-implements Redirector, PermanentRedirector {
-
- /**
- * Was there a call to <code>redirect()</code> ?
- */
- private boolean hasRedirected = false;
-
- /** The <code>Environment to use for redirection (either internal or external) */
- protected Environment env;
-
- /**
- * Constructor
- */
- public ForwardRedirector(Environment env) {
- this.env = env;
- }
-
- /**
- * Redirects to a given URL. If this URL starts with "cocoon:", then an internal
- * redirect is performed. Otherwise, an external redirect is send to the
- * environment.
- */
- public void redirect(boolean sessionMode, String url) throws IOException, ProcessingException {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Redirecting to '" + url + "'");
- }
-
- if (url.startsWith("cocoon:")) {
- cocoonRedirect(url);
- } else {
- this.doRedirect(sessionMode, url, false, false);
- }
-
- this.hasRedirected = true;
- }
-
- public void permanentRedirect(boolean sessionMode, String url) throws IOException, ProcessingException {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Redirecting to '" + url + "'");
- }
-
- if (url.startsWith("cocoon:")) {
- cocoonRedirect(url);
- } else {
- this.doRedirect(sessionMode, url, true, false);
- }
-
- this.hasRedirected = true;
- }
-
- /**
- * Unconditionally redirects to a given URL, even it this redirector is part of a
- * subpipeline.
- */
- public void globalRedirect(boolean sessionMode, String url) throws IOException, ProcessingException {
- if (getLogger().isInfoEnabled()) {
- getLogger().info("Redirecting to '" + url + "'");
- }
-
- // FIXME : how to handle global redirect to cocoon: ?
- if (url.startsWith("cocoon:")) {
- cocoonRedirect(url);
- } else {
- this.doRedirect(sessionMode, url, false, true);
- }
- this.hasRedirected = true;
- }
-
- protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Redirector#hasRedirected()
- */
- public boolean hasRedirected() {
- return this.hasRedirected;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Redirector#sendStatus(int)
- */
- public void sendStatus(int sc) {
- env.setStatus(sc);
- this.hasRedirected = true;
- }
-
-
- /**
- * Redirect the client to new URL with session mode
- */
- protected void doRedirect(boolean sessionmode,
- String newURL,
- boolean permanent,
- boolean global)
- throws IOException {
- final Request request = ObjectModelHelper.getRequest(this.env.getObjectModel());
- // check if session mode shall be activated
- if (sessionmode) {
-
- // The session
- Session session = null;
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("redirect: entering session mode");
- }
- String s = request.getRequestedSessionId();
- if (s != null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Old session ID found in request, id = " + s);
- if ( request.isRequestedSessionIdValid() ) {
- getLogger().debug("And this old session ID is valid");
- }
- }
- }
- // get session from request, or create new session
- session = request.getSession(true);
- if (session == null) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("redirect session mode: unable to get session object!");
- }
- } else {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug ("redirect: session mode completed, id = " + session.getId() );
- }
- }
- }
- // redirect
- this.env.redirect(newURL, global, permanent);
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/ContextURLException.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/ContextURLException.java
deleted file mode 100644
index df77623..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/ContextURLException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import org.apache.avalon.framework.CascadingRuntimeException;
-
-public final class ContextURLException extends CascadingRuntimeException
-{
- public ContextURLException(String message)
- {
- super(message, null);
- }
-
- public ContextURLException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpContext.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
deleted file mode 100644
index 7230475..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpContext.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-
-import org.apache.cocoon.environment.impl.AbstractContext;
-
-/**
- * Implements the {@link org.apache.cocoon.environment.Context} interface
- *
- * @version $Id$
- */
-public final class HttpContext extends AbstractContext {
-
- /** The ServletContext */
- private final ServletContext servletContext;
-
- /**
- * Constructs a HttpContext object from a ServletContext object
- */
- public HttpContext (ServletContext servletContext) {
- this.servletContext = servletContext;
- }
-
- public Object getAttribute(String name) {
- return servletContext.getAttribute(name);
- }
-
- public void setAttribute(String name, Object value) {
- servletContext.setAttribute(name, value);
- }
-
- public void removeAttribute(String name) {
- servletContext.removeAttribute(name);
- }
-
- public Enumeration getAttributeNames() {
- return servletContext.getAttributeNames();
- }
-
- public URL getResource(String path)
- throws MalformedURLException {
- return servletContext.getResource(path);
- }
-
- public InputStream getResourceAsStream(String path) {
- return servletContext.getResourceAsStream(path);
- }
-
- public String getRealPath(String path) {
- if (path.equals("/")) {
- String value = servletContext.getRealPath(path);
- if (value == null) {
- // Try to figure out the path of the root from that of WEB-INF
- try {
- URL webXml = this.servletContext.getResource("/WEB-INF/web.xml");
- // In some contexts there might not be any web.xml, then we stop
- // guessing an just return null, which follows the servlet specification
- if (webXml == null)
- return null;
- value = webXml.toString();
- } catch (MalformedURLException mue) {
- throw new ContextURLException("Cannot determine the base URL for " + path, mue);
- }
- value = value.substring(0,value.length()-"WEB-INF/web.xml".length());
- }
- return value;
- }
- return servletContext.getRealPath(path);
- }
-
- public String getMimeType(String file) {
- return servletContext.getMimeType(file);
- }
-
- public String getInitParameter(String name) {
- return servletContext.getInitParameter(name);
- }
-
- /*
- * These methods are not in Cocoon's Context interface, but in the
- * ServletContext. To use them you have to downcast Cocoon's Context
- * to this HttpContext until we decide to add them to the Context
- * interface too.
- *
- * The following methods are deprecated since Servlet API 2.0 or 2.1
- * and will not be implemented here:
- * - public Servlet getServlet(String name)
- * - public Enumeration getServletNames()
- * - public Enumeration getServlets()
- * - public void log(Exception exception, String msg)
- */
-
- public ServletContext getContext(String uripath) {
- return this.servletContext.getContext(uripath);
- }
-
- public Enumeration getInitParameterNames() {
- return this.servletContext.getInitParameterNames();
- }
-
- public int getMajorVersion() {
- return this.servletContext.getMajorVersion();
- }
-
- public int getMinorVersion() {
- return this.servletContext.getMinorVersion();
- }
-
- public RequestDispatcher getNamedDispatcher(String name) {
- return this.servletContext.getNamedDispatcher(name);
- }
-
- public RequestDispatcher getRequestDispatcher(String path) {
- return this.servletContext.getRequestDispatcher(path);
- }
-
- public String getServerInfo() {
- return this.servletContext.getServerInfo();
- }
-
- /**
- * @see org.apache.cocoon.environment.impl.AbstractContext#log(java.lang.String)
- */
- public void log(String msg) {
- this.servletContext.log(msg);
- }
-
- /**
- * @see org.apache.cocoon.environment.impl.AbstractContext#log(java.lang.String, java.lang.Throwable)
- */
- public void log(String msg, Throwable throwable) {
- this.servletContext.log(msg, throwable);
- }
-
- /**
- * @see org.apache.cocoon.environment.impl.AbstractContext#log(java.lang.Exception, java.lang.String)
- */
- public void log(Exception exception, String msg) {
- this.servletContext.log(msg, exception);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpCookie.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpCookie.java
deleted file mode 100644
index 1c9cdd0..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpCookie.java
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import org.apache.cocoon.environment.Cookie;
-
-/**
- *
- * Creates a cookie, a small amount of information sent by a servlet to
- * a Web browser, saved by the browser, and later sent back to the server.
- * A cookie's value can uniquely
- * identify a client, so cookies are commonly used for session management.
- *
- * <p>A cookie has a name, a single value, and optional attributes
- * such as a comment, path and domain qualifiers, a maximum age, and a
- * version number. Some Web browsers have bugs in how they handle the
- * optional attributes, so use them sparingly to improve the interoperability
- * of your servlets.
- *
- * <p>The servlet sends cookies to the browser by using the
- * {@link HttpResponse#addCookie(Cookie)} method, which adds
- * fields to HTTP response headers to send cookies to the
- * browser, one at a time. The browser is expected to
- * support 20 cookies for each Web server, 300 cookies total, and
- * may limit cookie size to 4 KB each.
- *
- * <p>The browser returns cookies to the servlet by adding
- * fields to HTTP request headers. Cookies can be retrieved
- * from a request by using the {@link HttpRequest#getCookies()} method.
- * Several cookies might have the same name but different path attributes.
- *
- * <p>Cookies affect the caching of the Web pages that use them.
- * HTTP 1.0 does not cache pages that use cookies created with
- * this class. This class does not support the cache control
- * defined with HTTP 1.1.
- *
- * <p>This class supports both the Version 0 (by Netscape) and Version 1
- * (by RFC 2109) cookie specifications. By default, cookies are
- * created using Version 0 to ensure the best interoperability.
- *
- *
- * @version $Id$
- */
-public final class HttpCookie
-implements Cookie {
-
- private javax.servlet.http.Cookie cookie;
-
- public HttpCookie(String name, String value) {
- this.cookie = new javax.servlet.http.Cookie(name, value);
- }
-
- public HttpCookie(javax.servlet.http.Cookie cookie) {
- this.cookie = cookie;
- }
-
- public javax.servlet.http.Cookie getServletCookie() {
- this.checkState();
- return this.cookie;
- }
-
- /**
- * Constructs a cookie with a specified name and value.
- *
- * <p>The name must conform to RFC 2109. That means it can contain
- * only ASCII alphanumeric characters and cannot contain commas,
- * semicolons, or white space or begin with a $ character. The cookie's
- * name cannot be changed after creation.
- *
- * <p>The value can be anything the server chooses to send. Its
- * value is probably of interest only to the server. The cookie's
- * value can be changed after creation with the
- * <code>setValue</code> method.
- *
- * <p>By default, cookies are created according to the Netscape
- * cookie specification. The version can be changed with the
- * <code>setVersion</code> method.
- *
- *
- * @param name a <code>String</code> specifying the name of the cookie
- *
- * @param value a <code>String</code> specifying the value of the cookie
- *
- * @throws IllegalArgumentException if the cookie name contains illegal characters
- * (for example, a comma, space, or semicolon)
- * or it is one of the tokens reserved for use
- * by the cookie protocol
- * @see #setValue(String)
- * @see #setVersion(int)
- *
- */
-
- public void init(String name, String value) {
- if (this.cookie == null) {
- this.cookie = new javax.servlet.http.Cookie(name, value);
- } else {
- throw new IllegalStateException("Cookie is already initialised");
- }
- }
-
-
- private void checkState() {
- if (this.cookie == null) {
- throw new IllegalStateException("Cookie is not initialised");
- }
- }
-
- /**
- *
- * Specifies a comment that describes a cookie's purpose.
- * The comment is useful if the browser presents the cookie
- * to the user. Comments
- * are not supported by Netscape Version 0 cookies.
- *
- * @param purpose a <code>String</code> specifying the comment
- * to display to the user
- *
- * @see #getComment()
- *
- */
-
- public void setComment(String purpose) {
- this.checkState();
- this.cookie.setComment(purpose);
- }
-
-
-
-
- /**
- * Returns the comment describing the purpose of this cookie, or
- * <code>null</code> if the cookie has no comment.
- *
- * @return a <code>String</code> containing the comment,
- * or <code>null</code> if none
- *
- * @see #setComment(String)
- *
- */
-
- public String getComment() {
- this.checkState();
- return this.cookie.getComment();
- }
-
-
-
-
- /**
- *
- * Specifies the domain within which this cookie should be presented.
- *
- * <p>The form of the domain name is specified by RFC 2109. A domain
- * name begins with a dot (<code>.foo.com</code>) and means that
- * the cookie is visible to servers in a specified Domain Name System
- * (DNS) zone (for example, <code>www.foo.com</code>, but not
- * <code>a.b.foo.com</code>). By default, cookies are only returned
- * to the server that sent them.
- *
- *
- * @param pattern a <code>String</code> containing the domain name
- * within which this cookie is visible;
- * form is according to RFC 2109
- *
- * @see #getDomain()
- *
- */
-
- public void setDomain(String pattern) {
- this.checkState();
- this.cookie.setDomain(pattern);
- }
-
-
-
-
-
- /**
- * Returns the domain name set for this cookie. The form of
- * the domain name is set by RFC 2109.
- *
- * @return a <code>String</code> containing the domain name
- *
- * @see #setDomain(String)
- *
- */
-
- public String getDomain() {
- this.checkState();
- return this.cookie.getDomain();
- }
-
-
-
-
- /**
- * Sets the maximum age of the cookie in seconds.
- *
- * <p>A positive value indicates that the cookie will expire
- * after that many seconds have passed. Note that the value is
- * the <i>maximum</i> age when the cookie will expire, not the cookie's
- * current age.
- *
- * <p>A negative value means
- * that the cookie is not stored persistently and will be deleted
- * when the Web browser exits. A zero value causes the cookie
- * to be deleted.
- *
- * @param expiry an integer specifying the maximum age of the
- * cookie in seconds; if negative, means
- * the cookie is not stored; if zero, deletes
- * the cookie
- *
- *
- * @see #getMaxAge()
- *
- */
-
- public void setMaxAge(int expiry) {
- this.checkState();
- this.cookie.setMaxAge(expiry);
- }
-
-
-
-
- /**
- * Returns the maximum age of the cookie, specified in seconds,
- * By default, <code>-1</code> indicating the cookie will persist
- * until browser shutdown.
- *
- *
- * @return an integer specifying the maximum age of the
- * cookie in seconds; if negative, means
- * the cookie persists until browser shutdown
- *
- *
- * @see #setMaxAge(int)
- *
- */
-
- public int getMaxAge() {
- this.checkState();
- return this.cookie.getMaxAge();
- }
-
-
-
-
- /**
- * Specifies a path for the cookie
- * to which the client should return the cookie.
- *
- * <p>The cookie is visible to all the pages in the directory
- * you specify, and all the pages in that directory's subdirectories.
- * A cookie's path must include the servlet that set the cookie,
- * for example, <i>/catalog</i>, which makes the cookie
- * visible to all directories on the server under <i>/catalog</i>.
- *
- * <p>Consult RFC 2109 (available on the Internet) for more
- * information on setting path names for cookies.
- *
- *
- * @param uri a <code>String</code> specifying a path
- *
- *
- * @see #getPath()
- *
- */
-
- public void setPath(String uri) {
- this.checkState();
- this.cookie.setPath(uri);
- }
-
-
-
-
- /**
- * Returns the path on the server
- * to which the browser returns this cookie. The
- * cookie is visible to all subpaths on the server.
- *
- *
- * @return a <code>String</code> specifying a path that contains
- * a servlet name, for example, <i>/catalog</i>
- *
- * @see #setPath(String)
- *
- */
-
- public String getPath() {
- this.checkState();
- return this.cookie.getPath();
- }
-
-
-
-
-
- /**
- * Indicates to the browser whether the cookie should only be sent
- * using a secure protocol, such as HTTPS or SSL.
- *
- * <p>The default value is <code>false</code>.
- *
- * @param flag if <code>true</code>, sends the cookie from the browser
- * to the server using only when using a secure protocol;
- * if <code>false</code>, sent on any protocol
- *
- * @see #getSecure()
- *
- */
-
- public void setSecure(boolean flag) {
- this.checkState();
- this.cookie.setSecure(flag);
- }
-
-
-
-
- /**
- * Returns <code>true</code> if the browser is sending cookies
- * only over a secure protocol, or <code>false</code> if the
- * browser can send cookies using any protocol.
- *
- * @return <code>true</code> if the browser can use
- * any standard protocol; otherwise, <code>false</code>
- *
- * @see #setSecure(boolean)
- *
- */
-
- public boolean getSecure() {
- this.checkState();
- return this.cookie.getSecure();
- }
-
-
-
-
-
- /**
- * Returns the name of the cookie. The name cannot be changed after
- * creation.
- *
- * @return a <code>String</code> specifying the cookie's name
- *
- */
-
- public String getName() {
- this.checkState();
- return this.cookie.getName();
- }
-
-
-
-
-
- /**
- *
- * Assigns a new value to a cookie after the cookie is created.
- * If you use a binary value, you may want to use BASE64 encoding.
- *
- * <p>With Version 0 cookies, values should not contain white
- * space, brackets, parentheses, equals signs, commas,
- * double quotes, slashes, question marks, at signs, colons,
- * and semicolons. Empty values may not behave the same way
- * on all browsers.
- *
- * @param newValue a <code>String</code> specifying the new value
- *
- *
- * @see #getValue()
- * @see Cookie
- *
- */
-
- public void setValue(String newValue) {
- this.checkState();
- this.cookie.setValue(newValue);
- }
-
-
-
-
- /**
- * Returns the value of the cookie.
- *
- * @return a <code>String</code> containing the cookie's
- * present value
- *
- * @see #setValue(String)
- * @see Cookie
- *
- */
-
- public String getValue() {
- this.checkState();
- return this.cookie.getValue();
- }
-
-
-
-
- /**
- * Returns the version of the protocol this cookie complies
- * with. Version 1 complies with RFC 2109,
- * and version 0 complies with the original
- * cookie specification drafted by Netscape. Cookies provided
- * by a browser use and identify the browser's cookie version.
- *
- *
- * @return 0 if the cookie complies with the
- * original Netscape specification; 1
- * if the cookie complies with RFC 2109
- *
- * @see #setVersion(int)
- *
- */
-
- public int getVersion() {
- this.checkState();
- return this.cookie.getVersion();
- }
-
-
-
-
- /**
- * Sets the version of the cookie protocol this cookie complies
- * with. Version 0 complies with the original Netscape cookie
- * specification. Version 1 complies with RFC 2109.
- *
- * <p>Since RFC 2109 is still somewhat new, consider
- * version 1 as experimental; do not use it yet on production sites.
- *
- *
- * @param v 0 if the cookie should comply with
- * the original Netscape specification;
- * 1 if the cookie should comply with RFC 2109
- *
- * @see #getVersion()
- *
- */
-
- public void setVersion(int v) {
- this.checkState();
- this.cookie.setVersion(v);
- }
-
-
-
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
deleted file mode 100644
index 5de521a..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpEnvironment.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.cocoon.environment.AbstractEnvironment;
-import org.apache.cocoon.environment.Context;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.util.NetUtils;
-
-/**
- * HTTP Servlet environment.
- *
- * @version $Id$
- */
-public class HttpEnvironment extends AbstractEnvironment {
-
- public static final String HTTP_REQUEST_OBJECT = "httprequest";
- public static final String HTTP_RESPONSE_OBJECT= "httpresponse";
- public static final String HTTP_SERVLET_CONTEXT= "httpservletcontext";
-
- /** The HttpRequest */
- private HttpRequest request;
-
- /** The HttpResponse */
- private HttpResponse response;
-
- /** Cache content type as there is no getContentType() in reponse object */
- private String contentType;
-
- /**
- * Constructs a HttpEnvironment object from a HttpServletRequest
- * and HttpServletResponse objects
- */
- public HttpEnvironment(String uri,
- HttpServletRequest req,
- HttpServletResponse res,
- ServletContext servletContext,
- Context context,
- String containerEncoding,
- String defaultFormEncoding)
- throws IOException {
- super(uri, null, null);
-
- this.request = new HttpRequest(req, this);
- this.request.setCharacterEncoding(defaultFormEncoding);
- this.request.setContainerEncoding(containerEncoding);
- this.response = new HttpResponse(res);
-
- setView(extractView(this.request));
- setAction(extractAction(this.request));
-
- this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
- this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, this.response);
- this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, context);
-
- // This is a kind of a hack for the components that need
- // the real servlet objects to pass them along to other
- // libraries.
- this.objectModel.put(HTTP_REQUEST_OBJECT, req);
- this.objectModel.put(HTTP_RESPONSE_OBJECT, res);
- this.objectModel.put(HTTP_SERVLET_CONTEXT, servletContext);
- }
-
- /**
- * Redirect the client to new URL
- */
- public void redirect(String newURL,
- boolean global,
- boolean permanent)
- throws IOException {
- // Redirect
- String redirect = this.response.encodeRedirectURL(newURL);
-
- // FIXME (VG): WebSphere 4.0/4.0.1 bug
- if (!newURL.startsWith("/") && newURL.indexOf(':') == -1 && redirect.indexOf(':') != -1) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Redirect: WebSphere Bug Detected!");
- }
- String base = NetUtils.getPath(request.getRequestURI());
- if (base.startsWith("/")) {
- base = base.substring(1);
- }
- redirect = response.encodeRedirectURL(base + '/' + newURL);
- }
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Sending redirect to '" + redirect + "'");
- }
-
- if (permanent) {
- this.response.sendPermanentRedirect(redirect);
- } else {
- this.response.sendRedirect(redirect);
- }
- }
-
- /**
- * Set the StatusCode
- */
- public void setStatus(int statusCode) {
- this.response.setStatus(statusCode);
- }
-
- /**
- * Set the ContentType
- */
- public void setContentType(String contentType) {
- this.response.setContentType(contentType);
- this.contentType = contentType;
- }
-
- /**
- * Get the ContentType
- */
- public String getContentType() {
- return this.contentType;
- }
-
- /**
- * Set the length of the generated content
- */
- public void setContentLength(int length) {
- this.response.setContentLength(length);
- }
-
- /**
- * Check if the response has been modified since the same
- * "resource" was requested.
- * The caller has to test if it is really the same "resource"
- * which is requested.
- * @return true if the response is modified or if the
- * environment is not able to test it
- */
- public boolean isResponseModified(long lastModified) {
- if (lastModified != 0) {
- long if_modified_since = this.request.getDateHeader("If-Modified-Since");
- this.response.setDateHeader("Last-Modified", lastModified);
- return (if_modified_since / 1000 < lastModified / 1000);
- }
- return true;
- }
-
- /**
- * Mark the response as not modified.
- */
- public void setResponseIsNotModified() {
- this.response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- }
-
- /**
- * Reset the response if possible. This allows error handlers to have
- * a higher chance to produce clean output if the pipeline that raised
- * the error has already output some data.
- *
- * @return true if the response was successfully reset
- */
- public boolean tryResetResponse()
- throws IOException {
- if (!super.tryResetResponse()) {
- try {
- if (!this.response.isCommitted()) {
- this.response.reset();
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Response successfully reset");
- }
- return true;
- }
- } catch (Exception e) {
- // Log the error, but don't transmit it
- getLogger().warn("Problem resetting response", e);
- }
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Response wasn't reset");
- }
- return false;
- }
- return true;
- }
-
-
- /**
- * Get the output stream where to write the generated resource.
- * The returned stream is buffered by the environment. If the
- * buffer size is -1 then the complete output is buffered.
- * If the buffer size is 0, no buffering takes place.
- */
- public OutputStream getOutputStream(final int bufferSize)
- throws IOException {
- if (this.outputStream == null) {
- this.outputStream = this.response.getOutputStream();
- }
- return super.getOutputStream(bufferSize);
- }
-
- /**
- * Always return <code>true</code>.
- */
- public boolean isExternal() {
- return true;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
deleted file mode 100644
index 68477af..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-import java.util.WeakHashMap;
-import java.lang.ref.WeakReference;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.cocoon.environment.Cookie;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Session;
-import org.apache.cocoon.environment.ValueHolder;
-import org.apache.cocoon.environment.impl.AbstractRequest;
-import org.apache.commons.collections.IteratorUtils;
-
-/**
- * Implements the {@link org.apache.cocoon.environment.Request} interface
- * to provide request information in the HTTP servlets environment.
- *
- * @version $Id$
- */
-public final class HttpRequest extends AbstractRequest {
-
- /** The real HttpServletRequest object */
- private final HttpServletRequest req;
-
- /** The HttpEnvironment object */
- private final HttpEnvironment env;
-
- /** The character encoding of parameters */
- private String form_encoding;
-
- /** The default form encoding of the servlet container */
- private String container_encoding;
-
- /**
- * The map to assure 1:1-mapping of server sessions and Cocoon session wrappers
- */
- private static final Map sessions = new WeakHashMap();
-
- private final Map attributes = new HashMap();
-
- /**
- * Creates a HttpRequest based on a real HttpServletRequest object
- */
- protected HttpRequest(HttpServletRequest req, HttpEnvironment env) {
- super();
- this.req = req;
- this.env = env;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#get(java.lang.String)
- */
- public Object get(String name) {
- // if the request has been wrapped then access its method
- if (req instanceof ValueHolder) {
- return ((ValueHolder) req).get(name);
- }
- String[] values = req.getParameterValues(name);
- if (values == null) {
- return null;
- }
- if (values.length == 1) {
- return values[0];
- }
- if (values.length > 1) {
- Vector vect = new Vector(values.length);
- for (int i = 0; i < values.length; i++) {
- vect.add(values[i]);
- }
- return vect;
- }
- return null;
- }
-
- /* The HttpServletRequest interface methods */
-
- public String getAuthType() {
- return this.req.getAuthType();
- }
-
- private Cookie[] wrappedCookies = null;
- private Map wrappedCookieMap = null;
-
- public Cookie[] getCookies() {
- if (this.wrappedCookieMap == null) {
- wrapCookies();
- }
- return this.wrappedCookies;
- }
-
- public Map getCookieMap() {
- if (this.wrappedCookieMap == null) {
- wrapCookies();
- }
- return this.wrappedCookieMap;
- }
-
- private synchronized void wrapCookies() {
- this.wrappedCookieMap = new HashMap();
- javax.servlet.http.Cookie[] cookies = this.req.getCookies();
- if (cookies != null) {
- this.wrappedCookies = new Cookie[cookies.length];
- for(int i=0; i<cookies.length;i++) {
- HttpCookie cookie = new HttpCookie(cookies[i]);
- this.wrappedCookies[i] = cookie;
- this.wrappedCookieMap.put(cookie.getName(),cookie);
- }
- }
- this.wrappedCookieMap = Collections.unmodifiableMap(this.wrappedCookieMap);
- }
-
- public long getDateHeader(String name) {
- return this.req.getDateHeader(name);
- }
-
- public String getHeader(String name) {
- return this.req.getHeader(name);
- }
-
- public Enumeration getHeaders(String name) {
- return this.req.getHeaders(name);
- }
-
- public Enumeration getHeaderNames() {
- return this.req.getHeaderNames();
- }
-
- public int getIntHeader(String name) {
- return this.req.getIntHeader(name);
- }
-
- public String getMethod() {
- return this.req.getMethod();
- }
-
- public String getPathInfo() {
- return this.req.getPathInfo();
- }
-
- public String getPathTranslated() {
- return this.req.getPathTranslated();
- }
-
- public String getContextPath() {
- return this.req.getContextPath();
- }
-
- public String getQueryString() {
- return this.req.getQueryString();
- }
-
- public String getRemoteUser() {
- return this.req.getRemoteUser();
- }
-
- public boolean isUserInRole(String role) {
- return this.req.isUserInRole(role);
- }
-
- public java.security.Principal getUserPrincipal() {
- return this.req.getUserPrincipal();
- }
-
- public String getRequestedSessionId() {
- return this.req.getRequestedSessionId();
- }
-
- protected String reqURI;
-
- public String getRequestURI() {
- if (this.reqURI == null) {
- this.reqURI = this.req.getRequestURI();
- if ( this.reqURI.equals("/") ) {
- String s = this.req.getServletPath();
- final StringBuffer buffer = new StringBuffer();
- if ( null != s ) buffer.append(s);
- s = this.req.getPathInfo();
- if ( null != s ) buffer.append(s);
- this.reqURI = buffer.toString();
- }
- }
- return this.reqURI;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getSitemapURI()
- */
- public String getSitemapURI() {
- return this.env.getURI();
- }
-
- public String getSitemapURIPrefix() {
- return this.env.getURIPrefix();
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getSitemapPath()
- */
- public String getSitemapPath() {
- return this.env.getURIPrefix();
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getServletPath()
- */
- public String getServletPath() {
- return this.req.getServletPath();
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getSession(boolean)
- */
- public Session getSession(boolean create) {
- javax.servlet.http.HttpSession serverSession = this.req.getSession(create);
- HttpSession session;
- if (serverSession != null)
- {
- synchronized (sessions)
- {
- // retrieve existing wrapper
- WeakReference ref = (WeakReference) sessions.get(serverSession);
- if (ref == null || (session = (HttpSession) ref.get()) == null)
- {
- // create new wrapper
- session = new HttpSession(serverSession);
- sessions.put(serverSession, new WeakReference(session));
- }
- }
- }
- else
- {
- // invalidate
- session = null;
- }
- return session;
- }
-
- public Session getSession() {
- return this.getSession(true);
- }
-
- public boolean isRequestedSessionIdValid() {
- return this.req.isRequestedSessionIdValid();
- }
-
- public boolean isRequestedSessionIdFromCookie() {
- return this.req.isRequestedSessionIdFromCookie();
- }
-
- public boolean isRequestedSessionIdFromURL() {
- return this.req.isRequestedSessionIdFromURL();
- }
-
- /**
- * @deprecated As of Version 2.1 of the Java Servlet API, use
- * {@link #isRequestedSessionIdFromURL()} instead.
- */
- public boolean isRequestedSessionIdFromUrl() {
- return this.req.isRequestedSessionIdFromURL();
- }
-
- /* The ServletRequest interface methods */
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String)
- */
- public Object getAttribute(String name) {
- return this.getAttribute(name, Request.GLOBAL_SCOPE);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getAttributeNames()
- */
- public Enumeration getAttributeNames() {
- return this.getAttributeNames(Request.GLOBAL_SCOPE);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object)
- */
- public void setAttribute(String name, Object value) {
- this.setAttribute(name, value, Request.GLOBAL_SCOPE);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String)
- */
- public void removeAttribute(String name) {
- this.removeAttribute(name, Request.GLOBAL_SCOPE);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
- */
- public Object getAttribute(String name, int scope) {
- if ( scope == Request.REQUEST_SCOPE ) {
- return this.attributes.get(name);
- }
- return this.req.getAttribute(name);
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
- */
- public Enumeration getAttributeNames(int scope) {
- if ( scope == Request.REQUEST_SCOPE ) {
- return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
- }
- return this.req.getAttributeNames();
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
- */
- public void setAttribute(String name, Object value, int scope) {
- if ( scope == Request.REQUEST_SCOPE ) {
- this.attributes.put(name, value);
- } else {
- this.req.setAttribute(name, value);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
- */
- public void removeAttribute(String name, int scope) {
- if ( scope == Request.REQUEST_SCOPE ) {
- this.attributes.remove(name);
- } else {
- this.req.removeAttribute(name);
- }
- }
-
- public String getCharacterEncoding() {
- if (this.form_encoding == null) {
- return this.req.getCharacterEncoding();
- }
- return this.form_encoding;
- }
-
- public void setCharacterEncoding(String form_encoding)
- throws java.io.UnsupportedEncodingException {
- this.form_encoding = form_encoding;
- }
-
- /**
- * Sets the default encoding of the servlet container.
- */
- public void setContainerEncoding(String container_encoding) {
- this.container_encoding = container_encoding;
- }
-
- public int getContentLength() {
- return this.req.getContentLength();
- }
-
- public String getContentType() {
- return this.req.getContentType();
- }
-
- public InputStream getInputStream() throws IOException {
- return this.req.getInputStream();
- }
-
- public String getParameter(String name) {
- String value = this.req.getParameter(name);
- if (this.form_encoding == null || this.container_encoding == null || value == null) {
- return value;
- }
- // Form and container encoding are equal, skip expensive value decoding
- if (this.container_encoding.equals(this.form_encoding)) {
- return value;
- }
- return decode(value);
- }
-
- private String decode(String str) {
- if (str == null) return null;
- try {
- if (this.container_encoding == null)
- this.container_encoding = "ISO-8859-1";
- byte[] bytes = str.getBytes(this.container_encoding);
- return new String(bytes, form_encoding);
- } catch (java.io.UnsupportedEncodingException uee) {
- throw new RequestEncodingException("Unsupported Encoding Exception", uee);
- }
- }
-
- public Enumeration getParameterNames() {
- return this.req.getParameterNames();
- }
-
- public String[] getParameterValues(String name) {
- String[] values = this.req.getParameterValues(name);
- if (values == null) return null;
- if (this.form_encoding == null) {
- return values;
- }
- String[] decoded_values = new String[values.length];
- for (int i = 0; i < values.length; ++i) {
- decoded_values[i] = decode(values[i]);
- }
- return decoded_values;
- }
-
- public String getProtocol() {
- return this.req.getProtocol();
- }
-
- public String getScheme() {
- return this.req.getScheme();
- }
-
- public String getServerName() {
- return this.req.getServerName();
- }
-
- public int getServerPort() {
- return this.req.getServerPort();
- }
-
- public BufferedReader getReader() throws IOException {
- return this.req.getReader();
- }
-
- public String getRemoteAddr() {
- return this.req.getRemoteAddr();
- }
-
- public String getRemoteHost() {
- return this.req.getRemoteHost();
- }
-
- public Locale getLocale() {
- return this.req.getLocale();
- }
-
- public Enumeration getLocales() {
- return this.req.getLocales();
- }
-
- public boolean isSecure() {
- return this.req.isSecure();
- }
-
- public RequestDispatcher getRequestDispatcher(String path) {
- return this.req.getRequestDispatcher(path);
- }
-
- /**
- * @deprecated As of Version 2.1 of the Java Servlet API, use
- * {@link javax.servlet.ServletContext#getRealPath(java.lang.String)}instead.
- */
- public String getRealPath(String path) {
- return this.req.getRealPath(path);
- }
-
- /**
- * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
- */
- public Object searchAttribute(String name) {
- Object result = this.getAttribute(name, REQUEST_SCOPE);
- if ( result == null ) {
- result = this.getAttribute(name, GLOBAL_SCOPE);
- }
- return result;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpResponse.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpResponse.java
deleted file mode 100644
index 21c0ca3..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpResponse.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import org.apache.cocoon.environment.Cookie;
-import org.apache.cocoon.environment.Response;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-/**
- * Implements the {@link org.apache.cocoon.environment.Response} interface
- * to provide response functionality in the HTTP servlets environment.
- *
- * @version $Id$
- */
-public final class HttpResponse implements Response {
-
- /** The real HttpServletResponse object */
- private final HttpServletResponse res;
-
- /**
- * Creates a HttpServletResponse based on a real HttpServletResponse object
- */
- protected HttpResponse (HttpServletResponse res) {
- this.res = res;
- }
-
- /**
- * Create a new cookie which is not added to the response
- */
- public Cookie createCookie(String name, String value) {
- return new HttpCookie(name, value);
- }
-
- public void addCookie(Cookie cookie) {
- if (cookie instanceof HttpCookie) {
- this.res.addCookie(((HttpCookie)cookie).getServletCookie());
- } else {
- javax.servlet.http.Cookie newCookie;
- newCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());
- newCookie.setComment(cookie.getComment());
- newCookie.setDomain(cookie.getDomain());
- newCookie.setMaxAge(cookie.getMaxAge());
- newCookie.setPath(cookie.getPath());
- newCookie.setSecure(cookie.getSecure());
- newCookie.setVersion(cookie.getVersion());
- this.res.addCookie(newCookie);
- }
- }
-
- public boolean containsHeader(String name) {
- return this.res.containsHeader(name);
- }
-
- public String encodeURL(String url) {
- if (url != null && url.indexOf(";jsessionid=") != -1)
- return url;
- return this.res.encodeURL(url);
- }
-
- public String encodeRedirectURL(String url) {
- if (url != null && url.indexOf(";jsessionid=") != -1) {
- return url;
- }
-
- return this.res.encodeRedirectURL(url);
- }
-
- public void sendError(int sc, String msg) throws IOException {
- this.res.sendError(sc, msg);
- }
-
- public void sendError(int sc) throws IOException {
- this.res.sendError(sc);
- }
-
- public void sendRedirect(String location) throws IOException {
- this.res.sendRedirect(location);
- }
-
- public void sendPermanentRedirect(String location) throws IOException {
- this.res.setHeader("location", location);
- this.res.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
- }
-
- public void setDateHeader(String name, long date) {
- this.res.setDateHeader(name, date);
- }
-
- public void addDateHeader(String name, long date) {
- this.res.addDateHeader(name, date);
- }
-
- public void setHeader(String name, String value) {
- this.res.setHeader(name, value);
- }
-
- public void addHeader(String name, String value) {
- this.res.addHeader(name, value);
- }
-
- public void setIntHeader(String name, int value) {
- this.res.setIntHeader(name, value);
- }
-
- public void addIntHeader(String name, int value) {
- this.res.addIntHeader(name, value);
- }
-
- public void setStatus(int sc) {
- this.res.setStatus(sc);
- }
-
- /**
- * @deprecated As of version 2.1, use encodeURL(String url) instead
- */
- public String encodeUrl(String url) {
- return this.res.encodeUrl(url);
- }
-
- /**
- * @deprecated As of version 2.1, use
- * encodeRedirectURL(String url) instead
- */
- public String encodeRedirectUrl(String url) {
- return this.res.encodeRedirectUrl(url);
- }
-
- /**
- * @deprecated As of version 2.1, due to ambiguous meaning of the
- * message parameter. To set a status code
- * use <code>setStatus(int)</code>, to send an error with a description
- * use <code>sendError(int, String)</code>.
- */
- public void setStatus(int sc, String sm) {
- this.res.setStatus(sc, sm);
- }
-
- /* The ServletResponse interface methods */
-
- public String getCharacterEncoding() {
- return this.res.getCharacterEncoding();
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- //throw new IllegalStateException ("you are not a serializer or reader");
- return this.res.getOutputStream();
- }
-
- public PrintWriter getWriter() throws IOException {
- //throw new IllegalStateException ("you are not a serializer or reader");
- return this.res.getWriter();
- }
-
- public void setContentLength(int len) {
- this.res.setContentLength(len);
- }
-
- public void setContentType(String type) {
- this.res.setContentType(type);
- }
-
- public void setBufferSize(int size) {
- this.res.setBufferSize(size);
- }
-
- public int getBufferSize() {
- return this.res.getBufferSize();
- }
-
- public void flushBuffer() throws IOException {
- this.res.flushBuffer();
- }
-
- public boolean isCommitted() {
- return this.res.isCommitted();
- }
-
- public void reset() {
- this.res.reset();
- }
-
- public void setLocale(Locale loc) {
- this.res.setLocale(loc);
- }
-
- public Locale getLocale() {
- return this.res.getLocale();
- }
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpSession.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpSession.java
deleted file mode 100644
index ffb2140..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/HttpSession.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import org.apache.cocoon.environment.impl.AbstractSession;
-
-import java.util.Enumeration;
-
-/**
- *
- * Provides a way to identify a user across more than one page
- * request or visit to a Web site and to store information about that user.
- *
- * <p>Cocoon uses this interface to create a session
- * between a client and the "cocoon server". The session persists
- * for a specified time period, across more than one connection or
- * page request from the user. A session usually corresponds to one
- * user, who may visit a site many times. The server can maintain a
- * session in many ways such as using cookies or rewriting URLs.
- *
- * <p>This interface allows Cocoon to
- * <ul>
- * <li>View and manipulate information about a session, such as
- * the session identifier, creation time, and last accessed time
- * <li>Bind objects to sessions, allowing user information to persist
- * across multiple user connections
- * </ul>
- *
- * <p>Session information is scoped only to the current context
- * (<code>Context</code>), so information stored in one context
- * will not be directly visible in another.
- *
- * @version $Id$
- *
- */
-public final class HttpSession
-extends AbstractSession {
-
- javax.servlet.http.HttpSession wrappedSession;
-
- /**
- * Construct a new session from an HttpSession
- */
- public HttpSession(javax.servlet.http.HttpSession session) {
- this.wrappedSession = session;
- }
-
- /**
- *
- * Returns the time when this session was created, measured
- * in milliseconds since midnight January 1, 1970 GMT.
- *
- * @return a <code>long</code> specifying
- * when this session was created,
- * expressed in
- * milliseconds since 1/1/1970 GMT
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
- public long getCreationTime() {
- return this.wrappedSession.getCreationTime();
- }
-
- /**
- *
- * Returns a string containing the unique identifier assigned
- * to this session. The identifier is assigned
- * by the context container and is implementation dependent.
- *
- * @return a string specifying the identifier
- * assigned to this session
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
- public String getId() {
- return this.wrappedSession.getId();
- }
-
- /**
- *
- * Returns the last time the client sent a request associated with
- * this session, as the number of milliseconds since midnight
- * January 1, 1970 GMT.
- *
- * <p>Actions that your application takes, such as getting or setting
- * a value associated with the session, do not affect the access
- * time.
- *
- * @return a <code>long</code>
- * representing the last time
- * the client sent a request associated
- * with this session, expressed in
- * milliseconds since 1/1/1970 GMT
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
-
- public long getLastAccessedTime() {
- return this.wrappedSession.getLastAccessedTime();
- }
-
- /**
- *
- * Specifies the time, in seconds, between client requests before the
- * contextcontainer will invalidate this session. A negative time
- * indicates the session should never timeout.
- *
- * @param interval An integer specifying the number
- * of seconds
- *
- */
- public void setMaxInactiveInterval(int interval) {
- this.wrappedSession.setMaxInactiveInterval(interval);
- }
-
- /**
- * Returns the maximum time interval, in seconds, that
- * the context container will keep this session open between
- * client accesses. After this interval, the context container
- * will invalidate the session. The maximum time interval can be set
- * with the <code>setMaxInactiveInterval</code> method.
- * A negative time indicates the session should never timeout.
- *
- *
- * @return an integer specifying the number of
- * seconds this session remains open
- * between client requests
- *
- * @see #setMaxInactiveInterval(int)
- *
- *
- */
- public int getMaxInactiveInterval() {
- return this.wrappedSession.getMaxInactiveInterval();
- }
-
- /**
- *
- * Returns the object bound with the specified name in this session, or
- * <code>null</code> if no object is bound under the name.
- *
- * @param name a string specifying the name of the object
- *
- * @return the object with the specified name
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
- public Object getAttribute(String name) {
- return this.wrappedSession.getAttribute(name);
- }
-
- /**
- *
- * Returns an <code>Enumeration</code> of <code>String</code> objects
- * containing the names of all the objects bound to this session.
- *
- * @return an <code>Enumeration</code> of
- * <code>String</code> objects specifying the
- * names of all the objects bound to
- * this session
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
- public Enumeration getAttributeNames() {
- return this.wrappedSession.getAttributeNames();
- }
-
- /**
- * Binds an object to this session, using the name specified.
- * If an object of the same name is already bound to the session,
- * the object is replaced.
- *
- *
- * @param name the name to which the object is bound;
- * cannot be null
- *
- * @param value the object to be bound; cannot be null
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- *
- */
- public void setAttribute(String name, Object value) {
- this.wrappedSession.setAttribute(name, value);
- }
-
- /**
- *
- * Removes the object bound with the specified name from
- * this session. If the session does not have an object
- * bound with the specified name, this method does nothing.
- *
- *
- * @param name the name of the object to
- * remove from this session
- *
- * @exception IllegalStateException if this method is called on an
- * invalidated session
- */
- public void removeAttribute(String name) {
- this.wrappedSession.removeAttribute(name);
- }
-
- /**
- *
- * Invalidates this session
- * to it.
- *
- * @exception IllegalStateException if this method is called on an
- * already invalidated session
- *
- */
- public void invalidate() {
- this.wrappedSession.invalidate();
- }
-
- /**
- *
- * Returns <code>true</code> if the client does not yet know about the
- * session or if the client chooses not to join the session. For
- * example, if the server used only cookie-based sessions, and
- * the client had disabled the use of cookies, then a session would
- * be new on each request.
- *
- * @return <code>true</code> if the
- * server has created a session,
- * but the client has not yet joined
- *
- * @exception IllegalStateException if this method is called on an
- * already invalidated session
- *
- */
- public boolean isNew() {
- return this.wrappedSession.isNew();
- }
-
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/RequestEncodingException.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/RequestEncodingException.java
deleted file mode 100644
index 97f61a8..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/http/RequestEncodingException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.http;
-
-import org.apache.avalon.framework.CascadingRuntimeException;
-
-public final class RequestEncodingException extends CascadingRuntimeException
-{
- public RequestEncodingException(String message)
- {
- super(message, null);
- }
-
- public RequestEncodingException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractContext.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractContext.java
deleted file mode 100644
index 8d4e11f..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractContext.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import org.apache.cocoon.environment.Context;
-
-/**
- * Base class for any context
- *
- * @version $Id$
- */
-public abstract class AbstractContext
- implements Context, ServletContext {
-
- /** Attributes. */
- protected final Map attributes = new HashMap();
-
- /**
- * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
- */
- public Object getAttribute(String key) {
- return this.attributes.get(key);
- }
-
- /**
- * @see javax.servlet.ServletContext#getAttributeNames()
- */
- public Enumeration getAttributeNames() {
- return Collections.enumeration(this.attributes.keySet());
- }
-
- /**
- * @see javax.servlet.ServletContext#getContext(java.lang.String)
- */
- public ServletContext getContext(String arg0) {
- return this;
- }
-
- /**
- * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
- */
- public String getInitParameter(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getInitParameterNames()
- */
- public Enumeration getInitParameterNames() {
- return Collections.enumeration(Collections.EMPTY_LIST);
- }
-
- /**
- * @see javax.servlet.ServletContext#getMajorVersion()
- */
- public int getMajorVersion() {
- return 2;
- }
-
- /**
- * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
- */
- public String getMimeType(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getMinorVersion()
- */
- public int getMinorVersion() {
- return 3;
- }
-
- /**
- * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
- */
- public RequestDispatcher getNamedDispatcher(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
- */
- public String getRealPath(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
- */
- public RequestDispatcher getRequestDispatcher(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getResource(java.lang.String)
- */
- public URL getResource(String arg0) throws MalformedURLException {
- return null;
- }
-
- /**
- * Get access to the resource as @link {@link InputStream}. If there is any problem,
- * <code>null</code> is returned.
- *
- * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
- */
- public InputStream getResourceAsStream(String path) {
- URL resourceURL = null;
- try {
- resourceURL = this.getResource(path);
- } catch (MalformedURLException e) {
- return null;
- }
- if(resourceURL != null) {
- try {
- return resourceURL.openStream();
- } catch (IOException e) {
- return null;
- }
- }
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
- */
- public Set getResourcePaths(String arg0) {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getServerInfo()
- */
- public String getServerInfo() {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getServlet(java.lang.String)
- */
- public Servlet getServlet(String arg0) throws ServletException {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getServletContextName()
- */
- public String getServletContextName() {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getServletNames()
- */
- public Enumeration getServletNames() {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#getServlets()
- */
- public Enumeration getServlets() {
- return null;
- }
-
- /**
- * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
- */
- public void removeAttribute(String key) {
- this.attributes.remove(key);
- }
-
- /**
- * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
- */
- public void setAttribute(String key, Object object) {
- this.attributes.put(key, object);
- }
-
- /**
- * @see org.apache.cocoon.environment.Context#getAttributes()
- */
- public Map getAttributes() {
- return new ContextMap(this);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractRequest.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractRequest.java
deleted file mode 100644
index 60ce8ed..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractRequest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import java.util.Map;
-
-import org.apache.cocoon.environment.Request;
-
-/**
- * Base class for any request
- *
- * @version $Id$
- */
-public abstract class AbstractRequest
- implements Request {
-
- public Map getAttributes() {
- return new RequestMap(this);
- }
-
- public Map getParameters() {
- return new RequestParameterMap(this);
- }
-
- public Map getHeaders() {
- return new RequestHeaderMap(this);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractSession.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractSession.java
deleted file mode 100644
index f018988..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/AbstractSession.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import java.util.Map;
-
-import org.apache.cocoon.environment.Session;
-
-/**
- * Base class for any session
- *
- * @version $Id$
- */
-public abstract class AbstractSession
- implements Session {
-
- public Map getAttributes() {
- return new SessionMap(this);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/BaseMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/BaseMap.java
deleted file mode 100644
index 07097df..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/BaseMap.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Base class for context maps
- *
- * @version $Id$
- */
-public abstract class BaseMap extends java.util.AbstractMap {
-
- protected static class Entry implements Map.Entry {
- private final Object key;
- private final Object value;
-
- public Entry(Object key, Object value) {
- this.key = key;
- this.value = value;
- }
-
- public Object getKey() {
- return key;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Object setValue(Object value) {
- throw new UnsupportedOperationException();
- }
-
- public int hashCode() {
- return (key != null ? key.hashCode() : 0) ^ (value != null ? value.hashCode() : 0);
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof Map.Entry)) {
- return false;
- }
-
- Map.Entry other = (Map.Entry) obj;
- Object key = other.getKey();
- if (key == this.key || key != null && key.equals(this.key)) {
- Object value = other.getValue();
- return value == this.value || value != null && value.equals(this.value);
- }
- return false;
- }
- }
-
-
- public BaseMap() {
- }
-
- public void clear() {
- throw new UnsupportedOperationException();
- }
-
- public void putAll(Map t) {
- throw new UnsupportedOperationException();
- }
-
- public Object remove(Object key) {
- throw new UnsupportedOperationException();
- }
-
- public Set entrySet() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/ContextMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/ContextMap.java
deleted file mode 100644
index b84f6ec..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/ContextMap.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import org.apache.cocoon.environment.Context;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Context attributes map
- *
- * @version $Id$
- */
-public class ContextMap extends BaseMap {
-
- private Context context;
-
-
- public ContextMap(Context context) {
- this.context = context;
- }
-
- public Object get(Object key) {
- return context.getAttribute(key.toString());
- }
-
- public Object put(Object key, Object value) {
- String sKey = key.toString();
- Object old = context.getAttribute(sKey);
- context.setAttribute(sKey, value);
- return old;
- }
-
- public Object remove(Object key) {
- String sKey = key.toString();
- Object old = context.getAttribute(sKey);
- context.removeAttribute(sKey);
- return old;
- }
-
- public Set entrySet() {
- Set entries = new HashSet();
- for (Enumeration e = context.getAttributeNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- entries.add(new BaseMap.Entry(name, context.getAttribute(name)));
- }
-
- return entries;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof ContextMap)) {
- return false;
- }
-
- return super.equals(obj);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java
deleted file mode 100644
index f109b3d..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import org.apache.cocoon.environment.Request;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Request headers map
- *
- * @version $Id$
- */
-public class RequestHeaderMap extends BaseMap {
-
- private Request request;
-
-
- public RequestHeaderMap(Request request) {
- this.request = request;
- }
-
- public Object get(Object key) {
- return request.getHeader(key.toString());
- }
-
- public Set entrySet() {
- Set entries = new HashSet();
- for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- entries.add(new BaseMap.Entry(name, request.getHeader(name)));
- }
-
- return entries;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof RequestHeaderMap)) {
- return false;
- }
-
- return super.equals(obj);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestMap.java
deleted file mode 100644
index 03f66a4..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestMap.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import org.apache.cocoon.environment.Request;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Request attributes map
- *
- * @version $Id$
- */
-public class RequestMap extends BaseMap {
-
- private Request request;
-
-
- public RequestMap(Request request) {
- this.request = request;
- }
-
- public Object get(Object key) {
- return request.getAttribute(key.toString());
- }
-
- public Object put(Object key, Object value) {
- String sKey = key.toString();
- Object old = request.getAttribute(sKey);
- request.setAttribute(sKey, value);
- return old;
- }
-
- public Object remove(Object key) {
- String sKey = key.toString();
- Object old = request.getAttribute(sKey);
- request.removeAttribute(sKey);
- return old;
- }
-
- public Set entrySet() {
- Set entries = new HashSet();
- for (Enumeration e = request.getAttributeNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- entries.add(new BaseMap.Entry(name, request.getAttribute(name)));
- }
-
- return entries;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof RequestMap)) {
- return false;
- }
-
- return super.equals(obj);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestParameterMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestParameterMap.java
deleted file mode 100644
index 993489d..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/RequestParameterMap.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import org.apache.cocoon.environment.Request;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Request parameters map
- *
- * @version $Id$
- */
-public class RequestParameterMap extends BaseMap {
-
- private Request request;
-
-
- public RequestParameterMap(Request request) {
- this.request = request;
- }
-
- public Object get(Object key) {
- return request.getParameter(key.toString());
- }
-
- public Set entrySet() {
- Set entries = new HashSet();
- for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- entries.add(new BaseMap.Entry(name, request.getParameter(name)));
- }
-
- return entries;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof RequestParameterMap)) {
- return false;
- }
-
- return super.equals(obj);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/SessionMap.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/SessionMap.java
deleted file mode 100644
index d349d3f..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/environment/impl/SessionMap.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.environment.impl;
-
-import org.apache.cocoon.environment.Session;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Session attributes map
- *
- * @version $Id$
- */
-public class SessionMap extends BaseMap {
-
- private Session session;
-
-
- public SessionMap(Session session) {
- this.session = session;
- }
-
- public Object get(Object key) {
- return session.getAttribute(key.toString());
- }
-
- public Object put(Object key, Object value) {
- String sKey = key.toString();
- Object old = session.getAttribute(sKey);
- session.setAttribute(sKey, value);
- return old;
- }
-
- public Object remove(Object key) {
- String sKey = key.toString();
- Object old = session.getAttribute(sKey);
- session.removeAttribute(sKey);
- return old;
- }
-
- public Set entrySet() {
- Set entries = new HashSet();
- for (Enumeration e = session.getAttributeNames(); e.hasMoreElements();) {
- String name = (String) e.nextElement();
- entries.add(new BaseMap.Entry(name, session.getAttribute(name)));
- }
-
- return entries;
- }
-
- public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof SessionMap)) {
- return false;
- }
-
- return super.equals(obj);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java
deleted file mode 100644
index 55a3826..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/AbstractGenerator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.generation;
-
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.xml.AbstractXMLProducer;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * An abstract class that can be used to implement an own generator.
- * If you need other components, use the {@link ServiceableGenerator}
- * instead.
- *
- * @version $Id$
- */
-public abstract class AbstractGenerator
- extends AbstractXMLProducer
- implements Generator {
-
- /** The current <code>SourceResolver</code>. */
- protected SourceResolver resolver;
- /** The current <code>Map</code> objectModel. */
- protected Map objectModel;
- /** The current <code>Parameters</code>. */
- protected Parameters parameters;
- /** The source URI associated with the request or <b>null</b>. */
- protected String source;
-
- /**
- * Set the <code>SourceResolver</code>, object model <code>Map</code>,
- * the source and sitemap <code>Parameters</code> used to process the request.
- */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
- this.resolver=resolver;
- this.objectModel=objectModel;
- this.source=src;
- this.parameters=par;
- }
-
- /**
- * Recycle the generator by removing references
- */
- public void recycle() {
- super.recycle();
- this.resolver = null;
- this.objectModel = null;
- this.source = null;
- this.parameters = null;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServiceableGenerator.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServiceableGenerator.java
deleted file mode 100644
index 04a39c2..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServiceableGenerator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.generation;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-/**
- * A default implementation that can be used for writing own generators.
- *
- * @version $Id$
- * @since 2.1.1
- */
-public abstract class ServiceableGenerator extends AbstractGenerator
-implements Serviceable, Disposable {
-
- /** The service manager instance */
- protected ServiceManager manager;
-
- /**
- * Set the current <code>ServiceManager</code> instance used by this
- * <code>Serviceable</code>.
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
-
- /**
- * Release all resources.
- */
- public void dispose() {
- this.manager = null;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServletGenerator.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServletGenerator.java
deleted file mode 100644
index e0aa211..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/generation/ServletGenerator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.generation;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Context;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Response;
-import org.apache.cocoon.environment.SourceResolver;
-
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- *
- * @version $Id$
- */
-public abstract class ServletGenerator extends AbstractGenerator
-implements Serviceable, Disposable {
-
- protected Request request;
- protected Response response;
- protected Context context;
-
- /** The service manager instance */
- protected ServiceManager manager;
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- this.manager = null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
- */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
-
- super.setup(resolver, objectModel, src, par);
- this.request = ObjectModelHelper.getRequest(objectModel);
- this.response = ObjectModelHelper.getResponse(objectModel);
- this.context = ObjectModelHelper.getContext(objectModel);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
- */
- public void recycle() {
- super.recycle();
- this.request = null;
- this.response = null;
- this.context = null;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/AbstractReader.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/AbstractReader.java
deleted file mode 100644
index 07f9382..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/AbstractReader.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.reading;
-
-import org.apache.avalon.excalibur.pool.Recyclable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.xml.sax.SAXException;
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Map;
-
-/**
- * A reader can be used to generate binary output for a request. This
- * abstract class helps in implementing a custom reader.
- *
- * @version $Id$
- */
-public abstract class AbstractReader
- extends AbstractLogEnabled
- implements Reader, Recyclable {
-
- /** The current <code>SourceResolver</code>. */
- protected SourceResolver resolver;
- /** The current <code>Map</code> of the object model. */
- protected Map objectModel;
- /** The current <code>Parameters</code>. */
- protected Parameters parameters;
- /** The source URI associated with the request or <b>null</b>. */
- protected String source;
- /** The <code>OutputStream</code> to write on. */
- protected OutputStream out;
-
- /**
- * Set the <code>SourceResolver</code> the object model <code>Map</code>,
- * the source and sitemap <code>Parameters</code> used to process the request.
- */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
- this.resolver=resolver;
- this.objectModel=objectModel;
- this.source=src;
- this.parameters=par;
- }
-
- /**
- * Set the <code>OutputStream</code>
- */
- public void setOutputStream(OutputStream out) {
- if ( out instanceof BufferedOutputStream
- || out instanceof org.apache.cocoon.util.BufferedOutputStream ) {
- this.out = out;
- } else {
- this.out = new BufferedOutputStream(out, 1536);
- }
- }
-
- /**
- * Get the mime-type of the output of this <code>Reader</code>
- */
- public String getMimeType() {
- return null;
- }
-
- /**
- * @return the time the read source was last modified or 0 if it is not
- * possible to detect
- */
- public long getLastModified() {
- return 0;
- }
-
- /**
- * Recycle the component
- */
- public void recycle() {
- this.out = null;
- this.resolver = null;
- this.source = null;
- this.parameters = null;
- this.objectModel = null;
- }
-
- /**
- * Test if the component wants to set the content length
- */
- public boolean shouldSetContentLength() {
- return false;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/ServiceableReader.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/ServiceableReader.java
deleted file mode 100644
index 9ec2b64..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/reading/ServiceableReader.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.reading;
-
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-/**
- * The serviceable reader will allow any {@link Reader} implementation that
- * extends this to access other Avalon components.
- *
- * @version $Id$
- */
-public abstract class ServiceableReader
- extends AbstractReader
- implements Serviceable {
-
-
- protected ServiceManager manager;
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager)
- throws ServiceException {
- this.manager = manager;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractSerializer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractSerializer.java
deleted file mode 100644
index 0ca0ace..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractSerializer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.serialization;
-
-import org.apache.cocoon.xml.AbstractXMLPipe;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @version $Id$
- */
-
-public abstract class AbstractSerializer
-extends AbstractXMLPipe implements Serializer {
-
- /**
- * The <code>OutputStream</code> used by this serializer.
- */
- protected OutputStream output;
-
- /**
- * Set the {@link OutputStream} where the requested resource should
- * be serialized.
- */
- public void setOutputStream(OutputStream out)
- throws IOException {
- this.output = out;
- }
-
- /**
- * Get the mime-type of the output of this <code>Serializer</code>
- */
- public String getMimeType() {
- return null;
- }
-
- /**
- * Recycle serializer by removing references
- */
- public void recycle() {
- super.recycle();
- this.output = null;
- }
-
- /**
- * Test if the component wants to set the content length
- */
- public boolean shouldSetContentLength() {
- return false;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractTextSerializer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
deleted file mode 100644
index 40a12bd..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.serialization;
-
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.Constants;
-import org.apache.cocoon.caching.CacheableProcessingComponent;
-import org.apache.cocoon.configuration.Settings;
-import org.apache.cocoon.util.ClassUtils;
-import org.apache.cocoon.util.TraxErrorHandler;
-import org.apache.cocoon.util.avalon.CLLoggerWrapper;
-import org.apache.cocoon.xml.AbstractXMLPipe;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLUtils;
-
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.excalibur.source.SourceValidity;
-import org.apache.excalibur.source.impl.validity.NOPValidity;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @version $Id$
- */
-public abstract class AbstractTextSerializer extends AbstractSerializer
- implements Configurable, Serviceable, CacheableProcessingComponent {
-
- /** The default logger for this class. */
- private Log logger = LogFactory.getLog(getClass());
-
- /**
- * Cache for avoiding unnecessary checks of namespaces abilities.
- * It associates a Boolean to the transformer class name.
- */
- private static final Map needsNamespaceCache = new HashMap();
-
- /**
- * The trax <code>TransformerFactory</code> used by this serializer.
- */
- private SAXTransformerFactory tfactory;
-
- /**
- * The <code>Properties</code> used by this serializer.
- */
- protected Properties format = new Properties();
-
- /**
- * The pipe that adds namespaces as xmlns attributes.
- */
- private NamespaceAsAttributes namespacePipe;
-
- /**
- * The caching key
- */
- private String cachingKey;
-
- private String transformerFactoryClass;
-
- private String defaultEncoding = null;
-
- /**
- * Set the properties used for transformer handler used by the serializer
- * see {@link OutputKeys} for possible settings.
- *
- * @param format
- */
- public void setFormat(Properties format) {
- this.format = format;
- }
-
- /**
- * Set the default encoding. This will be overided if the encoding is set
- * in the format properties. This is mainly useful together with Spring
- * bean inheritance.
- *
- * @param defaultEncoding
- */
- public void setDefaultEncoding(String defaultEncoding) {
- this.defaultEncoding = defaultEncoding;
- }
-
- /**
- * Initialize logger, caching key, transformer handler and namespace pipe
- *
- * @throws Exception
- */
- public void init() throws Exception {
- this.enableLogging(new CLLoggerWrapper(this.logger));
- if (!this.format.containsKey(OutputKeys.ENCODING) && this.defaultEncoding != null)
- this.format.put(OutputKeys.ENCODING, this.defaultEncoding);
- this.cachingKey = createCachingKey(format);
- this.initTransformerFactory();
- this.initNamespacePipe();
- }
-
- /**
- * Optionally set the transformer factory used for creating the transformer
- * handler that is used for serialization. Otherwise the standard transformer
- * factory is used ({@link TransformerFactory}).
- *
- * @param transformerFactoryClass the name of the class
- */
- public void setTransformerFactory(String transformerFactoryClass) {
- this.transformerFactoryClass = transformerFactoryClass;
- }
-
- /**
- * Interpose namespace pipe if needed.
- */
- public void setConsumer(XMLConsumer consumer) {
- if (this.namespacePipe == null) {
- super.setConsumer(consumer);
- } else {
- this.namespacePipe.setConsumer(consumer);
- super.setConsumer(this.namespacePipe);
- }
- }
-
- /**
- * Interpose namespace pipe if needed.
- */
- public void setContentHandler(ContentHandler handler) {
- if (this.namespacePipe == null) {
- super.setContentHandler(handler);
- } else {
- this.namespacePipe.setContentHandler(handler);
- super.setContentHandler(this.namespacePipe);
- }
- }
-
- /**
- * Interpose namespace pipe if needed.
- */
- public void setLexicalHandler(LexicalHandler handler) {
- if (this.namespacePipe == null) {
- super.setLexicalHandler(handler);
- } else {
- this.namespacePipe.setLexicalHandler(handler);
- super.setLexicalHandler(this.namespacePipe);
- }
- }
-
- /**
- * Helper for TransformerFactory.
- */
- protected SAXTransformerFactory getTransformerFactory() {
- return tfactory;
- }
-
- /**
- * Helper for TransformerHandler.
- */
- protected TransformerHandler getTransformerHandler() throws TransformerException {
- return this.getTransformerFactory().newTransformerHandler();
- }
-
-// /**
-// * Set the {@link OutputStream} where the requested resource should
-// * be serialized.
-// */
-// public void setOutputStream(OutputStream out) throws IOException {
-// /*
-// * Add a level of buffering to the output stream. Xalan serializes
-// * every character individually. In conjunction with chunked
-// * transfer encoding this would otherwise lead to a whopping 6-fold
-// * increase of data on the wire.
-// */
-// // if (outputBufferSize > 0) {
-// // super.setOutputStream(
-// // new BufferedOutputStream(out, outputBufferSize));
-// // } else {
-// super.setOutputStream(out);
-// // }
-// }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- *
- * @deprecated use property injection instead
- */
- public void service(ServiceManager manager) throws ServiceException {
- final Settings settings = (Settings)manager.lookup(Settings.ROLE);
- String defaultEncoding = settings.getFormEncoding();
- if (defaultEncoding != null) {
- this.format.setProperty(OutputKeys.ENCODING, defaultEncoding);
- }
- manager.release(settings);
- }
-
- /**
- * Set the configurations for this serializer.
- *
- * @deprecated use property injection instead
- */
- public void configure(Configuration conf) throws ConfigurationException {
- // configure buffer size
- // Configuration bsc = conf.getChild("buffer-size", false);
- // if(null != bsc)
- // outputBufferSize = bsc.getValueAsInteger(DEFAULT_BUFFER_SIZE);
-
- // configure xalan
- String cdataSectionElements = conf.getChild("cdata-section-elements").getValue(null);
- String dtPublic = conf.getChild("doctype-public").getValue(null);
- String dtSystem = conf.getChild("doctype-system").getValue(null);
- String encoding = conf.getChild("encoding").getValue(null);
- String indent = conf.getChild("indent").getValue(null);
- String mediaType = conf.getChild("media-type").getValue(null);
- String method = conf.getChild("method").getValue(null);
- String omitXMLDeclaration = conf.getChild("omit-xml-declaration").getValue(null);
- String standAlone = conf.getChild("standalone").getValue(null);
- String version = conf.getChild("version").getValue(null);
-
- if (cdataSectionElements != null) {
- format.put(OutputKeys.CDATA_SECTION_ELEMENTS, cdataSectionElements);
- }
- if (dtPublic != null) {
- format.put(OutputKeys.DOCTYPE_PUBLIC, dtPublic);
- }
- if (dtSystem != null) {
- format.put(OutputKeys.DOCTYPE_SYSTEM, dtSystem);
- }
- if (encoding != null) {
- format.put(OutputKeys.ENCODING, encoding);
- }
- if (indent != null) {
- format.put(OutputKeys.INDENT, indent);
- }
- if (mediaType != null) {
- format.put(OutputKeys.MEDIA_TYPE, mediaType);
- }
- if (method != null) {
- format.put(OutputKeys.METHOD, method);
- }
- if (omitXMLDeclaration != null) {
- format.put(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration);
- }
- if (standAlone != null) {
- format.put(OutputKeys.STANDALONE, standAlone);
- }
- if (version != null) {
- format.put(OutputKeys.VERSION, version);
- }
-
- this.cachingKey = createCachingKey(format);
-
- this.transformerFactoryClass = conf.getChild("transformer-factory").getValue(null);
- this.initTransformerFactory();
-
- this.initNamespacePipe();
-
- }
-
- /**
- * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
- */
- public void recycle() {
- super.recycle();
-
- if (this.namespacePipe != null) {
- this.namespacePipe.recycle();
- }
- }
-
- private void initTransformerFactory() throws ConfigurationException, TransformerFactoryConfigurationError {
- if (transformerFactoryClass != null) {
- try {
- this.tfactory = (SAXTransformerFactory) ClassUtils.newInstance(transformerFactoryClass);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Using transformer factory " + transformerFactoryClass);
- }
- } catch (Exception e) {
- throw new ConfigurationException("Cannot load transformer factory " + transformerFactoryClass, e);
- }
- } else {
- // Standard TrAX behaviour
- this.tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
- }
- tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
- }
-
- private void initNamespacePipe() {
- // Check if we need namespace as attributes.
- try {
- if (needsNamespacesAsAttributes()) {
- // Setup a correction pipe
- this.namespacePipe = new NamespaceAsAttributes();
- this.namespacePipe.enableLogging(getLogger());
- }
- } catch (Exception e) {
- getLogger().warn("Cannot know if transformer needs namespaces attributes - assuming NO.", e);
- }
- }
-
- /**
- * Create the caching key from the formating properties used by the
- * transformer handler that is used for serialization.
- * @param format
- *
- */
- protected static String createCachingKey(Properties format) {
- final StringBuffer buffer = new StringBuffer();
- String value = null;
-
- // Use lookup of the property values instead of just iterating through the
- // enumeration of them to give the caching key a deterministic order of its parts
-
- if ((value = format.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS)) != null) {
- buffer.append(";cdata-section-elements=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.DOCTYPE_PUBLIC)) != null) {
- buffer.append(";doctype-public=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.DOCTYPE_SYSTEM)) != null) {
- buffer.append(";doctype-system=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.ENCODING)) != null) {
- buffer.append(";encoding=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.INDENT)) != null) {
- buffer.append(";indent=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.MEDIA_TYPE)) != null) {
- buffer.append(";media-type=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.METHOD)) != null) {
- buffer.append(";method=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.OMIT_XML_DECLARATION)) != null) {
- buffer.append(";omit-xml-declaration=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.STANDALONE)) != null) {
- buffer.append(";standalone=").append(value);
- }
- if ((value = format.getProperty(OutputKeys.VERSION)) != null) {
- buffer.append(";version=").append(value);
- }
-
- if ( buffer.length() > 0 )
- return buffer.toString();
- else
- return "1";
- }
-
- /**
- * Generate the unique key.
- * This key must be unique inside the space of this component.
- * This method must be invoked before the generateValidity() method.
- *
- * @return The generated key or <code>0</code> if the component
- * is currently not cacheable.
- */
- public java.io.Serializable getKey() {
- return this.cachingKey;
- }
-
- /**
- * Generate the validity object.
- * Before this method can be invoked the generateKey() method
- * must be invoked.
- *
- * @return The generated validity object or <code>null</code> if the
- * component is currently not cacheable.
- */
- public SourceValidity getValidity() {
- return NOPValidity.SHARED_INSTANCE;
- }
-
- /**
- * Checks if the used Trax implementation correctly handles namespaces set using
- * <code>startPrefixMapping()</code>, but wants them also as 'xmlns:' attributes.
- * <p>
- * The check consists in sending SAX events representing a minimal namespaced document
- * with namespaces defined only with calls to <code>startPrefixMapping</code> (no
- * xmlns:xxx attributes) and check if they are present in the resulting text.
- */
- protected boolean needsNamespacesAsAttributes() throws Exception {
-
- SAXTransformerFactory factory = getTransformerFactory();
-
- Boolean cacheValue = (Boolean) needsNamespaceCache.get(factory.getClass().getName());
- if (cacheValue != null) {
- return cacheValue.booleanValue();
- } else {
- // Serialize a minimal document to check how namespaces are handled.
- StringWriter writer = new StringWriter();
-
- String uri = "namespaceuri";
- String prefix = "nsp";
- String check = "xmlns:" + prefix + "='" + uri + "'";
-
- TransformerHandler handler = this.getTransformerHandler();
-
- handler.getTransformer().setOutputProperties(format);
- handler.setResult(new StreamResult(writer));
-
- // Output a single element
- handler.startDocument();
- handler.startPrefixMapping(prefix, uri);
- handler.startElement(uri, "element", "element", XMLUtils.EMPTY_ATTRIBUTES);
- handler.endElement(uri, "element", "element");
- handler.endPrefixMapping(prefix);
- handler.endDocument();
-
- String text = writer.toString();
-
- // Check if the namespace is there (replace " by ' to be sure of what we search in)
- boolean needsIt = (text.replace('"', '\'').indexOf(check) == -1);
-
- String msg = needsIt ? " needs namespace attributes (will be slower)." : " handles correctly namespaces.";
-
- getLogger().debug("Trax handler " + handler.getClass().getName() + msg);
-
- needsNamespaceCache.put(factory.getClass().getName(), BooleanUtils.toBooleanObject(needsIt));
-
- return needsIt;
- }
- }
-
- //--------------------------------------------------------------------------------------------
-
- /**
- * A pipe that ensures that all namespace prefixes are also present as
- * 'xmlns:' attributes. This used to circumvent Xalan's serialization behaviour
- * which is to ignore namespaces if they're not present as 'xmlns:xxx' attributes.
- */
- public static class NamespaceAsAttributes extends AbstractXMLPipe {
-
- /**
- * The prefixes of startPrefixMapping() declarations for the coming element.
- */
- private List prefixList = new ArrayList();
-
- /**
- * The URIs of startPrefixMapping() declarations for the coming element.
- */
- private List uriList = new ArrayList();
-
- /**
- * Maps of URI<->prefix mappings. Used to work around a bug in the Xalan
- * serializer.
- */
- private Map uriToPrefixMap = new HashMap();
- private Map prefixToUriMap = new HashMap();
-
- /**
- * True if there has been some startPrefixMapping() for the coming element.
- */
- private boolean hasMappings = false;
-
- public void startDocument() throws SAXException {
- // Cleanup
- this.uriToPrefixMap.clear();
- this.prefixToUriMap.clear();
- clearMappings();
- super.startDocument();
- }
-
- /**
- * Track mappings to be able to add <code>xmlns:</code> attributes
- * in <code>startElement()</code>.
- */
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- // Store the mappings to reconstitute xmlns:attributes
- // except prefixes starting with "xml": these are reserved
- // VG: (uri != null) fixes NPE in startElement
- if (uri != null && !prefix.startsWith("xml")) {
- this.hasMappings = true;
- this.prefixList.add(prefix);
- this.uriList.add(uri);
-
- // append the prefix colon now, in order to save concatenations later, but
- // only for non-empty prefixes.
- if (prefix.length() > 0) {
- this.uriToPrefixMap.put(uri, prefix + ":");
- } else {
- this.uriToPrefixMap.put(uri, prefix);
- }
-
- this.prefixToUriMap.put(prefix, uri);
- }
- super.startPrefixMapping(prefix, uri);
- }
-
- /**
- * Ensure all namespace declarations are present as <code>xmlns:</code> attributes
- * and add those needed before calling superclass. This is a workaround for a Xalan bug
- * (at least in version 2.0.1) : <code>org.apache.xalan.serialize.SerializerToXML</code>
- * ignores <code>start/endPrefixMapping()</code>.
- */
- public void startElement(String eltUri, String eltLocalName, String eltQName, Attributes attrs)
- throws SAXException {
-
- // try to restore the qName. The map already contains the colon
- if (null != eltUri && eltUri.length() != 0 && this.uriToPrefixMap.containsKey(eltUri)) {
- eltQName = this.uriToPrefixMap.get(eltUri) + eltLocalName;
- }
- if (this.hasMappings) {
- // Add xmlns* attributes where needed
-
- // New Attributes if we have to add some.
- AttributesImpl newAttrs = null;
-
- int mappingCount = this.prefixList.size();
- int attrCount = attrs.getLength();
-
- for (int mapping = 0; mapping < mappingCount; mapping++) {
-
- // Build infos for this namespace
- String uri = (String) this.uriList.get(mapping);
- String prefix = (String) this.prefixList.get(mapping);
- String qName = prefix.equals("") ? "xmlns" : ("xmlns:" + prefix);
-
- // Search for the corresponding xmlns* attribute
- boolean found = false;
- for (int attr = 0; attr < attrCount; attr++) {
- if (qName.equals(attrs.getQName(attr))) {
- // Check if mapping and attribute URI match
- if (!uri.equals(attrs.getValue(attr))) {
- getLogger().error("URI in prefix mapping and attribute do not match : '"
- + uri + "' - '" + attrs.getURI(attr) + "'");
- throw new SAXException("URI in prefix mapping and attribute do not match");
- }
- found = true;
- break;
- }
- }
-
- if (!found) {
- // Need to add this namespace
- if (newAttrs == null) {
- // Need to test if attrs is empty or we go into an infinite loop...
- // Well know SAX bug which I spent 3 hours to remind of :-(
- if (attrCount == 0) {
- newAttrs = new AttributesImpl();
- } else {
- newAttrs = new AttributesImpl(attrs);
- }
- }
-
- if (prefix.equals("")) {
- newAttrs.addAttribute(Constants.XML_NAMESPACE_URI, "xmlns", "xmlns", "CDATA", uri);
- } else {
- newAttrs.addAttribute(Constants.XML_NAMESPACE_URI, prefix, qName, "CDATA", uri);
- }
- }
- } // end for mapping
-
- // Cleanup for the next element
- clearMappings();
-
- // Start element with new attributes, if any
- super.startElement(eltUri, eltLocalName, eltQName, newAttrs == null ? attrs : newAttrs);
- } else {
- // Normal job
- super.startElement(eltUri, eltLocalName, eltQName, attrs);
- }
- }
-
-
- /**
- * Receive notification of the end of an element.
- * Try to restore the element qName.
- */
- public void endElement(String eltUri, String eltLocalName, String eltQName) throws SAXException {
- // try to restore the qName. The map already contains the colon
- if (null != eltUri && eltUri.length() != 0 && this.uriToPrefixMap.containsKey(eltUri)) {
- eltQName = this.uriToPrefixMap.get(eltUri) + eltLocalName;
- }
- super.endElement(eltUri, eltLocalName, eltQName);
- }
-
- /**
- * End the scope of a prefix-URI mapping:
- * remove entry from mapping tables.
- */
- public void endPrefixMapping(String prefix) throws SAXException {
- // remove mappings for xalan-bug-workaround.
- // Unfortunately, we're not passed the uri, but the prefix here,
- // so we need to maintain maps in both directions.
- if (this.prefixToUriMap.containsKey(prefix)) {
- this.uriToPrefixMap.remove(this.prefixToUriMap.get(prefix));
- this.prefixToUriMap.remove(prefix);
- }
-
- if (hasMappings) {
- // most of the time, start/endPrefixMapping calls have an element event between them,
- // which will clear the hasMapping flag and so this code will only be executed in the
- // rather rare occasion when there are start/endPrefixMapping calls with no element
- // event in between. If we wouldn't remove the items from the prefixList and uriList here,
- // the namespace would be incorrectly declared on the next element following the
- // endPrefixMapping call.
- int pos = prefixList.lastIndexOf(prefix);
- if (pos != -1) {
- prefixList.remove(pos);
- uriList.remove(pos);
- }
- }
-
- super.endPrefixMapping(prefix);
- }
-
- /**
- *
- */
- public void endDocument() throws SAXException {
- // Cleanup
- this.uriToPrefixMap.clear();
- this.prefixToUriMap.clear();
- clearMappings();
- super.endDocument();
- }
-
- private void clearMappings() {
- this.hasMappings = false;
- this.prefixList.clear();
- this.uriList.clear();
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractDOMTransformer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractDOMTransformer.java
deleted file mode 100644
index 7a8bc03..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractDOMTransformer.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.apache.cocoon.xml.dom.DOMStreamer;
-
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-import org.xml.sax.Locator;
-import org.xml.sax.Attributes;
-
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * An Abstract DOM Transformer, for use when a transformer needs a DOM-based
- * view of the document.
- * Subclass this interface and implement <code>transform(Document doc)</code>.
- * If you need a ServiceManager there is an instance variable
- * <code>manager</code> for use.
- *
- * @version $Id$
- */
-public abstract class AbstractDOMTransformer extends AbstractTransformer
- implements DOMBuilder.Listener, Serviceable, Disposable {
-
- /**
- * The SAX entity resolver
- */
- protected SourceResolver resolver;
-
- /**
- * The request object model
- */
- protected Map objectModel;
-
- /**
- * The URI requested
- */
- protected String source;
-
- /**
- * Parameters in the sitemap
- */
- protected Parameters parameters;
-
- /**
- * A <code>ServiceManager</code> which is available for use.
- */
- protected ServiceManager manager;
-
- /**
- * The <code>DOMBuilder</code> used to build DOM tree out of
- *incoming SAX events.
- */
- protected DOMBuilder builder;
-
-
- public AbstractDOMTransformer() {
- this.builder = new DOMBuilder(this);
- }
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager aManager) throws ServiceException {
- this.manager = aManager;
- }
-
- /**
- * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
- * the source and sitemap <code>Parameters</code> used to process the request.
- *
- * If you wish to process the parameters, override this method, call
- * <code>super()</code> and then add your code.
- */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
-
- this.resolver = resolver;
- this.objectModel = objectModel;
- this.source = src;
- this.parameters = par;
- }
-
- /**
- * Recycle the component.
- */
- public void recycle() {
- this.resolver = null;
- this.source = null;
- this.objectModel = null;
- this.parameters = null;
- this.builder.recycle();
- super.recycle();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- this.builder = null;
- this.manager = null;
- }
-
- /**
- * This method is called when the Document is finished.
- * @param doc The DOM Document object representing this SAX stream
- * @see org.apache.cocoon.xml.dom.DOMBuilder.Listener
- */
- public void notify(Document doc) throws SAXException {
- // Call the user's transform method
- Document newdoc = transform(doc);
-
- // Now we stream the resulting DOM tree down the pipe
- DOMStreamer s = new DOMStreamer(contentHandler, lexicalHandler);
- s.stream(newdoc);
- }
-
- /**
- * Transform the specified DOM, returning a new DOM to stream down the pipeline.
- * @param doc The DOM Document representing the SAX stream
- * @return A DOM Document to stream down the pipeline
- */
- protected abstract Document transform(Document doc);
-
-
- //
- // SAX Methods. Send incoming SAX events to the DOMBuilder.
- //
-
- public void setDocumentLocator(Locator locator) {
- builder.setDocumentLocator(locator);
- }
-
- public void startDocument() throws SAXException {
- builder.startDocument();
- }
-
- public void endDocument() throws SAXException {
- builder.endDocument();
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- builder.startPrefixMapping(prefix, uri);
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- builder.endPrefixMapping(prefix);
- }
-
- public void startElement(String uri, String loc, String raw, Attributes a)
- throws SAXException {
- builder.startElement(uri, loc, raw, a);
- }
-
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
- builder.endElement(uri, loc, raw);
- }
-
- public void characters(char c[], int start, int len)
- throws SAXException {
- builder.characters(c, start, len);
- }
-
- public void ignorableWhitespace(char c[], int start, int len)
- throws SAXException {
- builder.ignorableWhitespace(c, start, len);
- }
-
- public void processingInstruction(String target, String data)
- throws SAXException {
- builder.processingInstruction(target, data);
- }
-
- public void skippedEntity(String name)
- throws SAXException {
- builder.skippedEntity(name);
- }
-
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- builder.startDTD(name, publicId, systemId);
- }
-
- public void endDTD()
- throws SAXException {
- builder.endDTD();
- }
-
- public void startEntity(String name)
- throws SAXException {
- builder.startEntity(name);
- }
-
- public void endEntity(String name)
- throws SAXException {
- builder.endEntity(name);
- }
-
- public void startCDATA()
- throws SAXException {
- builder.startCDATA();
- }
-
- public void endCDATA()
- throws SAXException {
- builder.endCDATA();
- }
-
- public void comment(char ch[], int start, int len)
- throws SAXException {
- builder.comment(ch, start, len);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractExtractionTransformer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractExtractionTransformer.java
deleted file mode 100644
index ad55b76..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractExtractionTransformer.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.avalon.framework.parameters.Parameters;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-
-/**
- * This transformer sieves an incoming stream of xml
- * and feeds a DOMBuilder with it.
- *
- * @version $Id$
- */
-abstract public class AbstractExtractionTransformer extends AbstractTransformer {
-
- protected DOMBuilder currentBuilder;
-
- private Map prefixMap;
-
- protected int extractLevel;
-
-
- /** Setup the transformer. */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
- throws ProcessingException, SAXException, IOException {
- extractLevel = 0;
- prefixMap = new HashMap();
- }
-
- public void recycle() {
- this.extractLevel = 0;
- this.currentBuilder = null;
- this.prefixMap = null;
- super.recycle();
- }
-
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping.
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- if (extractLevel == 0) {
- super.startPrefixMapping(prefix,uri);
- prefixMap.put(prefix,uri);
- } else {
- this.currentBuilder.startPrefixMapping(prefix,uri);
- }
- }
-
- /**
- * End the scope of a prefix-URI mapping.
- *
- * @param prefix The prefix that was being mapping.
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- if (extractLevel == 0) {
- super.endPrefixMapping(prefix);
- prefixMap.remove(prefix);
- } else {
- this.currentBuilder.endPrefixMapping(prefix);
- }
- }
-
-
- /**
- * Receive notification of the beginning of an element. Uses
- * startExtraction to determine whether to start
- * extracting. Nested triggering tags result in only one document.
- * * startExtractedDocument with the first node of the extracted
- * Document.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- * @param a The attributes attached to the element. If there are no
- * attributes, it shall be an empty Attributes object.
- */
- public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException {
- if (!startExtracting(uri, loc, raw, a)) {
-
- if (extractLevel == 0) {
- super.startElement(uri,loc,raw,a);
- } else {
- this.currentBuilder.startElement(uri,loc,raw,a);
- }
-
- } else {
-
- extractLevel++;
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("extractLevel now " + extractLevel + ".");
- }
-
- if (extractLevel != 1) {
- this.currentBuilder.startElement(uri,loc,raw,a);
- } else {
-
- // setup new document
- this.currentBuilder = new DOMBuilder();
- this.currentBuilder.startDocument();
- // setup namespaces
- Iterator itt = prefixMap.entrySet().iterator();
- while (itt.hasNext()) {
- Map.Entry entry = (Map.Entry)itt.next();
- this.currentBuilder.startPrefixMapping(
- (String)entry.getKey(),
- (String)entry.getValue()
- );
- }
- // start root node
- startExtractingDocument(uri, loc, raw, a);
-
- }
-
- }
- }
-
-
- /**
- * Receive notification of the end of an element. Uses
- * endExtraction to determine whether to stop extracting or
- * not. Calls endExtractedDocument with the extracted document.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- */
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
- if (extractLevel == 0) {
- super.endElement(uri,loc,raw);
- } else {
- if (endExtracting(uri, loc, raw)) {
- extractLevel--;
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("extractLevel now " + extractLevel + ".");
- }
-
- if (extractLevel != 0) {
- this.currentBuilder.endElement(uri,loc,raw);
- } else {
-
- // end root element
- endExtractingDocument(uri, loc, raw);
- // finish building the document. remove existing prefix mappings.
- Iterator itt = prefixMap.entrySet().iterator();
- while (itt.hasNext()) {
- Map.Entry entry = (Map.Entry) itt.next();
- this.currentBuilder.endPrefixMapping(
- (String)entry.getKey()
- );
- }
- this.currentBuilder.endDocument();
-
- handleExtractedDocument(this.currentBuilder.getDocument());
-
- if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("Stored document.");
- }
-
- }
- } else {
- this.currentBuilder.endElement(uri, loc, raw);
- }
- }
- }
-
- /**
- * Receive notification of character data.
- *
- * @param c The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void characters(char c[], int start, int len)
- throws SAXException {
- if (extractLevel == 0) {
- super.characters(c,start,len);
- } else {
- this.currentBuilder.characters(c,start,len);
- }
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- *
- * @param c The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void ignorableWhitespace(char c[], int start, int len)
- throws SAXException {
- if (extractLevel == 0) {
- super.ignorableWhitespace(c,start,len);
- } else {
- this.currentBuilder.ignorableWhitespace(c,start,len);
- }
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if none was
- * supplied.
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- if (extractLevel == 0) {
- super.processingInstruction(target,data);
- } else {
- this.currentBuilder.processingInstruction(target,data);
- }
- }
-
- /**
- * Receive notification of a skipped entity.
- *
- * @param name The name of the skipped entity. If it is a parameter
- * entity, the name will begin with '%'.
- */
- public void skippedEntity(String name)
- throws SAXException {
- if (extractLevel == 0) {
- super.skippedEntity(name);
- } else {
- this.currentBuilder.skippedEntity(name);
- }
- }
-
- /**
- * Report the start of DTD declarations, if any.
- *
- * @param name The document type name.
- * @param publicId The declared public identifier for the external DTD
- * subset, or null if none was declared.
- * @param systemId The declared system identifier for the external DTD
- * subset, or null if none was declared.
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- if (extractLevel == 0) {
- super.startDTD(name,publicId,systemId);
- } else {
- throw new SAXException(
- "Recieved startDTD after beginning fragment extraction process."
- );
- }
- }
-
- /**
- * Report the end of DTD declarations.
- */
- public void endDTD()
- throws SAXException {
- if (extractLevel == 0) {
- super.endDTD();
- } else {
- throw new SAXException(
- "Recieved endDTD after beginning fragment extraction process."
- );
- }
- }
-
- /**
- * Report the beginning of an entity.
- *
- * @param name The name of the entity. If it is a parameter entity, the
- * name will begin with '%'.
- */
- public void startEntity(String name)
- throws SAXException {
- if (extractLevel == 0) {
- super.startEntity(name);
- } else {
- this.currentBuilder.startEntity(name);
- }
- }
-
- /**
- * Report the end of an entity.
- *
- * @param name The name of the entity that is ending.
- */
- public void endEntity(String name)
- throws SAXException {
- if (extractLevel == 0) {
- super.endEntity(name);
- } else {
- this.currentBuilder.endEntity(name);
- }
- }
-
- /**
- * Report the start of a CDATA section.
- */
- public void startCDATA()
- throws SAXException {
- if (extractLevel == 0) {
- super.startCDATA();
- } else {
- this.currentBuilder.startCDATA();
- }
- }
-
- /**
- * Report the end of a CDATA section.
- */
- public void endCDATA()
- throws SAXException {
- if (extractLevel == 0) {
- super.endCDATA();
- } else {
- this.currentBuilder.endCDATA();
- }
- }
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param len The number of characters to use from the array.
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
- if (extractLevel == 0) {
- super.comment(ch,start,len);
- } else {
- this.currentBuilder.comment(ch,start,len);
- }
- }
-
-
-
- /**
- * Receive notification of the beginning of an element and signal extraction start.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- * @param a The attributes attached to the element. If there are no
- * attributes, it shall be an empty Attributes object.
- * @return a <code>boolean</code> value to signal to start extracting
- */
- abstract boolean startExtracting(String uri, String loc, String raw, Attributes a);
-
- /**
- * Receive notification of the beginning of the extracted Document. Per default send
- * startElement message to document builder. Override if necessary. Must override
- * {@link #endExtractingDocument(String, String, String)} as well.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- * @param a The attributes attached to the element. If there are no
- * attributes, it shall be an empty Attributes object.
- */
- public void startExtractingDocument(String uri, String loc, String raw, Attributes a) throws SAXException{
- this.currentBuilder.startElement(uri,loc,raw,a);
- }
-
- /**
- * Receive notification of the end of an element and signal extraction end.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * @return a <code>boolean</code> value to signal to stop extracting
- */
- abstract boolean endExtracting(String uri, String loc, String raw);
-
- /**
- * Receive notification of the end of the extracted Document. Per default,
- * send endElement message to document builder. Override if necessary.
- * Must override
- * {@link #startExtractingDocument(String, String, String, Attributes)}
- * as well.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- */
- public void endExtractingDocument(String uri, String loc, String raw) throws SAXException{
- this.currentBuilder.endElement(uri,loc,raw);
- }
-
- /**
- * Receive notification of the end of the extracted Document.
- *
- * @param doc a <code>Document</code> value
- */
- abstract void handleExtractedDocument(Document doc);
-
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
deleted file mode 100644
index 20d6023..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractSAXTransformer.java
+++ /dev/null
@@ -1,1097 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Context;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Response;
-import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.transformation.helpers.ParametersRecorder;
-import org.apache.cocoon.transformation.helpers.TextRecorder;
-import org.apache.cocoon.util.ClassUtils;
-import org.apache.cocoon.util.TraxErrorHandler;
-import org.apache.cocoon.xml.AttributesImpl;
-import org.apache.cocoon.xml.ImmutableAttributesImpl;
-import org.apache.cocoon.xml.IncludeXMLConsumer;
-import org.apache.cocoon.xml.SaxBuffer;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLUtils;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-
-import org.apache.excalibur.source.SourceParameters;
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Stack;
-
-/**
- * This class is the basis for all transformers. It provides various useful
- * methods and hooks for implementing own custom transformers.
- *
- * <p>The basic behaviour of each transformer consists of the following four
- * parts:</p>
- * <ul>
- * <li>Listen for specific events with a given namespace</li>
- * <li>Collect information via these events</li>
- * <li>Process the information</li>
- * <li>Create new events from the processed information</li>
- * </ul>
- *
- * <p>For all these four purposes the AbstractSAXTransformer offers some
- * powerful methods and hooks:</p>
- *
- * <h3>Namespace handling</h3>
- * By setting the instance variable namespaceURI to the namespace the
- * events are filtered and only events with this namespace are send to
- * the two hooks: <code>startTransformingElement</code> and
- * <code>endTransformingElement</code>. It is possible to override the default
- * namespace for the transformer by specifying the parameter "namespaceURI"
- * in the pipeline. This avoids possible namespace collisions.
- *
- * <h3>Recording of information</h3>
- * There are several methods for recording information, e.g. startRecording(),
- * startTextRecording() etc. These methods collect information from the xml
- * stream for further processing.
- *
- * <h3>Creating new events</h3>
- * New events can be easily created with the <code>sendEvents()</code>
- * method, the <code>sendStartElementEvent()</code> methods, the
- * <code>sendEndElementEvent()</code> method or the
- * <code>sendTextEvent()</code> method.
- *
- * <h3>Initialization</h3>
- * Before the document is processed the <code>setupTransforming</code> hook
- * is invoked.
- *
- * @version $Id$
- */
-public abstract class AbstractSAXTransformer extends AbstractTransformer
- implements Serviceable, Configurable, Disposable {
-
- /**
- * Empty immutable attributes (for performance). Use them
- * whenever creating an element with no attributes.
- */
- protected static final Attributes EMPTY_ATTRIBUTES = XMLUtils.EMPTY_ATTRIBUTES;
-
- /**
- * The trax <code>TransformerFactory</code> used by this transformer.
- */
- private SAXTransformerFactory tfactory;
-
- /**
- * Controlls SAX event handling.
- * If set to true all whitespace events are ignored.
- */
- protected boolean ignoreWhitespaces;
-
- /**
- * Controlls SAX event handling.
- * If set to true all characters events containing only whitespaces
- * are ignored.
- */
- protected boolean ignoreEmptyCharacters;
-
- /**
- * Controlls SAX event handling.
- * If this is incremented all events are not forwarded to the next
- * pipeline component, but the hooks are still called.
- */
- protected int ignoreEventsCount;
-
- /**
- * Controlls SAX event handling.
- * If this is greater than zero, the hooks are not called. Attention,
- * make sure, that you decrement this counter properly as your hooks are
- * not called anymore!
- */
- protected int ignoreHooksCount;
-
- /**
- * The namespace used by the transformer for the SAX events filtering.
- * This either equals to the {@link #defaultNamespaceURI} or to the value
- * set by the <code>namespaceURI</code> sitemap parameter for the pipeline.
- * Must never be null.
- */
- protected String namespaceURI;
-
- /**
- * This is the default namespace used by the transformer.
- * Implementations should set its value in the constructor.
- * Must never be null.
- */
- protected String defaultNamespaceURI;
-
- /**
- * A stack for collecting information.
- * The stack is important for collection information especially when
- * the tags can be nested.
- */
- protected final Stack stack = new Stack();
-
- /**
- * The stack of current used recorders
- */
- protected final Stack recorderStack = new Stack();
-
- /**
- * The current Request object
- */
- protected Request request;
-
- /**
- * The current Response object
- */
- protected Response response;
-
- /**
- * The current Context object
- */
- protected Context context;
-
- /**
- * The current objectModel of the environment
- */
- protected Map objectModel;
-
- /**
- * The parameters specified in the sitemap
- */
- protected Parameters parameters;
-
- /**
- * The source attribute specified in the sitemap
- */
- protected String source;
-
- /**
- * The Avalon ServiceManager for getting Components
- */
- protected ServiceManager manager;
-
- /**
- * The SourceResolver for this request
- */
- protected SourceResolver resolver;
-
- /**
- * Are we already initialized for the current request?
- */
- private boolean isInitialized;
-
- /**
- * The namespaces and their prefixes
- */
- private final List namespaces = new ArrayList(5);
-
- /**
- * The current prefix for our namespace
- */
- private String ourPrefix;
-
- /**
- * Remove namespace prefixes for our namespace?
- * @since 2.2
- */
- protected boolean removeOurNamespacePrefixes = false;
-
- /**
- * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
- */
- public void service(ServiceManager aManager) throws ServiceException {
- this.manager = aManager;
- }
-
- /**
- * @see Configurable#configure(Configuration)
- */
- public void configure(Configuration configuration) throws ConfigurationException {
- String tFactoryClass = configuration.getChild("transformer-factory").getValue(null);
- if (tFactoryClass != null) {
- try {
- this.tfactory = (SAXTransformerFactory) ClassUtils.newInstance(tFactoryClass);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Using transformer factory " + tFactoryClass);
- }
- } catch (Exception e) {
- throw new ConfigurationException("Cannot load transformer factory " + tFactoryClass, e);
- }
- } else {
- // Standard TrAX behaviour
- this.tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
- }
- tfactory.setErrorListener(new TraxErrorHandler(getLogger()));
- }
-
- /**
- * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(SourceResolver, Map, String, Parameters)
- */
- public void setup(SourceResolver resolver,
- Map objectModel,
- String src,
- Parameters params)
- throws ProcessingException, SAXException, IOException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Setup resolver=" + resolver +
- ", objectModel=" + objectModel +
- ", src=" + src +
- ", parameters=" + params);
- }
-
- // defaultNamespaceURI should never be null
- if (this.defaultNamespaceURI == null) {
- this.defaultNamespaceURI = "";
- }
- this.objectModel = objectModel;
-
- this.request = ObjectModelHelper.getRequest(objectModel);
- this.response = ObjectModelHelper.getResponse(objectModel);
- this.context = ObjectModelHelper.getContext(objectModel);
- this.resolver = resolver;
- this.parameters = params;
- this.source = src;
- this.isInitialized = false;
-
- // get the current namespace
- this.namespaceURI = params.getParameter("namespaceURI",
- this.defaultNamespaceURI);
-
- this.ignoreHooksCount = 0;
- this.ignoreEventsCount = 0;
- this.ignoreWhitespaces = true;
- this.ignoreEmptyCharacters = false;
- }
-
- /**
- * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
- */
- public void recycle() {
- this.namespaceURI = null;
- this.objectModel = null;
- this.request = null;
- this.response = null;
- this.context = null;
- this.resolver = null;
- this.stack.clear();
- this.recorderStack.clear();
- this.parameters = null;
- this.source = null;
- this.namespaces.clear();
- this.ourPrefix = null;
-
- super.recycle();
- }
-
- /**
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- this.manager = null;
- }
-
- //
- // SAX ContentHandler methods
- //
-
- /**
- * Process the SAX event.
- * @see ContentHandler#setDocumentLocator
- */
- public void setDocumentLocator(Locator locator) {
- if (this.ignoreEventsCount == 0) {
- super.setDocumentLocator(locator);
- }
- }
-
- /**
- * Process the SAX event. A new document is processed. The hook method
- * {@link #setupTransforming} is invoked.
- * @see ContentHandler#startDocument
- */
- public void startDocument()
- throws SAXException {
- if (!this.isInitialized) {
- try {
- setupTransforming();
- } catch (ProcessingException e) {
- throw new SAXException("ProcessingException: " + e, e);
- } catch (IOException e) {
- throw new SAXException("IOException: " + e, e);
- }
- this.isInitialized = true;
- }
-
- if (this.ignoreEventsCount == 0) {
- super.startDocument();
- }
- }
-
- /**
- * Process the SAX event. The processing of the document is finished.
- * @see org.xml.sax.ContentHandler#endDocument
- */
- public void endDocument()
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.endDocument();
- }
- }
-
- /**
- * Process the SAX event.
- * @see org.xml.sax.ContentHandler#startPrefixMapping
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- boolean isOurPrefix = false;
- if (prefix != null) {
- this.namespaces.add(new String[] {prefix, uri});
- }
- if (namespaceURI.equals(uri)) {
- this.ourPrefix = prefix;
- isOurPrefix = true;
- }
- if (this.ignoreEventsCount == 0) {
- if ( !removeOurNamespacePrefixes || !isOurPrefix) {
- super.startPrefixMapping(prefix, uri);
- }
- }
- }
-
- /**
- * Process the SAX event.
- * @see org.xml.sax.ContentHandler#endPrefixMapping
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- boolean isOurPrefix = false;
- if (prefix != null) {
- // Find and remove the namespace prefix
- boolean found = false;
- for (int i = this.namespaces.size() - 1; i >= 0; i--) {
- final String[] prefixAndUri = (String[]) this.namespaces.get(i);
- if (prefixAndUri[0].equals(prefix)) {
- this.namespaces.remove(i);
- found = true;
- break;
- }
- }
- if (!found) {
- throw new SAXException("Namespace for prefix '" + prefix + "' not found.");
- }
-
- if (prefix.equals(this.ourPrefix)) {
- isOurPrefix = true;
- // Reset our current prefix
- this.ourPrefix = null;
-
- // Now search if we have a different prefix for our namespace
- for (int i = this.namespaces.size() - 1; i >= 0; i--) {
- final String[] prefixAndUri = (String[]) this.namespaces.get(i);
- if (namespaceURI.equals(prefixAndUri[1])) {
- this.ourPrefix = prefixAndUri[0];
- break;
- }
- }
- }
- }
-
- if (this.ignoreEventsCount == 0) {
- if ( !removeOurNamespacePrefixes || !isOurPrefix) {
- super.endPrefixMapping(prefix);
- }
- }
- }
-
- /**
- * Process the SAX event. The namespace of the event is checked.
- * If it is the defined namespace for this transformer,
- * the {@link #startTransformingElement} hook is called.
- * @see org.xml.sax.ContentHandler#startElement
- */
- public void startElement(String uri,
- String name,
- String raw,
- Attributes attr)
- throws SAXException {
- if (namespaceURI.equals(uri) && ignoreHooksCount == 0) {
- // this is our namespace:
- try {
- startTransformingElement(uri, name, raw, attr);
- } catch (ProcessingException e) {
- throw new SAXException("ProcessingException: " + e, e);
- } catch (IOException e) {
- throw new SAXException("IOException occured during processing: " + e, e);
- }
- } else {
- if (ignoreEventsCount == 0) {
- super.startElement(uri, name, raw, attr);
- }
- }
- }
-
- /**
- * Process the SAX event. The namespace of the event is checked.
- * If it is the defined namespace for this transformer,
- * the {@link #endTransformingElement} hook is called.
- * @see org.xml.sax.ContentHandler#endElement
- */
- public void endElement(String uri, String name, String raw)
- throws SAXException {
- if (namespaceURI.equals(uri) && this.ignoreHooksCount == 0) {
- // this is our namespace:
- try {
- endTransformingElement(uri, name, raw);
- } catch (ProcessingException e) {
- throw new SAXException("ProcessingException: " + e, e);
- } catch (IOException e) {
- throw new SAXException("IOException occured during processing: " + e, e);
- }
- } else {
- if (ignoreEventsCount == 0) {
- super.endElement(uri, name, raw);
- }
- }
- }
-
- /**
- * Process the SAX event.
- * @see org.xml.sax.ContentHandler#characters
- */
- public void characters(char[] p0, int p1, int p2)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- if (this.ignoreEmptyCharacters) {
- String value = new String(p0, p1, p2);
- if (value.trim().length() > 0) {
- super.characters(p0, p1, p2);
- }
- } else {
- super.characters(p0, p1, p2);
- }
- }
- }
-
- /**
- * Process the SAX event.
- * @see org.xml.sax.ContentHandler#ignorableWhitespace
- */
- public void ignorableWhitespace(char[] p0, int p1, int p2)
- throws SAXException {
- if (ignoreWhitespaces == false && ignoreEventsCount == 0) {
- super.ignorableWhitespace(p0, p1, p2);
- }
- }
-
- /**
- * Process the SAX event.
- * @see ContentHandler#processingInstruction
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.processingInstruction(target, data);
- }
- }
-
- /**
- * Process the SAX event.
- * @see ContentHandler#skippedEntity
- */
- public void skippedEntity(String name)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.skippedEntity(name);
- }
- }
-
- //
- // SAX LexicalHandler methods
- //
-
- /**
- * @see LexicalHandler#startDTD
- */
- public void startDTD(String name, String public_id, String system_id)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.startDTD(name, public_id, system_id);
- }
- }
-
- /**
- * @see LexicalHandler#endDTD
- */
- public void endDTD() throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.endDTD();
- }
- }
-
- /**
- * @see LexicalHandler#startEntity
- */
- public void startEntity (String name)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.startEntity(name);
- }
- }
-
- /**
- * @see LexicalHandler#endEntity
- */
- public void endEntity (String name)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.endEntity(name);
- }
- }
-
- /**
- * @see LexicalHandler#startCDATA
- */
- public void startCDATA() throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.startCDATA();
- }
- }
-
- /**
- * @see LexicalHandler#endCDATA
- */
- public void endCDATA() throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.endCDATA();
- }
- }
-
- /**
- * @see LexicalHandler#comment
- */
- public void comment(char ary[], int start, int length)
- throws SAXException {
- if (this.ignoreEventsCount == 0) {
- super.comment(ary, start, length);
- }
- }
-
-
- /*
- * Recording of events.
- * With this method all events are not forwarded to the next component in the pipeline.
- * They are recorded to create a document fragment.
- */
-
- private LexicalHandler originalLexicalHandler;
- private ContentHandler originalContentHandler;
-
- /**
- * Add a new recorder to the recording chain.
- * Do not invoke this method directly.
- */
- protected void addRecorder(XMLConsumer recorder) {
- if (this.recorderStack.empty()) {
- // redirect if first (top) recorder
- this.originalLexicalHandler = this.lexicalHandler;
- this.originalContentHandler = this.contentHandler;
- }
- setContentHandler(recorder);
- setLexicalHandler(recorder);
- this.recorderStack.push(recorder);
- }
-
- /**
- * Remove a recorder from the recording chain.
- * Do not invoke this method directly.
- */
- protected Object removeRecorder() {
- Object recorder = this.recorderStack.pop();
- if (this.recorderStack.empty() == true) {
- // undo redirect if no recorder any more
- setContentHandler(originalContentHandler);
- setLexicalHandler(originalLexicalHandler);
- this.originalLexicalHandler = null;
- this.originalContentHandler = null;
- } else {
- XMLConsumer next = (XMLConsumer) recorderStack.peek();
- setContentHandler(next);
- setLexicalHandler(next);
- }
-
- return recorder;
- }
-
- /**
- * Start recording of SAX events.
- * All incoming events are recorded and not forwarded. The resulting
- * XMLizable can be obtained by the matching {@link #endSAXRecording} call.
- * @since 2.1.5
- */
- public void startSAXRecording()
- throws SAXException {
- addRecorder(new SaxBuffer());
- sendStartPrefixMapping();
- }
-
- /**
- * Stop recording of SAX events.
- * This method returns the resulting XMLizable.
- * @since 2.1.5
- */
- public XMLizable endSAXRecording()
- throws SAXException {
- sendEndPrefixMapping();
- return (XMLizable) removeRecorder();
- }
-
- /**
- * Start recording of a text.
- * No events forwarded, and all characters events
- * are collected into a string.
- */
- public void startTextRecording()
- throws SAXException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Start text recording");
- }
- addRecorder(new TextRecorder());
- sendStartPrefixMapping();
- }
-
- /**
- * Stop recording of text and return the recorded information.
- * @return The String, trimmed.
- */
- public String endTextRecording()
- throws SAXException {
- sendEndPrefixMapping();
-
- TextRecorder recorder = (TextRecorder) removeRecorder();
- String text = recorder.getText();
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("End text recording. Text=" + text);
- }
- return text;
- }
-
- /**
- * Start recording of serialized xml
- * All events are converted to an xml string which can be retrieved by
- * endSerializedXMLRecording.
- * @param format The format for the serialized output. If <CODE>null</CODE>
- * is specified, the default format is used.
- */
- public void startSerializedXMLRecording(Properties format)
- throws SAXException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Start serialized XML recording. Format=" + format);
- }
- this.stack.push(format == null? XMLUtils.createPropertiesForXML(false): format);
- startSAXRecording();
- }
-
- /**
- * Return the serialized xml string.
- * @return A string containing the recorded xml information, formatted by
- * the properties passed to the corresponding startSerializedXMLRecording().
- */
- public String endSerializedXMLRecording()
- throws SAXException, ProcessingException {
- XMLizable xml = endSAXRecording();
- String text = XMLUtils.serialize(xml, (Properties) this.stack.pop());
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("End serialized XML recording. XML=" + text);
- }
- return text;
- }
-
- /**
- * Start recording of parameters.
- * All events are not forwarded and the incoming xml is converted to
- * parameters. Each toplevel node is a parameter and its text subnodes
- * form the value.
- * The Parameters can eiter be retrieved by endParametersRecording().
- */
- public void startParametersRecording()
- throws SAXException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Start parameters recording");
- }
- addRecorder(new ParametersRecorder());
- sendStartPrefixMapping();
- }
-
- /**
- * End recording of parameters
- * If source is null a new parameters object is created, otherwise
- * the parameters are added to this object.
- * @param additionalParameters An optional parameters object.
- * @return The object containing all parameters.
- */
- public SourceParameters endParametersRecording(Parameters additionalParameters)
- throws SAXException {
- sendEndPrefixMapping();
-
- final ParametersRecorder recorder = (ParametersRecorder) this.removeRecorder();
- final SourceParameters sourceParameters = recorder.getParameters(additionalParameters);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("End parameters recording. Parameters=" + sourceParameters);
- }
- return sourceParameters;
- }
-
- /**
- * End recording of parameters
- * If source is null a new parameters object is created, otherwise
- * the parameters are added to this object.
- * @param additionalParameters An optional parameters object.
- * @return The object containing all parameters.
- */
- public SourceParameters endParametersRecording(SourceParameters additionalParameters)
- throws SAXException {
- sendEndPrefixMapping();
-
- final ParametersRecorder recorder = (ParametersRecorder) removeRecorder();
- final SourceParameters sourceParameters = recorder.getParameters(additionalParameters);
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("End parameters recording. Parameters=" + sourceParameters);
- }
- return sourceParameters;
- }
-
- /**
- * Start DOM DocumentFragment recording.
- * All incoming events are recorded and not forwarded. The resulting
- * DocumentFragment can be obtained by the matching {@link #endRecording} call.
- */
- public void startRecording()
- throws SAXException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Start recording");
- }
- DOMBuilder builder = new DOMBuilder(this.tfactory);
- addRecorder(builder);
- builder.startDocument();
- builder.startElement("", "cocoon", "cocoon", EMPTY_ATTRIBUTES);
- sendStartPrefixMapping();
- }
-
- /**
- * Stop DOM DocumentFragment recording.
- * This method returns the resulting DocumentFragment, normalized.
- */
- public DocumentFragment endRecording()
- throws SAXException {
- sendEndPrefixMapping();
-
- DOMBuilder builder = (DOMBuilder) removeRecorder();
- builder.endElement("", "cocoon", "cocoon");
- builder.endDocument();
-
- // Create Document Fragment
- final Document doc = builder.getDocument();
- final DocumentFragment fragment = doc.createDocumentFragment();
- final Node root = doc.getDocumentElement();
-
- // Remove empty text nodes and collapse neighbouring text nodes
- root.normalize();
-
- // Move all nodes into the fragment
- boolean space = true;
- while (root.hasChildNodes()) {
- Node child = root.getFirstChild();
- root.removeChild(child);
-
- // Leave out leading whitespace nodes
- // FIXME: Why leading spaces are trimmed at all? Why not trailing spaces?
- if (space && child.getNodeType() == Node.TEXT_NODE
- && child.getNodeValue().trim().length() == 0) {
- continue;
- }
- space = false;
-
- fragment.appendChild(child);
- }
-
- if (getLogger().isDebugEnabled()) {
- Object serializedXML = null;
- try {
- serializedXML = fragment == null? "null": XMLUtils.serializeNode(fragment);
- } catch (ProcessingException ignore) {
- serializedXML = fragment;
- }
- getLogger().debug("End recording. Fragment=" + serializedXML);
- }
-
- return fragment;
- }
-
- //
- // Hooks
- //
-
- /**
- * Setup the transformation of an xml document.
- * This method is called just before the transformation (sending of sax events)
- * starts. It should be used to initialize setup parameter depending on the
- * object modell.
- */
- public void setupTransforming()
- throws IOException, ProcessingException, SAXException {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("setupTransforming");
- }
- this.stack.clear();
- this.recorderStack.clear();
- this.ignoreWhitespaces = true;
- this.ignoreEmptyCharacters = false;
- }
-
- /**
- * Start processing elements of our namespace.
- * This hook is invoked for each sax event with our namespace.
- * @param uri The namespace of the element.
- * @param name The local name of the element.
- * @param raw The qualified name of the element.
- * @param attr The attributes of the element.
- */
- public void startTransformingElement(String uri,
- String name,
- String raw,
- Attributes attr)
- throws ProcessingException, IOException, SAXException {
- if (this.ignoreEventsCount == 0) {
- super.startElement(uri, name, raw, attr);
- }
- }
-
- /**
- * Start processing elements of our namespace.
- * This hook is invoked for each sax event with our namespace.
- * @param uri The namespace of the element.
- * @param name The local name of the element.
- * @param raw The qualified name of the element.
- */
- public void endTransformingElement(String uri,
- String name,
- String raw)
- throws ProcessingException, IOException, SAXException {
- if (this.ignoreEventsCount == 0) {
- super.endElement(uri, name, raw);
- }
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The characters event for the given text is send to the next
- * component in the current pipeline.
- * @param text The string containing the information.
- */
- public void sendTextEvent(String text)
- throws SAXException {
- characters(text.toCharArray(), 0, text.length());
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The startElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has no namespace and no attributes
- * @param localname The name of the event.
- */
- public void sendStartElementEvent(String localname)
- throws SAXException {
- startElement("", localname, localname, EMPTY_ATTRIBUTES);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The startElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has the namespace of the transformer,
- * but not attributes
- * @param localname The name of the event.
- */
- public void sendStartElementEventNS(String localname)
- throws SAXException {
- startElement(this.namespaceURI,
- localname, this.ourPrefix + ':' + localname, EMPTY_ATTRIBUTES);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The startElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has no namespace.
- * @param localname The name of the event.
- * @param attr The Attributes of the element
- */
- public void sendStartElementEvent(String localname, Attributes attr)
- throws SAXException {
- startElement("", localname, localname, attr);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The startElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has the namespace of the transformer.
- * @param localname The name of the event.
- * @param attr The Attributes of the element
- */
- public void sendStartElementEventNS(String localname, Attributes attr)
- throws SAXException {
- startElement(this.namespaceURI,
- localname, this.ourPrefix + ':' + localname, attr);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The endElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has no namespace.
- * @param localname The name of the event.
- */
- public void sendEndElementEvent(String localname)
- throws SAXException {
- endElement("", localname, localname);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The endElement event for the given element is send
- * to the next component in the current pipeline.
- * The element has the namespace of the transformer.
- * @param localname The name of the event.
- */
- public void sendEndElementEventNS(String localname)
- throws SAXException {
- endElement(this.namespaceURI,
- localname, this.ourPrefix + ':' + localname);
- }
-
- /**
- * Send SAX events to the next pipeline component.
- * The node is parsed and the events are send to
- * the next component in the pipeline.
- * @param node The tree to be included.
- */
- public void sendEvents(Node node)
- throws SAXException {
- IncludeXMLConsumer.includeNode(node, this, this);
- }
-
- /**
- * Send SAX events for the <code>SourceParameters</code>.
- * For each parametername/value pair an element is
- * created with the name of the parameter and the content
- * of this element is the value.
- */
- public void sendParametersEvents(SourceParameters pars)
- throws SAXException {
- if (pars != null) {
- Iterator names = pars.getParameterNames();
- while (names.hasNext()) {
- final String currentName = (String)names.next();
- Iterator values = pars.getParameterValues(currentName);
- while (values.hasNext()) {
- final String currentValue = (String)values.next();
- sendStartElementEvent(currentName);
- sendTextEvent(currentValue);
- sendEndElementEvent(currentName);
- }
- }
- }
- }
-
- /**
- * Send all start prefix mapping events to the current content handler
- */
- protected void sendStartPrefixMapping()
- throws SAXException {
- final int l = this.namespaces.size();
- for (int i = 0; i < l; i++) {
- String[] prefixAndUri = (String[]) this.namespaces.get(i);
- super.contentHandler.startPrefixMapping(prefixAndUri[0], prefixAndUri[1]);
- }
- }
-
- /**
- * Send all end prefix mapping events to the current content handler
- */
- protected void sendEndPrefixMapping()
- throws SAXException {
- final int l = this.namespaces.size();
- for (int i = 0; i < l; i++) {
- String[] prefixAndUri = (String[]) this.namespaces.get(i);
- super.contentHandler.endPrefixMapping(prefixAndUri[0]);
- }
- }
-
- /**
- * Find prefix mapping for the given namespace URI.
- * @return Prefix mapping or null if no prefix defined
- */
- protected String findPrefixMapping(String uri) {
- final int l = this.namespaces.size();
- for (int i = 0; i < l; i++) {
- String[] prefixAndUri = (String[]) this.namespaces.get(i);
- if (prefixAndUri[1].equals(uri)) {
- return prefixAndUri[0];
- }
- }
-
- return null;
- }
-
- /**
- * Helper method to get a modifiable attribute set.
- */
- protected AttributesImpl getMutableAttributes(Attributes a) {
- if ( a instanceof AttributesImpl && !(a instanceof ImmutableAttributesImpl)) {
- return (AttributesImpl)a;
- }
- return new AttributesImpl(a);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractTransformer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractTransformer.java
deleted file mode 100644
index 221ccc6..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/AbstractTransformer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation;
-
-import org.apache.cocoon.xml.AbstractXMLPipe;
-
-/**
- *
- * @version $Id$
- */
-
-public abstract class AbstractTransformer extends AbstractXMLPipe implements Transformer {
- // nothing do add here
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/ServiceableTransformer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/ServiceableTransformer.java
deleted file mode 100644
index 4d2d7aa..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/ServiceableTransformer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.SourceResolver;
-import org.xml.sax.SAXException;
-
-/**
- * This class can be used as a base class for own transformer implementations
- * that need to lookup other components.
- *
- * @version $Id$
- */
-
-public abstract class ServiceableTransformer
- extends AbstractTransformer
- implements Serviceable, Disposable {
-
- /** The current <code>SourceResolver</code>. */
- protected SourceResolver resolver;
- /** The current <code>Map</code> objectModel. */
- protected Map objectModel;
- /** The current <code>Parameters</code>. */
- protected Parameters parameters;
- /** The source URI associated with the request or <b>null</b>. */
- protected String source;
- /** The ServiceManager */
- protected ServiceManager manager;
-
- /**
- * Set the <code>SourceResolver</code>, object model <code>Map</code>,
- * the source and sitemap <code>Parameters</code> used to process the request.
- */
- public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
- throws ProcessingException, SAXException, IOException {
- this.resolver = resolver;
- this.objectModel = objectModel;
- this.source = src;
- this.parameters = par;
- }
-
- /**
- * Recycle the generator by removing references
- */
- public void recycle() {
- super.recycle();
- this.resolver = null;
- this.objectModel = null;
- this.source = null;
- this.parameters = null;
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager aManager) throws ServiceException {
- this.manager = aManager;
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- public void dispose() {
- this.manager = null;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/NOPRecorder.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/NOPRecorder.java
deleted file mode 100644
index 334905b..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/NOPRecorder.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation.helpers;
-
-import org.apache.cocoon.xml.XMLConsumer;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * The base class for all recorders. Simply does nothing
- *
- * @version $Id$
-*/
-public abstract class NOPRecorder
-implements ContentHandler, LexicalHandler, XMLConsumer {
-
- public NOPRecorder() {
- }
-
- public void setDocumentLocator(Locator locator) {
- }
-
- public void startDocument()
- throws SAXException {
- }
-
- public void endDocument()
- throws SAXException {
- }
-
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- }
-
- public void endPrefixMapping(String prefix)
- throws SAXException {
- }
-
- public void startElement(String namespace, String name, String raw,
- Attributes attr)
- throws SAXException {
- }
-
- public void endElement(String namespace, String name, String raw)
- throws SAXException {
- }
-
- public void characters(char ary[], int start, int length)
- throws SAXException {
- }
-
- public void ignorableWhitespace(char ary[], int start, int length)
- throws SAXException {
- }
-
- public void processingInstruction(String target, String data)
- throws SAXException {
- }
-
- public void skippedEntity(String name)
- throws SAXException {
- }
-
- public void startDTD(String name, String public_id, String system_id)
- throws SAXException {
- }
-
- public void endDTD() throws SAXException {
- }
-
- public void startEntity(String name) throws SAXException {
- }
-
- public void endEntity(String name) throws SAXException {
- }
-
- public void startCDATA() throws SAXException {
- }
-
- public void endCDATA() throws SAXException {
- }
-
- public void comment(char ary[], int start, int length)
- throws SAXException {
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/ParametersRecorder.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/ParametersRecorder.java
deleted file mode 100644
index 95072cf..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/ParametersRecorder.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation.helpers;
-
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.excalibur.source.SourceParameters;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import java.util.Iterator;
-
-
-/**
- * This class records SAX Events and generates Parameters from them
- * The xml is flat and consists of elements which all have exactly one text node:
- * <parone>value_one<parone>
- * <partwo>value_two<partwo>
- *
- * @version $Id$
- */
-public final class ParametersRecorder
-extends NOPRecorder {
-
- private SourceParameters parameters;
- private String key;
- private StringBuffer buffer;
-
- /**
- * If source is null a new Parameters object is created
- * Otherwise they are joined.
- */
- public ParametersRecorder() {
- super();
- this.parameters = new SourceParameters();
- }
-
- public SourceParameters getParameters(Parameters source) {
- if (source != null) {
- String[] names = source.getNames();
- for(int i=0; i<names.length; i++) {
- final String currentParameterName = names[i];
- this.parameters.setParameter(currentParameterName, source.getParameter(currentParameterName, ""));
- }
- }
- return parameters;
- }
-
- public SourceParameters getParameters(SourceParameters source) {
- if (source != null) {
- Iterator iter = source.getParameterNames();
- Iterator valuesIter;
- String value, parName;
- while (iter.hasNext() == true) {
- parName = (String)iter.next();
- valuesIter = source.getParameterValues(parName);
- while (valuesIter.hasNext() == true) {
- value = (String)valuesIter.next();
- this.parameters.setParameter(parName, value);
- }
- }
- }
- return parameters;
- }
-
- public void startElement(String namespace, String name, String raw,
- Attributes attr)
- throws SAXException {
- if (this.key == null) {
- this.key = name;
- this.buffer = new StringBuffer();
- }
- }
-
- public void endElement(String namespace, String name, String raw)
- throws SAXException {
- if (this.key != null && this.key.equals(name) == true) {
- String value = this.buffer.toString().trim();
- if (value.length() > 0) {
- this.parameters.setParameter(this.key, value);
- }
- this.buffer = null;
- this.key = null;
- }
- }
-
- public void characters(char ary[], int start, int length)
- throws SAXException {
- if (this.key != null && this.buffer != null) {
- String value = new String(ary, start, length).trim();
- if (value.length() > 0) {
- buffer.append(value);
- } else {
- buffer.append(' ');
- }
- }
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/TextRecorder.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/TextRecorder.java
deleted file mode 100644
index 4b6331f..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/transformation/helpers/TextRecorder.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.transformation.helpers;
-
-/**
- * This class records all character SAX events and creates a string
- * from them.
- *
- * @version $Id$
- */
-public final class TextRecorder extends NOPRecorder {
-
- /**
- * Buffer collecting all character events.
- */
- private StringBuffer buffer;
-
- public TextRecorder() {
- super();
- this.buffer = new StringBuffer();
- }
-
- public void characters(char ary[], int start, int length) {
- this.buffer.append(ary, start, length);
- }
-
- /**
- * @return Recorded text so far, trimmed.
- */
- public String getText() {
- return this.buffer.toString().trim();
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java
deleted file mode 100644
index 0ec727a..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractSAXFragment.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.w3c.dom.Node;
-import org.xml.sax.ContentHandler;
-
-/**
- * Abstract implementation of {@link XMLFragment} for objects that are more
- * easily represented as SAX events.
- *
- * <p>The {@link #toDOM} method is implemented by piping in a {@link DOMBuilder}
- * the results of {@link #toSAX(ContentHandler)} that must be implemented by concrete
- * subclasses.</p>
- *
- * @version $Id$
- */
-public abstract class AbstractSAXFragment implements XMLFragment {
-
- /**
- * Appends children representing the object's state to the given node
- * by using the results of <code>toSAX()</code>.
- */
- public void toDOM(Node node) throws Exception {
- toSAX(new DOMBuilder(node));
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java
deleted file mode 100644
index 23accf1..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLConsumer.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- * This abstract class provides default implementation of the methods specified
- * by the <code>XMLConsumer</code> interface.
- *
- * @version $Id$
- */
-public abstract class AbstractXMLConsumer extends AbstractLogEnabled implements XMLConsumer {
-
- /**
- * Receive an object for locating the origin of SAX document events.
- *
- * @param locator An object that can return the location of any SAX
- * document event.
- */
- public void setDocumentLocator(Locator locator) {
- }
-
- /**
- * Receive notification of the beginning of a document.
- */
- public void startDocument()
- throws SAXException {
- }
-
- /**
- * Receive notification of the end of a document.
- */
- public void endDocument()
- throws SAXException {
- }
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping.
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- }
-
- /**
- * End the scope of a prefix-URI mapping.
- *
- * @param prefix The prefix that was being mapping.
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- }
-
- /**
- * Receive notification of the beginning of an element.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- * @param a The attributes attached to the element. If there are no
- * attributes, it shall be an empty Attributes object.
- */
- public void startElement(String uri, String loc, String raw, Attributes a)
- throws SAXException {
- }
-
-
- /**
- * Receive notification of the end of an element.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- */
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
- }
-
- /**
- * Receive notification of character data.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void characters(char ch[], int start, int len)
- throws SAXException {
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void ignorableWhitespace(char ch[], int start, int len)
- throws SAXException {
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if none was
- * supplied.
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- }
-
- /**
- * Receive notification of a skipped entity.
- *
- * @param name The name of the skipped entity. If it is a parameter
- * entity, the name will begin with '%'.
- */
- public void skippedEntity(String name)
- throws SAXException {
- }
-
- /**
- * Report the start of DTD declarations, if any.
- *
- * @param name The document type name.
- * @param publicId The declared public identifier for the external DTD
- * subset, or null if none was declared.
- * @param systemId The declared system identifier for the external DTD
- * subset, or null if none was declared.
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- }
-
- /**
- * Report the end of DTD declarations.
- */
- public void endDTD()
- throws SAXException {
- }
-
- /**
- * Report the beginning of an entity.
- *
- * @param name The name of the entity. If it is a parameter entity, the
- * name will begin with '%'.
- */
- public void startEntity(String name)
- throws SAXException {
- }
-
- /**
- * Report the end of an entity.
- *
- * @param name The name of the entity that is ending.
- */
- public void endEntity(String name)
- throws SAXException {
- }
-
- /**
- * Report the start of a CDATA section.
- */
- public void startCDATA()
- throws SAXException {
- }
-
- /**
- * Report the end of a CDATA section.
- */
- public void endCDATA()
- throws SAXException {
- }
-
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param len The number of characters to use from the array.
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java
deleted file mode 100644
index 98db0bd..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLPipe.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-/**
- * This class provides a bridge class to connect to existing content
- * handlers and lexical handlers.
- *
- * @version $Id$
- */
-public abstract class AbstractXMLPipe extends AbstractXMLProducer
- implements XMLPipe {
-
- /**
- * Receive an object for locating the origin of SAX document events.
- *
- * @param locator An object that can return the location of any SAX
- * document event.
- */
- public void setDocumentLocator(Locator locator) {
- contentHandler.setDocumentLocator(locator);
- }
-
- /**
- * Receive notification of the beginning of a document.
- */
- public void startDocument()
- throws SAXException {
- contentHandler.startDocument();
- }
-
- /**
- * Receive notification of the end of a document.
- */
- public void endDocument()
- throws SAXException {
- contentHandler.endDocument();
- }
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping.
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- contentHandler.startPrefixMapping(prefix, uri);
- }
-
- /**
- * End the scope of a prefix-URI mapping.
- *
- * @param prefix The prefix that was being mapping.
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- contentHandler.endPrefixMapping(prefix);
- }
-
- /**
- * Receive notification of the beginning of an element.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- * @param a The attributes attached to the element. If there are no
- * attributes, it shall be an empty Attributes object.
- */
- public void startElement(String uri, String loc, String raw, Attributes a)
- throws SAXException {
- contentHandler.startElement(uri, loc, raw, a);
- }
-
-
- /**
- * Receive notification of the end of an element.
- *
- * @param uri The Namespace URI, or the empty string if the element has no
- * Namespace URI or if Namespace
- * processing is not being performed.
- * @param loc The local name (without prefix), or the empty string if
- * Namespace processing is not being performed.
- * @param raw The raw XML 1.0 name (with prefix), or the empty string if
- * raw names are not available.
- */
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
- contentHandler.endElement(uri, loc, raw);
- }
-
- /**
- * Receive notification of character data.
- *
- * @param c The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void characters(char c[], int start, int len)
- throws SAXException {
- contentHandler.characters(c, start, len);
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- *
- * @param c The characters from the XML document.
- * @param start The start position in the array.
- * @param len The number of characters to read from the array.
- */
- public void ignorableWhitespace(char c[], int start, int len)
- throws SAXException {
- contentHandler.ignorableWhitespace(c, start, len);
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if none was
- * supplied.
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- contentHandler.processingInstruction(target, data);
- }
-
- /**
- * Receive notification of a skipped entity.
- *
- * @param name The name of the skipped entity. If it is a parameter
- * entity, the name will begin with '%'.
- */
- public void skippedEntity(String name)
- throws SAXException {
- contentHandler.skippedEntity(name);
- }
-
- /**
- * Report the start of DTD declarations, if any.
- *
- * @param name The document type name.
- * @param publicId The declared public identifier for the external DTD
- * subset, or null if none was declared.
- * @param systemId The declared system identifier for the external DTD
- * subset, or null if none was declared.
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- lexicalHandler.startDTD(name, publicId, systemId);
- }
-
- /**
- * Report the end of DTD declarations.
- */
- public void endDTD()
- throws SAXException {
- lexicalHandler.endDTD();
- }
-
- /**
- * Report the beginning of an entity.
- *
- * @param name The name of the entity. If it is a parameter entity, the
- * name will begin with '%'.
- */
- public void startEntity(String name)
- throws SAXException {
- lexicalHandler.startEntity(name);
- }
-
- /**
- * Report the end of an entity.
- *
- * @param name The name of the entity that is ending.
- */
- public void endEntity(String name)
- throws SAXException {
- lexicalHandler.endEntity(name);
- }
-
- /**
- * Report the start of a CDATA section.
- */
- public void startCDATA()
- throws SAXException {
- lexicalHandler.startCDATA();
- }
-
- /**
- * Report the end of a CDATA section.
- */
- public void endCDATA()
- throws SAXException {
- lexicalHandler.endCDATA();
- }
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param len The number of characters to use from the array.
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
- lexicalHandler.comment(ch, start, len);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java
deleted file mode 100644
index 219a5e1..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AbstractXMLProducer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.apache.avalon.excalibur.pool.Recyclable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * This abstract class provides default implementation of the methods specified
- * by the <code>XMLProducer</code> interface.
- *
- * @version $Id$
- */
-public abstract class AbstractXMLProducer extends AbstractLogEnabled
- implements XMLProducer, Recyclable {
-
- protected static final ContentHandler EMPTY_CONTENT_HANDLER = new DefaultHandler();
-
- /** The <code>XMLConsumer</code> receiving SAX events. */
- protected XMLConsumer xmlConsumer;
-
- /** The <code>ContentHandler</code> receiving SAX events. */
- protected ContentHandler contentHandler = EMPTY_CONTENT_HANDLER;
-
- /** The <code>LexicalHandler</code> receiving SAX events. */
- protected LexicalHandler lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
-
- /**
- * Set the <code>XMLConsumer</code> that will receive XML data.
- * <br>
- * This method will simply call <code>setContentHandler(consumer)</code>
- * and <code>setLexicalHandler(consumer)</code>.
- */
- public void setConsumer(XMLConsumer consumer) {
- this.xmlConsumer = consumer;
- setContentHandler(consumer);
- setLexicalHandler(consumer);
- }
-
- /**
- * Set the <code>ContentHandler</code> that will receive XML data.
- * <br>
- * Subclasses may retrieve this <code>ContentHandler</code> instance
- * accessing the protected <code>super.contentHandler</code> field.
- */
- public void setContentHandler(ContentHandler handler) {
- this.contentHandler = handler;
- }
-
- /**
- * Set the <code>LexicalHandler</code> that will receive XML data.
- * <br>
- * Subclasses may retrieve this <code>LexicalHandler</code> instance
- * accessing the protected <code>super.lexicalHandler</code> field.
- */
- public void setLexicalHandler(LexicalHandler handler) {
- this.lexicalHandler = handler;
- }
-
- /**
- * Recycle the producer by removing references, and resetting handlers to
- * null (empty) implementations.
- */
- public void recycle() {
- this.xmlConsumer = null;
- this.contentHandler = EMPTY_CONTENT_HANDLER;
- this.lexicalHandler = DefaultLexicalHandler.NULL_HANDLER;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AttributesImpl.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AttributesImpl.java
deleted file mode 100644
index 2b03602..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/AttributesImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.Attributes;
-
-/**
- * A helper Class creating SAX Attributes
- *
- * @version $Id$
- */
-public class AttributesImpl extends org.xml.sax.helpers.AttributesImpl {
-
- /**
- * Constructor
- */
- public AttributesImpl() {
- super();
- }
-
- /**
- * Constructor
- */
- public AttributesImpl(Attributes attr) {
- super(attr);
- }
-
- /**
- * Add an attribute of type CDATA with empty Namespace to the end of the list.
- *
- * <p>For the sake of speed, this method does no checking
- * to see if the attribute is already in the list: that is
- * the responsibility of the application.</p>
- *
- * @param localName The local name.
- * @param value The attribute value.
- */
- public void addCDATAAttribute(String localName, String value) {
- addAttribute("", localName, localName, AttributeTypes.CDATA, value);
- }
-
- /**
- * Add an attribute of type CDATA with the namespace to the end of the list.
- *
- * <p>For the sake of speed, this method does no checking
- * to see if the attribute is already in the list: that is
- * the responsibility of the application.</p>
- *
- * @param namespace The namespace.
- * @param localName The local name.
- * @param value The attribute value.
- */
- public void addCDATAAttribute(String namespace, String localName, String value) {
- addAttribute(namespace, localName, localName, AttributeTypes.CDATA, value);
- }
-
- /**
- * Add an attribute of type CDATA to the end of the list.
- *
- * <p>For the sake of speed, this method does no checking
- * to see if the attribute is already in the list: that is
- * the responsibility of the application.</p>
- *
- * @param uri The Namespace URI, or the empty string if
- * none is available or Namespace processing is not
- * being performed.
- * @param localName The local name, or the empty string if
- * Namespace processing is not being performed.
- * @param qName The qualified (prefixed) name, or the empty string
- * if qualified names are not available.
- * @param value The attribute value.
- */
- public void addCDATAAttribute(String uri,
- String localName,
- String qName,
- String value) {
- addAttribute(uri, localName, qName, AttributeTypes.CDATA, value);
- }
-
- /**
- * Remove an attribute
- */
- public void removeAttribute(String localName) {
- final int index = this.getIndex(localName);
- if ( index != -1 ) {
- this.removeAttribute(index);
- }
- }
-
- /**
- * Remove an attribute
- */
- public void removeAttribute(String uri, String localName) {
- final int index = this.getIndex(uri, localName);
- if ( index != -1 ) {
- this.removeAttribute(index);
- }
- }
-}
-
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java
deleted file mode 100644
index 536dc3e..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ContentHandlerWrapper.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.apache.avalon.excalibur.pool.Recyclable;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class is an utility class "wrapping" around a SAX version 2.0
- * <code>ContentHandler</code> and forwarding it those events received throug
- * its <code>XMLConsumers</code> interface.
- * <br>
- *
- * @version $Id$
- */
-public class ContentHandlerWrapper extends AbstractXMLConsumer implements Recyclable {
-
- /** The current <code>ContentHandler</code>. */
- protected ContentHandler contentHandler;
-
- /** The optional <code>LexicalHandler</code> */
- protected LexicalHandler lexicalHandler;
-
- /**
- * Create a new <code>ContentHandlerWrapper</code> instance.
- */
- public ContentHandlerWrapper() {
- super();
- }
-
- /**
- * Create a new <code>ContentHandlerWrapper</code> instance.
- */
- public ContentHandlerWrapper(ContentHandler contentHandler) {
- this();
- this.setContentHandler(contentHandler);
- }
-
- /**
- * Create a new <code>ContentHandlerWrapper</code> instance.
- */
- public ContentHandlerWrapper(ContentHandler contentHandler,
- LexicalHandler lexicalHandler) {
- this();
- this.setContentHandler(contentHandler);
- this.setLexicalHandler(lexicalHandler);
- }
-
- /**
- * Set the <code>ContentHandler</code> that will receive XML data.
- *
- * @exception IllegalStateException If the <code>ContentHandler</code>
- * was already set.
- */
- public void setContentHandler(ContentHandler contentHandler)
- throws IllegalStateException {
- if (this.contentHandler!=null) throw new IllegalStateException();
- this.contentHandler=contentHandler;
- }
-
- /**
- * Set the <code>LexicalHandler</code> that will receive XML data.
- *
- * @exception IllegalStateException If the <code>LexicalHandler</code>
- * was already set.
- */
- public void setLexicalHandler(LexicalHandler lexicalHandler)
- throws IllegalStateException {
- if (this.lexicalHandler!=null) throw new IllegalStateException();
- this.lexicalHandler=lexicalHandler;
- }
-
- public void recycle () {
- this.contentHandler = null;
- this.lexicalHandler = null;
- }
-
- /**
- * Receive an object for locating the origin of SAX document events.
- */
- public void setDocumentLocator (Locator locator) {
- if (this.contentHandler==null) return;
- else this.contentHandler.setDocumentLocator(locator);
- }
-
- /**
- * Receive notification of the beginning of a document.
- */
- public void startDocument ()
- throws SAXException {
- if (this.contentHandler==null)
- throw new SAXException("ContentHandler not set");
- this.contentHandler.startDocument();
- }
-
- /**
- * Receive notification of the end of a document.
- */
- public void endDocument ()
- throws SAXException {
- this.contentHandler.endDocument();
- }
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping.
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- if (this.contentHandler==null)
- throw new SAXException("ContentHandler not set");
- this.contentHandler.startPrefixMapping(prefix, uri);
- }
-
- /**
- * End the scope of a prefix-URI mapping.
- */
- public void endPrefixMapping(String prefix)
- throws SAXException {
- this.contentHandler.endPrefixMapping(prefix);
- }
-
- /**
- * Receive notification of the beginning of an element.
- */
- public void startElement(String uri, String loc, String raw, Attributes a)
- throws SAXException {
- this.contentHandler.startElement(uri, loc, raw, a);
- }
-
-
- /**
- * Receive notification of the end of an element.
- */
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
- this.contentHandler.endElement(uri, loc, raw);
- }
-
- /**
- * Receive notification of character data.
- */
- public void characters(char ch[], int start, int len)
- throws SAXException {
- this.contentHandler.characters(ch,start,len);
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- */
- public void ignorableWhitespace(char ch[], int start, int len)
- throws SAXException {
- this.contentHandler.ignorableWhitespace(ch,start,len);
- }
-
- /**
- * Receive notification of a processing instruction.
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- this.contentHandler.processingInstruction(target,data);
- }
-
- /**
- * Receive notification of a skipped entity.
- *
- * @param name The name of the skipped entity. If it is a parameter
- * entity, the name will begin with '%'.
- */
- public void skippedEntity(String name)
- throws SAXException {
- this.contentHandler.skippedEntity(name);
- }
-
- /**
- * Report the start of DTD declarations, if any.
- *
- * @param name The document type name.
- * @param publicId The declared public identifier for the external DTD
- * subset, or null if none was declared.
- * @param systemId The declared system identifier for the external DTD
- * subset, or null if none was declared.
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.startDTD(name, publicId, systemId);
- }
-
- /**
- * Report the end of DTD declarations.
- */
- public void endDTD()
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.endDTD();
- }
-
- /**
- * Report the beginning of an entity.
- *
- * @param name The name of the entity. If it is a parameter entity, the
- * name will begin with '%'.
- */
- public void startEntity(String name)
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.startEntity(name);
- }
-
- /**
- * Report the end of an entity.
- *
- * @param name The name of the entity that is ending.
- */
- public void endEntity(String name)
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.endEntity(name);
- }
-
- /**
- * Report the start of a CDATA section.
- */
- public void startCDATA()
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.startCDATA();
- }
-
- /**
- * Report the end of a CDATA section.
- */
- public void endCDATA()
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.endCDATA();
- }
-
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param len The number of characters to use from the array.
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
- if (this.lexicalHandler != null)
- this.lexicalHandler.comment(ch, start, len);
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java
deleted file mode 100644
index 0400589..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/DefaultLexicalHandler.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * Default implementation of SAX's <code>LexicalHandler</code> interface. Empty implementation
- * of all methods so that you only have to redefine the ones of interest.
- *
- * @version $Id$
- */
-public class DefaultLexicalHandler implements LexicalHandler {
-
- /**
- * Shared instance that can be used when lexical events should be ignored.
- */
- public static final LexicalHandler NULL_HANDLER = new DefaultLexicalHandler();
-
- public void startDTD(String name, String publicId, String systemId) throws SAXException {
- // nothing
- }
-
- public void endDTD() throws SAXException {
- // nothing
- }
-
- public void startEntity(String name) throws SAXException {
- // nothing
- }
-
- public void endEntity(String name) throws SAXException {
- // nothing
- }
-
- public void startCDATA() throws SAXException {
- // nothing
- }
-
- public void endCDATA() throws SAXException {
- // nothing
- }
-
- public void comment(char[] ch, int start, int length) throws SAXException {
- // nothing
- }
-}
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java
deleted file mode 100644
index 663859a..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/EmbeddedXMLPipe.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class implements a ContentHandler for embedding a full SAX
- * event stream into an existing stream of SAX events. An instance of
- * this class will pass unmodified all the SAX events to the linked
- * ContentHandler, but it will ignore the startDocument/endDocument
- * and startDTD/endDTD events, as well as all comment events within
- * the DTD.
- *
- * @version $Id$
- */
-public class EmbeddedXMLPipe extends AbstractXMLPipe {
-
- private boolean inDTD;
-
- /**
- * Creates an EmbeddedXMLPipe that writes into the given XMLConsumer.
- */
- public EmbeddedXMLPipe(XMLConsumer consumer) {
- setConsumer(consumer);
- }
-
- /**
- * Creates an EmbeddedXMLPipe that writes into the given ContentHandler.
- */
- public EmbeddedXMLPipe(ContentHandler handler) {
- setContentHandler(handler);
- if (handler instanceof LexicalHandler) {
- setLexicalHandler((LexicalHandler) handler);
- }
- }
-
- /**
- * Creates an EmbeddedXMLPipe that writes into the given ContentHandler.
- */
- public EmbeddedXMLPipe(ContentHandler contentHandler, LexicalHandler lexicalHandler) {
- setContentHandler(contentHandler);
- setLexicalHandler(lexicalHandler);
- }
-
- /**
- * Ignore the <code>startDocument</code> event: this method does nothing.
- *
- * @exception SAXException if an error occurs
- */
- public void startDocument() throws SAXException {
- }
-
- /**
- * Ignore the <code>endDocument</code> event: this method does nothing.
- *
- * @exception SAXException if an error occurs
- */
- public void endDocument() throws SAXException {
- }
-
- /**
- * Ignore the <code>startDTD</code> event: this method does nothing.
- *
- * @exception SAXException if an error occurs
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
- // Ignored
- this.inDTD = true;
- }
-
- /**
- * Ignore the <code>endDTD</code> event: this method does nothing.
- *
- * @exception SAXException if an error occurs
- */
- public void endDTD() throws SAXException {
- // Ignored
- this.inDTD = false;
- }
-
- /**
- * Ignore all <code>comment</code> events if between
- * startDTD/endDTD events.
- *
- * @exception SAXException if an error occurs
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
- if (!inDTD) {
- super.comment(ch, start, len);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java
deleted file mode 100644
index d209061..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/ImmutableAttributesImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.Attributes;
-
-/**
- * Immutable attributes
- *
- * @version $Id$
- */
-public class ImmutableAttributesImpl extends AttributesImpl {
-
- public ImmutableAttributesImpl() {
- super();
- }
-
- public ImmutableAttributesImpl(Attributes attrs) {
- super(attrs);
- }
-
- public void clear() {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void removeAttribute(int index) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setLocalName(int index, String localName) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setQName(int index, String qName) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setType(int index, String type) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setURI(int index, String uri) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setValue(int index, String value) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setAttributes(Attributes atts) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void setAttribute(int index, String uri, String localName, String qName, String type, String value) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-
- public void addAttribute(String uri, String localName, String qName, String type, String value) {
- throw new UnsupportedOperationException("immutable attributes");
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java
deleted file mode 100644
index ff85cdf..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/IncludeXMLConsumer.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.w3c.dom.Node;
-
-/**
- * A special purpose <code>XMLConsumer</code> which can:
- * <ul>
- * <li>Trim empty characters if
- * {@link #setIgnoreEmptyCharacters(boolean) ignoreEmptyCharacters} is set.
- * <li>Ignore root element if
- * {@link #setIgnoreRootElement(boolean) ignoreRootElement} is set.
- * <li>Ignore startDocument, endDocument events.
- * <li>Ignore startDTD, endDTD, and all comments within DTD.
- * </ul>
- *
- * <p>It is more complicated version of {@link EmbeddedXMLPipe} which, except
- * being used to include other files into the SAX events stream, can perform
- * optional operations described above.</p>
- *
- * @see EmbeddedXMLPipe
- * @version $Id$
- */
-public class IncludeXMLConsumer implements XMLConsumer {
-
- /** The TrAX factory for serializing xml */
- private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
-
- private final ContentHandler contentHandler;
- private final LexicalHandler lexicalHandler;
-
- private boolean ignoreEmptyCharacters;
- private boolean ignoreRootElement;
- private int ignoreRootElementCount;
- private boolean inDTD;
-
- /**
- * Constructor
- */
- public IncludeXMLConsumer (XMLConsumer consumer) {
- this.contentHandler = consumer;
- this.lexicalHandler = consumer;
- }
-
- /**
- * Constructor
- */
- public IncludeXMLConsumer (ContentHandler contentHandler, LexicalHandler lexicalHandler) {
- this.contentHandler = contentHandler;
- this.lexicalHandler = lexicalHandler;
- }
-
- /**
- * Constructor
- */
- public IncludeXMLConsumer (ContentHandler contentHandler) {
- this.contentHandler = contentHandler;
- this.lexicalHandler = contentHandler instanceof LexicalHandler ? (LexicalHandler)contentHandler : null;
- }
-
- /**
- * Utility method to stream a DOM node into the provided content handler,
- * lexical handler.
- *
- * @param node The DOM Node to be included
- * @param contentHandler The SAX ContentHandler receiving the information
- * @param lexicalHandler The SAX LexicalHandler receiving the information (optional)
- */
- public static void includeNode(Node node,
- ContentHandler contentHandler,
- LexicalHandler lexicalHandler)
- throws SAXException {
- if (node != null) {
- if (node.getNodeType() == Node.TEXT_NODE){
- String value = node.getNodeValue();
- contentHandler.characters(value.toCharArray(), 0, value.length());
- } else {
- try {
- IncludeXMLConsumer filter = new IncludeXMLConsumer(contentHandler, lexicalHandler);
- Transformer transformer = FACTORY.newTransformer();
- DOMSource source = new DOMSource(node);
- SAXResult result = new SAXResult(filter);
- result.setLexicalHandler(filter);
- transformer.transform(source, result);
- } catch (TransformerConfigurationException e) {
- throw new SAXException("TransformerConfigurationException", e);
- } catch (TransformerException e) {
- throw new SAXException("TransformerException", e);
- }
- }
- }
- }
-
- /**
- * Control SAX event handling.
- * If set to <code>true</code> all empty characters events are ignored.
- * The default is <code>false</code>.
- */
- public void setIgnoreEmptyCharacters(boolean value) {
- this.ignoreEmptyCharacters = value;
- }
-
- /**
- * Control SAX event handling.
- * If set to <code>true</code> the root element is ignored.
- * The default is <code>false</code>.
- */
- public void setIgnoreRootElement(boolean value) {
- this.ignoreRootElement = value;
- this.ignoreRootElementCount = 0;
- }
-
- //
- // ContentHandler interface
- //
-
- public void setDocumentLocator(Locator loc) {
- this.contentHandler.setDocumentLocator(loc);
- }
-
- public void startDocument() throws SAXException {
- // Ignored
- }
-
- public void endDocument() throws SAXException {
- // Ignored
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- this.contentHandler.startPrefixMapping(prefix, uri);
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- this.contentHandler.endPrefixMapping(prefix);
- }
-
- public void startElement(String uri, String local, String qName, Attributes attr) throws SAXException {
- if (this.ignoreRootElement == false ||
- this.ignoreRootElementCount > 0) {
- this.contentHandler.startElement(uri,local,qName,attr);
- }
- this.ignoreRootElementCount++;
- }
-
- public void endElement(String uri, String local, String qName) throws SAXException {
- this.ignoreRootElementCount--;
- if (!this.ignoreRootElement || this.ignoreRootElementCount > 0) {
- this.contentHandler.endElement(uri, local, qName);
- }
- }
-
- public void characters(char[] ch, int start, int end) throws SAXException {
- if (this.ignoreEmptyCharacters) {
- String text = new String(ch, start, end).trim();
- if (text.length() > 0) {
- this.contentHandler.characters(text.toCharArray(), 0, text.length());
- }
- } else {
- this.contentHandler.characters(ch, start, end);
- }
- }
-
- public void ignorableWhitespace(char[] ch, int start, int end) throws SAXException {
- if (!this.ignoreEmptyCharacters) {
- this.contentHandler.ignorableWhitespace(ch, start, end);
- }
- }
-
- public void processingInstruction(String name, String value) throws SAXException {
- this.contentHandler.processingInstruction(name, value);
- }
-
- public void skippedEntity(String ent) throws SAXException {
- this.contentHandler.skippedEntity(ent);
- }
-
- //
- // LexicalHandler interface
- //
-
- public void startDTD(String name, String public_id, String system_id)
- throws SAXException {
- // Ignored
- this.inDTD = true;
- }
-
- public void endDTD() throws SAXException {
- // Ignored
- this.inDTD = false;
- }
-
- public void startEntity(String name) throws SAXException {
- if (lexicalHandler != null) {
- lexicalHandler.startEntity(name);
- }
- }
-
- public void endEntity(String name) throws SAXException {
- if (lexicalHandler != null) {
- lexicalHandler.endEntity(name);
- }
- }
-
- public void startCDATA() throws SAXException {
- if (lexicalHandler != null) {
- lexicalHandler.startCDATA();
- }
- }
-
- public void endCDATA() throws SAXException {
- if (lexicalHandler != null) {
- lexicalHandler.endCDATA();
- }
- }
-
- public void comment(char ary[], int start, int length) throws SAXException {
- if (!inDTD && lexicalHandler != null) {
- lexicalHandler.comment(ary,start,length);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/NamespacesTable.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/NamespacesTable.java
deleted file mode 100644
index 10329de..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/NamespacesTable.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Keeps track of namespaces declarations and resolve namespaces names.
- * <p>
- * This class also provides a very convenient and safe way of handling
- * namespace declarations in SAX pipes. It also allows to filter duplicate namespace
- * declarations that too often clutter up XML documents that went through
- * several transformations, and avoid useless namespace declarations that aren't followed
- * by element events.
- * <p>
- * Usage example in a SAX pipe:
- * <pre>
- * NamespacesTable namespaces = new NamespacesTable();
- * ContentHandler nextHandler;
- *
- * public void startPrefixMapping(String prefix, String uri) throws SAXException {
- * namespaces.addDeclaration(prefix, uri);
- * }
- *
- * public void startElement(...) throws SAXException {
- * // automatically start mappings for this scope
- * namespaces.enterScope(nextHandler);
- * nextHandler.startElement(...);
- * }
- *
- * public void endElement(...) throws SAXException {
- * nextHandler.endElement(...);
- * // automatically end mappings for this scope
- * namespaces.leaveScope(nextHandler);
- * }
- *
- * public void endPrefixMapping(String prefix) throws SAXException {
- * // Ignore, it is handled by leaveScope()
- * }
- * </pre>
- *
- * @version $Id$
- */
-public class NamespacesTable {
- /** The last namespace declaration. */
- private Entry lastEntry;
-
- /** The entry that start the prefix mappings for the scope that's about to be entered
- * or was just left.
- */
- private Entry lastDeclaredEntry;
-
- private boolean usesScopes = false;
-
- /**
- * Construct a new <code>NamespacesTable</code> instance.
- */
- public NamespacesTable() {
- clear();
- }
-
- /**
- * Clear and reinitialize this namespace table before reuse.
- *
- * @since 2.1.8
- */
- public void clear() {
- this.lastEntry = Entry.create("","");
- this.addDeclaration("xml", "http://www.w3.org/XML/1998/namespace");
- // Lock this scope
- this.lastEntry.closedScopes = 1;
- }
-
- /**
- * Declare a new namespace prefix-uri mapping.
- *
- * @return The newly added <code>Declaration</code>.
- */
- public Declaration addDeclaration(String prefix, String uri) {
- // Find a previous declaration of the same prefix
- Entry dup = this.lastEntry;
- while (dup != null && !dup.prefix.equals(prefix)) {
- dup = dup.previous;
- }
-
- if (dup != null) {
- if (usesScopes && dup.uri.equals(uri)) {
- return dup;
- }
- dup.overriden = true;
- }
-
- Entry e = Entry.create(prefix, uri);
- e.previous = this.lastEntry;
- e.overrides = dup;
- this.lastEntry = e;
- // this always starts the declared prefix chain
- this.lastDeclaredEntry = e;
- return e;
- }
-
- /**
- * Undeclare a namespace prefix-uri mapping. If the prefix was previously declared
- * mapping another URI, its value is restored.
- * <p>
- * When using {@link #enterScope()}/{@link #leaveScope()}, this method does nothing and always
- * returns <code>null</code>, as declaration removal is handled in {@link #leaveScope()}.
- *
- * @return the removed <code>Declaration</code> or <b>null</b>.
- */
- public Declaration removeDeclaration(String prefix) {
- if (usesScopes) {
- // Automatically handled in leaveScope
- return null; // or throw and IllegalStateException if enterScope(handler) was used?
- }
-
- Entry current = this.lastEntry;
- Entry afterCurrent = null;
- while(current != null) {
- if (current.closedScopes > 0) {
- // Don't undeclare mappings not declared in this scope
- return null;
- }
-
- if (current.prefix.equals(prefix)) {
- // Got it
- // Remove it from the chain
- if (afterCurrent != null) {
- afterCurrent.previous = current.previous;
- }
- // And report closed scopes on the previous entry
- current.previous.closedScopes += current.closedScopes;
- Entry overrides = current.overrides;
- if (overrides != null) {
- // No more overriden
- overrides.overriden = false;
- }
-
- if (this.lastDeclaredEntry == current) {
- if (current.previous.closedScopes == 0) {
- this.lastDeclaredEntry = current.previous;
- } else {
- this.lastDeclaredEntry = null;
- }
- }
-
- if (this.lastEntry == current) {
- this.lastEntry = current.previous;
- }
-
- return current;
- }
-
- afterCurrent = current;
- current = current.previous;
- }
-
- // Not found
- return null;
- }
-
- /**
- * Enter a new scope. This starts a new, empty list of declarations for the new scope.
- * <p>
- * Typically called in a SAX handler <em>before</em> sending a <code>startElement()</code>
- * event.
- *
- * @since 2.1.8
- */
- public void enterScope() {
- this.usesScopes = true;
- this.lastEntry.closedScopes++;
- this.lastDeclaredEntry = null;
- }
-
- /**
- * Start all declared mappings of the current scope and enter a new scope. This starts a new,
- * empty list of declarations for the new scope.
- * <p>
- * Typically called in a SAX handler <em>before</em> sending a <code>startElement()</code>
- * event.
- *
- * @param handler the handler that will receive startPrefixMapping events.
- * @throws SAXException
- * @since 2.1.8
- */
- public void enterScope(ContentHandler handler) throws SAXException {
- this.usesScopes = true;
- Entry current = this.lastEntry;
- while (current != null && current.closedScopes == 0) {
- handler.startPrefixMapping(current.prefix, current.uri);
- current = current.previous;
- }
- this.lastEntry.closedScopes++;
- this.lastDeclaredEntry = null;
- }
-
- /**
- * Leave a scope. The namespace declarations that occured before the corresponding
- * <code>enterScope()</code> are no more visible using the resolution methods, but
- * still available using {@link #getCurrentScopeDeclarations()} until the next call
- * to {@link #addDeclaration(String, String)} or {@link #enterScope()}.
- * <p>
- * Typically called in a SAX handler <em>after</em> sending a <code>endElement()</code>
- * event.
- *
- * @since 2.1.8
- */
- public void leaveScope() {
- Entry current = this.lastEntry;
-
- // Purge declarations that were added but not included in a scope
- while (current.closedScopes == 0) {
- current = current.previous;
- }
-
- current.closedScopes--;
-
- if (current.closedScopes == 0) {
- this.lastDeclaredEntry = current;
- } else {
- // More than one scope closed here: no local declarations
- this.lastDeclaredEntry = null;
- }
-
- while (current != null && current.closedScopes == 0) {
- Entry overrides = current.overrides;
- if (overrides != null) {
- // No more overriden
- overrides.overriden = false;
- }
- current = current.previous;
- }
- this.lastEntry = current;
- }
-
- /**
- * Leave a scope. The namespace declarations that occured before the corresponding
- * <code>enterScope()</code> are no more visible using the resolution methods, but
- * still available using {@link #getCurrentScopeDeclarations()} until the next call
- * to {@link #addDeclaration(String, String)} or {@link #enterScope()}.
- * <p>
- * Typically called in a SAX handler <em>after</em> sending a <code>endElement()</code>
- * event.
- *
- * @param handler the handler that will receive endPrefixMapping events.
- * @throws SAXException
- * @since 2.1.8
- */
- public void leaveScope(ContentHandler handler) throws SAXException {
- Entry current = this.lastEntry;
-
- // Purge declarations that were added but not included in a scope
- while (current.closedScopes == 0) {
- current = current.previous;
- }
-
- current.closedScopes--;
-
- if (current.closedScopes == 0) {
- this.lastDeclaredEntry = current;
- } else {
- // More than one scope closed here: no local declarations
- this.lastDeclaredEntry = null;
- }
-
- while (current != null && current.closedScopes == 0) {
- handler.endPrefixMapping(current.prefix);
- Entry overrides = current.overrides;
- if (overrides != null) {
- // No more overriden
- overrides.overriden = false;
- }
- current = current.previous;
- }
-
- this.lastEntry = current;
- }
-
- private static final Declaration[] NO_DECLS = new Declaration[0];
-
- /**
- * Get the declarations that were declared within the current scope.
- *
- * @return the declarations (possibly empty, but never null)
- * @since 2.1.8
- */
- public Declaration[] getCurrentScopeDeclarations() {
- int count = 0;
- Entry current = this.lastDeclaredEntry;
- while (current != null && current.closedScopes == 0) {
- count++;
- current = current.previous;
- }
-
- if (count == 0) return NO_DECLS;
-
- Declaration[] decls = new Declaration[count];
- count = 0;
- current = this.lastDeclaredEntry;
- while (current != null && current.closedScopes == 0) {
- decls[count++] = current;
- current = current.previous;
- }
- return decls;
- }
-
- /**
- * Return the URI associated with the given prefix or <b>null</b> if the
- * prefix was not mapped.
- */
- public String getUri(String prefix) {
- Entry current = this.lastEntry;
- while (current != null) {
- if (current.prefix.equals(prefix)) {
- return current.uri;
- }
- current = current.previous;
- }
-
- // Not found
- return null;
- }
-
- /**
- * Return an array with all prefixes currently mapped to the specified URI.
- * <br>
- * The array length might be <b>zero</b> if no prefixes are associated with
- * the specified uri.
- *
- * @return A <b>non-null</b> <code>String</code> array.
- */
- public String[] getPrefixes(String uri) {
-
- Entry current=this.lastEntry;
- int count=0;
- while (current!=null) {
- if(!current.overriden && current.uri.equals(uri))
- count++;
- current=current.previous;
- }
- if (count==0) return(new String[0]);
-
- String prefixes[]=new String[count];
- count=0;
- current = this.lastEntry;
- while (current!=null) {
- if(!current.overriden && current.uri.equals(uri))
- prefixes[count++] = current.prefix;
- current = current.previous;
- }
- return prefixes;
- }
-
-
- /**
- * Return one of the prefixes currently mapped to the specified URI or
- * <b>null</b>.
- */
- public String getPrefix(String uri) {
- Entry current = this.lastEntry;
- while (current != null) {
- if(!current.overriden && current.uri.equals(uri))
- return current.prefix;
- current = current.previous;
- }
- return null;
- }
-
- /**
- * Resolve a namespace-aware name against the current namespaces
- * declarations.
- *
- * @param uri The namespace URI or <b>null</b> if not known.
- * @param raw The raw (complete) name or <b>null</b> if not known.
- * @param prefix The namespace prefix or <b>null</b> if not known.
- * @param local The local name or <b>null</b> if not known.
- * @return A <b>non-null</b> <code>Name</code>.
- * @exception SAXException If the name cannot be resolved.
- */
- public Name resolve(String uri, String raw, String prefix, String local)
- throws SAXException {
- if (uri==null) uri="";
- if (raw==null) raw="";
- if (prefix==null) prefix="";
- if (local==null) local="";
- // Start examining the URI
- if (raw.length()>0) {
- // The raw name was specified
- int pos=raw.indexOf(':');
- if (pos>0) {
- // We have a namespace prefix:local separator
- String pre=raw.substring(0,pos);
- String loc=raw.substring(pos+1);
- if (prefix.length()==0) prefix=pre;
- else if (!prefix.equals(pre))
- throw new SAXException("Raw/Prefix mismatch");
- if (local.length()==0) local=loc;
- else if (!local.equals(loc))
- throw new SAXException("Raw/Local Name mismatch");
- } else {
- // We don't have a prefix:local separator
- if (prefix.length()>0)
- throw new SAXException("Raw Name/Prefix mismatch");
- if (local.length()==0) local=raw;
- else if (!local.equals(raw))
- throw new SAXException("Raw Name/Local Name mismatch");
- }
- } else {
- // The raw name was not specified
- if (local.length()==0) throw new SAXException("No Raw/Local Name");
- if (prefix.length()==0) raw=local;
- else raw=prefix+':'+local;
- }
- // We have resolved and checked data between the raw, local, and
- // prefix... We have to doublecheck the namespaces.
- if (uri.length()>0) {
- // We have a URI and a prefix, check them
- if ((prefix.length()>0) && (!uri.equals(this.getUri(prefix)))) {
- throw new SAXException("URI/Prefix mismatch [" + prefix + "," + uri + "]");
- } else {
- String temp=this.getPrefix(uri);
- if (temp==null) throw new SAXException("URI not declared");
- else if (temp.length()>0) {
- prefix=temp;
- raw=prefix+':'+local;
- }
- }
- } else {
- // We don't have a URI, check if we can find one from the prefix.
- String temp=this.getUri(prefix);
- if (temp==null) throw new SAXException("Prefix not declared");
- else uri=temp;
- }
- NameImpl name=new NameImpl();
- if (uri.length() > 0) name.uri=uri;
- else name.uri=null;
- name.raw=raw;
- name.prefix=prefix;
- name.local=local;
- return(name);
- }
-
- /** The internal entry structure for this table. */
- private static class Entry implements Declaration {
- /** The URI string. */
- protected String uri="";
- /** The prefix string. */
- protected String prefix="";
- /** The previous declaration. */
- protected Entry previous;
- protected Entry overrides;
- protected int closedScopes = 0;
- protected boolean overriden = false;
-
- /** Create a new namespace declaration. */
- protected static Entry create(String prefix, String uri) {
- // Create a new entry
- Entry e = new Entry();
- // Set the prefix string.
- if (prefix != null) e.prefix=prefix;
- // Set the uri string.
- if (uri != null) e.uri=uri;
- // Return the entry
- return e;
- }
-
- /** Return the namespace URI. */
- public String getUri() { return this.uri; }
- /** Return the namespace prefix. */
- public String getPrefix() { return this.prefix; }
- }
-
- /** The default namespace-aware name declaration implementation */
- private static class NameImpl implements Name {
- /** The namespace URI. */
- protected String uri;
- /** The namespace prefix. */
- protected String prefix;
- /** The namespace local name. */
- protected String local;
- /** The namespace raw name. */
- protected String raw;
-
- /** Return the namespace URI. */
- public String getUri() { return this.uri; }
- /** Return the namespace prefix. */
- public String getPrefix() { return this.prefix; }
- /** Return the namespace local name. */
- public String getLocalName() { return this.local; }
- /** Return the namespace raw name. */
- public String getQName() { return this.raw; }
- }
-
- /**
- * A namespace-aware name. (This interface is used in conjunction
- * with <code>NamespacesTable</code>).
- */
- public interface Name {
- /** Return the namespace URI. */
- String getUri();
- /** Return the namespace prefix. */
- String getPrefix();
- /** Return the namespace local name. */
- String getLocalName();
- /** Return the namespace raw name. */
- String getQName();
- }
-
- /**
- * A namespace declaration. (This interface is used in conjunction
- * with <code>NamespacesTable</code>).
- */
- public interface Declaration {
- /** Return the namespace URI. */
- String getUri();
- /** Return the namespace prefix. */
- String getPrefix();
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/SaxBuffer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/SaxBuffer.java
deleted file mode 100644
index fcba124..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/SaxBuffer.java
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.Locator;
-import org.xml.sax.Attributes;
-import org.xml.sax.ext.LexicalHandler;
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.apache.avalon.excalibur.pool.Recyclable;
-
-import java.io.Serializable;
-import java.io.Writer;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Collections;
-
-/**
- * A class that can record SAX events and replay them later.
- *
- * <p>Compared to {@link org.apache.cocoon.components.sax.XMLByteStreamCompiler},
- * this class is many times faster at sending out the recorded SAX events since
- * it doesn't need to convert between byte and char representations etc.
- * On the other hand, its data structure is more complex then a simple byte array,
- * making XMLByteStreamCompiler better in case the recorded SAX should be stored long-term.
- *
- * <p>Use this class if you need to frequently generate smaller amounts of SAX events,
- * or replay a set of recorded start events immediately.</p>
- *
- * <p>Both {@link ContentHandler} and {@link LexicalHandler} are supported, the only
- * exception is that the setDocumentLocator event is not recorded.</p>
- *
- * @version $Id$
- */
-public class SaxBuffer extends AbstractSAXFragment
- implements XMLConsumer, Recyclable, Serializable {
-
- /**
- * Stores list of {@link SaxBit} objects.
- */
- protected List saxbits;
-
- /**
- * Creates empty SaxBuffer
- */
- public SaxBuffer() {
- this.saxbits = new ArrayList();
- }
-
- /**
- * Creates SaxBuffer based on the provided bits list.
- */
- public SaxBuffer(List bits) {
- this.saxbits = bits;
- }
-
- /**
- * Creates copy of another SaxBuffer
- */
- public SaxBuffer(SaxBuffer saxBuffer) {
- this.saxbits = new ArrayList(saxBuffer.saxbits);
- }
-
- //
- // ContentHandler Interface
- //
-
- public void skippedEntity(String name) throws SAXException {
- saxbits.add(new SkippedEntity(name));
- }
-
- public void setDocumentLocator(Locator locator) {
- // Don't record this event
- }
-
- public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
- saxbits.add(new IgnorableWhitespace(ch, start, length));
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- saxbits.add(new PI(target, data));
- }
-
- public void startDocument() throws SAXException {
- saxbits.add(StartDocument.SINGLETON);
- }
-
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
- saxbits.add(new StartElement(namespaceURI, localName, qName, atts));
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- saxbits.add(new EndPrefixMapping(prefix));
- }
-
- public void characters(char ch[], int start, int length) throws SAXException {
- saxbits.add(new Characters(ch, start, length));
- }
-
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
- saxbits.add(new EndElement(namespaceURI, localName, qName));
- }
-
- public void endDocument() throws SAXException {
- saxbits.add(EndDocument.SINGLETON);
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- saxbits.add(new StartPrefixMapping(prefix, uri));
- }
-
- //
- // LexicalHandler Interface
- //
-
- public void endCDATA() throws SAXException {
- saxbits.add(EndCDATA.SINGLETON);
- }
-
- public void comment(char ch[], int start, int length) throws SAXException {
- saxbits.add(new Comment(ch, start, length));
- }
-
- public void startEntity(String name) throws SAXException {
- saxbits.add(new StartEntity(name));
- }
-
- public void endDTD() throws SAXException {
- saxbits.add(EndDTD.SINGLETON);
- }
-
- public void startDTD(String name, String publicId, String systemId) throws SAXException {
- saxbits.add(new StartDTD(name, publicId, systemId));
- }
-
- public void startCDATA() throws SAXException {
- saxbits.add(StartCDATA.SINGLETON);
- }
-
- public void endEntity(String name) throws SAXException {
- saxbits.add(new EndEntity(name));
- }
-
- //
- // Public Methods
- //
-
- /**
- * Add a bit containing XMLizable object
- */
- public void xmlizable(XMLizable xml) {
- saxbits.add(new XMLizableBit(xml));
- }
-
- /**
- * @return true if buffer is empty
- */
- public boolean isEmpty() {
- return saxbits.isEmpty();
- }
-
- /**
- * @return unmodifiable list of SAX bits
- */
- public List getBits() {
- return Collections.unmodifiableList(saxbits);
- }
-
- /**
- * Stream this buffer into the provided content handler.
- * If contentHandler object implements LexicalHandler, it will get lexical
- * events as well.
- */
- public void toSAX(ContentHandler contentHandler) throws SAXException {
- for (Iterator i = saxbits.iterator(); i.hasNext();) {
- SaxBit saxbit = (SaxBit)i.next();
- saxbit.send(contentHandler);
- }
- }
-
- /**
- * @return String value of the buffer
- */
- public String toString() {
- // NOTE: This method is used in i18n XML bundle implementation
- final StringBuffer value = new StringBuffer();
- for (Iterator i = saxbits.iterator(); i.hasNext();) {
- final SaxBit saxbit = (SaxBit) i.next();
- if (saxbit instanceof Characters) {
- ((Characters) saxbit).toString(value);
- }
- }
-
- return value.toString();
- }
-
- /**
- * Clear this buffer
- */
- public void recycle() {
- saxbits.clear();
- }
-
- /**
- * Dump buffer contents into the provided writer.
- */
- public void dump(Writer writer) throws IOException {
- Iterator i = saxbits.iterator();
- while (i.hasNext()) {
- final SaxBit saxbit = (SaxBit) i.next();
- saxbit.dump(writer);
- }
- writer.flush();
- }
-
- //
- // Implementation Methods
- //
-
- /**
- * Adds a SaxBit to the bits list
- */
- protected final void addBit(SaxBit bit) {
- saxbits.add(bit);
- }
-
- /**
- * Iterates through the bits list
- */
- protected final Iterator bits() {
- return saxbits.iterator();
- }
-
- /**
- * SaxBit is a representation of the SAX event. Every SaxBit is immutable object.
- */
- interface SaxBit {
- public void send(ContentHandler contentHandler) throws SAXException;
- public void dump(Writer writer) throws IOException;
- }
-
- public final static class StartDocument implements SaxBit, Serializable {
- public static final StartDocument SINGLETON = new StartDocument();
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.startDocument();
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartDocument]\n");
- }
- }
-
- public final static class EndDocument implements SaxBit, Serializable {
- public static final EndDocument SINGLETON = new EndDocument();
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.endDocument();
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndDocument]\n");
- }
- }
-
- public final static class PI implements SaxBit, Serializable {
- public final String target;
- public final String data;
-
- public PI(String target, String data) {
- this.target = target;
- this.data = data;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.processingInstruction(target, data);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[ProcessingInstruction] target=" + target + ",data=" + data + "\n");
- }
- }
-
- public final static class StartDTD implements SaxBit, Serializable {
- public final String name;
- public final String publicId;
- public final String systemId;
-
- public StartDTD(String name, String publicId, String systemId) {
- this.name = name;
- this.publicId = publicId;
- this.systemId = systemId;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).startDTD(name, publicId, systemId);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartDTD] name=" + name + ",publicId=" + publicId + ",systemId=" + systemId + "\n");
- }
- }
-
- public final static class EndDTD implements SaxBit, Serializable {
- public static final EndDTD SINGLETON = new EndDTD();
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).endDTD();
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndDTD]\n");
- }
- }
-
- public final static class StartEntity implements SaxBit, Serializable {
- public final String name;
-
- public StartEntity(String name) {
- this.name = name;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).startEntity(name);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartEntity] name=" + name + "\n");
- }
- }
-
- public final static class EndEntity implements SaxBit, Serializable {
- public final String name;
-
- public EndEntity(String name) {
- this.name = name;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).endEntity(name);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndEntity] name=" + name + "\n");
- }
- }
-
- public final static class SkippedEntity implements SaxBit, Serializable {
- public final String name;
-
- public SkippedEntity(String name) {
- this.name = name;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.skippedEntity(name);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[SkippedEntity] name=" + name + "\n");
- }
- }
-
- public final static class StartPrefixMapping implements SaxBit, Serializable {
- public final String prefix;
- public final String uri;
-
- public StartPrefixMapping(String prefix, String uri) {
- this.prefix = prefix;
- this.uri = uri;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.startPrefixMapping(prefix, uri);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartPrefixMapping] prefix=" + prefix + ",uri=" + uri + "\n");
- }
- }
-
- public final static class EndPrefixMapping implements SaxBit, Serializable {
- public final String prefix;
-
- public EndPrefixMapping(String prefix) {
- this.prefix = prefix;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.endPrefixMapping(prefix);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndPrefixMapping] prefix=" + prefix + "\n");
- }
- }
-
- public final static class StartElement implements SaxBit, Serializable {
- public final String namespaceURI;
- public final String localName;
- public final String qName;
- public final Attributes attrs;
-
- public StartElement(String namespaceURI, String localName, String qName, Attributes attrs) {
- this.namespaceURI = namespaceURI;
- this.localName = localName;
- this.qName = qName;
- this.attrs = new org.xml.sax.helpers.AttributesImpl(attrs);
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.startElement(namespaceURI, localName, qName, attrs);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartElement] namespaceURI=" + namespaceURI + ",localName=" + localName + ",qName=" + qName + "\n");
- for (int i = 0; i < attrs.getLength(); i++) {
- writer.write(" [Attribute] namespaceURI=" + attrs.getURI(i) + ",localName=" + attrs.getLocalName(i) + ",qName=" + attrs.getQName(i) + ",type=" + attrs.getType(i) + ",value=" + attrs.getValue(i) + "\n");
- }
- }
- }
-
- public final static class EndElement implements SaxBit, Serializable {
- public final String namespaceURI;
- public final String localName;
- public final String qName;
-
- public EndElement(String namespaceURI, String localName, String qName) {
- this.namespaceURI = namespaceURI;
- this.localName = localName;
- this.qName = qName;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.endElement(namespaceURI, localName, qName);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndElement] namespaceURI=" + namespaceURI + ",localName=" + localName + ",qName=" + qName + "\n");
- }
- }
-
- public final static class Characters implements SaxBit, Serializable {
- public final char[] ch;
-
- public Characters(char[] ch, int start, int length) {
- // make a copy so that we don't hold references to a potentially large array we don't control
- this.ch = new char[length];
- System.arraycopy(ch, start, this.ch, 0, length);
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.characters(ch, 0, ch.length);
- }
-
- public void toString(StringBuffer value) {
- value.append(ch);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[Characters] ch=" + new String(ch) + "\n");
- }
- }
-
- public final static class Comment implements SaxBit, Serializable {
- public final char[] ch;
-
- public Comment(char[] ch, int start, int length) {
- // make a copy so that we don't hold references to a potentially large array we don't control
- this.ch = new char[length];
- System.arraycopy(ch, start, this.ch, 0, length);
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).comment(ch, 0, ch.length);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[Comment] ch=" + new String(ch) + "\n");
- }
- }
-
- public final static class StartCDATA implements SaxBit, Serializable {
- public static final StartCDATA SINGLETON = new StartCDATA();
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).startCDATA();
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[StartCDATA]\n");
- }
- }
-
- public final static class EndCDATA implements SaxBit, Serializable {
- public static final EndCDATA SINGLETON = new EndCDATA();
-
- public void send(ContentHandler contentHandler) throws SAXException {
- if (contentHandler instanceof LexicalHandler)
- ((LexicalHandler)contentHandler).endCDATA();
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[EndCDATA]\n");
- }
- }
-
- public final static class IgnorableWhitespace implements SaxBit, Serializable {
- public final char[] ch;
-
- public IgnorableWhitespace(char[] ch, int start, int length) {
- // make a copy so that we don't hold references to a potentially large array we don't control
- this.ch = new char[length];
- System.arraycopy(ch, start, this.ch, 0, length);
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- contentHandler.ignorableWhitespace(ch, 0, ch.length);
- }
-
- public void dump(Writer writer) throws IOException {
- writer.write("[IgnorableWhitespace] ch=" + new String(ch) + "\n");
- }
- }
-
- public final static class XMLizableBit implements SaxBit, Serializable {
- public final XMLizable xml;
-
- public XMLizableBit(XMLizable xml) {
- this.xml = xml;
- }
-
- public void send(ContentHandler contentHandler) throws SAXException {
- this.xml.toSAX(new EmbeddedXMLPipe(contentHandler));
- }
-
- public void dump(Writer writer) throws IOException {
- if (xml instanceof SaxBuffer) {
- writer.write("[XMLizable] Begin nested SaxBuffer\n");
- ((SaxBuffer)xml).dump(writer);
- writer.write("[XMLizable] End nested SaxBuffer\n");
- } else {
- writer.write("[XMLizable] xml=" + xml + "\n");
- }
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLBaseSupport.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLBaseSupport.java
deleted file mode 100644
index f4d2db4..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLBaseSupport.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.Source;
-import org.apache.avalon.framework.logger.Logger;
-
-import java.util.Stack;
-import java.util.Collections;
-import java.io.IOException;
-
-/**
- * Helper class for handling xml:base attributes.
- *
- * <p>Usage:
- * <ul>
- * <li>set location of the containing document by calling {@link #setDocumentLocation(String)}.
- * This is usually done when getting setDocumentLocator SAX event.
- * <li>forward each startElement and endElement event to this object.
- * <li>to resolve a relative URL against the current base, call {@link #makeAbsolute(String)}.
- * </ul>
- *
- * <p>External entities are not yet taken into account when determing the current base.
- */
-public class XMLBaseSupport {
- public static final String XMLBASE_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
- public static final String XMLBASE_ATTRIBUTE = "base";
-
- /** Increased on each startElement, decreased on each endElement. */
- private int level = 0;
- /**
- * The stack contains an instance of {@link BaseInfo} for each XML element
- * that contained an xml:base attribute (not for the other elements).
- */
- private Stack bases = new Stack();
- private SourceResolver resolver;
- private Logger logger;
-
- public XMLBaseSupport(SourceResolver resolver, Logger logger) {
- this.resolver = resolver;
- this.logger = logger;
- }
-
- public void setDocumentLocation(String loc) throws SAXException {
- // -2 is used as level to avoid this BaseInfo to be ever popped of the stack
- bases.push(new BaseInfo(loc, -2));
- }
-
- public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {
- level++;
- String base = attrs.getValue(XMLBASE_NAMESPACE_URI, XMLBASE_ATTRIBUTE);
- if (base != null) {
- Source baseSource = null;
- String baseUrl;
- try {
- baseSource = resolve(getCurrentBase(), base);
- baseUrl = baseSource.getURI();
- } finally {
- if (baseSource != null) {
- resolver.release(baseSource);
- }
- }
- bases.push(new BaseInfo(baseUrl, level));
- }
- }
-
- public void endElement(String namespaceURI, String localName, String qName) {
- if (getCurrentBaseLevel() == level)
- bases.pop();
- level--;
- }
-
- /**
- * Warning: do not forget to release the source returned by this method.
- */
- private Source resolve(String baseURI, String location) throws SAXException {
- try {
- Source source;
- if (baseURI != null) {
- source = resolver.resolveURI(location, baseURI, Collections.EMPTY_MAP);
- } else {
- source = resolver.resolveURI(location);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("XMLBaseSupport: resolved location " + location +
- " against base URI " + baseURI + " to " + source.getURI());
- }
- return source;
- } catch (IOException e) {
- throw new SAXException("XMLBaseSupport: problem resolving uri.", e);
- }
- }
-
- /**
- * Makes the given path absolute based on the current base URL. Do not forget to release
- * the returned source object!
- * @param spec any URL (relative or absolute, containing a scheme or not)
- */
- public Source makeAbsolute(String spec) throws SAXException {
- return resolve(getCurrentBase(), spec);
- }
-
- private String getCurrentBase() {
- if (bases.size() > 0) {
- BaseInfo baseInfo = (BaseInfo)bases.peek();
- return baseInfo.getUrl();
- }
- return null;
- }
-
- private int getCurrentBaseLevel() {
- if (bases.size() > 0) {
- BaseInfo baseInfo = (BaseInfo)bases.peek();
- return baseInfo.getLevel();
- }
- return -1;
- }
-
- private static final class BaseInfo {
- private String url;
- private int level;
-
- public BaseInfo(String url, int level) {
- this.url = url;
- this.level = level;
- }
-
- public String getUrl() {
- return url;
- }
-
- public int getLevel() {
- return level;
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLUtils.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLUtils.java
deleted file mode 100644
index 4f5931f..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/XMLUtils.java
+++ /dev/null
@@ -1,684 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.xml.dom.DOMStreamer;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * XML utility methods.
- *
- * @version $Id$
- */
-public class XMLUtils {
-
- /**
- * Empty attributes immutable object.
- */
- public static final Attributes EMPTY_ATTRIBUTES = new ImmutableAttributesImpl();
-
- private static final SAXTransformerFactory FACTORY = (SAXTransformerFactory) TransformerFactory.newInstance();
- private static final Properties XML_FORMAT = createDefaultPropertiesForXML(false);
- private static final Properties XML_FORMAT_NODECL = createDefaultPropertiesForXML(true);
-
-
- // FIXME: parent parameter not used anymore
- // Using parent because some dom implementations like jtidy are bugged,
- // cannot get parent or delete child
- public static void stripDuplicateAttributes(Node node, Node parent) {
-
- // The output depends on the type of the node
- switch(node.getNodeType()) {
- case Node.DOCUMENT_NODE: {
- Document doc = (Document)node;
- Node child = doc.getFirstChild();
- while(child != null) {
- stripDuplicateAttributes(child, node);
- child = child.getNextSibling();
- }
- break;
- }
-
- case Node.ELEMENT_NODE: {
- Element elt = (Element) node;
- NamedNodeMap attrs = elt.getAttributes();
-
- ArrayList nodesToRemove = new ArrayList();
- int nodesToRemoveNum = 0;
-
- for (int i = 0; i < attrs.getLength(); i++) {
- final Node a = attrs.item(i);
-
- for (int j = 0; j < attrs.getLength(); j++) {
- final Node b = attrs.item(j);
-
- //if there are two attributes with same name
- if (i != j && (a.getNodeName().equals(b.getNodeName()))) {
- nodesToRemove.add(b);
- nodesToRemoveNum++;
- }
- }
- }
-
- for (int i = 0; i < nodesToRemoveNum; i++) {
- Attr nodeToDelete = (Attr) nodesToRemove.get(i);
- Element nodeToDeleteParent = (Element) node; // nodeToDelete.getParentNode();
- nodeToDeleteParent.removeAttributeNode(nodeToDelete);
- }
-
- nodesToRemove.clear();
-
- Node child = elt.getFirstChild();
- while (child != null) {
- stripDuplicateAttributes(child, node);
- child = child.getNextSibling();
- }
-
- break;
- }
-
- default:
- //do nothing
- break;
- }
- }
-
- /**
- * Get an <code>XMLConsumer</code> from a <code>ContentHandler</code> and
- * a <code>LexicalHandler</code>. If the content handler is already an
- * <code>XMLConsumer</code>, it is returned as is, otherwise it is wrapped
- * in an <code>XMLConsumer</code> with the lexical handler.
- *
- * @param ch the content handler, which should not be <code>null</code>
- * @param lh the lexical handler, which can be <code>null</code>
- * @return an <code>XMLConsumer</code> for <code>ch</code> an <code>lh</code>
- */
- public static XMLConsumer getConsumer(ContentHandler ch, LexicalHandler lh) {
- if (ch instanceof XMLConsumer) {
- return (XMLConsumer)ch;
- } else {
- if (lh == null && ch instanceof LexicalHandler) {
- lh = (LexicalHandler)ch;
- }
- return new ContentHandlerWrapper(ch, lh);
- }
- }
-
- /**
- * Get an <code>XMLConsumer</code> from <code>ContentHandler</code>. If the
- * content handler is already an <code>XMLConsumer</code>, it is returned as
- * is, otherwise it is wrapped in an <code>XMLConsumer</code>.
- *
- * @param ch the content handler, which should not be <code>null</code>
- * @return an <code>XMLConsumer</code> for <code>ch</code>
- */
- public static XMLConsumer getConsumer(ContentHandler ch) {
- return getConsumer(ch, null);
- }
-
- /**
- * Method for static initializer
- */
- private static Properties createDefaultPropertiesForXML(boolean omitXMLDeclaration) {
- final Properties format = new Properties();
- format.put(OutputKeys.METHOD, "xml");
- format.put(OutputKeys.OMIT_XML_DECLARATION, (omitXMLDeclaration ? "yes" : "no"));
- format.put(OutputKeys.INDENT, "yes");
- return format;
- }
-
- /**
- * Create a new properties set for serializing xml.
- * The omit xml declaration property can be controlled by the flag.
- *
- * <ul>
- * <li>Method: xml
- * <li>Omit xml declaration: according to the flag
- * <li>Indent: yes
- * </ul>
- */
- public static Properties createPropertiesForXML(boolean omitXMLDeclaration) {
- /* Properties passed as parameters to the Properties constructor become "default properties".
- But Xalan does not use the default properties, so they are lost.
- Therefore, we must promote them to "set properties".
- */
- Properties propertiesForXML = new Properties(omitXMLDeclaration? XML_FORMAT_NODECL: XML_FORMAT);
- for (Enumeration e = propertiesForXML.propertyNames(); e.hasMoreElements(); ) {
- String propertyName = (String)e.nextElement();
- propertiesForXML.setProperty(propertyName, propertiesForXML.getProperty(propertyName, ""));
- }
- return propertiesForXML;
- }
-
- /**
- * Serialize a DOM node into a string using format created by
- * <code>createPropertiesForXML(false)</code>.
- *
- * @see #createPropertiesForXML
- */
- public static String serializeNode(Node node)
- throws ProcessingException {
- // Don't create new properties as we do not intend to modify defaults.
- return serializeNode(node, XML_FORMAT);
- }
-
- /**
- * Serialize a DOM node into a string.
- * If the node is null the empty string is returned.
- *
- * @param format The format of the output to be used by SAX transformer.
- * @see OutputKeys
- */
- public static String serializeNode(Node node, Properties format)
- throws ProcessingException {
-
- try {
- if (node == null) {
- return "";
- }
-
- StringWriter writer = new StringWriter();
- TransformerHandler transformerHandler;
- transformerHandler = FACTORY.newTransformerHandler();
- transformerHandler.getTransformer().setOutputProperties(format);
- transformerHandler.setResult(new StreamResult(writer));
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- transformerHandler.startDocument();
- }
- DOMStreamer domStreamer = new DOMStreamer(transformerHandler, transformerHandler);
- domStreamer.stream(node);
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- transformerHandler.endDocument();
- }
-
- return writer.toString();
- } catch (TransformerException e) {
- throw new ProcessingException("TransformerException: " + e, e);
- } catch (SAXException e) {
- throw new ProcessingException("SAXException while streaming DOM node to SAX: " + e, e);
- }
- }
-
- /**
- * Serialize a XMLizable into a string.
- * If the object is null the empty string is returned.
- *
- * @param format The format of the output to be used by SAX transformer.
- * @see OutputKeys
- */
- public static String serialize(org.apache.excalibur.xml.sax.XMLizable xml, Properties format)
- throws ProcessingException {
-
- try {
- if (xml == null) {
- return "";
- }
-
- StringWriter writer = new StringWriter();
- TransformerHandler transformerHandler;
- transformerHandler = FACTORY.newTransformerHandler();
- transformerHandler.getTransformer().setOutputProperties(format);
- transformerHandler.setResult(new StreamResult(writer));
- transformerHandler.startDocument();
- xml.toSAX(new EmbeddedXMLPipe(transformerHandler));
- transformerHandler.endDocument();
-
- return writer.toString();
- } catch (TransformerException e) {
- throw new ProcessingException("TransformerException: " + e, e);
- } catch (SAXException e) {
- throw new ProcessingException("SAXException while streaming DOM node to SAX: " + e, e);
- }
- }
-
- /**
- * Add string data
- *
- * @param contentHandler The SAX content handler
- * @param data The string data
- */
- public static void data(ContentHandler contentHandler,
- String data)
- throws SAXException {
-
- contentHandler.characters(data.toCharArray(), 0, data.length());
- }
-
- /**
- * Implementation of <xsp:expr> for <code>String</code> :
- * outputs characters representing the value.
- *
- * @param contentHandler the SAX content handler
- * @param text the value
- */
- public static void valueOf(ContentHandler contentHandler, String text)
- throws SAXException {
-
- if (text != null) {
- data(contentHandler, text);
- }
- }
-
- /**
- * Implementation of <xsp:expr> for <code>XMLizable</code> :
- * outputs the value by calling <code>v.toSax(contentHandler)</code>.
- *
- * @param contentHandler the SAX content handler
- * @param v the XML fragment
- */
- public static void valueOf(ContentHandler contentHandler,
- org.apache.excalibur.xml.sax.XMLizable v)
- throws SAXException {
-
- if (v != null) {
- v.toSAX(contentHandler);
- }
- }
-
- /**
- * Implementation of <xsp:expr> for <code>org.w3c.dom.Node</code> :
- * converts the Node to a SAX event stream.
- *
- * @param contentHandler the SAX content handler
- * @param v the value
- */
- public static void valueOf(ContentHandler contentHandler, Node v)
- throws SAXException {
-
- if (v != null) {
- DOMStreamer streamer = new DOMStreamer(contentHandler);
- if (contentHandler instanceof LexicalHandler) {
- streamer.setLexicalHandler((LexicalHandler)contentHandler);
- }
- streamer.stream(v);
- }
- }
-
- /**
- * Implementation of <xsp:expr> for <code>java.util.Collection</code> :
- * outputs the value by calling <code>xspExpr()</code> on each element of the
- * collection.
- *
- * @param contentHandler the SAX content handler
- * @param v the XML fragment
- */
- public static void valueOf(ContentHandler contentHandler,
- Collection v)
- throws SAXException {
-
- if (v != null) {
- Iterator iterator = v.iterator();
- while (iterator.hasNext()) {
- valueOf(contentHandler, iterator.next());
- }
- }
- }
-
- /**
- * Implementation of <xsp:expr> for <code>Object</code> depending on its class :
- * <ul>
- * <li>if it's an array, call <code>xspExpr()</code> on all its elements,</li>
- * <li>if it's class has a specific <code>xspExpr()</code>implementation, use it,</li>
- * <li>else, output it's string representation.</li>
- * </ul>
- *
- * @param contentHandler the SAX content handler
- * @param v the value
- */
- public static void valueOf(ContentHandler contentHandler, Object v)
- throws SAXException {
-
- if (v == null) {
- return;
- }
-
- // Array: recurse over each element
- if (v.getClass().isArray()) {
- Object[] elements = (Object[]) v;
-
- for (int i = 0; i < elements.length; i++) {
- valueOf(contentHandler, elements[i]);
- }
- return;
- }
-
- // Check handled object types in case they were not typed in the XSP
-
- // XMLizable
- if (v instanceof org.apache.excalibur.xml.sax.XMLizable) {
- valueOf(contentHandler, (org.apache.excalibur.xml.sax.XMLizable)v);
- return;
- }
-
- // Node
- if (v instanceof Node) {
- valueOf(contentHandler, (Node)v);
- return;
- }
-
- // Collection
- if (v instanceof Collection) {
- valueOf(contentHandler, (Collection)v);
- return;
- }
-
- // Give up: hope it's a string or has a meaningful string representation
- data(contentHandler, String.valueOf(v));
- }
-
- /**
- * Create a start and endElement with a empty Namespace and without Attributes
- *
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void createElement(ContentHandler contentHandler,
- String localName)
- throws SAXException {
-
- startElement(contentHandler, localName);
- endElement(contentHandler, localName);
- }
-
- /**
- * Create a start and endElement with a empty Namespace and without Attributes
- * The content of the Element is set to the stringValue parameter
- *
- * @param localName The local name (without prefix)
- * @param stringValue The content of the Element
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void createElement(ContentHandler contentHandler,
- String localName,
- String stringValue)
- throws SAXException {
-
- startElement(contentHandler, localName);
- data(contentHandler, stringValue);
- endElement(contentHandler, localName);
- }
-
- /**
- * Create a start and endElement with a empty Namespace
- *
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void createElement(ContentHandler contentHandler,
- String localName,
- Attributes atts)
- throws SAXException {
-
- startElement(contentHandler, localName, atts);
- endElement(contentHandler, localName);
- }
-
- /**
- * Create a start and endElement with a empty Namespace
- * The content of the Element is set to the stringValue parameter
- *
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @param stringValue The content of the Element
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void createElement(ContentHandler contentHandler,
- String localName,
- Attributes atts,
- String stringValue)
- throws SAXException {
-
- startElement(contentHandler, localName, atts);
- data(contentHandler, stringValue);
- endElement(contentHandler, localName);
- }
-
- /**
- * Create a start and endElement without Attributes
- *
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void createElementNS(ContentHandler contentHandler,
- String namespaceURI,
- String localName)
- throws SAXException {
-
- startElement(contentHandler, namespaceURI, localName);
- endElement(contentHandler, namespaceURI, localName);
- }
-
- /**
- * Create a start and endElement without Attributes
- * The content of the Element is set to the stringValue parameter
- *
- * @param localName The local name (without prefix)
- * @param stringValue The content of the Element
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void createElementNS(ContentHandler contentHandler,
- String namespaceURI,
- String localName,
- String stringValue)
- throws SAXException {
-
- startElement(contentHandler, namespaceURI, localName);
- data(contentHandler, stringValue);
- endElement(contentHandler, namespaceURI, localName);
- }
-
- /**
- * Create a start and endElement
- *
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void createElementNS(ContentHandler contentHandler,
- String namespaceURI,
- String localName,
- Attributes atts)
- throws SAXException {
-
- startElement(contentHandler, namespaceURI, localName, atts);
- endElement(contentHandler, namespaceURI, localName);
- }
-
- /**
- * Create a start and endElement with a empty Namespace
- * The content of the Element is set to the stringValue parameter
- *
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @param stringValue The content of the Element
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void createElementNS(ContentHandler contentHandler,
- String namespaceURI,
- String localName,
- Attributes atts,
- String stringValue)
- throws SAXException {
-
- startElement(contentHandler, namespaceURI, localName, atts);
- data(contentHandler, stringValue);
- endElement(contentHandler, namespaceURI, localName);
- }
-
-
- /**
- * Create endElement with empty Namespace
- *
- * <p>For information on the names, see startElement.</p>
- *
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public static void endElement(ContentHandler contentHandler,
- String localName)
- throws SAXException {
-
- contentHandler.endElement("", localName, localName);
- }
-
- /**
- * Create endElement
- * Prefix must be mapped to empty String
- *
- * <p>For information on the names, see startElement.</p>
- *
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public static void endElement(ContentHandler contentHandler,
- String namespaceURI,
- String localName)
- throws SAXException {
-
- contentHandler.endElement(namespaceURI, localName, localName);
- }
-
- /**
- * Create a startElement with a empty Namespace and without Attributes
- *
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void startElement(ContentHandler contentHandler,
- String localName)
- throws SAXException {
-
- contentHandler.startElement("", localName, localName, EMPTY_ATTRIBUTES);
- }
-
- /**
- * Create a startElement without Attributes
- * Prefix must be mapped to empty String
- *
- * @param namespaceURI The Namespace URI
- * @param localName The local name (without prefix)
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- */
- public static void startElement(ContentHandler contentHandler,
- String namespaceURI,
- String localName)
- throws SAXException {
-
- contentHandler.startElement(namespaceURI, localName, localName, EMPTY_ATTRIBUTES);
- }
-
- /**
- * Create a startElement with a empty Namespace
- *
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void startElement(ContentHandler contentHandler,
- String localName,
- Attributes atts)
- throws SAXException {
-
- contentHandler.startElement("", localName, localName, atts);
- }
-
- /**
- * Create a startElement with a empty Namespace
- * Prefix must be mapped to empty String
- *
- * @param namespaceURI The Namespace URI
- * @param localName The local name (without prefix)
- * @param atts The attributes attached to the element. If
- * there are no attributes, it shall be an empty
- * Attributes object.
- * @exception org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement(ContentHandler, String)
- * @see org.xml.sax.Attributes
- */
- public static void startElement(ContentHandler contentHandler,
- String namespaceURI,
- String localName,
- Attributes atts)
- throws SAXException {
-
- contentHandler.startElement(namespaceURI, localName, localName, atts);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMBuilder.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMBuilder.java
deleted file mode 100644
index f3cab93..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMBuilder.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import org.apache.avalon.framework.CascadingRuntimeException;
-
-import org.apache.cocoon.xml.AbstractXMLPipe;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-
-/**
- * The <code>DOMBuilder</code> is a utility class that will generate a W3C
- * DOM Document from SAX events.
- *
- * @version $Id$
- */
-public class DOMBuilder extends AbstractXMLPipe {
-
- /** The default transformer factory shared by all instances */
- protected static final SAXTransformerFactory FACTORY = (SAXTransformerFactory) TransformerFactory.newInstance();
-
- /** The transformer factory */
- protected SAXTransformerFactory factory;
-
- /** The listener */
- protected Listener listener;
-
- /** The result */
- protected DOMResult result;
-
- /** The parentNode */
- protected Node parentNode;
-
- /**
- * Construct a new instance of this DOMBuilder.
- */
- public DOMBuilder() {
- this((Listener) null, (Node) null);
- }
-
- /**
- * Construct a new instance of this DOMBuilder.
- */
- public DOMBuilder(SAXTransformerFactory factory) {
- this(factory, null, null);
- }
-
- /**
- * Construct a new instance of this DOMBuilder.
- */
- public DOMBuilder(Listener listener) {
- this(listener, null);
- }
-
- /**
- * Constructs a new instance that appends nodes to the given parent node.
- * <br/>
- * <strong>Note:</strong> You cannot use a <code>Listener<code> when appending to a
- * <code>Node</code>, because the notification occurs at <code>endDocument()</code>
- * which does not happen here.
- */
- public DOMBuilder(Node parentNode) {
- this(null, parentNode);
- }
-
- /**
- * Construct a new instance of this DOMBuilder.
- */
- public DOMBuilder(Listener listener, Node parentNode) {
- this((SAXTransformerFactory) null, listener, parentNode);
- }
-
- /**
- * Construct a new instance of this DOMBuilder.
- */
- public DOMBuilder(SAXTransformerFactory factory, Listener listener, Node parentNode) {
- super();
- this.factory = factory == null? FACTORY: factory;
- this.listener = listener;
- this.parentNode = parentNode;
- setup();
- }
-
- /**
- * Setup this instance transformer and result objects.
- */
- private void setup() {
- try {
- TransformerHandler handler = this.factory.newTransformerHandler();
- setContentHandler(handler);
- setLexicalHandler(handler);
- if (this.parentNode != null) {
- this.result = new DOMResult(this.parentNode);
- } else {
- this.result = new DOMResult();
- }
- handler.setResult(this.result);
- } catch (javax.xml.transform.TransformerException local) {
- throw new CascadingRuntimeException("Fatal-Error: Unable to get transformer handler", local);
- }
- }
-
- /**
- * Recycle this builder, prepare for re-use.
- */
- public void recycle() {
- super.recycle();
- setup();
- }
-
- /**
- * Return the newly built Document.
- */
- public Document getDocument() {
- if (this.result == null || this.result.getNode() == null) {
- return null;
- } else if (this.result.getNode().getNodeType() == Node.DOCUMENT_NODE) {
- return (Document) this.result.getNode();
- } else {
- return this.result.getNode().getOwnerDocument();
- }
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * @exception SAXException If this method was not called appropriately.
- */
- public void endDocument() throws SAXException {
- super.endDocument();
- // Notify the listener
- notifyListener();
- }
-
- /**
- * Receive notification of a successfully completed DOM tree generation.
- */
- protected void notifyListener() throws SAXException {
- if (this.listener != null) {
- this.listener.notify(getDocument());
- }
- }
-
- /**
- * The Listener interface must be implemented by those objects willing to
- * be notified of a successful DOM tree generation.
- */
- public interface Listener {
-
- /**
- * Receive notification of a successfully completed DOM tree generation.
- */
- void notify(Document doc) throws SAXException;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMStreamer.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMStreamer.java
deleted file mode 100644
index 76ff0ca..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMStreamer.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import org.apache.avalon.excalibur.pool.Recyclable;
-
-import org.apache.cocoon.xml.AbstractXMLProducer;
-import org.apache.cocoon.xml.EmbeddedXMLPipe;
-import org.apache.cocoon.xml.XMLConsumer;
-import org.apache.cocoon.xml.XMLProducer;
-
-import org.apache.commons.lang.StringUtils;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.AttributesImpl;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * The <code>DOMStreamer</code> is a utility class that will generate SAX
- * events from a W3C DOM Document.
- *
- * <p>The DOMStreamer uses a different strategy based on the value of the
- * normalizeNamespaces property:
- * <ul>
- * <li>if true (the default), the DOMStreamer will normalize namespace
- * declarations (i.e. add missing xmlns attributes or correct them). See
- * also {@link NamespaceNormalizingDOMStreamer}.
- * <li>if false, the standard JAXP identity transformer is used.
- * </ul>
- *
- * @version $Id$
- */
-public class DOMStreamer implements XMLProducer, Recyclable {
-
- /** The transformer factory shared by all instances (only used by DefaultDOMStreamer) */
- private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
-
- /** Default value for normalizeNamespaces. */
- private static final boolean DEFAULT_NORMALIZE_NAMESPACES = true;
-
- /** Indicates whether namespace normalization should happen. */
- protected boolean normalizeNamespaces = DEFAULT_NORMALIZE_NAMESPACES;
-
- /** DOMStreamer used in case of namespace normalization. */
- protected NamespaceNormalizingDOMStreamer namespaceNormalizingDOMStreamer = new NamespaceNormalizingDOMStreamer();
-
- /** DOMStreamer used when namespace normalization should not explicitely happen. */
- protected DefaultDOMStreamer defaultDOMStreamer = new DefaultDOMStreamer();
-
- /**
- * Create a new <code>DOMStreamer</code> instance.
- */
- public DOMStreamer() {
- super();
- }
-
- /**
- * Create a new <code>DOMStreamer</code> instance.
- */
- public DOMStreamer(ContentHandler content, LexicalHandler lexical) {
- this();
- setContentHandler(content);
- setLexicalHandler(lexical);
- }
-
- /**
- * Create a new <code>DOMStreamer</code> instance.
- */
- public DOMStreamer(XMLConsumer consumer) {
- this(consumer, consumer);
- }
-
- /**
- * Create a new <code>DOMStreamer</code> instance.
- */
- public DOMStreamer(ContentHandler content) {
- this(content, content instanceof LexicalHandler ? (LexicalHandler) content : null);
- }
-
- /**
- * Set the <code>XMLConsumer</code> that will receive XML data.
- */
- public void setConsumer(XMLConsumer consumer) {
- setContentHandler(consumer);
- setLexicalHandler(consumer);
- }
-
- /**
- * Set the <code>ContentHandler</code> that will receive XML data.
- */
- public void setContentHandler(ContentHandler handler) {
- defaultDOMStreamer.setContentHandler(handler);
- namespaceNormalizingDOMStreamer.setContentHandler(handler);
- }
-
- /**
- * Set the <code>LexicalHandler</code> that will receive XML data.
- */
- public void setLexicalHandler(LexicalHandler handler) {
- defaultDOMStreamer.setLexicalHandler(handler);
- namespaceNormalizingDOMStreamer.setLexicalHandler(handler);
- }
-
- /**
- * Start the production of SAX events.
- */
- public void stream(Node node) throws SAXException {
- if (normalizeNamespaces) {
- namespaceNormalizingDOMStreamer.stream(node);
- } else {
- defaultDOMStreamer.stream(node);
- }
- }
-
- public boolean isNormalizeNamespaces() {
- return normalizeNamespaces;
- }
-
- public void setNormalizeNamespaces(boolean normalizeNamespaces) {
- this.normalizeNamespaces = normalizeNamespaces;
- }
-
- public void recycle() {
- defaultDOMStreamer.recycle();
- namespaceNormalizingDOMStreamer.recycle();
- normalizeNamespaces = DEFAULT_NORMALIZE_NAMESPACES;
- }
-
- /**
- * Streams a DOM tree to SAX events and normalizes namespace declarations on the way.
- *
- * <p>The code in this class is based on the org.apache.xml.utils.TreeWalker class from Xalan,
- * though it differs in some important ways.
- *
- * <p>This class will automatically fix up ("normalize") namespace declarations
- * while streaming to SAX. The original DOM-tree is not modified. The algorithm
- * used is described in
- * <a href="http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20021022/namespaces-algorithms.html#normalizeDocumentAlgo">an appendix of the DOM Level 3 spec</a>.
- *
- * <p>This class will NOT check the correctness of namespaces, e.g. it will not
- * check that the "xml" prefix is not misused etc.
- *
- */
- public static class NamespaceNormalizingDOMStreamer extends AbstractXMLProducer {
- /**
- * Information about the current element. Used to remember the localName, qName
- * and namespaceURI for generating the endElement event, and holds the namespaces
- * declared on the element. This extra class is needed because we don't want to
- * modify the DOM-tree itself. The currentElementInfo has a pointer to its parent
- * elementInfo.
- */
- protected NamespaceNormalizingDOMStreamer.ElementInfo currentElementInfo;
-
- /** Counter used when generating new namespace prefixes. */
- protected int newPrefixCounter;
-
- public void recycle() {
- super.recycle();
- currentElementInfo = null;
- newPrefixCounter = 0;
- }
-
- /**
- * Start the production of SAX events.
- *
- * <p>Perform a pre-order traversal non-recursive style.
- *
- * <p>Note that TreeWalker assumes that the subtree is intended to represent
- * a complete (though not necessarily well-formed) document and, during a
- * traversal, startDocument and endDocument will always be issued to the
- * SAX listener.
- *
- * @param pos Node in the tree where to start traversal
- */
- protected void stream(Node pos) throws SAXException {
-
- // Start document only if we're streaming a document
- boolean isDoc = (pos.getNodeType() == Node.DOCUMENT_NODE);
- if (isDoc) {
- contentHandler.startDocument();
- }
-
- Node top = pos;
- while (null != pos) {
- startNode(pos);
-
- Node nextNode = pos.getFirstChild();
- while (null == nextNode) {
- endNode(pos);
-
- if (top.equals(pos)) {
- break;
- }
-
- nextNode = pos.getNextSibling();
- if (null == nextNode) {
- pos = pos.getParentNode();
-
- if ((null == pos) || (top.equals(pos))) {
- if (null != pos) {
- endNode(pos);
- }
- nextNode = null;
-
- break;
- }
- }
- }
-
- pos = nextNode;
- }
-
- if (isDoc) {
- contentHandler.endDocument();
- }
- }
-
- private final void dispatchChars(Node node) throws SAXException {
- final String data = ((Text) node).getData();
- if ( data != null ) {
- contentHandler.characters(data.toCharArray(), 0, data.length());
- }
- }
-
- /**
- * Start processing given node
- *
- * @param node Node to process
- */
- protected void startNode(Node node) throws SAXException {
-
- switch (node.getNodeType()) {
- case Node.COMMENT_NODE:
- {
- if (lexicalHandler != null) {
- final String data = ((Comment) node).getData();
- if ( data != null ) {
- lexicalHandler.comment(data.toCharArray(), 0, data.length());
- }
- }
- }
- break;
- case Node.DOCUMENT_FRAGMENT_NODE:
- // ??;
- case Node.DOCUMENT_NODE:
- break;
- case Node.ELEMENT_NODE:
- NamedNodeMap atts = node.getAttributes();
- int nAttrs = atts.getLength();
-
- // create a list of localy declared namespace prefixes
- currentElementInfo = new NamespaceNormalizingDOMStreamer.ElementInfo(currentElementInfo);
- for (int i = 0; i < nAttrs; i++) {
- Node attr = atts.item(i);
- String attrName = attr.getNodeName();
-
- if (attrName.equals("xmlns") || attrName.startsWith("xmlns:")) {
- int index;
- String prefix = (index = attrName.indexOf(":")) < 0
- ? "" : attrName.substring(index + 1);
-
- currentElementInfo.put(prefix, attr.getNodeValue());
- }
- }
-
- String namespaceURI = node.getNamespaceURI();
- String prefix = node.getPrefix();
- String localName = node.getLocalName();
-
- if (localName == null) {
- // this is an element created with createElement instead of createElementNS
- String[] prefixAndLocalName = getPrefixAndLocalName(node.getNodeName());
- prefix = prefixAndLocalName[0];
- localName = prefixAndLocalName[1];
- // note: if prefix is null, there can still be a default namespace...
- namespaceURI = getNamespaceForPrefix(prefix, (Element)node);
- }
-
- if (namespaceURI != null) {
- // no prefix means: make this the default namespace
- if (prefix == null) {
- prefix = "";
- }
- // check that is declared
- String uri = currentElementInfo.findNamespaceURI(prefix);
- if (StringUtils.equals(uri, namespaceURI)) {
- // System.out.println("namespace is declared");
- // prefix is declared correctly, do nothing
- //} else if (uri != null) {
- // System.out.println("prefix is declared with other namespace, overwriting it");
- // prefix exists but is bound to another namespace, overwrite it
- // currentElementInfo.put(prefix, namespaceURI);
- } else {
- // System.out.println("prefix is not yet declared, declaring it now");
- currentElementInfo.put(prefix, namespaceURI);
- }
- } else {
- // element has no namespace
- // check if there is a default namespace, if so undeclare it
- String uri = currentElementInfo.findNamespaceURI("");
- if (StringUtils.isNotEmpty(uri)) {
- // System.out.println("undeclaring default namespace");
- currentElementInfo.put("", "");
- }
- }
-
- // SAX uses empty string to denote no namespace, while DOM uses null.
- if (namespaceURI == null)
- namespaceURI = "";
-
- String qName;
- if (StringUtils.isNotEmpty(prefix)) {
- qName = prefix + ":" + localName;
- } else {
- qName = localName;
- }
-
- // make the attributes
- AttributesImpl newAttrs = new AttributesImpl();
- for (int i = 0; i < nAttrs; i++) {
- Node attr = atts.item(i);
- String attrName = attr.getNodeName();
- String assignedAttrPrefix = null;
-
- // only do non-namespace attributes
- if (!(attrName.equals("xmlns") || attrName.startsWith("xmlns:"))) {
- String attrPrefix;
- String attrLocalName;
- String attrNsURI;
-
- if (attr.getLocalName() == null) {
- // this is an attribute created with setAttribute instead of setAttributeNS
- String[] prefixAndLocalName = getPrefixAndLocalName(attrName);
- attrPrefix = prefixAndLocalName[0];
- // the statement below causes the attribute to keep its prefix even if it is not
- // bound to a namespace (to support pre-namespace XML).
- assignedAttrPrefix = attrPrefix;
- attrLocalName = prefixAndLocalName[1];
- // note: if prefix is null, the attribute has no namespace (namespace defaulting
- // does not apply to attributes)
- if (attrPrefix != null)
- attrNsURI = getNamespaceForPrefix(attrPrefix, (Element)node);
- else
- attrNsURI = null;
- } else {
- attrLocalName = attr.getLocalName();
- attrPrefix = attr.getPrefix();
- attrNsURI = attr.getNamespaceURI();
- }
-
- if (attrNsURI != null) {
- String declaredUri = currentElementInfo.findNamespaceURI(attrPrefix);
- // if the prefix is null, or the prefix has not been declared, or conflicts with an in-scope binding
- if (declaredUri == null || !declaredUri.equals(attrNsURI)) {
- String availablePrefix = currentElementInfo.findPrefix(attrNsURI);
- if (availablePrefix != null && !availablePrefix.equals(""))
- assignedAttrPrefix = availablePrefix;
- else {
- if (attrPrefix != null && declaredUri == null) {
- // prefix is not null and is not yet declared: declare it
- assignedAttrPrefix = attrPrefix;
- currentElementInfo.put(assignedAttrPrefix, attrNsURI);
- } else {
- // attribute has no prefix (which is not allowed for namespaced attributes) or
- // the prefix is already bound to something else: generate a new prefix
- newPrefixCounter++;
- assignedAttrPrefix = "NS" + newPrefixCounter;
- currentElementInfo.put(assignedAttrPrefix, attrNsURI);
- }
- }
- } else {
- assignedAttrPrefix = attrPrefix;
- }
- }
-
- String assignedAttrNsURI = attrNsURI != null ? attrNsURI : "";
- String attrQName;
- if (assignedAttrPrefix != null) {
- attrQName = assignedAttrPrefix + ":" + attrLocalName;
- } else {
- attrQName = attrLocalName;
- }
- newAttrs.addAttribute(assignedAttrNsURI, attrLocalName, attrQName, "CDATA", attr.getNodeValue());
- }
- }
-
- // add local namespace declaration and fire startPrefixMapping events
- if (currentElementInfo.namespaceDeclarations != null && currentElementInfo.namespaceDeclarations.size() > 0) {
- Iterator localNsDeclIt = currentElementInfo.namespaceDeclarations.entrySet().iterator();
- while (localNsDeclIt.hasNext()) {
- Map.Entry entry = (Map.Entry) localNsDeclIt.next();
- String pr = (String) entry.getKey();
- String ns = (String) entry.getValue();
- // the following lines enable the creation of explicit xmlns attributes
- //String pr1 = pr.equals("") ? "xmlns" : pr;
- //String qn = pr.equals("") ? "xmlns" : "xmlns:" + pr;
- //newAttrs.addAttribute("", pr1, qn, "CDATA", ns);
- // System.out.println("starting prefix mapping for prefix " + pr + " for " + ns);
- contentHandler.startPrefixMapping(pr, ns);
- }
- }
-
- contentHandler.startElement(namespaceURI, localName, qName, newAttrs);
-
- currentElementInfo.localName = localName;
- currentElementInfo.namespaceURI = namespaceURI;
- currentElementInfo.qName = qName;
- break;
- case Node.PROCESSING_INSTRUCTION_NODE:
- {
- ProcessingInstruction pi = (ProcessingInstruction) node;
- contentHandler.processingInstruction(pi.getNodeName(), pi.getData());
- }
- break;
- case Node.CDATA_SECTION_NODE:
- {
- if (lexicalHandler != null)
- lexicalHandler.startCDATA();
-
- dispatchChars(node);
-
- if (lexicalHandler != null)
- lexicalHandler.endCDATA();
- }
- break;
- case Node.TEXT_NODE:
- {
- dispatchChars(node);
- }
- break;
- case Node.ENTITY_REFERENCE_NODE:
- {
- EntityReference eref = (EntityReference) node;
-
- if (lexicalHandler != null) {
- lexicalHandler.startEntity(eref.getNodeName());
- } else {
- // warning("Can not output entity to a pure SAX ContentHandler");
- }
- }
- break;
- default :
- }
- }
-
- /**
- * Searches the namespace for a given namespace prefix starting from a
- * given Element.
- *
- * <p>Note that this resolves the prefix in the orginal DOM-tree, not in
- * the {@link ElementInfo} objects. This is used to resolve prefixes
- * of elements or attributes created with createElement or setAttribute
- * instead of createElementNS or setAttributeNS.
- *
- * <p>The code in this method is largely based on
- * org.apache.xml.utils.DOMHelper.getNamespaceForPrefix() (from Xalan).
- *
- * @param prefix the prefix to look for, can be empty or null to find the
- * default namespace
- *
- * @return the namespace, or null if not found.
- */
- public String getNamespaceForPrefix(String prefix, Element namespaceContext) {
- int type;
- Node parent = namespaceContext;
- String namespace = null;
-
- if (prefix == null)
- prefix = "";
-
- if (prefix.equals("xml")) {
- namespace = "http://www.w3.org/XML/1998/namespace";
- } else if(prefix.equals("xmlns")) {
- namespace = "http://www.w3.org/2000/xmlns/";
- } else {
- // Attribute name for this prefix's declaration
- String declname = (prefix.length() == 0) ? "xmlns" : "xmlns:" + prefix;
-
- // Scan until we run out of Elements or have resolved the namespace
- while ((null != parent)
- && (((type = parent.getNodeType()) == Node.ELEMENT_NODE)
- || (type == Node.ENTITY_REFERENCE_NODE))) {
- if (type == Node.ELEMENT_NODE) {
- Attr attr=((Element)parent).getAttributeNode(declname);
- if (attr != null) {
- namespace = attr.getNodeValue();
- break;
- }
- }
- parent = parent.getParentNode();
- }
- }
- return namespace;
- }
-
- /**
- * Splits a nodeName into a prefix and a localName
- *
- * @return an array containing two elements, the first one is the prefix (can be null), the
- * second one is the localName
- */
- private String[] getPrefixAndLocalName(String nodeName) {
- String prefix, localName;
- int colonPos = nodeName.indexOf(":");
- if (colonPos != -1) {
- prefix = nodeName.substring(0, colonPos);
- localName = nodeName.substring(colonPos + 1, nodeName.length());
- } else {
- prefix = null;
- localName = nodeName;
- }
- return new String[] {prefix, localName};
- }
-
- /**
- * End processing of given node
- *
- * @param node Node we just finished processing
- */
- protected void endNode(Node node) throws org.xml.sax.SAXException {
-
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- contentHandler.endElement(currentElementInfo.namespaceURI,
- currentElementInfo.localName, currentElementInfo.qName);
-
- // generate endPrefixMapping events if needed
- if (currentElementInfo.namespaceDeclarations != null && currentElementInfo.namespaceDeclarations.size() > 0) {
- Iterator namespaceIt = currentElementInfo.namespaceDeclarations.entrySet().iterator();
- while (namespaceIt.hasNext()) {
- Map.Entry entry = (Map.Entry) namespaceIt.next();
- contentHandler.endPrefixMapping((String) entry.getKey());
- //System.out.println("ending prefix mapping " + (String) entry.getKey());
- }
- }
- currentElementInfo = currentElementInfo.parent;
- break;
- case Node.DOCUMENT_NODE:
- case Node.CDATA_SECTION_NODE:
- break;
- case Node.ENTITY_REFERENCE_NODE:
- {
- EntityReference eref = (EntityReference) node;
-
- if (lexicalHandler != null) {
- lexicalHandler.endEntity(eref.getNodeName());
- }
- }
- break;
- default :
- }
- }
-
- public static class ElementInfo {
- public String localName;
- public String namespaceURI;
- public String qName;
- public Map namespaceDeclarations = null;
- public ElementInfo parent;
-
- public ElementInfo(ElementInfo parent) {
- this.parent = parent;
- }
-
- /**
- * Declare a new namespace prefix on this element, possibly overriding
- * an existing one.
- */
- public void put(String prefix, String namespaceURI) {
- if (namespaceDeclarations == null)
- namespaceDeclarations = new HashMap();
- namespaceDeclarations.put(prefix, namespaceURI);
- }
-
- /**
- * Finds a prefix declared on this element.
- */
- public String getPrefix(String namespaceURI) {
- if (namespaceDeclarations == null || namespaceDeclarations.size() == 0)
- return null;
- // note: there could be more than one prefix for the same namespaceURI, but
- // we return the first found one.
- Iterator it = namespaceDeclarations.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry entry = (Map.Entry) it.next();
- if (entry.getValue().equals(namespaceURI))
- return (String) entry.getKey();
- }
- return null;
- }
-
- /**
- * Finds a namespace URI declared on this element.
- */
- public String getNamespaceURI(String prefix) {
- if (namespaceDeclarations == null || namespaceDeclarations.size() == 0)
- return null;
-
- return (String) namespaceDeclarations.get(prefix);
- }
-
- /**
- * Finds a prefix declaration on this element or containing elements.
- */
- public String findPrefix(String namespaceURI) {
- if (namespaceDeclarations != null && namespaceDeclarations.size() != 0) {
- String prefix = getPrefix(namespaceURI);
- if (prefix != null) {
- return prefix;
- }
- }
- if (parent != null) {
- return parent.findPrefix(namespaceURI);
- }
- return null;
- }
-
- /**
- * Finds a namespace declaration on this element or containing elements.
- */
- public String findNamespaceURI(String prefix) {
- if (namespaceDeclarations != null && namespaceDeclarations.size() != 0) {
- String uri = (String) namespaceDeclarations.get(prefix);
- if (uri != null) {
- return uri;
- }
- }
- if (parent != null) {
- return parent.findNamespaceURI(prefix);
- }
- return null;
- }
- }
- }
-
- /**
- * The <code>DefaultDOMStreamer</code> is a utility class that will generate SAX
- * events from a W3C DOM Document.
- */
- public static class DefaultDOMStreamer extends AbstractXMLProducer {
-
- /** The private transformer for this instance */
- protected Transformer transformer;
-
- /**
- * Start the production of SAX events.
- */
- public void stream(Node node)
- throws SAXException {
- if (this.transformer == null) {
- try {
- this.transformer = FACTORY.newTransformer();
- } catch (TransformerConfigurationException e) {
- throw new SAXException(e);
- }
- }
- DOMSource source = new DOMSource(node);
-
- ContentHandler handler;
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- // Pass all SAX events
- handler = contentHandler;
- } else {
- // Strip start/endDocument
- handler = new EmbeddedXMLPipe(contentHandler);
- }
-
- SAXResult result = new SAXResult(handler);
- result.setLexicalHandler(lexicalHandler);
-
- try {
- transformer.transform(source, result);
- } catch (TransformerException e) {
- throw new SAXException(e);
- }
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMUtil.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMUtil.java
deleted file mode 100644
index dd65414..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DOMUtil.java
+++ /dev/null
@@ -1,1145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.xml.IncludeXMLConsumer;
-import org.apache.cocoon.xml.XMLUtils;
-
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.excalibur.source.SourceParameters;
-import org.apache.excalibur.xml.sax.SAXParser;
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.apache.excalibur.xml.xpath.NodeListImpl;
-import org.apache.excalibur.xml.xpath.XPathProcessor;
-import org.apache.excalibur.xml.xpath.XPathUtil;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * This class is a utility class for miscellaneous DOM functions, like getting
- * and setting values of nodes.
- *
- * @version $Id$
- */
-public final class DOMUtil {
-
- private static final String XPATH_IS_REQUIRED = "XPath is required.";
-
- /**
- * Get the owner of the DOM document belonging to the node. This works even
- * if the node is the document itself.
- *
- * @param node
- * The node.
- * @return The corresponding document.
- */
- public static Document getOwnerDocument(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return (Document) node;
- } else {
- return node.getOwnerDocument();
- }
- }
-
- /**
- * Get the value of the node specified by the XPath. This works similar to
- * <xsl:value-of>. If the node does not exist <CODE>null</CODE> is
- * returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @return The value of the node or <CODE>null</CODE>
- */
- public static String getValueOfNode(XPathProcessor processor, Node root, String path) throws ProcessingException {
- if (path == null) {
- throw new ProcessingException(XPATH_IS_REQUIRED);
- }
- if (root != null) {
- path = StringUtils.strip(path, "/");
- Node node = XPathUtil.searchSingleNode(processor, root, path);
- if (node != null) {
- return getValueOfNode(node);
- }
- }
- return null;
- }
-
- /**
- * Get the value of the node specified by the XPath. This works similar to
- * <xsl:value-of>. If the node is not found the <CODE>defaultValue</CODE>
- * is returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param defaultValue
- * The default value if the node does not exist.
- * @return The value of the node or <CODE>defaultValue</CODE>
- */
- public static String getValueOfNode(XPathProcessor processor, Node root, String path, String defaultValue)
- throws ProcessingException {
- String value = getValueOfNode(processor, root, path);
- if (value == null)
- value = defaultValue;
-
- return value;
- }
-
- /**
- * Get the boolean value of the node specified by the XPath. This works
- * similar to <xsl:value-of>. If the node exists and has a value this
- * value is converted to a boolean, e.g. "true" or "false" as value will
- * result into the corresponding boolean values.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @return The boolean value of the node.
- * @throws ProcessingException
- * If the node is not found.
- */
- public static boolean getValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path)
- throws ProcessingException {
- String value = getValueOfNode(processor, root, path);
- if (value == null) {
- throw new ProcessingException("No such node: " + path);
- }
- return Boolean.valueOf(value).booleanValue();
- }
-
- /**
- * Get the boolean value of the node specified by the XPath. This works
- * similar to <xsl:value-of>. If the node exists and has a value this
- * value is converted to a boolean, e.g. "true" or "false" as value will
- * result into the corresponding boolean values. If the node does not exist,
- * the <CODE>defaultValue</CODE> is returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param defaultValue
- * Default boolean value.
- * @return The value of the node or <CODE>defaultValue</CODE>
- */
- public static boolean getValueOfNodeAsBoolean(XPathProcessor processor, Node root, String path, boolean defaultValue)
- throws ProcessingException {
- String value = getValueOfNode(processor, root, path);
- if (value != null) {
- return BooleanUtils.toBoolean(value);
- }
- return defaultValue;
- }
-
- /**
- * Get the value of the DOM node. The value of a node is the content of the
- * first text node. If the node has no text nodes, <code>null</code> is
- * returned.
- */
- public static String getValueOfNode(Node node) {
- if (node != null) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- return node.getNodeValue();
- } else {
- node.normalize();
- NodeList childs = node.getChildNodes();
- int i = 0;
- int length = childs.getLength();
- while (i < length) {
- if (childs.item(i).getNodeType() == Node.TEXT_NODE) {
- return childs.item(i).getNodeValue().trim();
- } else {
- i++;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Get the value of the node. The value of the node is the content of the
- * first text node. If the node has no text nodes the <CODE>defaultValue</CODE>
- * is returned.
- */
- public static String getValueOfNode(Node node, String defaultValue) {
- return StringUtils.defaultString(getValueOfNode(node), defaultValue);
- }
-
- /**
- * Set the value of the DOM node. All current children of the node are
- * removed and a new text node with the value is appended.
- */
- public static void setValueOfNode(Node node, String value) {
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- node.setNodeValue(value);
- } else {
- while (node.hasChildNodes()) {
- node.removeChild(node.getFirstChild());
- }
- node.appendChild(node.getOwnerDocument().createTextNode(value));
- }
- }
-
- /** XML definition for a document */
- private static final String XML_DEFINITION = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-
- private static final String XML_ROOT_DEFINITION = XML_DEFINITION + "<root>";
-
- /**
- * Get a document fragment from a <code>Reader</code>. The reader must
- * provide valid XML, but it is allowed that the XML has more than one root
- * node. This xml is parsed by the specified parser instance and a DOM
- * DocumentFragment is created.
- */
- public static DocumentFragment getDocumentFragment(SAXParser parser, Reader stream) throws ProcessingException {
- DocumentFragment frag = null;
-
- Writer writer;
- Reader reader;
- boolean removeRoot = true;
-
- try {
- // create a writer,
- // write the root element, then the input from the
- // reader
- writer = new StringWriter();
-
- writer.write(XML_ROOT_DEFINITION);
- char[] cbuf = new char[16384];
- int len;
- do {
- len = stream.read(cbuf, 0, 16384);
- if (len != -1) {
- writer.write(cbuf, 0, len);
- }
- } while (len != -1);
- writer.write("</root>");
-
- // now test if xml input start with <?xml
- String xml = writer.toString();
- String searchString = XML_ROOT_DEFINITION + "<?xml ";
- if (xml.startsWith(searchString)) {
- // now remove the surrounding root element
- xml = xml.substring(XML_ROOT_DEFINITION.length(), xml.length() - 7);
- removeRoot = false;
- }
-
- reader = new StringReader(xml);
-
- InputSource input = new InputSource(reader);
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startElement("", "root", "root", XMLUtils.EMPTY_ATTRIBUTES);
-
- IncludeXMLConsumer filter = new IncludeXMLConsumer(builder, builder);
- parser.parse(input, filter);
-
- builder.endElement("", "root", "root");
- builder.endDocument();
-
- // Create Document Fragment, remove <root>
- final Document doc = builder.getDocument();
- frag = doc.createDocumentFragment();
- final Node root = doc.getDocumentElement().getFirstChild();
- root.normalize();
- if (removeRoot == false) {
- root.getParentNode().removeChild(root);
- frag.appendChild(root);
- } else {
- Node child;
- while (root.hasChildNodes()) {
- child = root.getFirstChild();
- root.removeChild(child);
- frag.appendChild(child);
- }
- }
- } catch (SAXException sax) {
- throw new ProcessingException("SAXException: " + sax, sax);
- } catch (IOException ioe) {
- throw new ProcessingException("IOException: " + ioe, ioe);
- }
- return frag;
- }
-
- /**
- * Create a parameter object from xml. The xml is flat and consists of
- * elements which all have exactly one text node: <parone>value_one<parone>
- * <partwo>value_two<partwo> A parameter can occur more than once with
- * different values. If <CODE>source</CODE> is not specified a new
- * parameter object is created otherwise the parameters are added to source.
- */
- public static SourceParameters createParameters(Node fragment, SourceParameters source) {
- SourceParameters par = (source == null ? new SourceParameters() : source);
- if (fragment != null) {
- NodeList childs = fragment.getChildNodes();
- if (childs != null) {
- Node current;
- for (int i = 0; i < childs.getLength(); i++) {
- current = childs.item(i);
-
- // only element nodes
- if (current.getNodeType() == Node.ELEMENT_NODE) {
- current.normalize();
- NodeList valueChilds = current.getChildNodes();
- String key;
- StringBuffer valueBuffer;
- String value;
-
- key = current.getNodeName();
- valueBuffer = new StringBuffer();
- for (int m = 0; m < valueChilds.getLength(); m++) {
- current = valueChilds.item(m); // attention: current is reused here!
- if (current.getNodeType() == Node.TEXT_NODE) { // only text nodes
- if (valueBuffer.length() > 0)
- valueBuffer.append(' ');
- valueBuffer.append(current.getNodeValue());
- }
- }
- value = valueBuffer.toString().trim();
- if (key != null && value.length() > 0) {
- par.setParameter(key, value);
- }
- }
- }
- }
- }
- return par;
- }
-
- /**
- * Create a string from a DOM document fragment. Only the top level text
- * nodes are chained together to build the text.
- */
- public static String createText(DocumentFragment fragment) {
- StringBuffer value = new StringBuffer();
- if (fragment != null) {
- NodeList childs = fragment.getChildNodes();
- if (childs != null) {
- Node current;
-
- for (int i = 0; i < childs.getLength(); i++) {
- current = childs.item(i);
-
- // only text nodes
- if (current.getNodeType() == Node.TEXT_NODE) {
- if (value.length() > 0)
- value.append(' ');
- value.append(current.getNodeValue());
- }
- }
- }
- }
- return value.toString().trim();
- }
-
- /**
- * Compare all attributes of two elements. This method returns true only if
- * both nodes have the same number of attributes and the same attributes
- * with equal values. Namespace definition nodes are ignored
- */
- public static boolean compareAttributes(Element first, Element second) {
- NamedNodeMap attr1 = first.getAttributes();
- NamedNodeMap attr2 = second.getAttributes();
- String value;
-
- if (attr1 == null && attr2 == null)
- return true;
- int attr1Len = (attr1 == null ? 0 : attr1.getLength());
- int attr2Len = (attr2 == null ? 0 : attr2.getLength());
- if (attr1Len > 0) {
- int l = attr1.getLength();
- for (int i = 0; i < l; i++) {
- if (attr1.item(i).getNodeName().startsWith("xmlns:"))
- attr1Len--;
- }
- }
- if (attr2Len > 0) {
- int l = attr2.getLength();
- for (int i = 0; i < l; i++) {
- if (attr2.item(i).getNodeName().startsWith("xmlns:"))
- attr2Len--;
- }
- }
- if (attr1Len != attr2Len)
- return false;
- int i, l;
- int m, l2;
- i = 0;
- l = attr1.getLength();
- l2 = attr2.getLength();
- boolean ok = true;
- // each attribute of first must be in second with the same value
- while (i < l && ok) {
- value = attr1.item(i).getNodeName();
- if (value.startsWith("xmlns:") == false) {
- ok = false;
- m = 0;
- while (m < l2 && ok == false) {
- if (attr2.item(m).getNodeName().equals(value)) {
- // same name, same value?
- ok = attr1.item(i).getNodeValue().equals(attr2.item(m).getNodeValue());
- }
- m++;
- }
- }
-
- i++;
- }
- return ok;
- }
-
- /**
- * Implementation for <code>String</code> : outputs characters
- * representing the value.
- *
- * @param parent
- * The node getting the value
- * @param text
- * the value
- */
- public static void valueOf(Node parent, String text) throws ProcessingException {
- if (text != null) {
- parent.appendChild(parent.getOwnerDocument().createTextNode(text));
- }
- }
-
- /**
- * Implementation for <code>XMLizable</code> : outputs the value by
- * calling <code>v.toSax(contentHandler)</code>.
- *
- * @param parent
- * The node getting the value
- * @param v
- * the XML fragment
- */
- public static void valueOf(Node parent, XMLizable v) throws ProcessingException {
- if (v != null) {
- DOMBuilder builder = new DOMBuilder(parent);
- try {
- v.toSAX(builder);
- } catch (SAXException e) {
- throw new ProcessingException(e);
- }
- }
- }
-
- /**
- * Implementation for <code>org.w3c.dom.Node</code> : converts the Node to
- * a SAX event stream.
- *
- * @param parent
- * The node getting the value
- * @param v
- * the value
- */
- public static void valueOf(Node parent, Node v) throws ProcessingException {
- if (v != null) {
- parent.appendChild(parent.getOwnerDocument().importNode(v, true));
- }
- }
-
- /**
- * Implementation for <code>java.util.Collection</code> : outputs the
- * value by calling {@link #valueOf(Node, Object)} on each element of the
- * collection.
- *
- * @param parent
- * The node getting the value
- * @param v
- * the XML fragment
- */
- public static void valueOf(Node parent, Collection v) throws ProcessingException {
- if (v != null) {
- Iterator iterator = v.iterator();
- while (iterator.hasNext()) {
- valueOf(parent, iterator.next());
- }
- }
- }
-
- /**
- * Implementation for <code>java.util.Map</code> : For each entry an
- * element is created with the childs key and value Outputs the value and
- * the key by calling {@link #valueOf(Node, Object)} on each value and key
- * of the Map.
- *
- * @param parent
- * The node getting the value
- * @param v
- * the Map
- */
- public static void valueOf(Node parent, Map v) throws ProcessingException {
- if (v != null) {
- Node mapNode = parent.getOwnerDocument().createElementNS(null, "java.util.map");
- parent.appendChild(mapNode);
- for (Iterator iter = v.entrySet().iterator(); iter.hasNext();) {
- final Map.Entry me = (Map.Entry) iter.next();
-
- Node entryNode = mapNode.getOwnerDocument().createElementNS(null, "entry");
- mapNode.appendChild(entryNode);
-
- Node keyNode = entryNode.getOwnerDocument().createElementNS(null, "key");
- entryNode.appendChild(keyNode);
- valueOf(keyNode, me.getKey());
-
- Node valueNode = entryNode.getOwnerDocument().createElementNS(null, "value");
- entryNode.appendChild(valueNode);
- valueOf(valueNode, me.getValue());
- }
- }
- }
-
- /**
- * Implementation for <code>Object</code> depending on its class :
- * <ul>
- * <li>if it's an array, call {@link #valueOf(Node, Object)} on all its
- * elements,</li>
- * <li>if it's class has a specific {@link #valueOf(Node, Object)}
- * implementation, use it,</li>
- * <li>else, output it's string representation.</li>
- * </ul>
- *
- * @param parent
- * The node getting the value
- * @param v
- * the value
- */
- public static void valueOf(Node parent, Object v) throws ProcessingException {
- if (v == null) {
- return;
- }
-
- // Array: recurse over each element
- if (v.getClass().isArray()) {
- Object[] elements = (Object[]) v;
-
- for (int i = 0; i < elements.length; i++) {
- valueOf(parent, elements[i]);
- }
- return;
- }
-
- // Check handled object types in case they were not typed in the XSP
-
- // XMLizable
- if (v instanceof XMLizable) {
- valueOf(parent, (XMLizable) v);
- return;
- }
-
- // Node
- if (v instanceof Node) {
- valueOf(parent, (Node) v);
- return;
- }
-
- // Collection
- if (v instanceof Collection) {
- valueOf(parent, (Collection) v);
- return;
- }
-
- // Map
- if (v instanceof Map) {
- valueOf(parent, (Map) v);
- return;
- }
-
- // Give up: hope it's a string or has a meaningful string representation
- valueOf(parent, String.valueOf(v));
- }
-
- /**
- * Use an XPath string to select a single node. XPath namespace prefixes are
- * resolved from the context node, which may not be what you want (see the
- * next method).
- *
- * @param contextNode
- * The node to start searching from.
- * @param str
- * A valid XPath string.
- * @param processor
- * The XPath processor to use
- * @return The first node found that matches the XPath, or null.
- *
- * @throws TransformerException
- */
- public static Node getSingleNode(Node contextNode, String str, XPathProcessor processor)
- throws TransformerException {
- String[] pathComponents = buildPathArray(str);
- if (pathComponents == null) {
- return processor.selectSingleNode(contextNode, str);
- } else {
- return getFirstNodeFromPath(contextNode, pathComponents, false);
- }
- }
-
- /**
- * Return the <CODE>Node</CODE> from the DOM Node <CODE>rootNode</CODE>
- * using the XPath expression <CODE>path</CODE>. If the node does not
- * exist, it is created and then returned. This is a very simple method for
- * creating new nodes. If the XPath contains selectors ([,,,]) or "*" it is
- * of course not possible to create the new node. So if you use such XPaths
- * the node must exist beforehand. An simple exception is if the expression
- * contains attribute test to values (e.g. [@id = 'du' and
- *
- * @number = 'you'], the attributes with the given values are added. The
- * attributes must be separated with 'and'. Another problem are
- * namespaces: XPath requires sometimes selectors for namespaces,
- * e.g. : /*[namespace-uri()="uri" and local-name()="name"] Creating
- * such a node with a namespace is not possible right now as we use
- * a very simple XPath parser which is not able to parse all kinds
- * of selectors correctly.
- *
- * @param rootNode
- * The node to start the search.
- * @param path
- * XPath expression for searching the node.
- * @param processor
- * The XPath processor to use
- * @return The node specified by the path.
- * @throws ProcessingException
- * If no path is specified or the XPath engine fails.
- */
- public static Node selectSingleNode(Node rootNode, String path, XPathProcessor processor)
- throws ProcessingException {
- // Now we have to parse the string
- // First test: path? rootNode?
- if (path == null) {
- throw new ProcessingException(XPATH_IS_REQUIRED);
- }
- if (rootNode == null)
- return rootNode;
-
- if (path.length() == 0 || path.equals("/"))
- return rootNode;
-
- // now the first "quick" test is if the node exists using the
- // full XPathAPI
- try {
- Node testNode = getSingleNode(rootNode, path, processor);
- if (testNode != null)
- return testNode;
- } catch (TransformerException local) {
- throw new ProcessingException("Transforming exception during selectSingleNode with path: '" + path
- + "'. Exception: " + local, local);
- }
-
- // remove leading "/" oon both ends
- path = StringUtils.strip(path, "/");
-
- // now step through the nodes!
- Node parent = rootNode;
- int pos;
- int posSelector;
- do {
- pos = path.indexOf("/"); // get next separator
- posSelector = path.indexOf("[");
- if (posSelector != -1 && posSelector < pos) {
- posSelector = path.indexOf("]");
- pos = path.indexOf("/", posSelector);
- }
-
- String nodeName;
- boolean isAttribute = false;
- if (pos != -1) { // found separator
- nodeName = path.substring(0, pos); // string until "/"
- path = path.substring(pos + 1); // rest of string after "/"
- } else {
- nodeName = path;
- }
-
- // test for attribute spec
- if (nodeName.startsWith("@")) {
- isAttribute = true;
- }
-
- Node singleNode;
- try {
- singleNode = getSingleNode(parent, nodeName, processor);
- } catch (TransformerException localException) {
- throw new ProcessingException("XPathUtil.selectSingleNode: " + localException.getMessage(),
- localException);
- }
-
- // create node if necessary
- if (singleNode == null) {
- Node newNode;
- // delete XPath selectors
- int posSelect = nodeName.indexOf("[");
- String XPathExp = null;
- if (posSelect != -1) {
- XPathExp = nodeName.substring(posSelect + 1, nodeName.length() - 1);
- nodeName = nodeName.substring(0, posSelect);
- }
- if (isAttribute) {
- try {
- newNode = getOwnerDocument(rootNode).createAttributeNS(null, nodeName.substring(1));
- ((Element) parent).setAttributeNodeNS((org.w3c.dom.Attr) newNode);
- parent = newNode;
- } catch (DOMException local) {
- throw new ProcessingException("Unable to create new DOM node: '" + nodeName + "'.", local);
- }
- } else {
- try {
- newNode = getOwnerDocument(rootNode).createElementNS(null, nodeName);
- } catch (DOMException local) {
- throw new ProcessingException("Unable to create new DOM node: '" + nodeName + "'.", local);
- }
- if (XPathExp != null) {
- java.util.List attrValuePairs = new java.util.ArrayList(4);
- boolean noError = true;
-
- String attr;
- String value;
- // scan for attributes
- StringTokenizer tokenizer = new StringTokenizer(XPathExp, "= ");
- while (tokenizer.hasMoreTokens()) {
- attr = tokenizer.nextToken();
- if (attr.startsWith("@")) {
- if (tokenizer.hasMoreTokens()) {
- value = tokenizer.nextToken();
- if (value.startsWith("'") && value.endsWith("'"))
- value = value.substring(1, value.length() - 1);
- if (value.startsWith("\"") && value.endsWith("\""))
- value = value.substring(1, value.length() - 1);
- attrValuePairs.add(attr.substring(1));
- attrValuePairs.add(value);
- } else {
- noError = false;
- }
- } else if (attr.trim().equals("and") == false) {
- noError = false;
- }
- }
- if (noError) {
- for (int l = 0; l < attrValuePairs.size(); l = l + 2) {
- ((Element) newNode).setAttributeNS(null, (String) attrValuePairs.get(l),
- (String) attrValuePairs.get(l + 1));
- }
- }
- }
- parent.appendChild(newNode);
- parent = newNode;
- }
- } else {
- parent = singleNode;
- }
- }
- while (pos != -1);
- return parent;
- }
-
- /**
- * Get the value of the node specified by the XPath. This works similar to
- * <xsl:value-of>. If the node does not exist <CODE>null</CODE> is
- * returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param processor
- * The XPath processor to use
- * @return The value of the node or <CODE>null</CODE>
- */
- public static String getValueOf(Node root, String path, XPathProcessor processor) throws ProcessingException {
- if (path == null) {
- throw new ProcessingException(XPATH_IS_REQUIRED);
- }
- if (root == null)
- return null;
- path = StringUtils.strip(path, "/");
-
- try {
- Node node = getSingleNode(root, path, processor);
- if (node != null) {
- return getValueOfNode(node);
- }
- } catch (TransformerException localException) {
- throw new ProcessingException("XPathUtil.selectSingleNode: " + localException.getMessage(), localException);
- }
- return null;
- }
-
- /**
- * Get the value of the node specified by the XPath.
- * This works similar to xsl:value-of. If the node is not found
- * the <CODE>defaultValue</CODE> is returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param defaultValue
- * The default value if the node does not exist.
- * @param processor
- * The XPath Processor
- * @return The value of the node or <CODE>defaultValue</CODE>
- */
- public static String getValueOf(Node root, String path, String defaultValue, XPathProcessor processor)
- throws ProcessingException {
- String value = getValueOf(root, path, processor);
- if (value == null) {
- value = defaultValue;
- }
- return value;
- }
-
- /**
- * Get the boolean value of the node specified by the XPath.
- * This works similar to xsl:value-of. If the node exists and has a value
- * this value is converted to a boolean, e.g. "true" or "false" as value
- * will result into the corresponding boolean values.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param processor
- * The XPath Processor
- * @return The boolean value of the node.
- * @throws ProcessingException
- * If the node is not found.
- */
- public static boolean getValueAsBooleanOf(Node root, String path, XPathProcessor processor)
- throws ProcessingException {
- String value = getValueOf(root, path, processor);
- if (value == null) {
- throw new ProcessingException("No such node: " + path);
- }
- return Boolean.valueOf(value).booleanValue();
- }
-
- /**
- * Get the boolean value of the node specified by the XPath.
- * This works similar to xsl:value-of. If the node exists and has a value
- * this value is converted to a boolean, e.g. "true" or "false" as value
- * will result into the corresponding boolean values.
- * If the node does not exist, the <CODE>defaultValue</CODE> is returned.
- *
- * @param root
- * The node to start the search.
- * @param path
- * XPath search expression.
- * @param defaultValue
- * Default boolean value.
- * @param processor
- * The XPath Processor
- * @return The value of the node or <CODE>defaultValue</CODE>
- */
- public static boolean getValueAsBooleanOf(Node root, String path, boolean defaultValue, XPathProcessor processor)
- throws ProcessingException {
- String value = getValueOf(root, path, processor);
- if (value != null) {
- return Boolean.valueOf(value).booleanValue();
- }
- return defaultValue;
- }
-
- /**
- * Create a new empty DOM document.
- */
- public static Document createDocument() throws ProcessingException {
- try {
- DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
- documentFactory.setNamespaceAware(true);
- documentFactory.setValidating(false);
- DocumentBuilder docBuilder = documentFactory.newDocumentBuilder();
- return docBuilder.newDocument();
- } catch (ParserConfigurationException pce) {
- throw new ProcessingException("Creating document failed.", pce);
- }
- }
-
- /**
- * Use an XPath string to select a nodelist.
- * XPath namespace prefixes are resolved from the contextNode.
- *
- * @param contextNode
- * The node to start searching from.
- * @param str
- * A valid XPath string.
- * @param processor
- * The XPath Processor
- * @return A NodeIterator, should never be null.
- *
- * @throws TransformerException
- */
- public static NodeList selectNodeList(Node contextNode, String str, XPathProcessor processor)
- throws TransformerException {
- String[] pathComponents = buildPathArray(str);
- if (pathComponents != null) {
- return getNodeListFromPath(contextNode, pathComponents);
- }
- return processor.selectNodeList(contextNode, str);
- }
-
- /**
- * Build the input for the get...FromPath methods. If the XPath expression
- * cannot be handled by the methods, <code>null</code> is returned.
- */
- public static String[] buildPathArray(String xpath) {
- String[] result = null;
- if (xpath != null && xpath.charAt(0) != '/') {
- // test
- int components = 1;
- int i, l;
- l = xpath.length();
- boolean found = false;
- i = 0;
- while (i < l && found == false) {
- switch (xpath.charAt(i)) {
- case '[':
- found = true;
- break;
- case '(':
- found = true;
- break;
- case '*':
- found = true;
- break;
- case '@':
- found = true;
- break;
- case ':':
- found = true;
- break;
- case '/':
- components++;
- default:
- i++;
- }
- }
- if (found == false) {
- result = new String[components];
- if (components == 1) {
- result[components - 1] = xpath;
- } else {
- i = 0;
- int start = 0;
- components = 0;
- while (i < l) {
- if (xpath.charAt(i) == '/') {
- result[components] = xpath.substring(start, i);
- start = i + 1;
- components++;
- }
- i++;
- }
- result[components] = xpath.substring(start);
- }
- }
- }
- return result;
- }
-
- /**
- * Use a path to select the first occurence of a node. The namespace of a
- * node is ignored!
- *
- * @param contextNode
- * The node starting the search.
- * @param path
- * The path to search the node. The contextNode is searched for a
- * child named path[0], this node is searched for a child named
- * path[1]...
- * @param create
- * If a child with the corresponding name is not found and create
- * is set, this node will be created.
- */
- public static Node getFirstNodeFromPath(Node contextNode, final String[] path, final boolean create) {
- if (contextNode == null || path == null || path.length == 0)
- return contextNode;
- // first test if the node exists
- Node item = getFirstNodeFromPath(contextNode, path, 0);
- if (item == null && create) {
- int i = 0;
- NodeList childs;
- boolean found;
- int m, l;
- while (contextNode != null && i < path.length) {
- childs = contextNode.getChildNodes();
- found = false;
- if (childs != null) {
- m = 0;
- l = childs.getLength();
- while (found == false && m < l) {
- item = childs.item(m);
- if (item.getNodeType() == Node.ELEMENT_NODE && item.getLocalName().equals(path[i])) {
- found = true;
- contextNode = item;
- }
- m++;
- }
- }
- if (found == false) {
- Element e = contextNode.getOwnerDocument().createElementNS(null, path[i]);
- contextNode.appendChild(e);
- contextNode = e;
- }
- i++;
- }
- item = contextNode;
- }
- return item;
- }
-
- /**
- * Private helper method for getFirstNodeFromPath()
- */
- private static Node getFirstNodeFromPath(final Node contextNode, final String[] path, final int startIndex) {
- int i = 0;
- NodeList childs;
- boolean found;
- int l;
- Node item = null;
-
- childs = contextNode.getChildNodes();
- found = false;
- if (childs != null) {
- i = 0;
- l = childs.getLength();
- while (found == false && i < l) {
- item = childs.item(i);
- if (item.getNodeType() == Node.ELEMENT_NODE
- && path[startIndex].equals(item.getLocalName() != null ? item.getLocalName() : item
- .getNodeName())) {
- if (startIndex == path.length - 1) {
- found = true;
- } else {
- item = getFirstNodeFromPath(item, path, startIndex + 1);
- if (item != null)
- found = true;
- }
- }
- if (found == false) {
- i++;
- }
- }
- if (found == false) {
- item = null;
- }
- }
- return item;
- }
-
- /**
- * Use a path to select all occurences of a node. The namespace of a node is
- * ignored!
- *
- * @param contextNode
- * The node starting the search.
- * @param path
- * The path to search the node. The contextNode is searched for a
- * child named path[0], this node is searched for a child named
- * path[1]...
- */
- public static NodeList getNodeListFromPath(Node contextNode, String[] path) {
- if (contextNode == null)
- return new NodeListImpl();
- if (path == null || path.length == 0) {
- return new NodeListImpl(new Node[] { contextNode });
- }
- NodeListImpl result = new NodeListImpl();
- try {
- getNodesFromPath(result, contextNode, path, 0);
- } catch (NullPointerException npe) {
- // this NPE is thrown because the parser is not configured
- // to use DOM Level 2
- throw new NullPointerException("XMLUtil.getNodeListFromPath() did catch a NullPointerException."
- + "This might be due to a missconfigured XML parser which does not use DOM Level 2."
- + "Make sure that you use the XML parser shipped with Cocoon.");
- }
- return result;
- }
-
- /**
- * Helper method for getNodeListFromPath()
- */
- private static void getNodesFromPath(final NodeListImpl result, final Node contextNode, final String[] path,
- final int startIndex) {
- final NodeList childs = contextNode.getChildNodes();
- int m, l;
- Node item;
- if (startIndex == (path.length - 1)) {
- if (childs != null) {
- m = 0;
- l = childs.getLength();
- while (m < l) {
- item = childs.item(m);
- if (item.getNodeType() == Node.ELEMENT_NODE) {
- // Work around: org.apache.xerces.dom.ElementImpl
- // doesn't handle getLocalName() correct
- if (path[startIndex].equals(item.getLocalName() != null ? item.getLocalName() : item
- .getNodeName())) {
- result.addNode(item);
- }
- }
- m++;
- }
- }
- } else {
- if (childs != null) {
- m = 0;
- l = childs.getLength();
- while (m < l) {
- item = childs.item(m);
- if (item.getNodeType() == Node.ELEMENT_NODE) {
- // Work around: org.apache.xerces.dom.ElementImpl
- // doesn't handle getLocalName() correct
- if (path[startIndex].equals(item.getLocalName() != null ? item.getLocalName() : item
- .getNodeName())) {
- getNodesFromPath(result, item, path, startIndex + 1);
- }
- }
- m++;
- }
- }
- }
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DocumentWrapper.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DocumentWrapper.java
deleted file mode 100644
index 4839c59..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DocumentWrapper.java
+++ /dev/null
@@ -1,1085 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.xml.XMLUtils;
-
-import org.apache.excalibur.xml.sax.XMLizable;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMConfiguration;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.w3c.dom.UserDataHandler;
-import org.xml.sax.SAXException;
-
-
-/**
- * Wraps an org.w3c.dom.Document and offers additional interfaces
- * like XMLizable and a toString() method.
- *
- * @version $Id$
- */
-public class DocumentWrapper implements org.w3c.dom.Document, XMLizable {
-
- protected final static String DOMLEVEL3_ERR_MSG =
- "This method was just added for providing future compatibility to JDK 1.5's DOM level 3 Document interface.";
-
- protected final Document document;
-
- /** Creates a new instance of DocmentWrapper */
- public DocumentWrapper(Document doc) {
- this.document = doc;
- }
-
-
- /**
- * Generates SAX events representing the object's state.<br/>
- * <b>NOTE</b> : if the implementation can produce lexical events,
- * care should be taken that <code>handler</code> can actually be
- * a {@link org.apache.cocoon.xml.XMLConsumer} that accepts such
- * events.
- */
- public void toSAX(org.xml.sax.ContentHandler handler) throws SAXException {
-
- DOMStreamer ds = new DOMStreamer(handler);
- ds.stream(this.document.getDocumentElement());
- }
-
-
- public String toString() {
- try {
- return XMLUtils.serializeNode(this.document);
- } catch (ProcessingException e) {
- }
- return "";
- }
-
-
- /** Adds the node <code>newChild</code> to the end of the list of children
- * of this node. If the <code>newChild</code> is already in the tree, it
- * is first removed.
- * @param newChild The node to add.If it is a
- * <code>DocumentFragment</code> object, the entire contents of the
- * document fragment are moved into the child list of this node
- * @return The node added.
- * @exception DOMException
- * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
- * allow children of the type of the <code>newChild</code> node, or if
- * the node to append is one of this node's ancestors or this node
- * itself.
- * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
- * from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
- * if the previous parent of the node being inserted is readonly.
- *
- */
- public Node appendChild(Node newChild) throws DOMException {
- return this.document.appendChild(newChild);
- }
-
- /** Returns a duplicate of this node, i.e., serves as a generic copy
- * constructor for nodes. The duplicate node has no parent; (
- * <code>parentNode</code> is <code>null</code>.).
- * <br>Cloning an <code>Element</code> copies all attributes and their
- * values, including those generated by the XML processor to represent
- * defaulted attributes, but this method does not copy any text it
- * contains unless it is a deep clone, since the text is contained in a
- * child <code>Text</code> node. Cloning an <code>Attribute</code>
- * directly, as opposed to be cloned as part of an <code>Element</code>
- * cloning operation, returns a specified attribute (
- * <code>specified</code> is <code>true</code>). Cloning any other type
- * of node simply returns a copy of this node.
- * <br>Note that cloning an immutable subtree results in a mutable copy,
- * but the children of an <code>EntityReference</code> clone are readonly
- * . In addition, clones of unspecified <code>Attr</code> nodes are
- * specified. And, cloning <code>Document</code>,
- * <code>DocumentType</code>, <code>Entity</code>, and
- * <code>Notation</code> nodes is implementation dependent.
- * @param deep If <code>true</code>, recursively clone the subtree under
- * the specified node; if <code>false</code>, clone only the node
- * itself (and its attributes, if it is an <code>Element</code>).
- * @return The duplicate node.
- *
- */
- public Node cloneNode(boolean deep) {
- return this.document.cloneNode(deep);
- }
-
- /** Creates an <code>Attr</code> of the given name. Note that the
- * <code>Attr</code> instance can then be set on an <code>Element</code>
- * using the <code>setAttributeNode</code> method.
- * <br>To create an attribute with a qualified name and namespace URI, use
- * the <code>createAttributeNS</code> method.
- * @param name The name of the attribute.
- * @return A new <code>Attr</code> object with the <code>nodeName</code>
- * attribute set to <code>name</code>, and <code>localName</code>,
- * <code>prefix</code>, and <code>namespaceURI</code> set to
- * <code>null</code>. The value of the attribute is the empty string.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * illegal character.
- *
- */
- public Attr createAttribute(String name) throws DOMException {
- return this.document.createAttribute(name);
- }
-
- /** Creates an attribute of the given qualified name and namespace URI.
- * @param namespaceURI The namespace URI of the attribute to create.
- * @param qualifiedName The qualified name of the attribute to
- * instantiate.
- * @return A new <code>Attr</code> object with the following attributes:
- * <table border='1'>
- * <tr>
- * <th>
- * Attribute</th>
- * <th>Value</th>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
- * <td valign='top' rowspan='1' colspan='1'>qualifiedName</td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>Node.namespaceURI</code></td>
- * <td valign='top' rowspan='1' colspan='1'><code>namespaceURI</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>Node.prefix</code></td>
- * <td valign='top' rowspan='1' colspan='1'>prefix, extracted from
- * <code>qualifiedName</code>, or <code>null</code> if there is no
- * prefix</td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
- * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
- * <code>qualifiedName</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Attr.name</code></td>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>qualifiedName</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeValue</code></td>
- * <td valign='top' rowspan='1' colspan='1'>the empty
- * string</td>
- * </tr>
- * </table>
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified qualified name
- * contains an illegal character, per the XML 1.0 specification .
- * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
- * malformed per the Namespaces in XML specification, if the
- * <code>qualifiedName</code> has a prefix and the
- * <code>namespaceURI</code> is <code>null</code>, if the
- * <code>qualifiedName</code> has a prefix that is "xml" and the
- * <code>namespaceURI</code> is different from "
- * http://www.w3.org/XML/1998/namespace", or if the
- * <code>qualifiedName</code>, or its prefix, is "xmlns" and the
- * <code>namespaceURI</code> is different from "
- * http://www.w3.org/2000/xmlns/".
- * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
- * support the <code>"XML"</code> feature, since namespaces were
- * defined by XML.
- * @since DOM Level 2
- *
- */
- public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException {
- return this.document.createAttributeNS(namespaceURI, qualifiedName);
- }
-
- /** Creates a <code>CDATASection</code> node whose value is the specified
- * string.
- * @param data The data for the <code>CDATASection</code> contents.
- * @return The new <code>CDATASection</code> object.
- * @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
- *
- */
- public CDATASection createCDATASection(String data) throws DOMException {
- return this.document.createCDATASection(data);
- }
-
- /** Creates a <code>Comment</code> node given the specified string.
- * @param data The data for the node.
- * @return The new <code>Comment</code> object.
- *
- */
- public Comment createComment(String data) {
- return this.document.createComment(data);
- }
-
- /** Creates an empty <code>DocumentFragment</code> object.
- * @return A new <code>DocumentFragment</code>.
- *
- */
- public DocumentFragment createDocumentFragment() {
- return this.document.createDocumentFragment();
- }
-
- /** Creates an element of the type specified. Note that the instance
- * returned implements the <code>Element</code> interface, so attributes
- * can be specified directly on the returned object.
- * <br>In addition, if there are known attributes with default values,
- * <code>Attr</code> nodes representing them are automatically created
- * and attached to the element.
- * <br>To create an element with a qualified name and namespace URI, use
- * the <code>createElementNS</code> method.
- * @param tagName The name of the element type to instantiate. For XML,
- * this is case-sensitive. For HTML, the <code>tagName</code>
- * parameter may be provided in any case, but it must be mapped to the
- * canonical uppercase form by the DOM implementation.
- * @return A new <code>Element</code> object with the
- * <code>nodeName</code> attribute set to <code>tagName</code>, and
- * <code>localName</code>, <code>prefix</code>, and
- * <code>namespaceURI</code> set to <code>null</code>.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * illegal character.
- *
- */
- public Element createElement(String tagName) throws DOMException {
- return this.document.createElement(tagName);
- }
-
- /** Creates an element of the given qualified name and namespace URI.
- * @param namespaceURI The namespace URI of the element to create.
- * @param qualifiedName The qualified name of the element type to
- * instantiate.
- * @return A new <code>Element</code> object with the following
- * attributes:
- * <table border='1'>
- * <tr>
- * <th>Attribute</th>
- * <th>Value</th>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>qualifiedName</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.namespaceURI</code></td>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>namespaceURI</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.prefix</code></td>
- * <td valign='top' rowspan='1' colspan='1'>prefix, extracted
- * from <code>qualifiedName</code>, or <code>null</code> if there is
- * no prefix</td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
- * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
- * <code>qualifiedName</code></td>
- * </tr>
- * <tr>
- * <td valign='top' rowspan='1' colspan='1'><code>Element.tagName</code></td>
- * <td valign='top' rowspan='1' colspan='1'>
- * <code>qualifiedName</code></td>
- * </tr>
- * </table>
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified qualified name
- * contains an illegal character, per the XML 1.0 specification .
- * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
- * malformed per the Namespaces in XML specification, if the
- * <code>qualifiedName</code> has a prefix and the
- * <code>namespaceURI</code> is <code>null</code>, or if the
- * <code>qualifiedName</code> has a prefix that is "xml" and the
- * <code>namespaceURI</code> is different from "
- * http://www.w3.org/XML/1998/namespace" .
- * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
- * support the <code>"XML"</code> feature, since namespaces were
- * defined by XML.
- * @since DOM Level 2
- *
- */
- public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException {
- return this.document.createElementNS(namespaceURI, qualifiedName);
- }
-
- /** Creates an <code>EntityReference</code> object. In addition, if the
- * referenced entity is known, the child list of the
- * <code>EntityReference</code> node is made the same as that of the
- * corresponding <code>Entity</code> node.If any descendant of the
- * <code>Entity</code> node has an unbound namespace prefix, the
- * corresponding descendant of the created <code>EntityReference</code>
- * node is also unbound; (its <code>namespaceURI</code> is
- * <code>null</code>). The DOM Level 2 does not support any mechanism to
- * resolve namespace prefixes.
- * @param name The name of the entity to reference.
- * @return The new <code>EntityReference</code> object.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified name contains an
- * illegal character.
- * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
- *
- */
- public EntityReference createEntityReference(String name) throws DOMException {
- return this.document.createEntityReference(name);
- }
-
- /** Creates a <code>ProcessingInstruction</code> node given the specified
- * name and data strings.
- * @param target The target part of the processing instruction.
- * @param data The data for the node.
- * @return The new <code>ProcessingInstruction</code> object.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified target contains an
- * illegal character.
- * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
- *
- */
- public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
- return this.document.createProcessingInstruction(target, data);
- }
-
- /** Creates a <code>Text</code> node given the specified string.
- * @param data The data for the node.
- * @return The new <code>Text</code> object.
- *
- */
- public Text createTextNode(String data) {
- return this.document.createTextNode(data);
- }
-
- /** A <code>NamedNodeMap</code> containing the attributes of this node (if
- * it is an <code>Element</code>) or <code>null</code> otherwise.
- *
- */
- public NamedNodeMap getAttributes() {
- return this.document.getAttributes();
- }
-
- /** A <code>NodeList</code> that contains all children of this node. If
- * there are no children, this is a <code>NodeList</code> containing no
- * nodes.
- *
- */
- public NodeList getChildNodes() {
- return this.document.getChildNodes();
- }
-
- /** The Document Type Declaration (see <code>DocumentType</code>)
- * associated with this document. For HTML documents as well as XML
- * documents without a document type declaration this returns
- * <code>null</code>. The DOM Level 2 does not support editing the
- * Document Type Declaration. <code>docType</code> cannot be altered in
- * any way, including through the use of methods inherited from the
- * <code>Node</code> interface, such as <code>insertNode</code> or
- * <code>removeNode</code>.
- *
- */
- public DocumentType getDoctype() {
- return this.document.getDoctype();
- }
-
- /** This is a convenience attribute that allows direct access to the child
- * node that is the root element of the document. For HTML documents,
- * this is the element with the tagName "HTML".
- *
- */
- public Element getDocumentElement() {
- return this.document.getDocumentElement();
- }
-
- /** Returns the <code>Element</code> whose <code>ID</code> is given by
- * <code>elementId</code>. If no such element exists, returns
- * <code>null</code>. Behavior is not defined if more than one element
- * has this <code>ID</code>. The DOM implementation must have
- * information that says which attributes are of type ID. Attributes
- * with the name "ID" are not of type ID unless so defined.
- * Implementations that do not know whether attributes are of type ID or
- * not are expected to return <code>null</code>.
- * @param elementId The unique <code>id</code> value for an element.
- * @return The matching element.
- * @since DOM Level 2
- *
- */
- public Element getElementById(String elementId) {
- return this.document.getElementById(elementId);
- }
-
- /** Returns a <code>NodeList</code> of all the <code>Elements</code> with a
- * given tag name in the order in which they are encountered in a
- * preorder traversal of the <code>Document</code> tree.
- * @param tagname The name of the tag to match on. The special value "*"
- * matches all tags.
- * @return A new <code>NodeList</code> object containing all the matched
- * <code>Elements</code>.
- *
- */
- public NodeList getElementsByTagName(String tagname) {
- return this.document.getElementsByTagName(tagname);
- }
-
- /** Returns a <code>NodeList</code> of all the <code>Elements</code> with a
- * given local name and namespace URI in the order in which they are
- * encountered in a preorder traversal of the <code>Document</code> tree.
- * @param namespaceURI The namespace URI of the elements to match on. The
- * special value "*" matches all namespaces.
- * @param localName The local name of the elements to match on. The
- * special value "*" matches all local names.
- * @return A new <code>NodeList</code> object containing all the matched
- * <code>Elements</code>.
- * @since DOM Level 2
- *
- */
- public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
- return this.document.getElementsByTagNameNS(namespaceURI, localName);
- }
-
- /** The first child of this node. If there is no such node, this returns
- * <code>null</code>.
- *
- */
- public Node getFirstChild() {
- return this.document.getFirstChild();
- }
-
- /** The <code>DOMImplementation</code> object that handles this document. A
- * DOM application may use objects from multiple implementations.
- *
- */
- public DOMImplementation getImplementation() {
- return this.document.getImplementation();
- }
-
- /** The last child of this node. If there is no such node, this returns
- * <code>null</code>.
- *
- */
- public Node getLastChild() {
- return this.document.getLastChild();
- }
-
- /** Returns the local part of the qualified name of this node.
- * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
- * method, such as <code>createElement</code> from the
- * <code>Document</code> interface, this is always <code>null</code>.
- * @since DOM Level 2
- *
- */
- public String getLocalName() {
- return this.document.getLocalName();
- }
-
- /** The namespace URI of this node, or <code>null</code> if it is
- * unspecified.
- * <br>This is not a computed value that is the result of a namespace
- * lookup based on an examination of the namespace declarations in
- * scope. It is merely the namespace URI given at creation time.
- * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
- * method, such as <code>createElement</code> from the
- * <code>Document</code> interface, this is always <code>null</code>.Per
- * the Namespaces in XML Specification an attribute does not inherit
- * its namespace from the element it is attached to. If an attribute is
- * not explicitly given a namespace, it simply has no namespace.
- * @since DOM Level 2
- *
- */
- public String getNamespaceURI() {
- return this.document.getNamespaceURI();
- }
-
- /** The node immediately following this node. If there is no such node,
- * this returns <code>null</code>.
- *
- */
- public Node getNextSibling() {
- return this.document.getNextSibling();
- }
-
- /** The name of this node, depending on its type; see the table above.
- *
- */
- public String getNodeName() {
- return this.document.getNodeName();
- }
-
- /** A code representing the type of the underlying object, as defined above.
- *
- */
- public short getNodeType() {
- return this.document.getNodeType();
- }
-
- /** The value of this node, depending on its type; see the table above.
- * When it is defined to be <code>null</code>, setting it has no effect.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
- * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
- * fit in a <code>DOMString</code> variable on the implementation
- * platform.
- *
- */
- public String getNodeValue() throws DOMException {
- return this.document.getNodeValue();
- }
-
- /** The <code>Document</code> object associated with this node. This is
- * also the <code>Document</code> object used to create new nodes. When
- * this node is a <code>Document</code> or a <code>DocumentType</code>
- * which is not used with any <code>Document</code> yet, this is
- * <code>null</code>.
- * @since DOM Level 2
- *
- */
- public Document getOwnerDocument() {
- return this.document.getOwnerDocument();
- }
-
- /** The parent of this node. All nodes, except <code>Attr</code>,
- * <code>Document</code>, <code>DocumentFragment</code>,
- * <code>Entity</code>, and <code>Notation</code> may have a parent.
- * However, if a node has just been created and not yet added to the
- * tree, or if it has been removed from the tree, this is
- * <code>null</code>.
- *
- */
- public Node getParentNode() {
- return this.document.getParentNode();
- }
-
- /** The namespace prefix of this node, or <code>null</code> if it is
- * unspecified.
- * <br>Note that setting this attribute, when permitted, changes the
- * <code>nodeName</code> attribute, which holds the qualified name, as
- * well as the <code>tagName</code> and <code>name</code> attributes of
- * the <code>Element</code> and <code>Attr</code> interfaces, when
- * applicable.
- * <br>Note also that changing the prefix of an attribute that is known to
- * have a default value, does not make a new attribute with the default
- * value and the original prefix appear, since the
- * <code>namespaceURI</code> and <code>localName</code> do not change.
- * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
- * method, such as <code>createElement</code> from the
- * <code>Document</code> interface, this is always <code>null</code>.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
- * illegal character, per the XML 1.0 specification .
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
- * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
- * malformed per the Namespaces in XML specification, if the
- * <code>namespaceURI</code> of this node is <code>null</code>, if the
- * specified prefix is "xml" and the <code>namespaceURI</code> of this
- * node is different from "http://www.w3.org/XML/1998/namespace", if
- * this node is an attribute and the specified prefix is "xmlns" and
- * the <code>namespaceURI</code> of this node is different from "
- * http://www.w3.org/2000/xmlns/", or if this node is an attribute and
- * the <code>qualifiedName</code> of this node is "xmlns" .
- * @since DOM Level 2
- *
- */
- public String getPrefix() {
- return this.document.getPrefix();
- }
-
- /** The node immediately preceding this node. If there is no such node,
- * this returns <code>null</code>.
- *
- */
- public Node getPreviousSibling() {
- return this.document.getPreviousSibling();
- }
-
- /** Returns whether this node (if it is an element) has any attributes.
- * @return <code>true</code> if this node has any attributes,
- * <code>false</code> otherwise.
- * @since DOM Level 2
- *
- */
- public boolean hasAttributes() {
- return this.document.hasAttributes();
- }
-
- /** Returns whether this node has any children.
- * @return <code>true</code> if this node has any children,
- * <code>false</code> otherwise.
- *
- */
- public boolean hasChildNodes() {
- return this.document.hasChildNodes();
- }
-
- /** Imports a node from another document to this document. The returned
- * node has no parent; (<code>parentNode</code> is <code>null</code>).
- * The source node is not altered or removed from the original document;
- * this method creates a new copy of the source node.
- * <br>For all nodes, importing a node creates a node object owned by the
- * importing document, with attribute values identical to the source
- * node's <code>nodeName</code> and <code>nodeType</code>, plus the
- * attributes related to namespaces (<code>prefix</code>,
- * <code>localName</code>, and <code>namespaceURI</code>). As in the
- * <code>cloneNode</code> operation on a <code>Node</code>, the source
- * node is not altered.
- * <br>Additional information is copied as appropriate to the
- * <code>nodeType</code>, attempting to mirror the behavior expected if
- * a fragment of XML or HTML source was copied from one document to
- * another, recognizing that the two documents may have different DTDs
- * in the XML case. The following list describes the specifics for each
- * type of node.
- * <dl>
- * <dt>ATTRIBUTE_NODE</dt>
- * <dd>The <code>ownerElement</code> attribute
- * is set to <code>null</code> and the <code>specified</code> flag is
- * set to <code>true</code> on the generated <code>Attr</code>. The
- * descendants of the source <code>Attr</code> are recursively imported
- * and the resulting nodes reassembled to form the corresponding subtree.
- * Note that the <code>deep</code> parameter has no effect on
- * <code>Attr</code> nodes; they always carry their children with them
- * when imported.</dd>
- * <dt>DOCUMENT_FRAGMENT_NODE</dt>
- * <dd>If the <code>deep</code> option
- * was set to <code>true</code>, the descendants of the source element
- * are recursively imported and the resulting nodes reassembled to form
- * the corresponding subtree. Otherwise, this simply generates an empty
- * <code>DocumentFragment</code>.</dd>
- * <dt>DOCUMENT_NODE</dt>
- * <dd><code>Document</code>
- * nodes cannot be imported.</dd>
- * <dt>DOCUMENT_TYPE_NODE</dt>
- * <dd><code>DocumentType</code>
- * nodes cannot be imported.</dd>
- * <dt>ELEMENT_NODE</dt>
- * <dd>Specified attribute nodes of the
- * source element are imported, and the generated <code>Attr</code>
- * nodes are attached to the generated <code>Element</code>. Default
- * attributes are not copied, though if the document being imported into
- * defines default attributes for this element name, those are assigned.
- * If the <code>importNode</code> <code>deep</code> parameter was set to
- * <code>true</code>, the descendants of the source element are
- * recursively imported and the resulting nodes reassembled to form the
- * corresponding subtree.</dd>
- * <dt>ENTITY_NODE</dt>
- * <dd><code>Entity</code> nodes can be
- * imported, however in the current release of the DOM the
- * <code>DocumentType</code> is readonly. Ability to add these imported
- * nodes to a <code>DocumentType</code> will be considered for addition
- * to a future release of the DOM.On import, the <code>publicId</code>,
- * <code>systemId</code>, and <code>notationName</code> attributes are
- * copied. If a <code>deep</code> import is requested, the descendants
- * of the the source <code>Entity</code> are recursively imported and
- * the resulting nodes reassembled to form the corresponding subtree.</dd>
- * <dt>
- * ENTITY_REFERENCE_NODE</dt>
- * <dd>Only the <code>EntityReference</code> itself is
- * copied, even if a <code>deep</code> import is requested, since the
- * source and destination documents might have defined the entity
- * differently. If the document being imported into provides a
- * definition for this entity name, its value is assigned.</dd>
- * <dt>NOTATION_NODE</dt>
- * <dd>
- * <code>Notation</code> nodes can be imported, however in the current
- * release of the DOM the <code>DocumentType</code> is readonly. Ability
- * to add these imported nodes to a <code>DocumentType</code> will be
- * considered for addition to a future release of the DOM.On import, the
- * <code>publicId</code> and <code>systemId</code> attributes are copied.
- * Note that the <code>deep</code> parameter has no effect on
- * <code>Notation</code> nodes since they never have any children.</dd>
- * <dt>
- * PROCESSING_INSTRUCTION_NODE</dt>
- * <dd>The imported node copies its
- * <code>target</code> and <code>data</code> values from those of the
- * source node.</dd>
- * <dt>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</dt>
- * <dd>These three
- * types of nodes inheriting from <code>CharacterData</code> copy their
- * <code>data</code> and <code>length</code> attributes from those of
- * the source node.</dd>
- * </dl>
- * @param importedNode The node to import.
- * @param deep If <code>true</code>, recursively import the subtree under
- * the specified node; if <code>false</code>, import only the node
- * itself, as explained above. This has no effect on <code>Attr</code>
- * , <code>EntityReference</code>, and <code>Notation</code> nodes.
- * @return The imported node that belongs to this <code>Document</code>.
- * @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
- * supported.
- * @since DOM Level 2
- *
- */
- public Node importNode(Node importedNode, boolean deep) throws DOMException {
- return this.document.importNode(importedNode, deep);
- }
-
- /** Inserts the node <code>newChild</code> before the existing child node
- * <code>refChild</code>. If <code>refChild</code> is <code>null</code>,
- * insert <code>newChild</code> at the end of the list of children.
- * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
- * all of its children are inserted, in the same order, before
- * <code>refChild</code>. If the <code>newChild</code> is already in the
- * tree, it is first removed.
- * @param newChild The node to insert.
- * @param refChild The reference node, i.e., the node before which the
- * new node must be inserted.
- * @return The node being inserted.
- * @exception DOMException
- * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
- * allow children of the type of the <code>newChild</code> node, or if
- * the node to insert is one of this node's ancestors or this node
- * itself.
- * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
- * from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
- * if the parent of the node being inserted is readonly.
- * <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
- * this node.
- *
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- return this.document.insertBefore(newChild, refChild);
- }
-
- /** Tests whether the DOM implementation implements a specific feature and
- * that feature is supported by this node.
- * @param feature The name of the feature to test. This is the same name
- * which can be passed to the method <code>hasFeature</code> on
- * <code>DOMImplementation</code>.
- * @param version This is the version number of the feature to test. In
- * Level 2, version 1, this is the string "2.0". If the version is not
- * specified, supporting any version of the feature will cause the
- * method to return <code>true</code>.
- * @return Returns <code>true</code> if the specified feature is
- * supported on this node, <code>false</code> otherwise.
- * @since DOM Level 2
- *
- */
- public boolean isSupported(String feature, String version) {
- return this.document.isSupported(feature, version);
- }
-
- /** Puts all <code>Text</code> nodes in the full depth of the sub-tree
- * underneath this <code>Node</code>, including attribute nodes, into a
- * "normal" form where only structure (e.g., elements, comments,
- * processing instructions, CDATA sections, and entity references)
- * separates <code>Text</code> nodes, i.e., there are neither adjacent
- * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can
- * be used to ensure that the DOM view of a document is the same as if
- * it were saved and re-loaded, and is useful when operations (such as
- * XPointer lookups) that depend on a particular document tree
- * structure are to be used.In cases where the document contains
- * <code>CDATASections</code>, the normalize operation alone may not be
- * sufficient, since XPointers do not differentiate between
- * <code>Text</code> nodes and <code>CDATASection</code> nodes.
- * @since DOM Level 2
- *
- */
- public void normalize() {
- this.document.normalize();
- }
-
- /** Removes the child node indicated by <code>oldChild</code> from the list
- * of children, and returns it.
- * @param oldChild The node being removed.
- * @return The node removed.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
- * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
- * this node.
- *
- */
- public Node removeChild(Node oldChild) throws DOMException {
- return this.document.removeChild(oldChild);
- }
-
- /** Replaces the child node <code>oldChild</code> with <code>newChild</code>
- * in the list of children, and returns the <code>oldChild</code> node.
- * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
- * <code>oldChild</code> is replaced by all of the
- * <code>DocumentFragment</code> children, which are inserted in the
- * same order. If the <code>newChild</code> is already in the tree, it
- * is first removed.
- * @param newChild The new node to put in the child list.
- * @param oldChild The node being replaced in the list.
- * @return The node replaced.
- * @exception DOMException
- * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
- * allow children of the type of the <code>newChild</code> node, or if
- * the node to put in is one of this node's ancestors or this node
- * itself.
- * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
- * from a different document than the one that created this node.
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
- * the new node is readonly.
- * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
- * this node.
- *
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- return this.document.replaceChild(newChild, oldChild);
- }
-
- /** The value of this node, depending on its type; see the table above.
- * When it is defined to be <code>null</code>, setting it has no effect.
- * @exception DOMException
- * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
- * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
- * fit in a <code>DOMString</code> variable on the implementation
- * platform.
- *
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- this.document.setNodeValue(nodeValue);
- }
-
- /** The namespace prefix of this node, or <code>null</code> if it is
- * unspecified.
- * <br>Note that setting this attribute, when permitted, changes the
- * <code>nodeName</code> attribute, which holds the qualified name, as
- * well as the <code>tagName</code> and <code>name</code> attributes of
- * the <code>Element</code> and <code>Attr</code> interfaces, when
- * applicable.
- * <br>Note also that changing the prefix of an attribute that is known to
- * have a default value, does not make a new attribute with the default
- * value and the original prefix appear, since the
- * <code>namespaceURI</code> and <code>localName</code> do not change.
- * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
- * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
- * method, such as <code>createElement</code> from the
- * <code>Document</code> interface, this is always <code>null</code>.
- * @exception DOMException
- * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
- * illegal character, per the XML 1.0 specification .
- * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
- * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
- * malformed per the Namespaces in XML specification, if the
- * <code>namespaceURI</code> of this node is <code>null</code>, if the
- * specified prefix is "xml" and the <code>namespaceURI</code> of this
- * node is different from "http://www.w3.org/XML/1998/namespace", if
- * this node is an attribute and the specified prefix is "xmlns" and
- * the <code>namespaceURI</code> of this node is different from "
- * http://www.w3.org/2000/xmlns/", or if this node is an attribute and
- * the <code>qualifiedName</code> of this node is "xmlns" .
- * @since DOM Level 2
- *
- */
- public void setPrefix(String prefix) throws DOMException {
- this.document.setPrefix(prefix);
- }
-
- /**
- * @since DOM Level 3
- */
- public Node renameNode(Node node, String namespaceURI, String qualifiedName) throws DOMException {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void normalizeDocument() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public DOMConfiguration getDomConfig() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public Node adoptNode(Node source) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setDocumentURI(String uri) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getDocumentURI() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setStrictErrorChecking(boolean value) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public boolean getStrictErrorChecking() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setXmlVersion(String version) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getXmlVersion() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setXmlStandalone(boolean value) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public boolean getXmlStandalone() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setXmlEncoding(String version) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getXmlEncoding() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getInputEncoding() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public Object getUserData(String key) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public Object setUserData(String key, Object value, UserDataHandler handler) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public Object getFeature(String feature, String version) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public short compareDocumentPosition(Node other) throws DOMException {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getBaseURI() {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String getTextContent() throws DOMException {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public boolean isDefaultNamespace(String namespaceURI) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public boolean isEqualNode(Node arg) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public boolean isSameNode(Node other) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String lookupNamespaceURI(String prefix) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public String lookupPrefix(String namespaceURI) {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-
- /**
- * @since DOM Level 3
- */
- public void setTextContent(String textContent) throws DOMException {
- throw new UnsupportedOperationException(DOMLEVEL3_ERR_MSG);
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DomHelper.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DomHelper.java
deleted file mode 100644
index e7217b9..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/dom/DomHelper.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.apache.cocoon.util.location.Location;
-import org.apache.cocoon.util.location.LocationAttributes;
-import org.apache.cocoon.xml.SaxBuffer;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
-
-/**
- * Helper class to create and retrieve information from DOM-trees. It provides
- * some functionality comparable to what's found in Avalon's Configuration
- * objects. These lasts one could however not be used by Cocoon Forms because they
- * don't provide an accurate model of an XML file (no mixed content,
- * no namespaced attributes, no namespace declarations, ...).
- *
- * <p>This class depends specifically on the Xerces DOM implementation to be
- * able to provide information about the location of elements in their source
- * XML file. See the {@link #getLocation(Element)} method.
- * @version $Id$
- */
-public class DomHelper {
-
- protected static final SAXParserFactory saxFactory = SAXParserFactory.newInstance();
- static {
- saxFactory.setNamespaceAware(true);
- saxFactory.setValidating(false);
- }
-
- public static final String XMLNS_URI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
-
- /**
- * Creates a W3C Document that remembers the location of each element in
- * the source file. The location of element nodes can then be retrieved
- * using the {@link #getLocation(Element)} method.
- *
- * @param inputSource the inputSource to read the document from
- */
- public static Document parse(InputSource inputSource)
- throws SAXException, SAXNotSupportedException, IOException {
- try {
- final XMLReader parser = saxFactory.newSAXParser().getXMLReader();
- final DOMBuilder builder = new DOMBuilder();
-
- // Enhance the sax stream with location information
- final ContentHandler locationHandler = new LocationAttributes.Pipe(builder);
- parser.setContentHandler(locationHandler);
-
- parser.parse(inputSource);
-
- return builder.getDocument();
- } catch (ParserConfigurationException pce) {
- throw new SAXException(pce);
- }
- }
-
- public static Location getLocationObject(Element element) {
- return LocationAttributes.getLocation(element);
- }
-
- /**
- * Retrieves the location of an element node in the source file from which
- * the Document was created. This will only work for Document's created
- * with the method {@link #parse(InputSource, ServiceManager)} of this class.
- */
- public static String getLocation(Element element) {
- return LocationAttributes.getLocationString(element);
- }
-
- public static String getSystemIdLocation(Element element) {
- return LocationAttributes.getURI(element);
- }
-
- public static int getLineLocation(Element element) {
- return LocationAttributes.getLine(element);
- }
-
- public static int getColumnLocation(Element element) {
- return LocationAttributes.getColumn(element);
- }
-
- /**
- * Returns all Element children of an Element that belong to the given
- * namespace.
- */
- public static Element[] getChildElements(Element element, String namespace) {
- ArrayList elements = new ArrayList();
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element
- && namespace.equals(node.getNamespaceURI()))
- elements.add(node);
- }
- return (Element[])elements.toArray(new Element[elements.size()]);
- }
-
- /**
- * Returns all Element children of an Element that belong to the given
- * namespace and have the given local name.
- */
- public static Element[] getChildElements(Element element,
- String namespace, String localName) {
- ArrayList elements = new ArrayList();
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element
- && namespace.equals(node.getNamespaceURI())
- && localName.equals(node.getLocalName())) {
- elements.add(node);
- }
- }
- return (Element[])elements.toArray(new Element[elements.size()]);
- }
-
- /**
- * Returns the first child element with the given namespace and localName,
- * or null if there is no such element.
- */
- public static Element getChildElement(Element element, String namespace,
- String localName) {
- Element node = null;
- try {
- node = getChildElement(element, namespace, localName, false);
- } catch (Exception e) {
- node = null;
- }
- return node;
- }
-
- /**
- * Returns the first child element with the given namespace and localName,
- * or null if there is no such element and required flag is unset or
- * throws an Exception if the "required" flag is set.
- */
- public static Element getChildElement(Element element, String namespace,
- String localName, boolean required) throws Exception {
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element
- && namespace.equals(node.getNamespaceURI())
- && localName.equals(node.getLocalName())) {
- return (Element)node;
- }
- }
- if (required) {
- throw new Exception("Missing element \"" + localName +
- "\" as child of element \"" + element.getTagName() +
- "\" at " + DomHelper.getLocation(element));
- } else {
- return null;
- }
- }
-
- /**
- * Returns the value of an element's attribute, but throws an exception
- * if the element has no such attribute.
- */
- public static String getAttribute(Element element, String attributeName)
- throws Exception {
- String attrValue = element.getAttribute(attributeName);
- if (attrValue.length() == 0) {
- throw new Exception("Missing attribute \"" + attributeName +
- "\" on element \"" + element.getTagName() +
- "\" at " + getLocation(element));
- }
- return attrValue;
- }
-
- /**
- * Returns the value of an element's attribute, or a default value if the
- * element has no such attribute.
- */
- public static String getAttribute(Element element, String attributeName,
- String defaultValue) {
- String attrValue = element.getAttribute(attributeName);
- if (attrValue.length() == 0) {
- return defaultValue;
- }
- return attrValue;
- }
-
- public static int getAttributeAsInteger(Element element,
- String attributeName) throws Exception {
- String attrValue = getAttribute(element, attributeName);
- try {
- return Integer.parseInt(attrValue);
- } catch (NumberFormatException e) {
- throw new Exception("Cannot parse the value \"" + attrValue +
- "\" as an integer in the attribute \"" + attributeName +
- "\" on the element \"" + element.getTagName() +
- "\" at " + getLocation(element));
- }
- }
-
- public static int getAttributeAsInteger(Element element,
- String attributeName, int defaultValue) throws Exception {
- String attrValue = element.getAttribute(attributeName);
- if (attrValue.length() == 0) {
- return defaultValue;
- } else {
- try {
- return Integer.parseInt(attrValue);
- } catch (NumberFormatException e) {
- throw new Exception("Cannot parse the value \"" + attrValue +
- "\" as an integer in the attribute \"" +
- attributeName + "\" on the element \"" +
- element.getTagName() + "\" at " +
- getLocation(element));
- }
- }
- }
-
- public static boolean getAttributeAsBoolean(Element element,
- String attributeName, boolean defaultValue) {
- String attrValue = element.getAttribute(attributeName);
- Boolean result;
- try {
- result = BooleanUtils.toBooleanObject(attrValue, "true", "false", null);
- } catch (IllegalArgumentException iae) {
- result = null;
- }
- if (result != null) {
- return result.booleanValue();
- }
- try {
- result = BooleanUtils.toBooleanObject(attrValue, "yes", "no", null);
- } catch (IllegalArgumentException iae) {
- result = null;
- }
- if (result != null) {
- return result.booleanValue();
- }
- return defaultValue;
- }
-
- public static String getElementText(Element element) {
- StringBuffer value = new StringBuffer();
- NodeList nodeList = element.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Text || node instanceof CDATASection) {
- value.append(node.getNodeValue());
- }
- }
- return value.toString();
- }
-
- /**
- * Returns the content of the given Element as an object implementing the
- * XMLizable interface. Practically speaking, the implementation uses the
- * {@link SaxBuffer} class. The XMLizable object will be a standalone blurb
- * of SAX events, not producing start/endDocument calls and containing all
- * necessary namespace declarations.
- */
- public static XMLizable compileElementContent(Element element) {
- // Remove location information
- LocationAttributes.remove(element, true);
-
- SaxBuffer saxBuffer = new SaxBuffer();
- DOMStreamer domStreamer = new DOMStreamer();
- domStreamer.setContentHandler(saxBuffer);
-
- NodeList childNodes = element.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- try {
- domStreamer.stream(childNodes.item(i));
- } catch (SAXException e) {
- // It's unlikely that an exception will occur here,
- // so use a runtime exception
- throw new RuntimeException(
- "Error in DomHelper.compileElementContent: " +
- e.toString());
- }
- }
- return saxBuffer;
- }
-
- public static Map getLocalNSDeclarations(Element elm) {
- return addLocalNSDeclarations(elm, null);
- }
-
- private static Map addLocalNSDeclarations(Element elm, Map nsDeclarations) {
- NamedNodeMap atts = elm.getAttributes();
- int attsSize = atts.getLength();
-
- for (int i = 0; i < attsSize; i++)
- {
- Attr attr = (Attr)atts.item(i);
- if (XMLNS_URI.equals(attr.getNamespaceURI()))
- {
- String nsUri = attr.getValue();
- String pfx = attr.getLocalName();
- if (nsDeclarations == null)
- nsDeclarations = new HashMap();
- nsDeclarations.put(nsUri, pfx);
- }
- }
- return nsDeclarations; }
-
- public static Map getInheritedNSDeclarations(Element elm) {
- List ancestorsAndSelf = new LinkedList();
- Element current = elm;
- while (current != null) {
- ancestorsAndSelf.add(current);
- Node parent = current.getParentNode();
- if (parent.getNodeType() == Node.ELEMENT_NODE)
- current = (Element)parent;
- else
- current = null;
- }
-
- Map nsDeclarations = null;
- ListIterator iter = ancestorsAndSelf.listIterator(ancestorsAndSelf.size());
- while (iter.hasPrevious()) {
- Element element = (Element) iter.previous();
- nsDeclarations = addLocalNSDeclarations(element, nsDeclarations);
- }
-
- return nsDeclarations;
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/ExtendedXLinkPipe.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/ExtendedXLinkPipe.java
deleted file mode 100644
index 091f338..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/ExtendedXLinkPipe.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.xlink;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * This class extends the XLink semantic capabilities to understand those
- * elements that are have default linking semantics associated.
- *
- * <p>This class reacts on 'href' and 'src' attributes and is able to understand
- * the semantics of XHTML/WML/SMIL/SVG and all the rest of the languages that
- * use either XLink of the above attributes.</p>
- *
- * <p>NOTE: this class is clearly a hack and is not future compatible, but
- * since many XML formats to date are not compatible with the XLink semantics
- * this is what we have to do to live in the bleeding edge. Once there will
- * be a way to remove this, that will be a happy day for XML and for Cocoon too.</p>
- *
- * @version $Id$
- */
-public abstract class ExtendedXLinkPipe extends XLinkPipe {
-
- protected static Set arrayToSet(Object[] array) {
- final Set set = new HashSet(array.length);
-
- for (int i = 0; i < array.length; i++)
- set.add(array[i]);
- return set;
- }
-
- private final Map MAP = new HashMap() {
- {
- put(
- "",
- arrayToSet(
- new String[] {
- "about",
- "action",
- "background",
- "data",
- "discuri",
- "href",
- "longdesc",
- "onenterforward",
- "onenterbackward",
- "ontimer",
- "onpick",
- "src" }));
- put(
- "http://www.w3.org/1999/xhtml",
- arrayToSet(
- new String[] {
- "action",
- "background",
- "data",
- "href",
- "longdesc",
- "src" }));
- put(
- "http://www.w3.org/2001/XInclude",
- arrayToSet(new String[] { "href" }));
- put(
- "http://www.wapforum.org/2001/wml",
- arrayToSet(
- new String[] {
- "onenterforward",
- "onenterbackward",
- "ontimer",
- "href",
- "onpick",
- "src" }));
- put(
- "http://www.w3.org/2002/01/P3Pv1",
- arrayToSet(
- new String[] { "about", "discuri", "src", "service" }));
- }
- };
-
- private int attrIndex = -1;
-
- public void startElement(
- String uri,
- final String name,
- final String raw,
- final Attributes attr)
- throws SAXException {
- final Set attrList = (Set) MAP.get((uri == null) ? "" : uri);
-
- if (attrList != null) {
- for (int i = attrIndex + 1; i < attr.getLength(); i++)
- if (attr.getURI(i).equals("")
- && attrList.contains(attr.getLocalName(i))) {
-
- final String att = attr.getValue(i);
-
- if (att != null) {
- final String str =
- ": URI="
- + uri
- + " NAME="
- + name
- + " RAW="
- + raw
- + " ATT="
- + attr.getLocalName(i)
- + " NS="
- + uri
- + " VALUE="
- + att;
-
- if (getLogger().isDebugEnabled())
- getLogger().debug("Transforming to XLink" + str);
-
- attrIndex = i;
-
- simpleLink(
- att,
- null,
- null,
- null,
- null,
- null,
- uri,
- name,
- raw,
- attr);
-
- return;
- }
- }
- attrIndex = -1;
- }
-
- super.startElement(uri, name, raw, attr);
- }
-
- public void simpleLink(
- final String href,
- final String role,
- final String arcrole,
- final String title,
- final String show,
- final String actuate,
- final String uri,
- final String name,
- final String raw,
- final Attributes attr)
- throws SAXException {
- if (attrIndex != -1) {
- final AttributesImpl newattr = new AttributesImpl(attr);
- newattr.setValue(attrIndex, href);
- startElement(uri, name, raw, newattr);
- } else {
- super.simpleLink(
- href,
- role,
- arcrole,
- title,
- show,
- actuate,
- uri,
- name,
- raw,
- attr);
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/XLinkPipe.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/XLinkPipe.java
deleted file mode 100644
index cecbb10..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/java/org/apache/cocoon/xml/xlink/XLinkPipe.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.xlink;
-
-import org.apache.cocoon.xml.AbstractXMLPipe;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * This class implements a SAX consumer wrapper that transforms the
- * general SAX semantic into XLink semantics for easier consumption.
- *
- * Classes should extend this class and overwrite the abstract method
- * to consume the XLink events that come in as SAX events.
- *
- * NOTE: this is based on XLink W3C Candidate Recommendation 3 July 2000
- *
- * @version $Id$
- */
-public abstract class XLinkPipe extends AbstractXMLPipe implements XLinkHandler {
-
- public static final String XLINK_NAMESPACE_URI = "http://www.w3.org/1999/xlink";
- public static final String XLINK_TYPE = "type";
- public static final String XLINK_HREF = "href";
- public static final String XLINK_ROLE = "role";
- public static final String XLINK_ARCROLE = "arcrole";
- public static final String XLINK_TITLE = "title";
- public static final String XLINK_SHOW = "show";
- public static final String XLINK_ACTUATE = "actuate";
- public static final String XLINK_LABEL = "label";
- public static final String XLINK_FROM = "from";
- public static final String XLINK_TO = "to";
- public static final String XLINK_TYPE_SIMPLE = "simple";
- public static final String XLINK_TYPE_EXTENDED = "extended";
- public static final String XLINK_TYPE_LOCATOR = "locator";
- public static final String XLINK_TYPE_ARC = "arc";
- public static final String XLINK_TYPE_RESOURCE = "resource";
- public static final String XLINK_TYPE_TITLE = "title";
-
- private String extendedLinkElementName = null;
- private String extendedLinkElementURI = null;
- private String linkLocatorElementName = null;
- private String linkLocatorElementURI = null;
- private String linkArcElementName = null;
- private String linkArcElementURI = null;
-
- public void startElement( String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- String type = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TYPE );
- if ( type != null )
- {
- if ( type.equals( XLINK_TYPE_SIMPLE ) )
- {
- if ( this.extendedLinkElementName != null )
- {
- throw new SAXException( "An XLink simple link cannot be included into an 'extended' element" );
- }
- else if ( this.linkLocatorElementName != null )
- {
- throw new SAXException( "An XLink simple link cannot be included into a 'locator' element" );
- }
- else if ( this.linkArcElementName != null )
- {
- throw new SAXException( "An XLink simple link cannot be included into an 'arc' element" );
- }
- String href = attr.getValue( XLINK_NAMESPACE_URI, XLINK_HREF );
- String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
- String arcrole = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
- String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
- String show = attr.getValue( XLINK_NAMESPACE_URI, XLINK_SHOW );
- String actuate = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
- simpleLink( href, role, arcrole, title, show, actuate, uri, name, raw, attr );
- }
- else if ( type.equals( XLINK_TYPE_EXTENDED ) )
- {
- if ( this.extendedLinkElementName != null )
- {
- throw new SAXException( "An XLink extended link cannot include another 'extended' element" );
- }
- else if ( this.linkLocatorElementName != null )
- {
- throw new SAXException( "An XLink extended link cannot be included into a 'locator' element" );
- }
- else if ( this.linkArcElementName != null )
- {
- throw new SAXException( "An XLink extended link cannot be included into an 'arc' element" );
- }
- String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
- String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
- this.extendedLinkElementName = name;
- this.extendedLinkElementURI = uri;
- startExtendedLink( role, title, uri, name, raw, attr );
- }
- else if ( type.equals( XLINK_TYPE_LOCATOR ) )
- {
- if ( this.extendedLinkElementName == null )
- {
- throw new SAXException( "An XLink locator must be included into an 'extended' element" );
- }
- else if ( this.linkLocatorElementName != null )
- {
- throw new SAXException( "An XLink locator cannot be included into another 'locator' element" );
- }
- else if ( this.linkArcElementName != null )
- {
- throw new SAXException( "An XLink locator cannot be included into an 'arc' element" );
- }
- String href = attr.getValue( XLINK_NAMESPACE_URI, XLINK_HREF );
- String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
- String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
- String label = attr.getValue( XLINK_NAMESPACE_URI, XLINK_LABEL );
- this.linkLocatorElementName = name;
- this.linkLocatorElementURI = uri;
- startLocator( href, role, title, label, uri, name, raw, attr );
- }
- else if ( type.equals( XLINK_TYPE_ARC ) )
- {
- if ( this.extendedLinkElementName == null )
- {
- throw new SAXException( "An XLink arc must be included into an 'extended' element" );
- }
- else if ( this.linkLocatorElementName != null )
- {
- throw new SAXException( "An XLink arc cannot be included into a 'locator' element" );
- }
- else if ( this.linkArcElementName != null )
- {
- throw new SAXException( "An XLink arc cannot be included into another 'arc' element" );
- }
- String arcrole = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
- String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
- String show = attr.getValue( XLINK_NAMESPACE_URI, XLINK_SHOW );
- String actuate = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
- String from = attr.getValue( XLINK_NAMESPACE_URI, XLINK_FROM );
- String to = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TO );
- this.linkArcElementName = name;
- this.linkArcElementURI = uri;
- startArc( arcrole, title, show, actuate, from, to, uri, name, raw, attr );
- }
- else if ( type.equals( XLINK_TYPE_RESOURCE ) )
- {
- if ( this.extendedLinkElementName == null )
- {
- throw new SAXException( "An XLink resource must be included into an 'extended' element" );
- }
- String role = attr.getValue( XLINK_NAMESPACE_URI, XLINK_ROLE );
- String title = attr.getValue( XLINK_NAMESPACE_URI, XLINK_TITLE );
- String label = attr.getValue( XLINK_NAMESPACE_URI, XLINK_LABEL );
- linkResource( role, title, label, uri, name, raw, attr );
- }
- else if ( type.equals( XLINK_TYPE_TITLE ) )
- {
- if ( ( this.extendedLinkElementName == null )
- && ( this.linkLocatorElementName == null )
- && ( this.linkArcElementName == null ) )
- {
- throw new SAXException( "An XLink title must be included into an 'extended', 'locator' or 'arc' element" );
- }
- linkTitle( uri, name, raw, attr );
- }
- else
- {
- super.startElement( uri, name, raw, attr );
- }
- }
- else
- {
- super.startElement( uri, name, raw, attr );
- }
- }
-
- public void endElement( String uri, String name, String raw ) throws SAXException
- {
- if ( ( name.equals( this.extendedLinkElementName ) ) && ( uri.equals( this.extendedLinkElementURI ) ) )
- {
- this.extendedLinkElementName = null;
- this.extendedLinkElementURI = null;
- this.endExtendedLink( uri, name, raw );
- }
- else if ( ( name.equals( this.linkLocatorElementName ) ) && ( uri.equals( this.linkLocatorElementURI ) ) )
- {
- this.linkLocatorElementName = null;
- this.linkLocatorElementURI = null;
- this.endLocator( uri, name, raw );
- }
- else if ( ( name.equals( this.linkArcElementName ) ) && ( uri.equals( this.linkArcElementURI ) ) )
- {
- this.linkArcElementName = null;
- this.linkArcElementURI = null;
- this.endArc( uri, name, raw );
- }
- else
- {
- super.endElement( uri, name, raw );
- }
- }
-
- // Default XLinkHandler implementation (defaults to copy over)
-
- public void simpleLink( String href, String role, String arcrole, String title, String show, String actuate, String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- AttributesImpl newattr = new AttributesImpl( attr );
- int hrefIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_HREF );
- int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
- int arcroleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
- int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
- int showIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_SHOW );
- int actuateIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
- if ( hrefIndex > -1 )
- newattr.setValue( hrefIndex, href );
- if ( roleIndex > -1 )
- newattr.setValue( roleIndex, role );
- if ( arcroleIndex > -1 )
- newattr.setValue( arcroleIndex, arcrole );
- if ( titleIndex > -1 )
- newattr.setValue( titleIndex, title );
- if ( showIndex > -1 )
- newattr.setValue( showIndex, show );
- if ( actuateIndex > -1 )
- newattr.setValue( actuateIndex, actuate );
- super.startElement( uri, name, raw, newattr );
- }
-
- public void startExtendedLink( String role, String title, String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- AttributesImpl newattr = new AttributesImpl( attr );
- int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
- int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
- if ( roleIndex > -1 )
- newattr.setValue( roleIndex, role );
- if ( titleIndex > -1 )
- newattr.setValue( titleIndex, title );
- super.startElement( uri, name, raw, newattr );
- }
-
- public void startLocator( String href, String role, String title, String label, String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- AttributesImpl newattr = new AttributesImpl( attr );
- int hrefIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_HREF );
- int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
- int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
- int labelIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_LABEL );
- if ( hrefIndex > -1 )
- newattr.setValue( hrefIndex, href );
- if ( roleIndex > -1 )
- newattr.setValue( roleIndex, role );
- if ( titleIndex > -1 )
- newattr.setValue( titleIndex, title );
- if ( labelIndex > -1 )
- newattr.setValue( labelIndex, label );
- super.startElement( uri, name, raw, newattr );
- }
-
- public void startArc( String arcrole, String title, String show, String actuate, String from, String to, String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- AttributesImpl newattr = new AttributesImpl( attr );
- int arcroleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ARCROLE );
- int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
- int showIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_SHOW );
- int actuateIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ACTUATE );
- int fromIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_FROM );
- int toIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TO );
- if ( arcroleIndex > -1 )
- newattr.setValue( arcroleIndex, arcrole );
- if ( titleIndex > -1 )
- newattr.setValue( titleIndex, title );
- if ( showIndex > -1 )
- newattr.setValue( showIndex, show );
- if ( actuateIndex > -1 )
- newattr.setValue( actuateIndex, actuate );
- if ( fromIndex > -1 )
- newattr.setValue( actuateIndex, from );
- if ( toIndex > -1 )
- newattr.setValue( actuateIndex, to );
- super.startElement( uri, name, raw, newattr );
- }
-
- public void linkResource( String role, String title, String label, String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- AttributesImpl newattr = new AttributesImpl( attr );
- int roleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_ROLE );
- int titleIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_TITLE );
- int labelIndex = attr.getIndex( XLINK_NAMESPACE_URI, XLINK_LABEL );
- if ( roleIndex > -1 )
- newattr.setValue( roleIndex, role );
- if ( titleIndex > -1 )
- newattr.setValue( titleIndex, title );
- if ( labelIndex > -1 )
- newattr.setValue( labelIndex, label );
- super.startElement( uri, name, raw, newattr );
- }
-
- public void linkTitle( String uri, String name, String raw, Attributes attr ) throws SAXException
- {
- super.startElement( uri, name, raw, attr );
- }
-
- public void endExtendedLink( String uri, String name, String raw ) throws SAXException
- {
- super.endElement( uri, name, raw );
- }
-
- public void endLocator( String uri, String name, String raw ) throws SAXException
- {
- super.endElement( uri, name, raw );
- }
-
- public void endArc( String uri, String name, String raw ) throws SAXException
- {
- super.endElement( uri, name, raw );
- }
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
deleted file mode 100644
index 2d7fec1..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-impl-cache.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- SVN $Id$ -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
-
- <!--+
- | This is the Cocoon cache. This component is responsible for storing
- | and retrieving cached responses. It can be used to monitor the cache
- | or the investigate which responses are cached etc.
- |
- | The cache uses the store to save its values.
- +-->
- <bean name="org.apache.cocoon.caching.Cache" class="org.apache.cocoon.caching.impl.CacheImpl">
- <property name="store" ref="org.apache.excalibur.store.Store"/>
- </bean>
-
-</beans>
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/license.txt b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/license.txt
deleted file mode 100644
index 261eeb9..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/license.txt
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/notice.txt b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/notice.txt
deleted file mode 100644
index 672aaa3..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/notice.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Cocoon
-Copyright 1999-2006 The Apache Software Foundation.
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.handlers b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.handlers
deleted file mode 100644
index fafb310..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.handlers
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-http\://cocoon.apache.org/schema/pipeline=org.apache.cocoon.core.container.spring.pipeline.PipelineNamespaceHandler
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.schemas b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.schemas
deleted file mode 100644
index 1b8b823..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/META-INF/spring.schemas
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-http\://cocoon.apache.org/schema/pipeline/cocoon-pipeline-1.0.xsd=org/apache/cocoon/core/container/spring/pipeline/pipeline.xsd
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/org/apache/cocoon/core/container/spring/pipeline/pipeline.xsd b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/org/apache/cocoon/core/container/spring/pipeline/pipeline.xsd
deleted file mode 100644
index 1cb6047..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/main/resources/org/apache/cocoon/core/container/spring/pipeline/pipeline.xsd
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://cocoon.apache.org/schema/pipeline"
- xmlns:tns="http://cocoon.apache.org/schema/pipeline">
-
- <xsd:element name="component" type="tns:componentType"/>
-
- <xsd:complexType name="componentType">
- <xsd:attribute name="mime-type" type="xsd:string" use="optional"/>
- <xsd:attribute name="label" type="xsd:string" use="optional"/>
- <xsd:attribute name="hint" type="xsd:string" use="optional"/>
- </xsd:complexType>
-</xsd:schema>
\ No newline at end of file
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/MockLogger.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/MockLogger.java
deleted file mode 100644
index 81504f3..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/MockLogger.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon;
-
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Mock logger for test cases. Delegates to a Commons Logging logger.
- *
- * @version $Id$
- */
-public class MockLogger implements Logger {
- protected Log logger;
-
- /**
- * Create a new logger for a given class.
- *
- * @param clazz The class.
- */
- public MockLogger(Class clazz) {
- this.logger = LogFactory.getLog(clazz);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#debug(java.lang.String)
- */
- public void debug(String msg) {
- this.logger.debug(msg);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#debug(java.lang.String, java.lang.Throwable)
- */
- public void debug(String msg, Throwable t) {
- this.logger.debug(msg, t);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return this.logger.isDebugEnabled();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#info(java.lang.String)
- */
- public void info(String msg) {
- this.logger.info(msg);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#info(java.lang.String, java.lang.Throwable)
- */
- public void info(String msg, Throwable t) {
- this.logger.info(msg, t);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return this.logger.isInfoEnabled();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#warn(java.lang.String)
- */
- public void warn(String msg) {
- this.logger.warn(msg);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#warn(java.lang.String, java.lang.Throwable)
- */
- public void warn(String msg, Throwable t) {
- this.logger.warn(msg, t);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return this.logger.isWarnEnabled();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#error(java.lang.String)
- */
- public void error(String msg) {
- this.logger.error(msg);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#error(java.lang.String, java.lang.Throwable)
- */
- public void error(String msg, Throwable t) {
- this.logger.error(msg, t);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return this.logger.isErrorEnabled();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#fatalError(java.lang.String)
- */
- public void fatalError(String msg) {
- this.logger.fatal(msg);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#fatalError(java.lang.String, java.lang.Throwable)
- */
- public void fatalError(String msg, Throwable t) {
- this.logger.fatal(msg, t);
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#isFatalErrorEnabled()
- */
- public boolean isFatalErrorEnabled() {
- return this.logger.isFatalEnabled();
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.logger.Logger#getChildLogger(java.lang.String)
- */
- public Logger getChildLogger(String arg0) {
- return null;
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/components/sax/XMLByteStreamCompilerInterpreterTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/components/sax/XMLByteStreamCompilerInterpreterTestCase.java
deleted file mode 100644
index fb600bf..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/components/sax/XMLByteStreamCompilerInterpreterTestCase.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.sax;
-
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.ContentHandler;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.apache.cocoon.xml.AbstractXMLTestCase;
-import org.apache.cocoon.xml.DefaultHandlerWrapper;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import java.io.ByteArrayInputStream;
-
-/**
- * Testcase for XMLByteStreamCompiler and Interpreter
- *
- */
-public final class XMLByteStreamCompilerInterpreterTestCase extends AbstractXMLTestCase {
- public XMLByteStreamCompilerInterpreterTestCase(String s) {
- super(s);
- }
-
- public void testCompareDOM() throws Exception {
- // reference
- DOMBuilder in = new DOMBuilder();
- generateLargeSAX(in);
-
- // capture events
- XMLByteStreamCompiler xmlc = new XMLByteStreamCompiler();
- generateLargeSAX(xmlc);
-
- // recall events and build a DOM from it
- XMLByteStreamInterpreter xmli = new XMLByteStreamInterpreter();
- DOMBuilder out = new DOMBuilder();
- xmli.setConsumer(out);
- xmli.deserialize(xmlc.getSAXFragment());
-
- // compare DOMs
- assertXMLEqual(in.getDocument(), out.getDocument());
- }
-
- public void testCompareByteArray() throws Exception {
- // capture events
- XMLByteStreamCompiler sa = new XMLByteStreamCompiler();
- generateLargeSAX(sa);
-
- // serialize events
- byte[] aa = (byte[]) sa.getSAXFragment();
-
- // deserialize and capture
- XMLByteStreamCompiler sb = new XMLByteStreamCompiler();
- XMLByteStreamInterpreter xmli = new XMLByteStreamInterpreter();
- xmli.setConsumer(sb);
- xmli.deserialize(aa);
-
- // serialize again
- byte[] ab = (byte[]) sb.getSAXFragment();
-
- assertTrue(aa.length == ab.length);
-
- for (int i=0;i<aa.length;i++) {
- assertEquals(aa[i],ab[i]);
- }
- }
-
- public void testStressLoop() throws Exception {
- XMLByteStreamCompiler xmlc = new XMLByteStreamCompiler();
-
- long loop = 10000;
-
- // simply consume documents
- long start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- generateSmallSAX(xmlc);
- xmlc.recycle();
- }
- long stop = System.currentTimeMillis();
-
- double r = 1000*loop/(stop-start);
- System.out.println("consuming: "+ r + " documents per second");
- }
-
- public void testCompareToParsing() throws Exception {
- DOMBuilder in = new DOMBuilder();
- generateSmallSAX(in);
-
- SAXParserFactory pfactory = SAXParserFactory.newInstance();
- SAXParser p = pfactory.newSAXParser();
-
- XMLByteStreamCompiler xmlc = new XMLByteStreamCompiler();
- DefaultHandlerWrapper wrapper = new DefaultHandlerWrapper(xmlc);
-
- ByteArrayInputStream bis = new ByteArrayInputStream(generateByteArray());
-
- long loop = 10000;
-
- // parse documents
- long start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- xmlc.recycle();
- bis.reset();
- p.parse(bis,wrapper);
- }
- long stop = System.currentTimeMillis();
-
- double r = 1000*loop/(stop-start);
- System.out.println("parsed: " + r + " documents per second");
-
-
- XMLByteStreamInterpreter xmli = new XMLByteStreamInterpreter();
- ContentHandler ch = new DefaultHandler();
-
- // recall documents
- start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- xmli.setContentHandler(ch);
- xmli.deserialize(xmlc.getSAXFragment());
- }
- stop = System.currentTimeMillis();
-
- r = 1000*loop/(stop-start);
- System.out.println("recalling: " + r + " documents per second");
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/AbstractXMLTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/AbstractXMLTestCase.java
deleted file mode 100644
index 4861ab4..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/AbstractXMLTestCase.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.custommonkey.xmlunit.XMLTestCase;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-import org.apache.cocoon.xml.dom.DOMBuilder;
-
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.Source;
-import javax.xml.transform.Result;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.dom.DOMSource;
-import java.io.ByteArrayOutputStream;
-
-
-/**
- * general functions for XML related Testcases
- *
- */
-public abstract class AbstractXMLTestCase extends XMLTestCase {
-
- public AbstractXMLTestCase(String s) {
- super(s);
- }
-
- protected void generateLargeSAX( ContentHandler consumer ) throws SAXException {
- AttributesImpl atts = new AttributesImpl();
-
- final int size = 65000;
- char[] large = new char[size];
- for(int i=0;i<size;i++) {
- large[i] = 'x';
- }
-
- consumer.startDocument();
- consumer.startElement("", "root", "root", atts);
- consumer.characters(large,0,size);
- consumer.endElement("", "root", "root");
- consumer.endDocument();
- }
-
- protected void generateSmallSAX( ContentHandler consumer ) throws SAXException {
- AttributesImpl atts = new AttributesImpl();
-
- consumer.startDocument();
- consumer.startElement("", "root", "root", atts);
- consumer.characters("test".toCharArray(),0,4);
- consumer.endElement("", "root", "root");
- consumer.endDocument();
- }
-
- protected byte[] generateByteArray() throws Exception {
- DOMBuilder in = new DOMBuilder();
- generateSmallSAX(in);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- TransformerFactory tFactory = TransformerFactory.newInstance();
- Transformer t = tFactory.newTransformer();
- Source input = new DOMSource(in.getDocument());
- Result output = new StreamResult(bos);
- t.transform(input, output);
- bos.close();
-
- return bos.toByteArray();
- }
-}
-
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/DefaultHandlerWrapper.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/DefaultHandlerWrapper.java
deleted file mode 100644
index c3d2347..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/DefaultHandlerWrapper.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Wrap a ContentHandler in a DefaultHandler
- *
- */
-public final class DefaultHandlerWrapper extends DefaultHandler {
- private final ContentHandler handler;
-
- public DefaultHandlerWrapper( ContentHandler handler ) {
- this.handler = handler;
- }
-
- public void setDocumentLocator(Locator locator) {
- handler.setDocumentLocator(locator);
- }
-
- public void startDocument() throws SAXException {
- handler.startDocument();
- }
-
- public void endDocument() throws SAXException {
- handler.endDocument();
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- handler.startPrefixMapping(prefix,uri);
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- handler.endPrefixMapping(prefix);
- }
-
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
- handler.startElement(namespaceURI,localName,qName,atts);
- }
-
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
- handler.endElement(namespaceURI,localName,qName);
- }
-
- public void characters(char ch[], int start, int length) throws SAXException {
- handler.characters(ch,start,length);
- }
-
- public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
- handler.ignorableWhitespace(ch,start, length);
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- handler.processingInstruction(target,data);
- }
-
- public void skippedEntity(String name) throws SAXException {
- handler.skippedEntity(name);
- }
-
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/NamespacesTableTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/NamespacesTableTestCase.java
deleted file mode 100644
index 07c3c71..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/NamespacesTableTestCase.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import junit.framework.TestCase;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Test case for NamespacesTable
- *
- * @version $Id$
- */
-public class NamespacesTableTestCase extends TestCase {
- public NamespacesTableTestCase(String name) {
- super(name);
- }
-
- public void testSimple() {
- NamespacesTable ns = new NamespacesTable();
-
- ns.addDeclaration("ns1", "http://ns1");
- ns.addDeclaration("ns2", "http://ns2");
-
- ns.enterScope();
-
- assertEquals("http://ns1", ns.getUri("ns1"));
- assertEquals("ns1", ns.getPrefix("http://ns1"));
-
- assertEquals("http://ns2", ns.getUri("ns2"));
- assertEquals("ns2", ns.getPrefix("http://ns2"));
-
- ns.enterScope();
-
- ns.addDeclaration("ns3", "http://ns3");
- ns.enterScope();
-
- assertEquals("ns1", ns.getPrefix("http://ns1"));
- assertEquals("ns3", ns.getPrefix("http://ns3"));
- assertEquals(0, ns.getCurrentScopeDeclarations().length);
- ns.leaveScope();
-
- // Declarations in this scope are no more visible...
- assertNull(ns.getUri("ns3"));
- // ... but still listed in the declared mappings
- assertEquals(1, ns.getCurrentScopeDeclarations().length);
- assertEquals("ns3", ns.getCurrentScopeDeclarations()[0].getPrefix());
-
- ns.leaveScope();
-
- assertNull(ns.getPrefix(ns.getPrefix("http://ns3")));
- assertNull(ns.getUri("ns3"));
-
- ns.leaveScope();
- // Declarations that occured before this scope are no more visible...
- assertNull(ns.getUri("ns1"));
- assertNull(ns.getPrefix("http://ns1"));
-
- assertNull(ns.getUri("ns2"));
- assertNull(ns.getPrefix("http://ns2"));
-
- //... but are still available in getDeclaredPrefixes
- NamespacesTable.Declaration[] prefixes = ns.getCurrentScopeDeclarations();
- assertEquals(2, prefixes.length);
-
- assertEquals("ns2", prefixes[0].getPrefix());
- assertEquals("http://ns2", prefixes[0].getUri());
- assertEquals("ns1", prefixes[1].getPrefix());
- assertEquals("http://ns1", prefixes[1].getUri());
-
- }
-
- public void testOverride() {
- NamespacesTable ns = new NamespacesTable();
-
- ns.addDeclaration("ns1", "http://ns1");
- ns.enterScope();
- ns.addDeclaration("ns1", "http://otherns1");
- ns.enterScope();
- ns.addDeclaration("ns1", "http://yetanotherns1");
- ns.enterScope();
-
- assertEquals("http://yetanotherns1", ns.getUri("ns1"));
- assertEquals(0, ns.getPrefixes("http://ns1").length);
-
- ns.leaveScope();
- ns.leaveScope();
-
- assertEquals("http://ns1", ns.getUri("ns1"));
- assertEquals(1, ns.getPrefixes("http://ns1").length);
-
- ns.leaveScope();
- assertNull(ns.getUri("ns1"));
- }
-
- public void testMultiDeclaration() {
- NamespacesTable ns = new NamespacesTable();
- ns.addDeclaration("ns1", "http://ns1");
- ns.enterScope();
- // two in the same scope
- ns.addDeclaration("ns2", "http://ns1");
- ns.addDeclaration("ns3", "http://ns1");
- ns.enterScope();
-
- String[] prefixes = ns.getPrefixes("http://ns1");
- assertEquals(3, prefixes.length);
- assertEquals("ns3", prefixes[0]);
- assertEquals("ns2", prefixes[1]);
- assertEquals("ns1", prefixes[2]);
- }
-
- public void testStreamDeclarations() throws Exception {
- NamespacesTable ns = new NamespacesTable();
- ns.addDeclaration("ns1", "http://ns1");
- ns.enterScope();
- ns.addDeclaration("ns2", "http://ns2");
- ns.enterScope(new DefaultHandler() {
- public void startPrefixMapping(String prefix, String uri) throws org.xml.sax.SAXException {
- assertEquals("ns2", prefix);
- assertEquals("http://ns2", uri);
- }
- });
-
- // Enter and leave a nested scope
- ns.addDeclaration("ns3", "http://ns3");
- ns.enterScope();
- ns.leaveScope();
-
- ns.leaveScope(new DefaultHandler() {
- public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException {
- assertEquals("ns2", prefix);
- }
- });
- }
-
- /**
- * A scenario that occurs in with jx:import where some prefixes are started but not used.
- * @throws Exception
- */
- public void testJXImport() throws Exception {
- NamespacesTable ns = new NamespacesTable();
- ContentHandler handler = new DefaultHandler();
-
- ns.addDeclaration("ft", "http://apache.org/cocoon/forms/1.0#template");
- ns.addDeclaration("fi", "http://apache.org/cocoon/forms/1.0#instance");
- ns.addDeclaration("jx", "http://apache.org/cocoon/templates/jx/1.0");
- ns.enterScope(handler);
- assertEquals("ft", ns.getPrefix("http://apache.org/cocoon/forms/1.0#template"));
- assertEquals("fi", ns.getPrefix("http://apache.org/cocoon/forms/1.0#instance"));
- assertEquals("jx", ns.getPrefix("http://apache.org/cocoon/templates/jx/1.0"));
-
- // Add declarations that won't be used
- ns.addDeclaration("jx", "http://apache.org/cocoon/templates/jx/1.0");
- ns.addDeclaration("fi", "http://apache.org/cocoon/forms/1.0#instance");
- ns.addDeclaration("bu", "http://apache.org/cocoon/browser-update/1.0");
-
- ns.leaveScope(handler);
- assertNull(ns.getPrefix("http://apache.org/cocoon/forms/1.0#template"));
- assertNull(ns.getPrefix("http://apache.org/cocoon/forms/1.0#instance"));
- assertNull(ns.getPrefix("http://apache.org/cocoon/templates/jx/1.0"));
- assertEquals(3, ns.getCurrentScopeDeclarations().length);
-
- }
-
- public void testDuplicate() throws Exception {
- NamespacesTable ns = new NamespacesTable();
-
- ns.addDeclaration("ns1", "http://ns1");
- ns.enterScope();
- ns.addDeclaration("ns1", "http://ns1");
- ns.enterScope();
- ns.leaveScope();
- ns.removeDeclaration("ns1");
- assertEquals("http://ns1", ns.getUri("ns1"));
- ns.leaveScope();
- ns.removeDeclaration("ns1");
- assertNull(ns.getUri("ns1"));
- }
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/SaxBufferTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/SaxBufferTestCase.java
deleted file mode 100644
index 0e45cb1..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/SaxBufferTestCase.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import java.io.ByteArrayInputStream;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Testcase for SaxBuffer
- *
- */
-public final class SaxBufferTestCase extends AbstractXMLTestCase {
- public SaxBufferTestCase(String s) {
- super(s);
- }
-
- public void testCompareDOM() throws Exception {
- DOMBuilder in = new DOMBuilder();
- generateLargeSAX(in);
-
- SaxBuffer sb = new SaxBuffer();
- generateLargeSAX(sb);
-
- DOMBuilder out = new DOMBuilder();
- sb.toSAX(out);
-
- assertXMLEqual(in.getDocument(), out.getDocument());
- }
-
- public void testStressLoop() throws Exception {
- SaxBuffer sb = new SaxBuffer();
-
- long loop = 10000;
-
- // simply consume documents
- long start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- generateSmallSAX(sb);
- sb.recycle();
- }
- long stop = System.currentTimeMillis() + 1;
-
- double r = 1000*loop/(stop-start);
- System.out.println("consuming: "+ r + " documents per second");
- }
-
- public void testCompareToParsing() throws Exception {
- DOMBuilder in = new DOMBuilder();
- generateSmallSAX(in);
-
- SAXParserFactory pfactory = SAXParserFactory.newInstance();
- SAXParser p = pfactory.newSAXParser();
-
-
- SaxBuffer b = new SaxBuffer();
- DefaultHandlerWrapper wrapper = new DefaultHandlerWrapper(b);
- ByteArrayInputStream bis = new ByteArrayInputStream(generateByteArray());
-
- long loop = 10000;
-
- long start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- b.recycle();
- bis.reset();
- p.parse(bis,wrapper);
- }
- long stop = System.currentTimeMillis() + 1;
-
- double r = 1000*loop/(stop-start);
- System.out.println("parsed:" + r + " documents per second");
-
-
- ContentHandler ch = new DefaultHandler();
-
- start = System.currentTimeMillis();
- for(int i=0;i<loop;i++) {
- b.toSAX(ch);
- }
- stop = System.currentTimeMillis() + 1;
-
- r = 1000*loop/(stop-start);
- System.out.println("recalling: " + r + " documents per second");
- }
-
-
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/WhitespaceFilter.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/WhitespaceFilter.java
deleted file mode 100644
index 10d940e..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/WhitespaceFilter.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml;
-
-import org.apache.cocoon.xml.AbstractXMLPipe;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A SAX filter to remove whitespace character, which disturb the
- * XML matching process.
- *
- * @version $Id$
- */
-public class WhitespaceFilter extends AbstractXMLPipe {
- private StringBuffer buffer = null;
-
- /**
- * Create a new WhitespaceFilter.
- *
- * @param handler Content handler.
- */
- public WhitespaceFilter(ContentHandler handler) {
- setContentHandler(handler);
- }
-
- /**
- * Receive notification of character data.
- */
- public void characters(char c[], int start, int len) throws SAXException {
- if (contentHandler==null) {
- return;
- }
-
- if (buffer==null) {
- buffer = new StringBuffer();
- }
-
- buffer.append(c, start, len);
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- */
- public void ignorableWhitespace(char c[], int start,
- int len) throws SAXException {
- // ignore
- }
-
- /**
- * Receive notification of the beginning of an element.
- */
- public void startElement(String namespaceURI, String localName,
- String qName,
- Attributes atts) throws SAXException {
-
- pushText();
- contentHandler.startElement(namespaceURI, localName, qName, atts);
- }
-
- /**
- * Receive notification of the end of an element.
- */
- public void endElement(String uri, String loc, String raw)
- throws SAXException {
-
- pushText();
- contentHandler.endElement(uri, loc, raw);
- }
-
- /**
- * Receive notification of a processing instruction.
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
-
- pushText();
- contentHandler.processingInstruction(target, data);
- }
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param len The number of characters to use from the array.
- */
- public void comment(char ch[], int start, int len)
- throws SAXException {
-
- pushText();
- super.comment(ch, start, len);
- }
-
-
- public void pushText() throws SAXException {
-
- if (buffer!=null) {
- String text = buffer.toString();
-
- StringBuffer normalized = new StringBuffer();
-
- for(int i=0; i<text.length(); i++) {
- if (Character.isWhitespace(text.charAt(i))) {
- normalized.append(' ');
- while (((i+1)<text.length()) && (Character.isWhitespace(text.charAt(i+1))))
- i++;
- } else {
- normalized.append(text.charAt(i));
- }
- }
-
- text = normalized.toString().trim();
-
- if (text.length()>0) {
- contentHandler.characters(text.toCharArray(), 0,
- text.length());
- }
-
- buffer = null;
- }
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderStreamerTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderStreamerTestCase.java
deleted file mode 100644
index e7c3202..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderStreamerTestCase.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import org.custommonkey.xmlunit.XMLTestCase;
-import org.custommonkey.xmlunit.XMLUnit;
-
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * Testcase for DOMStreamer and DOMBuilder.
- *
- * @version $Id$
- */
-public class DOMBuilderStreamerTestCase extends XMLTestCase {
-
- public DOMBuilderStreamerTestCase(String name) {
- super(name);
- }
-
- public void testBuilderWithOneElement() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startElement("", "root", "root", atts);
- builder.endElement("", "root", "root");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<root/>");
- assertXMLEqual(document, builder.getDocument());
- }
-
- public void testBuilderWithMoreElements() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startElement("", "root", "root", atts);
- builder.startElement("", "node", "node", atts);
- builder.endElement("", "node", "node");
- builder.startElement("", "node", "node", atts);
- builder.endElement("", "node", "node");
- builder.endElement("", "root", "root");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<root><node/><node/></root>");
- assertXMLEqual(document, builder.getDocument());
- }
-
- public void testBuilderWithText() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startElement("", "root", "root", atts);
- builder.characters("abcd".toCharArray(), 0, 4);
- builder.endElement("", "root", "node");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<root>abcd</root>");
- assertXMLEqual(document, builder.getDocument());
- }
-
- /*public void testBuilderWithNS() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startPrefixMapping("", "http://xml.apache.org");
- builder.startElement("", "root", "root", atts);
- builder.endElement("", "node", "node");
- builder.endPrefixMapping("");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<root xmlns=\"http://xml.apache.org\"/>");
- assertXMLEqual(document, builder.getDocument());
- }*/
-
- /*public void testBuilderWithPrefix() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startPrefixMapping("bla", "http://xml.apache.org");
- builder.startElement("http://xml.apache.org", "root", "bla:root", atts);
- builder.endElement("http://xml.apache.org", "root", "bla:root");
- builder.endPrefixMapping("bla");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<bla:root xmlns:bla=\"http://xml.apache.org\"/>");
- assertXMLEqual(document, builder.getDocument());
- }*/
-
- /*public void testBuilderWithNSError() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
-
- try {
- builder.startDocument();
- builder.startPrefixMapping("bla", "http://xml.apache.org");
- atts.addAttribute( "", "bla", "xmlns:bla", "CDATA", "http://xml.apache.org");
- builder.startElement("http://xml.apache.org", "root", "bla:root", atts);
- builder.endElement("http://xml.apache.org", "root", "bla:root");
- builder.endPrefixMapping("bla");
- builder.endDocument();
-
- fail("DOMBuilder should throw exception because of permitted attribute");
- } catch (Exception e) {
- // nothing
- }
- }*/
-
- public void testBuilderWithComments() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startElement("", "root", "root", atts);
- builder.comment("abcd".toCharArray(), 0, 4);
- builder.endElement("", "root", "node");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<root><!--abcd--></root>");
-
- assertXMLEqual(document, builder.getDocument());
- }
-
- public void testBuilderWithCommentWithinDocType() throws Exception {
- AttributesImpl atts = new AttributesImpl();
-
- DOMBuilder builder = new DOMBuilder();
- builder.startDocument();
- builder.startDTD("skinconfig", null, null);
- builder.comment("abcd".toCharArray(), 0, 4);
- builder.endDTD();
- builder.startElement("", "root", "root", atts);
- builder.endElement("", "root", "node");
- builder.endDocument();
-
- Document document = XMLUnit.buildControlDocument("<!DOCTYPE skinconfig [<!--abcd-->]><root></root>");
-
- print(document);
- print(builder.getDocument());
-
- assertXMLEqual(document, builder.getDocument());
- }
-
- public final void print(Document document) {
- TransformerFactory factory = TransformerFactory.newInstance();
- try
- {
- javax.xml.transform.Transformer serializer = factory.newTransformer();
- serializer.transform(new DOMSource(document), new StreamResult(System.out));
- System.out.println();
- }
- catch (TransformerException te)
- {
- te.printStackTrace();
- }
- }
-
-
- public void testTestFacility() throws Exception {
- Document document = XMLUnit.getControlParser().newDocument();
- Element elemA = document.createElement("root");
- document.appendChild(elemA);
-
- Document oneElementDocument = XMLUnit.buildControlDocument("<root/>");
- assertXMLEqual(oneElementDocument, document);
-
- document = XMLUnit.getControlParser().newDocument();
- elemA = document.createElement("node");
- document.appendChild(elemA);
-
- oneElementDocument = XMLUnit.buildControlDocument("<root/>");
- assertXMLNotEqual(oneElementDocument, document);
- }
-
- public void testStreamer() throws Exception {
-
- Document document = XMLUnit.getControlParser().newDocument();
- Element elemA = document.createElement("root");
- document.appendChild(elemA);
-
- Element elemB = document.createElement("node");
- elemA.appendChild(elemB);
-
- elemB = document.createElement("node");
- elemA.appendChild(elemB);
-
- DOMBuilder builder = new DOMBuilder();
- DOMStreamer streamer = new DOMStreamer(builder);
-
- streamer.stream(document);
-
- document = builder.getDocument();
-
- Document moreElementDocument = XMLUnit.buildControlDocument("<root><node/><node/></root>");
- assertXMLEqual(moreElementDocument, document);
- }
-
- /*public void testStreamerWithNS() throws Exception {
-
- Document document = XMLUnit.getControlParser().newDocument();
- Element elemA = document.createElementNS("http://xml.apache.org", "root");
- document.appendChild(elemA);
-
- Element elemB = document.createElementNS("http://xml.apache.org", "node");
- elemA.appendChild(elemB);
-
- elemB = document.createElementNS("http://xml.apache.org", "node");
- elemA.appendChild(elemB);
-
- DOMBuilder builder = new DOMBuilder();
- DOMStreamer streamer = new DOMStreamer(builder);
-
- streamer.stream(document);
-
- document = builder.getDocument();
-
- Document moreElementDocument = XMLUnit.buildControlDocument("<root xmlns=\"http://xml.apache.org\"><node/><node/></root>");
- assertXMLEqual(moreElementDocument, document);
- }*/
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderTestCase.java b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderTestCase.java
deleted file mode 100644
index e7940a5..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/java/org/apache/cocoon/xml/dom/DOMBuilderTestCase.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.xml.dom;
-
-import junit.framework.TestCase;
-
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-
-/**
- * JUnit Testcase for {@link DOMBuilder}.
- *
- * @version $Id$
- */
-public class DOMBuilderTestCase extends TestCase {
-
- /**
- * Constructor.
- * @param name
- */
- public DOMBuilderTestCase(String name) {
- super(name);
- }
-
- /**
- * Test if two consecutive "characters" events result in two text nodes
- * whose concatenation is equal to the concatenation
- * of the two strings (cfr. bug #26219).
- *
- * @throws SAXException
- */
- public void testMultipleCharactersEvents() throws SAXException {
- DOMBuilder builder = new DOMBuilder();
- Attributes attrs = new AttributesImpl();
- char c1[] = "ABC".toCharArray();
- char c2[] = "DEF".toCharArray();
- builder.startDocument();
- builder.startElement("", "test", "test", attrs);
- builder.characters(c1, 0, 3);
- builder.characters(c2, 0, 3);
- builder.endElement("", "test", "test");
- builder.endDocument();
- Document dom = builder.getDocument();
- StringBuffer value = new StringBuffer();
- for (int i = 0 ; i < dom.getDocumentElement().getChildNodes().getLength() ; ++i) {
- value.append(dom.getDocumentElement().getChildNodes().item(i).getNodeValue());
- }
- assertEquals("Content of root element not what expected",
- "ABCDEF", value.toString());
- }
-}
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/LICENSE.txt b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/LICENSE.txt
deleted file mode 100644
index 261eeb9..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/LICENSE.txt
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/NOTICE.txt b/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/NOTICE.txt
deleted file mode 100644
index 672aaa3..0000000
--- a/cocoon-pipeline-impl/cocoon-pipeline-impl-1.0.0-RC1/src/test/resources/META-INF/cocoon/NOTICE.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Cocoon
-Copyright 1999-2006 The Apache Software Foundation.
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).