You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2007/10/23 18:28:58 UTC
svn commit: r587550 [6/6] - in
/incubator/abdera/java/trunk/extensions/json/src/main: java/nu/
java/nu/validator/ java/nu/validator/htmlparser/
java/nu/validator/htmlparser/common/ java/nu/validator/htmlparser/impl/
java/nu/validator/htmlparser/sax/ ja...
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Element.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Element.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Element.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Element.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+public final class Element extends ParentNode {
+
+ private final String uri;
+
+ private final String localName;
+
+ private final String qName;
+
+ private final Attributes attributes;
+
+ private final List<PrefixMapping> prefixMappings;
+
+ public Element(Locator locator, String uri, String localName, String qName,
+ Attributes atts, boolean retainAttributes,
+ List<PrefixMapping> prefixMappings) {
+ super(locator);
+ this.uri = uri;
+ this.localName = localName;
+ this.qName = qName;
+ if (retainAttributes) {
+ this.attributes = atts;
+ } else {
+ this.attributes = new AttributesImpl(atts);
+ }
+ this.prefixMappings = prefixMappings;
+ }
+
+ @Override
+ void visit(TreeParser treeParser) throws SAXException {
+ if (prefixMappings != null) {
+ for (PrefixMapping mapping : prefixMappings) {
+ treeParser.startPrefixMapping(mapping.getPrefix(),
+ mapping.getUri(), this);
+ }
+ }
+ treeParser.startElement(uri, localName, qName, attributes, this);
+ }
+
+ /**
+ * @throws SAXException
+ * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
+ */
+ @Override
+ void revisit(TreeParser treeParser) throws SAXException {
+ treeParser.endElement(uri, localName, qName, endLocator);
+ if (prefixMappings != null) {
+ for (PrefixMapping mapping : prefixMappings) {
+ treeParser.endPrefixMapping(mapping.getPrefix(), endLocator);
+ }
+ }
+ }
+
+ /**
+ * Returns the attributes.
+ *
+ * @return the attributes
+ */
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Returns the localName.
+ *
+ * @return the localName
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /**
+ * Returns the prefixMappings.
+ *
+ * @return the prefixMappings
+ */
+ public List<PrefixMapping> getPrefixMappings() {
+ return prefixMappings;
+ }
+
+ /**
+ * Returns the qName.
+ *
+ * @return the qName
+ */
+ public String getQName() {
+ return qName;
+ }
+
+ /**
+ * Returns the uri.
+ *
+ * @return the uri
+ */
+ public String getUri() {
+ return uri;
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.ELEMENT;
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Entity.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Entity.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Entity.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Entity.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public final class Entity extends ParentNode {
+
+ private final String name;
+
+ public Entity(Locator locator, String name) {
+ super(locator);
+ this.name = name;
+ }
+
+ @Override
+ void visit(TreeParser treeParser) throws SAXException {
+ treeParser.startEntity(name, this);
+ }
+
+ /**
+ * @throws SAXException
+ * @see nu.validator.saxtree.Node#revisit(nu.validator.saxtree.TreeParser)
+ */
+ @Override
+ void revisit(TreeParser treeParser) throws SAXException {
+ treeParser.endEntity(name, endLocator);
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.ENTITY;
+ }
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/IgnorableWhitespace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/IgnorableWhitespace.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/IgnorableWhitespace.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/IgnorableWhitespace.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public final class IgnorableWhitespace extends CharBufferNode {
+
+ public IgnorableWhitespace(Locator locator, char[] buf, int start, int length) {
+ super(locator, buf, start, length);
+ }
+
+ @Override
+ void visit(TreeParser treeParser) throws SAXException {
+ treeParser.ignorableWhitespace(buffer, 0, buffer.length, this);
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.IGNORABLE_WHITESPACE;
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/LocatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/LocatorImpl.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/LocatorImpl.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/LocatorImpl.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+
+public final class LocatorImpl implements Locator {
+
+ private final String systemId;
+ private final String publicId;
+ private final int column;
+ private final int line;
+
+ public LocatorImpl(Locator locator) {
+ this.systemId = locator.getSystemId();
+ this.publicId = locator.getPublicId();
+ this.column = locator.getColumnNumber();
+ this.line = locator.getLineNumber();
+ }
+
+ public int getColumnNumber() {
+ return column;
+ }
+
+ public int getLineNumber() {
+ return line;
+ }
+
+ public String getPublicId() {
+ return publicId;
+ }
+
+ public String getSystemId() {
+ return systemId;
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Node.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Node.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Node.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/Node.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public abstract class Node implements Locator {
+
+ private final String systemId;
+ private final String publicId;
+ private final int column;
+ private final int line;
+
+ private Node nextSibling = null;
+
+ private ParentNode parentNode = null;
+
+ Node(Locator locator) {
+ this.systemId = locator.getSystemId();
+ this.publicId = locator.getPublicId();
+ this.column = locator.getColumnNumber();
+ this.line = locator.getLineNumber();
+ }
+
+ public int getColumnNumber() {
+ return column;
+ }
+
+ public int getLineNumber() {
+ return line;
+ }
+
+ public String getPublicId() {
+ return publicId;
+ }
+
+ public String getSystemId() {
+ return systemId;
+ }
+
+ abstract void visit(TreeParser treeParser) throws SAXException;
+
+ void revisit(TreeParser treeParser) throws SAXException {
+ return;
+ }
+
+ public Node getFirstChild() {
+ return null;
+ }
+
+ /**
+ * Returns the nextSibling.
+ *
+ * @return the nextSibling
+ */
+ public final Node getNextSibling() {
+ return nextSibling;
+ }
+
+ /**
+ * Sets the nextSibling.
+ *
+ * @param nextSibling the nextSibling to set
+ */
+ void setNextSibling(Node nextSibling) {
+ this.nextSibling = nextSibling;
+ }
+
+
+ /**
+ * Returns the parentNode.
+ *
+ * @return the parentNode
+ */
+ public final ParentNode getParentNode() {
+ return parentNode;
+ }
+
+ public abstract NodeType getNodeType();
+
+ // Subclass-specific accessors that are hoisted here to
+ // avoid casting.
+
+ /**
+ * Sets the parentNode.
+ *
+ * @param parentNode the parentNode to set
+ */
+ void setParentNode(ParentNode parentNode) {
+ this.parentNode = parentNode;
+ }
+
+ public void detach() {
+ if (parentNode != null) {
+ parentNode.removeChild(this);
+ parentNode = null;
+ }
+ }
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the publicIdentifier.
+ *
+ * @return the publicIdentifier
+ */
+ public String getPublicIdentifier() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the systemIdentifier.
+ *
+ * @return the systemIdentifier
+ */
+ public String getSystemIdentifier() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the attributes.
+ *
+ * @return the attributes
+ */
+ public Attributes getAttributes() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the localName.
+ *
+ * @return the localName
+ */
+ public String getLocalName() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the prefixMappings.
+ *
+ * @return the prefixMappings
+ */
+ public List<PrefixMapping> getPrefixMappings() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the qName.
+ *
+ * @return the qName
+ */
+ public String getQName() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the uri.
+ *
+ * @return the uri
+ */
+ public String getUri() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the data.
+ *
+ * @return the data
+ */
+ public String getData() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the target.
+ *
+ * @return the target
+ */
+ public String getTarget() {
+ throw new UnsupportedOperationException();
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NodeType.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NodeType.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NodeType.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NodeType.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,15 @@
+package nu.validator.saxtree;
+
+public enum NodeType {
+ CDATA,
+ CHARACTERS,
+ COMMENT,
+ DOCUMENT,
+ DOCUMENT_FRAGMENT,
+ DTD,
+ ELEMENT,
+ ENTITY,
+ IGNORABLE_WHITESPACE,
+ PROCESSING_INSTRUCTION,
+ SKIPPED_ENTITY
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NullLexicalHandler.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NullLexicalHandler.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NullLexicalHandler.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/NullLexicalHandler.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+final class NullLexicalHandler implements LexicalHandler {
+
+ public void comment(char[] arg0, int arg1, int arg2) throws SAXException {
+ }
+
+ public void endCDATA() throws SAXException {
+ }
+
+ public void endDTD() throws SAXException {
+ }
+
+ public void endEntity(String arg0) throws SAXException {
+ }
+
+ public void startCDATA() throws SAXException {
+ }
+
+ public void startDTD(String arg0, String arg1, String arg2) throws SAXException {
+ }
+
+ public void startEntity(String arg0) throws SAXException {
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ParentNode.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ParentNode.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ParentNode.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ParentNode.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+
+public abstract class ParentNode extends Node {
+
+ protected Locator endLocator;
+
+ private Node firstChild = null;
+
+ private Node lastChild = null;
+
+ ParentNode(Locator locator) {
+ super(locator);
+ }
+
+ /**
+ * Sets the endLocator.
+ *
+ * @param endLocator the endLocator to set
+ */
+ public void setEndLocator(Locator endLocator) {
+ this.endLocator = new LocatorImpl(endLocator);
+ }
+
+ /**
+ * Copies the endLocator from another node.
+ *
+ * @param another the another node
+ */
+ public void copyEndLocator(ParentNode another) {
+ this.endLocator = another.endLocator;
+ }
+
+ /**
+ * Returns the firstChild.
+ *
+ * @return the firstChild
+ */
+ public final Node getFirstChild() {
+ return firstChild;
+ }
+
+ /**
+ * Returns the lastChild.
+ *
+ * @return the lastChild
+ */
+ public final Node getLastChild() {
+ return lastChild;
+ }
+
+ public Node insertBefore(Node child, Node sibling) {
+ assert sibling == null || this == sibling.getParentNode();
+ if (sibling == null) {
+ return appendChild(child);
+ }
+ child.detach();
+ child.setParentNode(this);
+ if (firstChild == sibling) {
+ child.setNextSibling(sibling);
+ firstChild = child;
+ } else {
+ Node prev = firstChild;
+ Node next = firstChild.getNextSibling();
+ while (next != sibling) {
+ prev = next;
+ next = next.getNextSibling();
+ }
+ prev.setNextSibling(child);
+ child.setNextSibling(next);
+ }
+ return child;
+ }
+
+ public Node appendChild(Node child) {
+ child.detach();
+ child.setParentNode(this);
+ if (firstChild == null) {
+ firstChild = child;
+ } else {
+ lastChild.setNextSibling(child);
+ }
+ lastChild = child;
+ return child;
+ }
+
+ public void appendChildren(Node parent) {
+ Node child = parent.getFirstChild();
+ if (child == null) {
+ return;
+ }
+ ParentNode another = (ParentNode) parent;
+ if (firstChild == null) {
+ firstChild = child;
+ } else {
+ lastChild.setNextSibling(child);
+ }
+ lastChild = another.lastChild;
+ do {
+ child.setParentNode(this);
+ } while ((child = child.getNextSibling()) != null);
+ another.firstChild = null;
+ another.lastChild = null;
+ }
+
+ void removeChild(Node node) {
+ assert this == node.getParentNode();
+ if (firstChild == node) {
+ firstChild = node.getNextSibling();
+ if (lastChild == node) {
+ lastChild = null;
+ }
+ } else {
+ Node prev = firstChild;
+ Node next = firstChild.getNextSibling();
+ while (next != node) {
+ prev = next;
+ next = next.getNextSibling();
+ }
+ prev.setNextSibling(node.getNextSibling());
+ if (lastChild == node) {
+ lastChild = prev;
+ }
+ }
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/PrefixMapping.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/PrefixMapping.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/PrefixMapping.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/PrefixMapping.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+public final class PrefixMapping {
+ private final String prefix;
+ private final String uri;
+ /**
+ * @param prefix
+ * @param uri
+ */
+ public PrefixMapping(final String prefix, final String uri) {
+ this.prefix = prefix;
+ this.uri = uri;
+ }
+ /**
+ * Returns the prefix.
+ *
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+ /**
+ * Returns the uri.
+ *
+ * @return the uri
+ */
+ public String getUri() {
+ return uri;
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ProcessingInstruction.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ProcessingInstruction.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ProcessingInstruction.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/ProcessingInstruction.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public final class ProcessingInstruction extends Node {
+
+ private final String target;
+ private final String data;
+
+ public ProcessingInstruction(Locator locator, String target, String data) {
+ super(locator);
+ this.target = target;
+ this.data = data;
+ }
+
+ @Override
+ void visit(TreeParser treeParser) throws SAXException {
+ treeParser.processingInstruction(target, data, this);
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.PROCESSING_INSTRUCTION;
+ }
+
+ /**
+ * Returns the data.
+ *
+ * @return the data
+ */
+ public String getData() {
+ return data;
+ }
+
+ /**
+ * Returns the target.
+ *
+ * @return the target
+ */
+ public String getTarget() {
+ return target;
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/SkippedEntity.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/SkippedEntity.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/SkippedEntity.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/SkippedEntity.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+public final class SkippedEntity extends Node {
+
+ private final String name;
+
+ public SkippedEntity(Locator locator, String name) {
+ super(locator);
+ this.name = name;
+ }
+
+ @Override
+ void visit(TreeParser treeParser) throws SAXException {
+ treeParser.skippedEntity(name, this);
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return NodeType.SKIPPED_ENTITY;
+ }
+
+ /**
+ * Returns the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeBuilder.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeBuilder.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeBuilder.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+import java.util.LinkedList;
+import java.util.List;
+
+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;
+
+/**
+ * Builds a SAX Tree representation of a document or a fragment
+ * streamed as <code>ContentHandler</code> and
+ * <code>LexicalHandler</code> events. The start/end event matching
+ * is expected to adhere to the SAX API contract. Things will
+ * simply break if this is not the case. Fragments are expected to
+ * omit <code>startDocument()</code> and <code>endDocument()</code>
+ * calls.
+ *
+ * @version $Id: TreeBuilder.java 150 2007-08-16 19:21:25Z hsivonen $
+ * @author hsivonen
+ */
+public class TreeBuilder implements ContentHandler, LexicalHandler {
+
+ private Locator locator;
+
+ private ParentNode current;
+
+ private final boolean retainAttributes;
+
+ private List<PrefixMapping> prefixMappings;
+
+ /**
+ * Constructs a reusable <code>TreeBuilder</code> that builds
+ * <code>Document</code>s and copies attributes.
+ */
+ public TreeBuilder() {
+ this(false, false);
+ }
+
+ /**
+ * The constructor. The instance will be reusabe if building a full
+ * document and not reusable if building a fragment.
+ *
+ * @param fragment whether this <code>TreeBuilder</code> should build
+ * a <code>DocumentFragment</code> instead of a <code>Document</code>.
+ * @param retainAttributes whether instances of the <code>Attributes</code>
+ * interface passed to <code>startElement</code> should be retained
+ * (the alternative is copying).
+ */
+ public TreeBuilder(boolean fragment, boolean retainAttributes) {
+ if (fragment) {
+ current = new DocumentFragment();
+ }
+ this.retainAttributes = retainAttributes;
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ current.appendChild(new Characters(locator, ch, start, length));
+ }
+
+ public void endDocument() throws SAXException {
+ current.setEndLocator(locator);
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ current.setEndLocator(locator);
+ current = current.getParentNode();
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ current.appendChild(new IgnorableWhitespace(locator, ch, start, length));
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ current.appendChild(new ProcessingInstruction(locator, target, data));
+ }
+
+ public void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ public void skippedEntity(String name) throws SAXException {
+ current.appendChild(new SkippedEntity(locator, name));
+ }
+
+ public void startDocument() throws SAXException {
+ current = new Document(locator);
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ current = (ParentNode) current.appendChild(new Element(locator, uri, localName, qName, atts, retainAttributes, prefixMappings));
+ prefixMappings = null;
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ if (prefixMappings == null) {
+ prefixMappings = new LinkedList<PrefixMapping>();
+ }
+ prefixMappings.add(new PrefixMapping(prefix, uri));
+ }
+
+ public void comment(char[] ch, int start, int length) throws SAXException {
+ current.appendChild(new Comment(locator, ch, start, length));
+ }
+
+ public void endCDATA() throws SAXException {
+ current.setEndLocator(locator);
+ current = current.getParentNode();
+ }
+
+ public void endDTD() throws SAXException {
+ current.setEndLocator(locator);
+ current = current.getParentNode();
+ }
+
+ public void endEntity(String name) throws SAXException {
+ current.setEndLocator(locator);
+ current = current.getParentNode();
+ }
+
+ public void startCDATA() throws SAXException {
+ current = (ParentNode) current.appendChild(new CDATA(locator));
+ }
+
+ public void startDTD(String name, String publicId, String systemId) throws SAXException {
+ current = (ParentNode) current.appendChild(new DTD(locator, name, publicId, systemId));
+ }
+
+ public void startEntity(String name) throws SAXException {
+ current = (ParentNode) current.appendChild(new Entity(locator, name));
+ }
+
+ /**
+ * Returns the root (<code>Document</code> if building a full document or
+ * <code>DocumentFragment</code> if building a fragment.).
+ *
+ * @return the root
+ */
+ public ParentNode getRoot() {
+ return current;
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeParser.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeParser.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/TreeParser.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package nu.validator.saxtree;
+
+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;
+
+public final class TreeParser implements Locator {
+ private final ContentHandler contentHandler;
+
+ private final LexicalHandler lexicalHandler;
+
+ private Locator locatorDelegate;
+
+ /**
+ * The constructor.
+ *
+ * @param contentHandler
+ * must not be <code>null</code>
+ * @param lexicalHandler
+ * may be <code>null</code>
+ */
+ public TreeParser(final ContentHandler contentHandler,
+ final LexicalHandler lexicalHandler) {
+ if (contentHandler == null) {
+ throw new IllegalArgumentException("contentHandler was null.");
+ }
+ this.contentHandler = contentHandler;
+ if (lexicalHandler == null) {
+ this.lexicalHandler = new NullLexicalHandler();
+ } else {
+ this.lexicalHandler = lexicalHandler;
+ }
+ }
+
+ /**
+ * Causes SAX events for the tree rooted at the argument to be emitted.
+ * <code>startDocument()</code> and <code>endDocument()</code> are only
+ * emitted for a <code>Document</code> node.
+ *
+ * @param node
+ * the root
+ * @throws SAXException
+ */
+ public void parse(Node node) throws SAXException {
+ contentHandler.setDocumentLocator(this);
+ Node current = node;
+ Node next;
+ for (;;) {
+ current.visit(this);
+ if ((next = current.getFirstChild()) != null) {
+ current = next;
+ continue;
+ }
+ for (;;) {
+ current.revisit(this);
+ if (current == node) {
+ return;
+ }
+ if ((next = current.getNextSibling()) != null) {
+ current = next;
+ break;
+ }
+ current = current.getParentNode();
+ }
+ }
+ }
+
+ /**
+ * @param ch
+ * @param start
+ * @param length
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+ */
+ void characters(char[] ch, int start, int length, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.characters(ch, start, length);
+ }
+
+ /**
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#endDocument()
+ */
+ void endDocument(Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.endDocument();
+ }
+
+ /**
+ * @param uri
+ * @param localName
+ * @param qName
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ void endElement(String uri, String localName, String qName, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.endElement(uri, localName, qName);
+ }
+
+ /**
+ * @param prefix
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
+ */
+ void endPrefixMapping(String prefix, Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.endPrefixMapping(prefix);
+ }
+
+ /**
+ * @param ch
+ * @param start
+ * @param length
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
+ */
+ void ignorableWhitespace(char[] ch, int start, int length, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.ignorableWhitespace(ch, start, length);
+ }
+
+ /**
+ * @param target
+ * @param data
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String,
+ * java.lang.String)
+ */
+ void processingInstruction(String target, String data, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.processingInstruction(target, data);
+ }
+
+ /**
+ * @param name
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
+ */
+ void skippedEntity(String name, Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.skippedEntity(name);
+ }
+
+ /**
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#startDocument()
+ */
+ void startDocument(Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.startDocument();
+ }
+
+ /**
+ * @param uri
+ * @param localName
+ * @param qName
+ * @param atts
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ void startElement(String uri, String localName, String qName,
+ Attributes atts, Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.startElement(uri, localName, qName, atts);
+ }
+
+ /**
+ * @param prefix
+ * @param uri
+ * @throws SAXException
+ * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
+ * java.lang.String)
+ */
+ void startPrefixMapping(String prefix, String uri, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ contentHandler.startPrefixMapping(prefix, uri);
+ }
+
+ /**
+ * @param ch
+ * @param start
+ * @param length
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
+ */
+ void comment(char[] ch, int start, int length, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.comment(ch, start, length);
+ }
+
+ /**
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#endCDATA()
+ */
+ void endCDATA(Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.endCDATA();
+ }
+
+ /**
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#endDTD()
+ */
+ void endDTD(Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.endDTD();
+ }
+
+ /**
+ * @param name
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
+ */
+ void endEntity(String name, Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.endEntity(name);
+ }
+
+ /**
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#startCDATA()
+ */
+ void startCDATA(Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.startCDATA();
+ }
+
+ /**
+ * @param name
+ * @param publicId
+ * @param systemId
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ void startDTD(String name, String publicId, String systemId, Locator locator)
+ throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.startDTD(name, publicId, systemId);
+ }
+
+ /**
+ * @param name
+ * @throws SAXException
+ * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
+ */
+ void startEntity(String name, Locator locator) throws SAXException {
+ this.locatorDelegate = locator;
+ lexicalHandler.startEntity(name);
+ }
+
+ /**
+ * @return
+ * @see org.xml.sax.Locator#getColumnNumber()
+ */
+ public int getColumnNumber() {
+ if (locatorDelegate == null) {
+ return -1;
+ } else {
+ return locatorDelegate.getColumnNumber();
+ }
+ }
+
+ /**
+ * @return
+ * @see org.xml.sax.Locator#getLineNumber()
+ */
+ public int getLineNumber() {
+ if (locatorDelegate == null) {
+ return -1;
+ } else {
+ return locatorDelegate.getLineNumber();
+ }
+ }
+
+ /**
+ * @return
+ * @see org.xml.sax.Locator#getPublicId()
+ */
+ public String getPublicId() {
+ if (locatorDelegate == null) {
+ return null;
+ } else {
+
+ return locatorDelegate.getPublicId();
+ }
+ }
+
+ /**
+ * @return
+ * @see org.xml.sax.Locator#getSystemId()
+ */
+ public String getSystemId() {
+ if (locatorDelegate == null) {
+ return null;
+ } else {
+ return locatorDelegate.getSystemId();
+ }
+ }
+}
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/package.html
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/package.html?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/package.html (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/nu/validator/saxtree/package.html Tue Oct 23 09:28:51 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head><title>Package Overview</title>
+<!--
+ Copyright (c) 2007 Henri Sivonen
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+-->
+</head>
+<body bgcolor="white">
+<p>This package provides SAX Tree: a tree model optimized for creation from SAX
+events and replay as SAX events.</p>
+<h2>Design Principles</h2>
+<ol>
+<li>Preserve information exposed through <code>ContentHandler</code>,
+<code>LexicalHandler</code> <em>and</em> <code>Locator</code>.
+<li>Creation from SAX events or as part of the parse of a conforming
+HTML5 document should be <em>fast</em>.</li>
+<li>Emitting SAX events based on the tree should be <em>fast</em>.</li>
+<li>Mutations should be <em>possible</em> but should not make the above
+"fast" cases slower.</li>
+<li>Concurrent reads should work without locking when there are no
+concurrent mutations.</li>
+<li>The user of the API has the responsibility of using the API properly:
+for the sake of performance, the model does not check if it is being
+used properly. Improper use may, therefore, put the model in and
+inconsistent state.</li>
+</ol>
+</body>
+</html>
\ No newline at end of file
Added: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/html/HtmlHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/html/HtmlHelper.java?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/html/HtmlHelper.java (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/html/HtmlHelper.java Tue Oct 23 09:28:51 2007
@@ -0,0 +1,101 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. 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. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.html;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+
+import nu.validator.htmlparser.common.XmlViolationPolicy;
+import nu.validator.htmlparser.sax.HtmlSerializer;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Div;
+import org.xml.sax.InputSource;
+
+public class HtmlHelper {
+
+ public static Div parse(String value) {
+ return parse(new Abdera(),value);
+ }
+
+ public static Div parse(InputStream in) {
+ return parse(new Abdera(),in);
+ }
+
+ public static Div parse(InputStream in, String charset) {
+ return parse(new Abdera(),in,charset);
+ }
+
+ public static Div parse(Reader in) {
+ return parse(new Abdera(),in);
+ }
+
+ public static Div parse(Abdera abdera, String value) {
+ return parse(abdera, new StringReader(value));
+ }
+
+ public static Div parse(Abdera abdera, InputStream in) {
+ return parse(abdera, in, "UTF-8");
+ }
+
+ public static Div parse(Abdera abdera, InputStream in, String charset) {
+ try {
+ return parse(abdera, new InputStreamReader(in, charset));
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Div parse(Abdera abdera, Reader in) {
+ String result = null;
+ Div div = abdera.getFactory().newDiv();
+ try {
+ nu.validator.htmlparser.sax.HtmlParser htmlParser = new nu.validator.htmlparser.sax.HtmlParser();
+ htmlParser.setBogusXmlnsPolicy(XmlViolationPolicy.ALTER_INFOSET);
+ htmlParser.setMappingLangToXmlLang(true);
+ htmlParser.setReportingDoctype(false);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Writer w = new OutputStreamWriter(out, "UTF-8");
+ HtmlSerializer ser = new HtmlSerializer(w);
+ htmlParser.setContentHandler(ser);
+ htmlParser.setLexicalHandler(ser);
+ //htmlParser.setErrorHandler(new SystemErrErrorHandler());
+ htmlParser.parseFragment(new InputSource(in), "div");
+ w.flush();
+ result = new String(out.toByteArray(),"UTF-8");
+ div.setValue(result);
+ return div;
+ } catch (Exception e) {
+ // this is a temporary hack. some html really
+ // can't be parsed successfully. in that case,
+ // we produce something that will likely render
+ // rather ugly. but there's not much else we
+ // can do
+ if (result != null) div.setText(result);
+ return div;
+ }
+ }
+
+}
Modified: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java?rev=587550&r1=587549&r2=587550&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java (original)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java Tue Oct 23 09:28:51 2007
@@ -25,6 +25,7 @@
import org.apache.abdera.Abdera;
import org.apache.abdera.ext.bidi.BidiHelper;
import org.apache.abdera.ext.history.FeedPagingHelper;
+import org.apache.abdera.ext.html.HtmlHelper;
import org.apache.abdera.ext.thread.InReplyTo;
import org.apache.abdera.ext.thread.ThreadHelper;
import org.apache.abdera.i18n.iri.IRI;
@@ -34,6 +35,7 @@
import org.apache.abdera.model.Collection;
import org.apache.abdera.model.Content;
import org.apache.abdera.model.Control;
+import org.apache.abdera.model.Div;
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Element;
import org.apache.abdera.model.Entry;
@@ -72,9 +74,10 @@
((Document)element).getBaseUri() :
((Element)element).getResolvedBaseUri();
}
- if (parentbase == null &&
- element.getResolvedBaseUri() != null)
- return false;
+ IRI base = element.getResolvedBaseUri();
+
+ if (parentbase == null && base != null) return false;
+ if (parentbase == null && base == null) return true;
return parentbase.equals(element.getResolvedBaseUri());
}
@@ -101,11 +104,14 @@
jstream.writeField("children");
switch(text.getTextType()) {
case TEXT:
- case HTML:
jstream.startArray();
jstream.writeQuoted(text.getValue());
jstream.endArray();
break;
+ case HTML:
+ Div div = HtmlHelper.parse(text.getValue());
+ writeElementValue(div, jstream);
+ break;
case XHTML:
writeElementValue(text.getValueElement(), jstream);
break;
@@ -146,10 +152,8 @@
jstream.endArray();
break;
case HTML:
- // TODO: eventually we'll parse this out into the hash
- jstream.startArray();
- jstream.writeQuoted(content.getValue());
- jstream.endArray();
+ Div div = HtmlHelper.parse(content.getValue());
+ writeElementValue(div, jstream);
break;
case XHTML:
writeElementValue(content.getValueElement(), jstream);
@@ -157,6 +161,7 @@
case MEDIA:
case XML:
jstream.startArray();
+ jstream.writeQuoted(content.getValue());
jstream.endArray();
}
jstream.endObject();
@@ -377,10 +382,18 @@
jstream.writeField("xml:base",child.getResolvedBaseUri());
writeLanguageFields(child, jstream);
for (QName attr : attributes) {
- jstream.writeField(getName(attr));
+ String name = getName(attr);
+ jstream.writeField(name);
if ("".equals(attr.getPrefix()) ||
"xml".equals(attr.getPrefix())) {
- jstream.writeQuoted(child.getAttributeValue(attr));
+ String val = child.getAttributeValue(attr);
+ if ("href".equalsIgnoreCase(name) ||
+ "src".equalsIgnoreCase(name) ||
+ "action".equalsIgnoreCase(name)) {
+ IRI base = child.getResolvedBaseUri();
+ if (base != null) val = base.resolve(val).toASCIIString();
+ }
+ jstream.writeQuoted(val);
} else {
jstream.startObject();
jstream.writeField("attributes");
@@ -410,7 +423,7 @@
Object child = children[n];
if (child instanceof Element) {
writeElement((Element)child, parentqname, jstream);
- if (n < children.length-1) jstream.writeSeparator();
+ if (n < children.length-2) jstream.writeSeparator();
} else if (child instanceof TextValue) {
TextValue textvalue = (TextValue) child;
String value = textvalue.getText();
@@ -504,7 +517,7 @@
throws IOException {
if (needToWriteLang(element)) {
String lang = element.getLanguage();
- jstream.writeField("xml:lang",lang);
+ jstream.writeField("lang",lang);
}
if (needToWriteDir(element)) {
BidiHelper.Direction dir = BidiHelper.getDirection(element);
@@ -532,8 +545,11 @@
jstream.writeField(name);
jstream.startArray();
for (int n = 0; n < list.size(); n++) {
- toJson((Element)list.get(n),jstream);
- if (n < list.size()-1) jstream.writeSeparator();
+ Element el = (Element)list.get(n);
+ if (!(el instanceof InReplyTo)) {
+ toJson(el,jstream);
+ if (n < list.size()-1) jstream.writeSeparator();
+ }
}
jstream.endArray();
return true;
Added: incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.htmlparser.txt
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.htmlparser.txt?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.htmlparser.txt (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.htmlparser.txt Tue Oct 23 09:28:51 2007
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2007 Henri Sivonen
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
\ No newline at end of file
Added: incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.serializer.txt
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.serializer.txt?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.serializer.txt (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/LICENSE.serializer.txt Tue Oct 23 09:28:51 2007
@@ -0,0 +1,201 @@
+ 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.
Added: incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.htmlparser.txt
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.htmlparser.txt?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.htmlparser.txt (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.htmlparser.txt Tue Oct 23 09:28:51 2007
@@ -0,0 +1,7 @@
+
+ nu.validator html parser
+ Copyright (c) 2007 Henri Sivonen
+
+ This product includes software developed at
+ http://about.validator.nu/htmlparser/
+
Added: incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.serializer.txt
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.serializer.txt?rev=587550&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.serializer.txt (added)
+++ incubator/abdera/java/trunk/extensions/json/src/main/resources/META-INF/NOTICE.serializer.txt Tue Oct 23 09:28:51 2007
@@ -0,0 +1,18 @@
+ =========================================================================
+ == NOTICE file corresponding to section 4(d) of the Apache License, ==
+ == Version 2.0, in this case for the Apache Xalan Java distribution. ==
+ =========================================================================
+
+ Apache Xalan (Xalan serializer)
+ Copyright 1999-2006 The Apache Software Foundation
+
+ This product includes software developed at
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Portions of this software was originally based on the following:
+ - software copyright (c) 1999-2002, Lotus Development Corporation.,
+ http://www.lotus.com.
+ - software copyright (c) 2001-2002, Sun Microsystems.,
+ http://www.sun.com.
+ - software copyright (c) 2003, IBM Corporation.,
+ http://www.ibm.com.