info.bliki.wiki.template.expr.operator
Class ASTNodeFactory

java.lang.Object
  extended by info.bliki.wiki.template.expr.operator.ASTNodeFactory
All Implemented Interfaces:
IParserFactory

public class ASTNodeFactory
extends java.lang.Object
implements IParserFactory


Field Summary
static java.lang.String[] HEADER_STRINGS
           
static ASTNodeFactory MMA_STYLE_FACTORY
           
static java.lang.String[] OPERATOR_STRINGS
           
static Operator[] OPERATORS
           
static int PLUS_PRECEDENCE
           
static int TIMES_PRECEDENCE
           
 
Fields inherited from interface info.bliki.wiki.template.expr.ast.IParserFactory
DEFAULT_OPERATOR_CHARACTERS
 
Constructor Summary
ASTNodeFactory()
          Create a default ASTNode factory
 
Method Summary
static void addOperator(java.util.HashMap<java.lang.String,Operator> operatorMap, java.util.HashMap<java.lang.String,java.util.ArrayList<Operator>> operatorTokenStartSet, java.lang.String operatorStr, java.lang.String headStr, Operator oper)
           
 FunctionNode createAST(ASTNode headExpr)
          Creates a new list with no arguments from the given header object .
 ASTNode createDouble(java.lang.String doubleString)
          Create an double node from the given double value string
 FractionNode createFraction(IntegerNode numerator, IntegerNode denominator)
          Create a "fractional" number
 FunctionNode createFunction(SymbolNode head)
          Creates a new function with head head and 0 arguments.
 FunctionNode createFunction(SymbolNode head, ASTNode arg0)
          Creates a new function with head head and 1 argument.
 FunctionNode createFunction(SymbolNode head, ASTNode arg0, ASTNode arg1)
          Creates a new function with head head and 2 arguments.
static InfixOperator createInfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence, int grouping)
           
 IntegerNode createInteger(int intValue)
          Create an integer node from the given value
 IntegerNode createInteger(java.lang.String integerString, int numberFormat)
          Create an integer node from the given string
static PostfixOperator createPostfixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
           
static PrefixOperator createPrefixOperator(java.lang.String operatorStr, java.lang.String headStr, int precedence)
           
 StringNode createString(java.lang.StringBuffer buffer)
          Create a string node from the scanned double quoted string
 SymbolNode createSymbol(java.lang.String symbolName)
          Create a symbol from the scanned identifier string
 Operator get(java.lang.String identifier)
          Get the operator for a given identifier string like Times, Plus, Sin,...
 java.lang.String getConstantSymbol(java.lang.String key)
           
 java.util.Map<java.lang.String,Operator> getIdentifier2OperatorMap()
          public Map getIdentifier2OperatorMap()
 java.util.Map<java.lang.String,java.util.ArrayList<Operator>> getOperator2ListMap()
          public Map> getOperator2ListMap()
 java.lang.String getOperatorCharacters()
          The set of characters, which could form an operator
 java.util.List<Operator> getOperatorList(java.lang.String key)
          public List getOperatorList(final String key)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUS_PRECEDENCE

public static final int PLUS_PRECEDENCE
See Also:
Constant Field Values

TIMES_PRECEDENCE

public static final int TIMES_PRECEDENCE
See Also:
Constant Field Values

HEADER_STRINGS

public static final java.lang.String[] HEADER_STRINGS

OPERATOR_STRINGS

public static final java.lang.String[] OPERATOR_STRINGS

OPERATORS

public static final Operator[] OPERATORS

MMA_STYLE_FACTORY

public static final ASTNodeFactory MMA_STYLE_FACTORY
Constructor Detail

ASTNodeFactory

public ASTNodeFactory()
Create a default ASTNode factory

Method Detail

addOperator

public static void addOperator(java.util.HashMap<java.lang.String,Operator> operatorMap,
                               java.util.HashMap<java.lang.String,java.util.ArrayList<Operator>> operatorTokenStartSet,
                               java.lang.String operatorStr,
                               java.lang.String headStr,
                               Operator oper)

getOperatorCharacters

public java.lang.String getOperatorCharacters()
Description copied from interface: IParserFactory
The set of characters, which could form an operator

Specified by:
getOperatorCharacters in interface IParserFactory

getIdentifier2OperatorMap

public java.util.Map<java.lang.String,Operator> getIdentifier2OperatorMap()
public Map getIdentifier2OperatorMap()

Specified by:
getIdentifier2OperatorMap in interface IParserFactory
Returns:
the map which stores the Operators for a given head string like Times, Plus, Sin,...

get

public Operator get(java.lang.String identifier)
Description copied from interface: IParserFactory
Get the operator for a given identifier string like Times, Plus, Sin,...

Specified by:
get in interface IParserFactory
Returns:

getOperator2ListMap

public java.util.Map<java.lang.String,java.util.ArrayList<Operator>> getOperator2ListMap()
public Map> getOperator2ListMap()

Specified by:
getOperator2ListMap in interface IParserFactory
Returns:
the map which stores the operator-list for a given operator string like *, +, ==...

getOperatorList

public java.util.List<Operator> getOperatorList(java.lang.String key)
public List getOperatorList(final String key)

Specified by:
getOperatorList in interface IParserFactory
Returns:
the operator-list for a given operator string like *, +, ==...

getConstantSymbol

public java.lang.String getConstantSymbol(java.lang.String key)
Specified by:
getConstantSymbol in interface IParserFactory

createInfixOperator

public static InfixOperator createInfixOperator(java.lang.String operatorStr,
                                                java.lang.String headStr,
                                                int precedence,
                                                int grouping)

createPrefixOperator

public static PrefixOperator createPrefixOperator(java.lang.String operatorStr,
                                                  java.lang.String headStr,
                                                  int precedence)

createPostfixOperator

public static PostfixOperator createPostfixOperator(java.lang.String operatorStr,
                                                    java.lang.String headStr,
                                                    int precedence)

createDouble

public ASTNode createDouble(java.lang.String doubleString)
Description copied from interface: IParserFactory
Create an double node from the given double value string

Specified by:
createDouble in interface IParserFactory
Returns:

createFunction

public FunctionNode createFunction(SymbolNode head)
Description copied from interface: IParserFactory
Creates a new function with head head and 0 arguments.

Specified by:
createFunction in interface IParserFactory

createFunction

public FunctionNode createFunction(SymbolNode head,
                                   ASTNode arg0)
Description copied from interface: IParserFactory
Creates a new function with head head and 1 argument.

Specified by:
createFunction in interface IParserFactory

createFunction

public FunctionNode createFunction(SymbolNode head,
                                   ASTNode arg0,
                                   ASTNode arg1)
Description copied from interface: IParserFactory
Creates a new function with head head and 2 arguments.

Specified by:
createFunction in interface IParserFactory

createAST

public FunctionNode createAST(ASTNode headExpr)
Creates a new list with no arguments from the given header object .

Specified by:
createAST in interface IParserFactory

createInteger

public IntegerNode createInteger(java.lang.String integerString,
                                 int numberFormat)
Description copied from interface: IParserFactory
Create an integer node from the given string

Specified by:
createInteger in interface IParserFactory
Parameters:
integerString - the integer number represented as a String
numberFormat - the format of the number (usually 10)
Returns:
IInteger

createInteger

public IntegerNode createInteger(int intValue)
Description copied from interface: IParserFactory
Create an integer node from the given value

Specified by:
createInteger in interface IParserFactory
Parameters:
intValue - the integer number's value
Returns:
IInteger

createFraction

public FractionNode createFraction(IntegerNode numerator,
                                   IntegerNode denominator)
Description copied from interface: IParserFactory
Create a "fractional" number

Specified by:
createFraction in interface IParserFactory
Parameters:
numerator - numerator of the fractional number
denominator - denominator of the fractional number
Returns:
IFraction

createString

public StringNode createString(java.lang.StringBuffer buffer)
Description copied from interface: IParserFactory
Create a string node from the scanned double quoted string

Specified by:
createString in interface IParserFactory
Returns:

createSymbol

public SymbolNode createSymbol(java.lang.String symbolName)
Description copied from interface: IParserFactory
Create a symbol from the scanned identifier string

Specified by:
createSymbol in interface IParserFactory
Returns:


Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.