Package edu.hws.jcm.functions

# Class SummationParser

java.lang.Object
edu.hws.jcm.functions.SummationParser

All Implemented Interfaces:
  `MathObject`, `ParserExtension`, `Serializable`

public class SummationParser extends Object implements ParserExtension
The SummationParser class makes it possible to use summations such as sum(i,1,5,x^i) in a Parser. The summation psedu-function has four parameters: (1) The summation variable, which must be an identifier; (2) The lower limit for the summation, given as an expression; (3) The upper limit for the summation, given as an expression; and (4) The expression that is summed. The values of the lower and upper limit expressions are rounded to the nearest integer. The expression in the fourth parameter can (and presumably will) use the summation variable (as well as other identifiers known to the parser).

To use summations with a Parser p, just say p.add(new SummationParser()). It's unlikely that you will ever need to do anything else with SummationParsers. If you want to use a name other than "sum", you can change the name after creating the SummationParser object but before adding it to a parser. (Note, by the way, that parsers by default do not do factorials. If you want a parser that recognizes factorials, you could do something like p = new Parser(Parser.DEFAULT_OPTIONS | Parser.FACTORIAL).)

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`SummationParser()`

## Method Summary

Modifier and Type
Method
Description
`void`
`doParse(Parser parser, ParserContext context)`
When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the summation subexpression.
`String`
`getName()`
Get the name, which will be used in place of "sum" in expressions.
`void`
`setName(String name)`
Set the name, which will be used in place of "sum" in expressions.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SummationParser

public SummationParser()

## Method Details

### setName

public void setName(String name)
Set the name, which will be used in place of "sum" in expressions. This should not be done after the SummationParser has been added to a Parser. The default name is "sum".

Specified by:
  `setName` in interface `MathObject`

### getName

public String getName()
Get the name, which will be used in place of "sum" in expressions.

Specified by:
  `getName` in interface `MathObject`

### doParse

public void doParse(Parser parser, ParserContext context)
When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the summation subexpression. The subexpression has the form (<variable>,invalid input: '<'lower-limit>,invalid input: '<'upper-limit>,<expression>). This method is not meant to be called directly

Specified by:
  `doParse` in interface `ParserExtension`