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 NamespaceBinding
predefinedXML
static String
XML_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 NamespaceBinding
commonAncestor(NamespaceBinding ns1, NamespaceBinding ns2)
int
count(NamespaceBinding fencePost)
Return the number of bindings before thefencePost
.NamespaceBinding
getNext()
String
getPrefix()
Namespace prefix.String
getUri()
Namespace uri.static NamespaceBinding
maybeAdd(String prefix, String uri, NamespaceBinding bindings)
Append a new NamespaceBinding if not redundant.static NamespaceBinding
nconc(NamespaceBinding list1, NamespaceBinding list2)
Chain the first list in front of the second list.void
readExternal(ObjectInput in)
String
resolve(String prefix)
Resolve a prefix.String
resolve(String prefix, NamespaceBinding fencePost)
Resolve a prefix, in the initial part of this list.NamespaceBinding
reversePrefix(NamespaceBinding fencePost)
Reverse the chain, until a fencePost.void
setNext(NamespaceBinding next)
void
setPrefix(String prefix)
void
setUri(String uri)
String
toString()
Return a String showing just a single namespace binding.String
toStringAll()
Return a String showing the full namespace binding list.void
writeExternal(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 namenconc
comes 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:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
-