Permalink
Browse files

STXM-11 Add unregister methods

  • Loading branch information...
1 parent 6bb456f commit 8f05c65339482bcf2260dc9c3d62d71d8e46960c @bstansberry bstansberry committed Jan 6, 2012
View
16 src/main/java/org/jboss/staxmapper/XMLMapper.java
@@ -43,6 +43,13 @@
void registerRootElement(QName name, XMLElementReader<?> reader);
/**
+ * Removes a {@link #registerRootElement(QName, XMLElementReader) previously registered root element}.
+ *
+ * @param name the element name
+ */
+ void unregisterRootElement(QName name);
+
+ /**
* Add a known root attribute which can be read by {@link XMLExtendedStreamReader#handleAttribute(Object, int)}.
*
* @param name the attribute name
@@ -51,6 +58,13 @@
void registerRootAttribute(QName name, XMLAttributeReader<?> reader);
/**
+ * Removes a {@link #registerRootAttribute(QName, XMLAttributeReader) previously registered root attribute}.
+ *
+ * @param name the element name
+ */
+ void unregisterRootAttribute(QName name);
+
+ /**
* Parse a document. The document must have a known, registered root element which can accept the given root object.
*
* @param rootObject the root object to send in
@@ -78,7 +92,7 @@
*/
@Deprecated
void deparseDocument(XMLContentWriter contentWriter, XMLStreamWriter streamWriter) throws XMLStreamException;
-
+
/**
* A factory for creating an instance of {@link XMLMapper}.
*/
View
10 src/main/java/org/jboss/staxmapper/XMLMapperImpl.java
@@ -45,12 +45,22 @@ public void registerRootElement(QName name, XMLElementReader<?> reader) {
}
}
+ @Override
+ public void unregisterRootElement(QName name) {
+ rootElements.remove(name);
+ }
+
public void registerRootAttribute(QName name, XMLAttributeReader<?> reader) {
if (rootAttributes.putIfAbsent(name, reader) != null) {
throw new IllegalArgumentException("Root attribute for " + name + " already registered");
}
}
+ @Override
+ public void unregisterRootAttribute(QName name) {
+ rootAttributes.remove(name);
+ }
+
public void parseDocument(Object rootObject, XMLStreamReader reader) throws XMLStreamException {
try {
reader.require(START_DOCUMENT, null, null);

0 comments on commit 8f05c65

Please sign in to comment.