Package org.codehaus.staxmate.out
Class SMLocalNamespace
- java.lang.Object
-
- org.codehaus.staxmate.out.SMNamespace
-
- org.codehaus.staxmate.out.SMLocalNamespace
-
public final class SMLocalNamespace extends SMNamespace
Namespace that is local to a specific output context (SMOutputContext
), think of it as the document or sub-tree StaxMate will output using a stream writer).
-
-
Field Summary
Fields Modifier and Type Field Description protected SMOutputContext
_context
Output context in which this namespace is to be used (scope of which it is bound)protected java.lang.String
_currPrefix
Prefix this namespace is currently bound to, if any.protected boolean
_isPermanent
Flag that indicates whether this binding (with current prefix) is permanent or not; that is, whether prefix associated with the namespace URI can still change or not.protected boolean
_preferDefaultNs
Flag that indicates whether this namespaces prefers to be bound as the default namespace (for elements), or not.protected java.lang.String
_preferredPrefix
Preferred (or suggested) prefix for the namespace; StaxMate will try to use this prefix if possible when binding namespaces and also passes it to the underlying stream writer.protected java.lang.String
_prevPrefix
Last prefix this name was bound to, if any.-
Fields inherited from class org.codehaus.staxmate.out.SMNamespace
_uri
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SMLocalNamespace(SMOutputContext ctxt, java.lang.String uri, boolean preferDefaultNs, java.lang.String prefPrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_bindAs(java.lang.String prefix)
The only trick with regard to binding/unbinding of local namespaces is that "re-binding" is not allowed (by StaxMate design; XML would allow it).protected void
_bindPermanentlyAs(java.lang.String prefix)
Method used to permanently bind this (local) namespace to a prefix.protected void
_unbind()
Method called to indicate that the namespace is no longer bound to its current prefix within the current output context.java.lang.String
getBoundPrefix()
java.lang.String
getLastBoundPrefix()
java.lang.String
getPreferredPrefix()
protected boolean
isValidIn(SMOutputContext ctxt)
Method used to verify that the namespace is actually valid within the specified output context.boolean
prefersDefaultNs()
void
prefersDefaultNs(boolean state)
void
setPreferredPrefix(java.lang.String prefPrefix)
Method that can be called to associate a "preferred" prefix; prefix that this namespace should be bound to instead of some automatically generated one (unless that prefix is already bound to another URI).-
Methods inherited from class org.codehaus.staxmate.out.SMNamespace
getURI, isBoundToPrefix
-
-
-
-
Field Detail
-
_context
protected final SMOutputContext _context
Output context in which this namespace is to be used (scope of which it is bound)
-
_preferredPrefix
protected java.lang.String _preferredPrefix
Preferred (or suggested) prefix for the namespace; StaxMate will try to use this prefix if possible when binding namespaces and also passes it to the underlying stream writer.This value will be automatically set when namespace is created, and there is also a way to explicitly set it. Finally, it will also be set if a dynamic prefix is created for the namespace
-
_currPrefix
protected java.lang.String _currPrefix
Prefix this namespace is currently bound to, if any.
-
_prevPrefix
protected java.lang.String _prevPrefix
Last prefix this name was bound to, if any.
-
_preferDefaultNs
protected boolean _preferDefaultNs
Flag that indicates whether this namespaces prefers to be bound as the default namespace (for elements), or not. Output context will use this preference in some situations to determine how to best bind this namespace to a prefix or as the default namespace.
-
_isPermanent
protected boolean _isPermanent
Flag that indicates whether this binding (with current prefix) is permanent or not; that is, whether prefix associated with the namespace URI can still change or not.
-
-
Constructor Detail
-
SMLocalNamespace
protected SMLocalNamespace(SMOutputContext ctxt, java.lang.String uri, boolean preferDefaultNs, java.lang.String prefPrefix)
- Parameters:
ctxt
- Output context that "owns" this namespace (within which namespace will be bound when output)uri
- URI that defines identity of the namespaceprefPrefix
- Prefererred (or suggested) prefix for the namespace; StaxMate will try to use this prefix if possible when binding namespaces and also passes it to the underlying stream writer.preferDefaultNs
- Whether this namespaces prefers to be bound as the default namespace when used for elements.
-
-
Method Detail
-
getPreferredPrefix
public java.lang.String getPreferredPrefix()
- Specified by:
getPreferredPrefix
in classSMNamespace
- Returns:
- Prefix that the caller application has at some point indicated to be a prefix it'd like to see; StaxMate may try to use it as the prefix to bind if there are no
-
getBoundPrefix
public java.lang.String getBoundPrefix()
- Specified by:
getBoundPrefix
in classSMNamespace
-
getLastBoundPrefix
public java.lang.String getLastBoundPrefix()
- Specified by:
getLastBoundPrefix
in classSMNamespace
-
prefersDefaultNs
public boolean prefersDefaultNs()
- Specified by:
prefersDefaultNs
in classSMNamespace
-
prefersDefaultNs
public void prefersDefaultNs(boolean state)
- Specified by:
prefersDefaultNs
in classSMNamespace
-
setPreferredPrefix
public void setPreferredPrefix(java.lang.String prefPrefix)
Description copied from class:SMNamespace
Method that can be called to associate a "preferred" prefix; prefix that this namespace should be bound to instead of some automatically generated one (unless that prefix is already bound to another URI).- Specified by:
setPreferredPrefix
in classSMNamespace
-
isValidIn
protected boolean isValidIn(SMOutputContext ctxt)
Description copied from class:SMNamespace
Method used to verify that the namespace is actually valid within the specified output context.- Specified by:
isValidIn
in classSMNamespace
-
_bindAs
protected void _bindAs(java.lang.String prefix)
The only trick with regard to binding/unbinding of local namespaces is that "re-binding" is not allowed (by StaxMate design; XML would allow it). So let's allow transitions to and from null, but not between two non-empty prefixes.- Specified by:
_bindAs
in classSMNamespace
-
_bindPermanentlyAs
protected void _bindPermanentlyAs(java.lang.String prefix)
Description copied from class:SMNamespace
Method used to permanently bind this (local) namespace to a prefix. Generally called if a new "global" binding is found at point where a global instance can not be created. Calling this method will essentially mark a local instace as behaving similar to a global one.- Specified by:
_bindPermanentlyAs
in classSMNamespace
-
_unbind
protected void _unbind()
Description copied from class:SMNamespace
Method called to indicate that the namespace is no longer bound to its current prefix within the current output context. Since default namespace declarations do not cause binding, this method will not be called for default namespaces either.- Specified by:
_unbind
in classSMNamespace
-
-