Improve ACR attribute typing.
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / AttributeFormatter.java
index c7023f1a37a4a58b2582fc62e4f9f7d509fb7336..9f338965f829d2781649cb7fe192f9e2afa11a28 100644 (file)
@@ -1,5 +1,7 @@
 package org.argeo.api.acr;
 
+import javax.xml.namespace.NamespaceContext;
+
 /**
  * An attribute type MUST consistently parse a string to an object so that
  * <code>parse(obj.toString()).equals(obj)</code> is verified.
@@ -9,7 +11,15 @@ package org.argeo.api.acr;
  */
 public interface AttributeFormatter<T> {
        /** Parses a String to a Java object. */
-       T parse(String str) throws IllegalArgumentException;
+       default T parse(String str) throws IllegalArgumentException {
+               return parse(RuntimeNamespaceContext.getNamespaceContext(), str);
+       }
+
+       /**
+        * Parses a String to a Java object, possibly using the namespace context to
+        * resolve QName or CURIE.
+        */
+       T parse(NamespaceContext namespaceContext, String str) throws IllegalArgumentException;
 
        /** Default implementation returns {@link Object#toString()} on the argument. */
        default String format(T obj) {