org.jibx.schema.codegen
Class SwitchBuilder

java.lang.Object
  extended by org.jibx.schema.codegen.ASTBuilderBase
      extended by org.jibx.schema.codegen.StatementBuilderBase
          extended by org.jibx.schema.codegen.SwitchBuilder

public class SwitchBuilder
extends StatementBuilderBase

Switch statement builder. This wraps the AST switch representation with convenience methods and added control information.

Author:
Dennis M. Sosnoski

Field Summary
private  SwitchStatement m_switch
          Method invocation.
 
Fields inherited from class org.jibx.schema.codegen.StatementBuilderBase
m_source
 
Fields inherited from class org.jibx.schema.codegen.ASTBuilderBase
m_ast
 
Constructor Summary
SwitchBuilder(ClassBuilder source, Expression expr)
          Constructor.
 
Method Summary
 void addDefault(StatementBuilderBase stmt)
          Add default case to switch statement.
 void addNamedCase(java.lang.String name, StatementBuilderBase stmt)
          Add case to switch statement with a named constant as the match value.
 void addNumberCase(java.lang.String value, StatementBuilderBase stmt)
          Add case to switch statement with a number as the match value.
(package private)  Statement getStatement()
          Get the statement.
private static boolean isBreakNeeded(Statement stmt)
          Check if a break statement is needed following the statement for a particular case.
private  BlockBuilder newCaseBlock(Expression expr)
          Add case to switch statement with new block for case code.
 BlockBuilder newNamedCase(java.lang.String name)
          Add case to switch statement with returned block for code.
 BlockBuilder newNumberCase(java.lang.String value)
          Add case to switch statement with returned block for code.
 
Methods inherited from class org.jibx.schema.codegen.ASTBuilderBase
numberLiteral, setFinal, setPrivate, setPrivateFinal, setPrivateStaticFinal, setPublic, setPublicStatic, setPublicStaticFinal, setStatic, stringLiteral
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_switch

private final SwitchStatement m_switch
Method invocation.

Constructor Detail

SwitchBuilder

public SwitchBuilder(ClassBuilder source,
                     Expression expr)
Constructor.

Parameters:
source -
expr - expression
Method Detail

getStatement

Statement getStatement()
Get the statement.

Specified by:
getStatement in class StatementBuilderBase
Returns:
statement

isBreakNeeded

private static boolean isBreakNeeded(Statement stmt)
Check if a break statement is needed following the statement for a particular case.

Parameters:
stmt -
Returns:
true if break needed, false if not

addNamedCase

public void addNamedCase(java.lang.String name,
                         StatementBuilderBase stmt)
Add case to switch statement with a named constant as the match value.

Parameters:
name - named constant
stmt - statement to be executed

addNumberCase

public void addNumberCase(java.lang.String value,
                          StatementBuilderBase stmt)
Add case to switch statement with a number as the match value.

Parameters:
value - match value
stmt - statement to be executed

addDefault

public void addDefault(StatementBuilderBase stmt)
Add default case to switch statement.

Parameters:
stmt - statement to be executed

newCaseBlock

private BlockBuilder newCaseBlock(Expression expr)
Add case to switch statement with new block for case code.

Parameters:
expr -
Returns:
block

newNamedCase

public BlockBuilder newNamedCase(java.lang.String name)
Add case to switch statement with returned block for code.

Parameters:
name - named constant
Returns:
block

newNumberCase

public BlockBuilder newNumberCase(java.lang.String value)
Add case to switch statement with returned block for code.

Parameters:
value - match value
Returns:
block


Project Web Site