You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/08/11 15:50:30 UTC
svn commit: r231455 - in
/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml:
NamespacesTable.java RedundantNamespacesFilter.java
Author: vgritsenko
Date: Thu Aug 11 06:50:25 2005
New Revision: 231455
URL: http://svn.apache.org/viewcvs?rev=231455&view=rev
Log:
fix javadoc
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/RedundantNamespacesFilter.java
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java?rev=231455&r1=231454&r2=231455&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/NamespacesTable.java Thu Aug 11 06:50:25 2005
@@ -1,12 +1,12 @@
/*
* Copyright 1999-2004 The Apache Software Foundation.
- *
+ *
* 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.
@@ -35,30 +35,30 @@
* 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 the call to leaveScope above.
* }
* </pre>
- *
+ *
* @version $Id$
*/
public class NamespacesTable {
/** The last namespace declaration. */
- private Entry lastEntry = null;
-
+ private Entry lastEntry;
+
private boolean filterDuplicate = true;
/**
@@ -67,7 +67,7 @@
public NamespacesTable() {
clear();
}
-
+
/**
* Clear and reinitialize this namespace table before reuse.
*
@@ -91,14 +91,14 @@
while (dup != null && !dup.prefix.equals(prefix)) {
dup = dup.previous;
}
-
+
if (dup != null) {
if (filterDuplicate && dup.uri.equals(uri)) {
return dup;
}
dup.overriden = true;
}
-
+
Entry e = Entry.create(prefix, uri);
e.previous = this.lastEntry;
e.overrides = dup;
@@ -115,7 +115,7 @@
* @return The removed <code>Declaration</code> or <b>null</b>.
*/
public Declaration removeDeclaration(String prefix) {
-
+
Entry current = this.lastEntry;
Entry afterCurrent = null;
while(current != null) {
@@ -123,7 +123,7 @@
// Don't undeclare mappings not declared in this scope
return null;
}
-
+
if (current.prefix.equals(prefix)) {
// Got it
// Remove it from the chain
@@ -137,33 +137,33 @@
// No more overriden
overrides.overriden = false;
}
-
+
return current;
}
-
+
afterCurrent = current;
current = current.previous;
}
-
+
// Not found
return null;
}
-
+
/**
* Enter a new scope, with no declared mappings.
- *
+ *
* @see #getCurrentScopeDeclarations()
* @since 2.1.8
*/
public void enterScope() {
this.lastEntry.closedScopes++;
}
-
+
/**
* Start all declared mappings of the current scope and enter a new scope.
* 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
@@ -176,13 +176,13 @@
}
enterScope();
}
-
+
/**
* Leave a scope. If <code>autoRemove</code> is true, all declared mappings for the
* scope that is left are automatically removed, without having to explicitely call
* {@link #removeDeclaration(String)}.
- *
- * @param autoRemove if <code>true</code>, remove all mappings for the current scope.
+ *
+ * @param autoUndeclare if <code>true</code>, remove all mappings for the current scope.
* @since 2.1.8
*/
public void leaveScope(boolean autoUndeclare) {
@@ -203,12 +203,12 @@
}
this.lastEntry = current;
}
-
+
/**
* Leave a scope and end all declared mappings of the new scope.
* 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
@@ -231,12 +231,12 @@
current.closedScopes--;
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 (never null)
* @since 2.1.8
*/
@@ -272,7 +272,7 @@
}
current = current.previous;
}
-
+
// Not found
return null;
}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/RedundantNamespacesFilter.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/RedundantNamespacesFilter.java?rev=231455&r1=231454&r2=231455&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/RedundantNamespacesFilter.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/xml/RedundantNamespacesFilter.java Thu Aug 11 06:50:25 2005
@@ -20,22 +20,24 @@
/**
* A SAX filter that strips out redundant namespace declarations.
+ *
* <p>
* It handles both duplicate declarations (i.e. a namespace already declared by a
* parent element) and empty namespaces scopes (i.e. start/stopPrefixMapping with
* no element inbetween) that can be produced by some components (e.g. JXTG or
* BrowserUpdateTransformer). Such empty scopes confuse the Xalan serializer which
* then produces weird namespace declarations (<code>xmlns:%@$#^@#="%@$#^@#"</code>).
+ *
* <p>
- * This is a the most simple use of {@link NamespaceHelper}.
- *
+ * This is a the most simple use of {@link NamespacesTable}.
+ *
* @version CVS $Id$
*/
public class RedundantNamespacesFilter extends AbstractXMLPipe {
-
+
/** Layered storage for all namespace declarations */
private NamespacesTable ns = new NamespacesTable();
-
+
/**
* No-arg constructor. Requires an explicit call to
* <code>setConsumer()</code>.
@@ -46,14 +48,14 @@
/**
* Creates a filter directly linked to its consumer
- *
+ *
* @param consumer
* the SAX stream consumer
*/
public RedundantNamespacesFilter(XMLConsumer consumer) {
setConsumer(consumer);
}
-
+
public void startPrefixMapping(String prefix, String uri) throws SAXException {
// Just declare it: duplicate declarations are ignorede by NamespacesTable
ns.addDeclaration(prefix, uri);