net.sourceforge.webcompmath.data.beans
Class WCMParserBean

java.lang.Object
  extended by net.sourceforge.webcompmath.data.Parser
      extended by net.sourceforge.webcompmath.data.beans.WCMParserBean
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class WCMParserBean
extends Parser
implements java.beans.PropertyChangeListener

This class is for use with GUI builders. It's primary job is to expose the options that Parser encodes in an integer. It provides a set/get pair of methods for each option. Note that you can only add an option to a Parser, so setSomeOption(false) will have no effect. it is provided so that Gui builders will recognize the property and so that designers can change their minds about which options to set for a parser (i.e., if you set an option property to true in a gui builder, and later in the design you decide it should be false, the gui builder will usually generate a method call to set the option false; this will then juse be ignored by the parser, since the option is false by default). The only problem this causes is for the Boolean and Standard Function properties; these are turned on by default in the parser and there is currently no way to turn them off when using a WCMParserBean.

Author:
Tom Downey
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.webcompmath.data.Parser
BOOLEANS, BRACES, BRACKETS, CASE_SENSITIVE, DEFAULT_OPTIONS, FACTORIAL, NO_DIGITS_IN_IDENTIFIERS, NO_UNDERSCORE_IN_IDENTIFIERS, OPTIONAL_FUNCTIONS, OPTIONAL_PARENS, OPTIONAL_SPACES, OPTIONAL_STARS, options, RATIONAL_EXPONENTS, STANDARD_FUNCTIONS, symbols
 
Constructor Summary
WCMParserBean()
          The default constructor
WCMParserBean(int options)
          Constructor with options
WCMParserBean(Parser parent)
          Constructor with parent
WCMParserBean(Parser parent, int options)
          Constructor with parent and options
 
Method Summary
 boolean getBooleans()
          Get the booleans option.
 boolean getBraces()
          Get the braces option
 boolean getBrackets()
          Get the brackets option
 boolean getCaseSensitive()
          Get the case sensitive option
 boolean getFactorial()
          Get the factorial option
 boolean getNoDigitsInIdentifiers()
          Get the no digits in identifiers option
 boolean getNoUnderscoreInIdentifiers()
          Get the no underscore in identifiers option
 boolean getOptionalFunctions()
          Get the optional functions option
 boolean getOptionalParens()
          Get the optional parens option
 boolean getOptionalSpaces()
          Get the optional spaces option
 boolean getOptionalStars()
          Get the optional stars option
 boolean getRationalExponents()
          Get the rational exponents option
 boolean getStandardFunctions()
          Get the standard functions option.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Handle notifications of property changes.
 void setBraces(boolean b)
          An option that can be set for this parser.
 void setBrackets(boolean b)
          An option that can be set for this parser.
 void setCaseSensitive(boolean b)
          An option that can be set for this parser.
 void setFactorial(boolean b)
          An option that can be set for this parser.
 void setMathObject1(ParserMathObject m)
          Add a named object to the parser, usually a WCMVariableBean, WCMExpressionInputBean, WCMExpressionFunctionBean, WCMVariableInputBean, WCMVariableJSliderBean, or WCMConstantBean.
 void setMathObject2(ParserMathObject m)
          add another named object
 void setMathObject3(ParserMathObject m)
          add another named object
 void setMathObject4(ParserMathObject m)
          add another named object
 void setMathObject5(ParserMathObject m)
          add another named object
 void setMathObject6(ParserMathObject m)
          add another named object
 void setMathObject7(ParserMathObject m)
          add another named object
 void setMathObject8(ParserMathObject m)
          add another named object
 void setMathObject9(ParserMathObject m)
          add another named object
 void setNoDigitsInIdentifiers(boolean b)
          An option that can be set for this parser.
 void setNoUnderscoreInIdentifiers(boolean b)
          An option that can be set for this parser.
 void setOptionalFunctions(boolean b)
          An option that can be set for this parser.
 void setOptionalParens(boolean b)
          An option that can be set for this parser.
 void setOptionalSpaces(boolean b)
          An option that can be set for this parser.
 void setOptionalStars(boolean b)
          An that can be set for this parser.
 void setRationalExponents(boolean b)
          An option that can be set for this parser.
 
Methods inherited from class net.sourceforge.webcompmath.data.Parser
add, addOptions, get, getOptions, parse, parseExpression, parseFactor, parseLogical, parseLogicalExpression, parseLogicalFactor, parseLogicalTerm, parsePrimary, parseRelation, parseTerm, remove, setVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WCMParserBean

public WCMParserBean()
The default constructor


WCMParserBean

public WCMParserBean(int options)
Constructor with options

Parameters:
options -

WCMParserBean

public WCMParserBean(Parser parent,
                     int options)
Constructor with parent and options

Parameters:
parent -
options -

WCMParserBean

public WCMParserBean(Parser parent)
Constructor with parent

Parameters:
parent -
Method Detail

setCaseSensitive

public void setCaseSensitive(boolean b)
An option that can be set for this parser. If enabled, identifiers are case-sensitive. For example, Sin, sin, and SIN will be treated as separate identifiers. It really only makes sense to enable this at the time the Parser is first constructed.

Parameters:
b -

getCaseSensitive

public boolean getCaseSensitive()
Get the case sensitive option

Returns:
whether the parser is set for case sensitivity

setOptionalStars

public void setOptionalStars(boolean b)
An that can be set for this parser. If enabled, mutltiplication can be indicated implicitely, as well as with a "*". For example, 2x will mean 2*x.

Parameters:
b -

getOptionalStars

public boolean getOptionalStars()
Get the optional stars option

Returns:
whether the parser is set for optional stars

setOptionalSpaces

public void setOptionalSpaces(boolean b)
An option that can be set for this parser. If enabled, spaces are not required to separate identifiers. This only has an effect if one of OPTIONAL_STARS or OPTIONAL_PARENS is also enabled. For example, xsin(x) will be read as x*sin(x), and sine will be read as sin(e).

Parameters:
b -

getOptionalSpaces

public boolean getOptionalSpaces()
Get the optional spaces option

Returns:
whether the parser is set for optional spaces

setBrackets

public void setBrackets(boolean b)
An option that can be set for this parser. If enabled, brackets, [ and ], can be used for grouping.

Parameters:
b -

getBrackets

public boolean getBrackets()
Get the brackets option

Returns:
whether the parser is set for brackets

setBraces

public void setBraces(boolean b)
An option that can be set for this parser. If enabled, braces, { and }, can be used for grouping.

Parameters:
b -

getBraces

public boolean getBraces()
Get the braces option

Returns:
whether the parser is set for braces

getBooleans

public boolean getBooleans()
Get the booleans option. Note that since there is currently no way to turn this option off (it is on by default in a default parser), there is no setter for this option.

Returns:
whether the parser is set for booleans

setFactorial

public void setFactorial(boolean b)
An option that can be set for this parser. If enabled, the factorial operator, !, is recognized.

Parameters:
b -

getFactorial

public boolean getFactorial()
Get the factorial option

Returns:
whether the parser is set for factorial

setNoUnderscoreInIdentifiers

public void setNoUnderscoreInIdentifiers(boolean b)
An option that can be set for this parser. The character "_", which can usually be used just like a letter, is not allowed in identifers.

Parameters:
b -

getNoUnderscoreInIdentifiers

public boolean getNoUnderscoreInIdentifiers()
Get the no underscore in identifiers option

Returns:
whether the parser is set for no underscore in identifiers

setNoDigitsInIdentifiers

public void setNoDigitsInIdentifiers(boolean b)
An option that can be set for this parser. Digits 0 through 9, which can usually be used in an identifier after the first character, are not allowed in identifiers.

Parameters:
b -

getNoDigitsInIdentifiers

public boolean getNoDigitsInIdentifiers()
Get the no digits in identifiers option

Returns:
whether the parser is set for no digits in identifiers

setOptionalParens

public void setOptionalParens(boolean b)
An option that can be set for this parser. If enabled, parentheses are optional around the parameter of a standard function. If the parentheses are omited, then the argument is the term that follows the function name. For example, "sin x + 1" means "sin(x) + 1" while "sin x * cos x" means "sin( x*cos(x) )".

Parameters:
b -

getOptionalParens

public boolean getOptionalParens()
Get the optional parens option

Returns:
whether the parser is set for optional parens

getStandardFunctions

public boolean getStandardFunctions()
Get the standard functions option. Note that since there is currently no way to turn this option off (it is on by default in a default parser), there is no setter for this option.

Returns:
whether the parser is set for standard functions

setOptionalFunctions

public void setOptionalFunctions(boolean b)
An option that can be set for this parser. When enabled, a set of optional functions are registered with the parser. This option is disabled by default. The optional functions are: sinh, cosh, tanh.

Parameters:
b -

getOptionalFunctions

public boolean getOptionalFunctions()
Get the optional functions option

Returns:
whether the parser is set for optional functions

setRationalExponents

public void setRationalExponents(boolean b)
An option that can be set for this parser. When enabled, the parser will use rpow instead of pow for exponentiation. rpow attempts to determine if the exponent is a rational number. If it is and the denominator of the reduced fraction is odd, then negative bases are allowed (which is not the case with pow). rpow only looks for rational exponents with a denominator up to 1000. This option is disabled by default.

Parameters:
b -

getRationalExponents

public boolean getRationalExponents()
Get the rational exponents option

Returns:
whether the parser is set for rational exponents

setMathObject1

public void setMathObject1(ParserMathObject m)
Add a named object to the parser, usually a WCMVariableBean, WCMExpressionInputBean, WCMExpressionFunctionBean, WCMVariableInputBean, WCMVariableJSliderBean, or WCMConstantBean. If you need to add more than nine objects you will need to do hand coding. It would be nice if Eclipse VE supported indexed properties, or made it easier to support "add" semantics for the parser, sigh...

Parameters:
m - the object to add

setMathObject2

public void setMathObject2(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject3

public void setMathObject3(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject4

public void setMathObject4(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject5

public void setMathObject5(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject6

public void setMathObject6(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject7

public void setMathObject7(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject8

public void setMathObject8(ParserMathObject m)
add another named object

Parameters:
m - the object to add

setMathObject9

public void setMathObject9(ParserMathObject m)
add another named object

Parameters:
m - the object to add

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Handle notifications of property changes.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)