org.ujac.util.template
Class BaseConditionToken

java.lang.Object
  extended by org.ujac.util.template.TemplateToken
      extended by org.ujac.util.template.TemplateTokenContainer
          extended by org.ujac.util.template.BaseConditionToken
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ElseifToken, ElseToken, IfToken

public abstract class BaseConditionToken
extends TemplateTokenContainer

Name: BaseConditionToken
Description: A base class for condition tokens.

Author:
lauerc
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.ujac.util.template.TemplateTokenContainer
procedureRegistry
 
Fields inherited from class org.ujac.util.template.TemplateToken
interpreter, nextLegalAncestor, parent, position, source
 
Constructor Summary
BaseConditionToken()
          Constructs a BaseConditionToken instance with no specific attributes.
 
Method Summary
 void execute(Writer writer, TemplateContext ctx)
          Excecutes the statement token.
protected  BaseConditionToken getPreviousCondition()
          Gets the previous condition token in the parent's child list.
abstract  BaseConditionToken getRootCondition()
          Gets the root condition.
 boolean isResolved()
          Tells whether or not the condition bas been resolved so far.
abstract  boolean isTrue(TemplateContext ctx)
          Tells whether or not the condition is true.
 int parseArguments()
          Parses the arguments of the token.
 void setResolved(boolean resolved)
          Tells whether or not the condition bas been resolved so far.
 
Methods inherited from class org.ujac.util.template.TemplateTokenContainer
addToken, clearTokens, cloneChildTokens, close, getBodyEnd, getBodyStart, getProcedureRegistry, getToken, getTokenCount, isBodyToken, isClosed, setBodyStart, setProcedureRegistry, toString
 
Methods inherited from class org.ujac.util.template.TemplateToken
checkContainer, cloneToken, getAncestorRules, getArgumentsAsString, getEndPosition, getIndention, getLength, getLevel, getParent, getPosition, getSource, getTokenName, initialize, isLegalAncestor, isLegalAncestor, parseArguments, setArgument, setLength, setLevel, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseConditionToken

public BaseConditionToken()
Constructs a BaseConditionToken instance with no specific attributes.

Method Detail

parseArguments

public int parseArguments()
                   throws StatementException
Parses the arguments of the token.

Overrides:
parseArguments in class TemplateToken
Returns:
The position after the argument list.
Throws:
StatementException - In case the argument parsing failed.

execute

public void execute(Writer writer,
                    TemplateContext ctx)
             throws TemplateException,
                    IOException
Excecutes the statement token.

Specified by:
execute in class TemplateToken
Parameters:
writer - The writer to write to.
ctx - The template context.
Throws:
TemplateException - If the token could not be successfuly executed.
IOException - In case an output failure occurred.

isTrue

public abstract boolean isTrue(TemplateContext ctx)
                        throws ExpressionException
Tells whether or not the condition is true.

Parameters:
ctx - The template context.
Returns:
true or false.
Throws:
ExpressionException - If the token could not be successfuly executed.

isResolved

public boolean isResolved()
Tells whether or not the condition bas been resolved so far.

Returns:
true or false.

setResolved

public void setResolved(boolean resolved)
Tells whether or not the condition bas been resolved so far.

Parameters:
resolved - The value to seet.

getPreviousCondition

protected BaseConditionToken getPreviousCondition()
                                           throws StatementException
Gets the previous condition token in the parent's child list.

Returns:
The condition token.
Throws:
StatementException - In case the latest token was no condition token.

getRootCondition

public abstract BaseConditionToken getRootCondition()
Gets the root condition.

Returns:
The root condition of the current condition.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.