org.jboss.dna.common.text
Class TokenStream.CharacterArrayStream

java.lang.Object
  extended by org.jboss.dna.common.text.TokenStream.CharacterArrayStream
All Implemented Interfaces:
TokenStream.CharacterStream
Enclosing class:
TokenStream

public static final class TokenStream.CharacterArrayStream
extends Object
implements TokenStream.CharacterStream

An implementation of TokenStream.CharacterStream that works with a single character array.


Constructor Summary
TokenStream.CharacterArrayStream(char[] content)
           
 
Method Summary
 boolean hasNext()
          Determine if there is another character available in this stream.
 int index()
          Get the index for the last character returned from TokenStream.CharacterStream.next().
 boolean isNext(char c)
          Determine if the next character on the sream is the supplied value.
 boolean isNext(char nextChar1, char nextChar2)
          Determine if the next two characters on the stream match the supplied values.
 boolean isNext(char nextChar1, char nextChar2, char nextChar3)
          Determine if the next three characters on the sream match the supplied values.
 boolean isNextAnyOf(char[] characters)
          Determine if the next character on the stream matches one of the supplied characters.
 boolean isNextAnyOf(String characters)
          Determine if the next character on the stream matches one of the supplied characters.
 boolean isNextLetterOrDigit()
          Determine if the next character on the sream is a letter or digit.
 boolean isNextValidXmlCharacter()
          Determine if the next character on the sream is a valid XML character.
 boolean isNextValidXmlNameCharacter()
          Determine if the next character on the sream is a valid XML NCName character.
 boolean isNextValidXmlNcNameCharacter()
          Determine if the next character on the sream is a valid XML NCName character.
 boolean isNextWhitespace()
          Determine if the next character on the sream is a whitespace character.
 char next()
          Obtain the next character value, and advance the stream.
 Position position(int startIndex)
          Get the position for the last character returned from TokenStream.CharacterStream.next().
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenStream.CharacterArrayStream

public TokenStream.CharacterArrayStream(char[] content)
Method Detail

hasNext

public boolean hasNext()
Determine if there is another character available in this stream.

Specified by:
hasNext in interface TokenStream.CharacterStream
Returns:
true if there is another character (and TokenStream.CharacterStream.next() can be called), or false otherwise
See Also:
TokenStream.CharacterStream.hasNext()

index

public int index()
Get the index for the last character returned from TokenStream.CharacterStream.next().

Specified by:
index in interface TokenStream.CharacterStream
Returns:
the index of the last character returned
See Also:
TokenStream.CharacterStream.index()

position

public Position position(int startIndex)
Get the position for the last character returned from TokenStream.CharacterStream.next().

Specified by:
position in interface TokenStream.CharacterStream
Parameters:
startIndex -
Returns:
the position of the token. never null
See Also:
TokenStream.CharacterStream.position(int)

next

public char next()
Obtain the next character value, and advance the stream.

Specified by:
next in interface TokenStream.CharacterStream
Returns:
the next character
See Also:
TokenStream.CharacterStream.next()

isNext

public boolean isNext(char c)
Determine if the next character on the sream is the supplied value. This method does not advance the stream.

Specified by:
isNext in interface TokenStream.CharacterStream
Parameters:
c - the character value to compare to the next character on the stream
Returns:
true if there is a next character and it is the supplied character, or false otherwise
See Also:
TokenStream.CharacterStream.isNext(char)

isNext

public boolean isNext(char nextChar1,
                      char nextChar2)
Determine if the next two characters on the stream match the supplied values. This method does not advance the stream.

Specified by:
isNext in interface TokenStream.CharacterStream
Parameters:
nextChar1 - the character value to compare to the next character on the stream
nextChar2 - the character value to compare to the character immediately after the next character on the stream
Returns:
true if there are at least two characters left on the stream and the first matches nextChar and the second matches followingChar
See Also:
TokenStream.CharacterStream.isNext(char, char)

isNext

public boolean isNext(char nextChar1,
                      char nextChar2,
                      char nextChar3)
Determine if the next three characters on the sream match the supplied values. This method does not advance the stream.

Specified by:
isNext in interface TokenStream.CharacterStream
Parameters:
nextChar1 - the character value to compare to the next character on the stream
nextChar2 - the character value to compare to the second character on the stream
nextChar3 - the character value to compare to the second character on the stream
Returns:
true if there are at least two characters left on the stream and the first matches nextChar and the second matches followingChar
See Also:
TokenStream.CharacterStream.isNext(char, char, char)

isNextAnyOf

public boolean isNextAnyOf(char[] characters)
Determine if the next character on the stream matches one of the supplied characters. This method does not advance the stream.

Specified by:
isNextAnyOf in interface TokenStream.CharacterStream
Parameters:
characters - the characters to match
Returns:
true if there is a next character and it does match one of the supplied characters, or false otherwise
See Also:
TokenStream.CharacterStream.isNextAnyOf(char[])

isNextAnyOf

public boolean isNextAnyOf(String characters)
Determine if the next character on the stream matches one of the supplied characters. This method does not advance the stream.

Specified by:
isNextAnyOf in interface TokenStream.CharacterStream
Parameters:
characters - the characters to match
Returns:
true if there is a next character and it does match one of the supplied characters, or false otherwise
See Also:
TokenStream.CharacterStream.isNextAnyOf(java.lang.String)

isNextWhitespace

public boolean isNextWhitespace()
Determine if the next character on the sream is a whitespace character. This method does not advance the stream.

Specified by:
isNextWhitespace in interface TokenStream.CharacterStream
Returns:
true if there is a next character and it is a whitespace character, or false otherwise
See Also:
TokenStream.CharacterStream.isNextWhitespace()

isNextLetterOrDigit

public boolean isNextLetterOrDigit()
Determine if the next character on the sream is a letter or digit. This method does not advance the stream.

Specified by:
isNextLetterOrDigit in interface TokenStream.CharacterStream
Returns:
true if there is a next character and it is a letter or digit, or false otherwise
See Also:
TokenStream.CharacterStream.isNextLetterOrDigit()

isNextValidXmlCharacter

public boolean isNextValidXmlCharacter()
Determine if the next character on the sream is a valid XML character. This method does not advance the stream.

Specified by:
isNextValidXmlCharacter in interface TokenStream.CharacterStream
Returns:
true if there is a next character and it is a valid XML character, or false otherwise
See Also:
TokenStream.CharacterStream.isNextValidXmlCharacter()

isNextValidXmlNameCharacter

public boolean isNextValidXmlNameCharacter()
Determine if the next character on the sream is a valid XML NCName character. This method does not advance the stream.

Specified by:
isNextValidXmlNameCharacter in interface TokenStream.CharacterStream
Returns:
true if there is a next character and it is a valid XML Name character, or false otherwise
See Also:
TokenStream.CharacterStream.isNextValidXmlNameCharacter()

isNextValidXmlNcNameCharacter

public boolean isNextValidXmlNcNameCharacter()
Determine if the next character on the sream is a valid XML NCName character. This method does not advance the stream.

Specified by:
isNextValidXmlNcNameCharacter in interface TokenStream.CharacterStream
Returns:
true if there is a next character and it is a valid XML NCName character, or false otherwise
See Also:
TokenStream.CharacterStream.isNextValidXmlNcNameCharacter()


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.