Package gnu.xml
Class NamespaceBinding
- java.lang.Object
-
- gnu.xml.NamespaceBinding
-
- All Implemented Interfaces:
Externalizable,Serializable
public final class NamespaceBinding extends Object implements Externalizable
A "namespace node" as a link in a linked list. The list may contain duplicates - i.e. multiple namespace bindings for the same prefix but (usually) different uris. In that case the first binding "wins". One reason for allowing duplicates it to allow sharing of the lists between a child and its parent element.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static NamespaceBindingpredefinedXMLstatic StringXML_NAMESPACE
-
Constructor Summary
Constructors Constructor Description NamespaceBinding(String prefix, String uri, NamespaceBinding next)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NamespaceBindingcommonAncestor(NamespaceBinding ns1, NamespaceBinding ns2)intcount(NamespaceBinding fencePost)Return the number of bindings before thefencePost.NamespaceBindinggetNext()StringgetPrefix()Namespace prefix.StringgetUri()Namespace uri.static NamespaceBindingmaybeAdd(String prefix, String uri, NamespaceBinding bindings)Append a new NamespaceBinding if not redundant.static NamespaceBindingnconc(NamespaceBinding list1, NamespaceBinding list2)Chain the first list in front of the second list.voidreadExternal(ObjectInput in)Stringresolve(String prefix)Resolve a prefix.Stringresolve(String prefix, NamespaceBinding fencePost)Resolve a prefix, in the initial part of this list.NamespaceBindingreversePrefix(NamespaceBinding fencePost)Reverse the chain, until a fencePost.voidsetNext(NamespaceBinding next)voidsetPrefix(String prefix)voidsetUri(String uri)StringtoString()Return a String showing just a single namespace binding.StringtoStringAll()Return a String showing the full namespace binding list.voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
XML_NAMESPACE
public static final String XML_NAMESPACE
- See Also:
- Constant Field Values
-
predefinedXML
public static final NamespaceBinding predefinedXML
-
-
Constructor Detail
-
NamespaceBinding
public NamespaceBinding(String prefix, String uri, NamespaceBinding next)
-
-
Method Detail
-
getPrefix
public final String getPrefix()
Namespace prefix. An interned String. A default namespace declaration is represented using null.
-
setPrefix
public final void setPrefix(String prefix)
-
getUri
public final String getUri()
Namespace uri. An interned String. The value null "undeclares" any following namespaces with the same prefix; it corresponds to an empty uri as in the XML Namespaces 1.1 Candidate Recommendation.
-
setUri
public final void setUri(String uri)
-
getNext
public final NamespaceBinding getNext()
-
setNext
public final void setNext(NamespaceBinding next)
-
nconc
public static final NamespaceBinding nconc(NamespaceBinding list1, NamespaceBinding list2)
Chain the first list in front of the second list. (The namenconccomes from Common Lisp.)
-
resolve
public String resolve(String prefix)
Resolve a prefix.- Parameters:
prefix- an interned namespace prefix to search for.- Returns:
- a uri or null if not bound
-
resolve
public String resolve(String prefix, NamespaceBinding fencePost)
Resolve a prefix, in the initial part of this list.- Parameters:
prefix- an interned namespace prefix to search for.fencePost- only search this list until then.- Returns:
- a uri or null if not bound
-
commonAncestor
public static NamespaceBinding commonAncestor(NamespaceBinding ns1, NamespaceBinding ns2)
-
reversePrefix
public NamespaceBinding reversePrefix(NamespaceBinding fencePost)
Reverse the chain, until a fencePost.
-
count
public int count(NamespaceBinding fencePost)
Return the number of bindings before thefencePost.
-
maybeAdd
public static NamespaceBinding maybeAdd(String prefix, String uri, NamespaceBinding bindings)
Append a new NamespaceBinding if not redundant.
-
toString
public String toString()
Return a String showing just a single namespace binding.
-
toStringAll
public String toStringAll()
Return a String showing the full namespace binding list.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-