org.overlord.sramp.common.query.xpath
Class TokenStream

java.lang.Object
  extended by org.overlord.sramp.common.query.xpath.TokenStream

public class TokenStream
extends Object

A stream of tokens produced by the tokenizer.

Author:
eric.wittmann@redhat.com

Constructor Summary
TokenStream()
          Constructor.
 
Method Summary
 void addToken(String value, TokenType type)
          Adds a token to the stream.
 TokenStream build()
          Builds the stream for consumption.
 boolean canConsume(String tokenValue)
          Attempts to consume a token that matches any of the given token values.
 boolean canConsume(String tokenValue1, String tokenValue2)
          Attempts to consume the next two tokens, but only if they match the given token values.
 boolean canConsumeAnyOf(String... tokenValues)
          Attempts to consume a token that matches any of the given token values.
 Token consume()
          Consume the next token in the stream, and return what it was.
 boolean hasNext()
          Returns true if there are more tokens in the stream.
 boolean matches(String tokenValue)
          Returns true if the next token in the stream matches any of the given token values.
 boolean matches(TokenType tokenType)
          Returns true if the next token in the stream matches any of the given types.
 boolean matchesAnyOf(String... tokenValues)
          Returns true if the next token in the stream matches any of the given token values.
 boolean matchesAnyOf(TokenType... tokenTypes)
          Returns true if the next token in the stream matches any of the given types.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TokenStream

public TokenStream()
Constructor.

Method Detail

addToken

public void addToken(String value,
                     TokenType type)
Adds a token to the stream.

Parameters:
value -
type -

build

public TokenStream build()
Builds the stream for consumption.


hasNext

public boolean hasNext()
Returns true if there are more tokens in the stream.


canConsume

public boolean canConsume(String tokenValue)
Attempts to consume a token that matches any of the given token values. Returns true if the token was able to be consumed.

Parameters:
tokenValue -

canConsume

public boolean canConsume(String tokenValue1,
                          String tokenValue2)
Attempts to consume the next two tokens, but only if they match the given token values. Returns true only if both tokens matched and were consumed.

Parameters:
tokenValue1 -
tokenValue2 -

canConsumeAnyOf

public boolean canConsumeAnyOf(String... tokenValues)
Attempts to consume a token that matches any of the given token values. Returns true if the token was able to be consumed.

Parameters:
tokenValues -

matches

public boolean matches(TokenType tokenType)
Returns true if the next token in the stream matches any of the given types.

Parameters:
tokenType -

matchesAnyOf

public boolean matchesAnyOf(TokenType... tokenTypes)
Returns true if the next token in the stream matches any of the given types.

Parameters:
tokenTypes -

matches

public boolean matches(String tokenValue)
Returns true if the next token in the stream matches any of the given token values.

Parameters:
tokenValue -

matchesAnyOf

public boolean matchesAnyOf(String... tokenValues)
Returns true if the next token in the stream matches any of the given token values.

Parameters:
tokenValues -

consume

public Token consume()
Consume the next token in the stream, and return what it was.


toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2011-2013 JBoss, a division of Red Hat. All Rights Reserved.