Author: veithen
Date: Mon May 24 09:07:41 2010
New Revision: 947570
URL: http://svn.apache.org/viewvc?rev=947570&view=rev
Log:
Resolved some TODO items.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamReader.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamWriter.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLFragmentStreamReader.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamReader.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamReader.java?rev=947570&r1=947569&r2=947570&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamReader.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamReader.java
Mon May 24 09:07:41 2010
@@ -80,19 +80,47 @@ public abstract class AbstractXMLStreamR
public boolean hasName() {
int event = getEventType();
- // TODO: need to check the StAX specs if this is correct
return event == START_ELEMENT || event == END_ELEMENT;
}
- /**
- * @param i
- * @param s
- * @param s1
- * @throws XMLStreamException
- * @see javax.xml.stream.XMLStreamReader#require(int, String, String)
- */
- // TODO: this comes from OMStAXWrapper and needs to be implemented properly
- public void require(int i, String s, String s1) throws XMLStreamException {
- throw new XMLStreamException();
+ public void require(int type, String uri, String localName) throws
XMLStreamException {
+ int actualType = getEventType();
+
+ if (type != actualType) {
+ throw new XMLStreamException("Required type " +
XMLEventUtils.getEventTypeString(type)
+ + ", actual type " +
XMLEventUtils.getEventTypeString(actualType));
+ }
+
+ if (localName != null) {
+ if (actualType != START_ELEMENT && actualType != END_ELEMENT
+ && actualType != ENTITY_REFERENCE) {
+ throw new XMLStreamException("Required a non-null local name,
but current token " +
+ "not a START_ELEMENT, END_ELEMENT or
ENTITY_REFERENCE (was " +
+ XMLEventUtils.getEventTypeString(actualType) +
")");
+ }
+ String actualLocalName = getLocalName();
+ if (actualLocalName != localName &&
!actualLocalName.equals(localName)) {
+ throw new XMLStreamException("Required local name '" +
localName +
+ "'; current local name '" + actualLocalName + "'.");
+ }
+ }
+
+ if (uri != null) {
+ if (actualType != START_ELEMENT && actualType != END_ELEMENT) {
+ throw new XMLStreamException("Required non-null namespace URI,
but current token " +
+ "not a START_ELEMENT or END_ELEMENT (was " +
+ XMLEventUtils.getEventTypeString(actualType) +
")");
+ }
+ String actualUri = getNamespaceURI();
+ if (uri.length() == 0) {
+ if (actualUri != null && actualUri.length() > 0) {
+ throw new XMLStreamException("Required empty namespace,
instead have '" + actualUri + "'.");
+ }
+ } else {
+ if (!uri.equals(actualUri)) {
+ throw new XMLStreamException("Required namespace '" + uri
+ "'; have '" + actualUri +"'.");
+ }
+ }
+ }
}
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamWriter.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamWriter.java?rev=947570&r1=947569&r2=947570&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamWriter.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/AbstractXMLStreamWriter.java
Mon May 24 09:07:41 2010
@@ -44,7 +44,7 @@ public abstract class AbstractXMLStreamW
}
public final void setNamespaceContext(NamespaceContext context) throws
XMLStreamException {
- // TODO: not sure yet how to implement this method
+ // We currently don't support this method
throw new UnsupportedOperationException();
}
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLFragmentStreamReader.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLFragmentStreamReader.java?rev=947570&r1=947569&r2=947570&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLFragmentStreamReader.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/XMLFragmentStreamReader.java
Mon May 24 09:07:41 2010
@@ -320,9 +320,10 @@ public class XMLFragmentStreamReader imp
}
public String getNamespaceURI(String prefix) {
- // TODO: It is not clear whether this method is allowed in all states.
- // The XMLStreamReader Javadoc suggest it is, but Woodstox
doesn't
- // allow it on states other than START_ELEMENT and END_ELEMENT.
+ // It is not clear whether this method is allowed in all states.
+ // The XMLStreamReader Javadoc suggest it is, but Woodstox doesn't
+ // allow it on states other than START_ELEMENT and END_ELEMENT.
+ // We emulate behavior of Woodstox.
if (state == STATE_START_DOCUMENT || state == STATE_END_DOCUMENT) {
throw new IllegalStateException();
} else {