org.idoox.xml
Class TokenizerWrapper.DefaultTokenizerState

java.lang.Object
  extended byorg.idoox.xml.TokenizerWrapper.DefaultTokenizerState
All Implemented Interfaces:
TokenizerWrapper.TokenizerState
Enclosing class:
TokenizerWrapper

public static class TokenizerWrapper.DefaultTokenizerState
extends java.lang.Object
implements TokenizerWrapper.TokenizerState

This is default implementation of internal tokenizers state. You can manipulate internal state of TokenzierWrapper with TokenizerWrapper.getCurrentState() and TokenizerWrapper.setCurrentState(org.idoox.xml.TokenizerWrapper.TokenizerState) methods.

Since:
4.6
See Also:
TokenizerState

Constructor Summary
TokenizerWrapper.DefaultTokenizerState()
          Constructs empty tokenizer state.
TokenizerWrapper.DefaultTokenizerState(java.lang.String content)
          Constructs tokenizer state with specified content.
TokenizerWrapper.DefaultTokenizerState(Token currentToken)
          Constructs tokenizer state with specified token.
TokenizerWrapper.DefaultTokenizerState(Token currentToken, java.util.Map newNamespaceDeclarations)
          Constructs tokenizer state with specified token and new namespace declarations.
TokenizerWrapper.DefaultTokenizerState(Token currentToken, java.util.Map namespaceDeclarations, java.lang.String[] newPrefixes)
          Constructs tokenizer state with specified token and namespace declarations.
 
Method Summary
 java.lang.String getContent()
          Returns content which is used by TokenizerWrapper to implement Tokenizer.readContent().
Note that this function is used only if type of token returned by getToken() is Tokenizer.CONTENT.
 java.util.Map getNamespaceDeclarations()
          Returns map of namespace prefixes (mapping from prefixes to namespace URIs).
 java.util.Map getNewNamespaceDeclarations()
          Returns map of newly declared namespace prefixes (complete mapping is defined by prefix map of underlying tokenizer and this map).
 java.lang.String[] getNewPrefixes()
          Returns array of newly declared prefixes.
 Token getToken()
          Returns token which will be used by TokenizerWrapper to implement functions of Tokenizer (e.g.
 void setContent(java.lang.String content)
           
 void setNamespaceDeclarations(java.util.Map namespaceDeclarations)
           
 void setNewPrefixes(java.lang.String[] newPrefixes)
           
 void setToken(Token currentToken)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenizerWrapper.DefaultTokenizerState

public TokenizerWrapper.DefaultTokenizerState()
Constructs empty tokenizer state.


TokenizerWrapper.DefaultTokenizerState

public TokenizerWrapper.DefaultTokenizerState(Token currentToken)
Constructs tokenizer state with specified token. This function can be used to override Tokenizer.START_TOKEN and Tokenizer.END_TOKEN of the underlying tokenizer. Namespaces are not affected (namespace declarations are used from underlying tokenizer). This function is useful if user wants to change name or namespace of some element.

Parameters:
currentToken - token which overrides token returned by underlying tokenzier

TokenizerWrapper.DefaultTokenizerState

public TokenizerWrapper.DefaultTokenizerState(java.lang.String content)
Constructs tokenizer state with specified content. This function can be used to override Tokenizer.CONTENT token of the underlying tokenizer. This function is useful if user wants to change content of some element.

Parameters:
content - content which overrides token returned by underlying tokenzier

TokenizerWrapper.DefaultTokenizerState

public TokenizerWrapper.DefaultTokenizerState(Token currentToken,
                                              java.util.Map newNamespaceDeclarations)
Constructs tokenizer state with specified token and new namespace declarations. This function can be used to override Tokenizer.START_TOKEN and Tokenizer.END_TOKEN of the underlying tokenizer and add declarations of namespaces. Namespaces declared by underlying tokenizer are updated with new namespace declarations specified. This function is useful if user wants to change name or namespace of some element and add declarations of namespaces.

Parameters:
currentToken - token which overrides token returned by underlying tokenzier
newNamespaceDeclarations - new namespace declarations

TokenizerWrapper.DefaultTokenizerState

public TokenizerWrapper.DefaultTokenizerState(Token currentToken,
                                              java.util.Map namespaceDeclarations,
                                              java.lang.String[] newPrefixes)
Constructs tokenizer state with specified token and namespace declarations. This function can be used to override Tokenizer.START_TOKEN and Tokenizer.END_TOKEN of the underlying tokenizer and override declarations of namespaces. Namespaces declared by underlying tokenizer are overrided with namespace declarations specified. This function is useful if user wants to change name or namespace of some element and override declarations of namespaces.

Parameters:
currentToken - token which overrides token returned by underlying tokenzier
namespaceDeclarations - new namespace declarations
newPrefixes - array of newly defined prefixes (that were not defined on the Tokenizer.START_TOKEN of parent element)
Method Detail

getToken

public Token getToken()
Description copied from interface: TokenizerWrapper.TokenizerState
Returns token which will be used by TokenizerWrapper to implement functions of Tokenizer (e.g. Tokenizer.readToken(org.idoox.xml.Token), Tokenizer.getLocalName(), ...).

Specified by:
getToken in interface TokenizerWrapper.TokenizerState
Returns:
token

setToken

public void setToken(Token currentToken)

getContent

public java.lang.String getContent()
Description copied from interface: TokenizerWrapper.TokenizerState
Returns content which is used by TokenizerWrapper to implement Tokenizer.readContent().
Note that this function is used only if type of token returned by TokenizerWrapper.TokenizerState.getToken() is Tokenizer.CONTENT.

Specified by:
getContent in interface TokenizerWrapper.TokenizerState
Returns:
content of "content token"

setContent

public void setContent(java.lang.String content)

getNamespaceDeclarations

public java.util.Map getNamespaceDeclarations()
Description copied from interface: TokenizerWrapper.TokenizerState
Returns map of namespace prefixes (mapping from prefixes to namespace URIs). If this function returns non-null it will overide mapping declared by underlying tokenizer and also TokenizerWrapper.TokenizerState.getNewPrefixes() must be defined.

Specified by:
getNamespaceDeclarations in interface TokenizerWrapper.TokenizerState
Returns:
map of namespace prefixes (mapping from prefixes to namespace URIs)

getNewNamespaceDeclarations

public java.util.Map getNewNamespaceDeclarations()
Description copied from interface: TokenizerWrapper.TokenizerState
Returns map of newly declared namespace prefixes (complete mapping is defined by prefix map of underlying tokenizer and this map). If this function returns non-null it TokenizerWrapper.TokenizerState.getNewPrefixes() function won't be used.

Specified by:
getNewNamespaceDeclarations in interface TokenizerWrapper.TokenizerState
Returns:
map of newly declared namespace prefixes

setNamespaceDeclarations

public void setNamespaceDeclarations(java.util.Map namespaceDeclarations)

getNewPrefixes

public java.lang.String[] getNewPrefixes()
Description copied from interface: TokenizerWrapper.TokenizerState
Returns array of newly declared prefixes. If this TokenizerWrapper.TokenizerState.getNamespaceDeclarations() returns non-null this function must return array of prefixes which are newly declared (were not declared on the start token of the parent element).

Specified by:
getNewPrefixes in interface TokenizerWrapper.TokenizerState
Returns:
array of newly declared prefixes

setNewPrefixes

public void setNewPrefixes(java.lang.String[] newPrefixes)