Java Doc for FunctionParserExtension.java in  » Science » jcm1-source » edu » hws » jcm » functions » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » jcm1 source » edu.hws.jcm.functions 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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

All known Subclasses:   edu.hws.jcm.functions.WrapperFunction,  edu.hws.jcm.functions.ExpressionFunction,  edu.hws.jcm.functions.TableFunction,
FunctionParserExtension
abstract public class FunctionParserExtension implements Function,ParserExtension,ExpressionCommand(Code)
An object belonging to a concrete subclass of FunctionParserExtesion is a mathematical function that can be registered with a Parser and then used in strings that are parsed by that parser. (See the Function inteface for more information.)

Since a FunctionParserExtension object implements the ParserExtension interface, it has a name and can be registered with a Parser. When the parser encounters the name of a function in a string, it turns control of the parsing process over to the function. When a Function occurs in an ExpressionProgram, the Function is responsible for evaluating itself and for differentiating itself. This functionality is defined in the abstract class FunctionParserExtension. The concrete subclasses of FunctionParserExtension represent actual functions. They must implement the five methods defined in the Function interface, but most of the parser- and expression-related behavior can probably be inherited from this class. (This is good, since the programming is rather tricky.)

(The point of all this is that Parsers and Expressions can deal with Functions, even though there is no reference to Functions in the Parser or ExpressionProgram classes. Everything is done through the ParserExtension interface.)



Field Summary
protected  Stringname
     The name of this MathObject, possibly null.


Method Summary
public  voidappendOutputString(ExpressionProgram prog, int myIndex, StringBuffer buffer)
    
public  voidapply(StackOfDouble stack, Cases cases)
     Evaluate the function applied to argument values popped from the stack, and leave the result on the stack.
public  voidcompileDerivative(ExpressionProgram prog, int myIndex, ExpressionProgram deriv, Variable wrt)
     The function object occurs as a command at index myIndex in prog.
public  voiddoParse(Parser parser, ParserContext context)
     If this ParserExtension is registered with a parser and the parser encounters the name of the function in the string it is parsing, then the parser will call this routine.
public  intextent(ExpressionProgram prog, int myIndex)
     Return the number of commands in prog that are part of this function reference, including the space occupied by the commands that compute the values of the function's arguments.
Parameters:
  prog - program to check commands against.
Parameters:
  myIndex - index in program.
public  StringgetName()
     Get the name of this MathObject.
public  voidsetName(String name)
     Set the name of this object.
public  voidsetParensCanBeOptional(boolean b)
     Call this function with b = true if this is a function of one variable and you want it to behave like a standard function in that parentheses can be optional around the argument of the function.

Field Detail
name
protected String name(Code)
The name of this MathObject, possibly null.





Method Detail
appendOutputString
public void appendOutputString(ExpressionProgram prog, int myIndex, StringBuffer buffer)(Code)
Append a string representation of the function and its arguments to the buffer
Parameters:
  prog - program whose string representation is being generated.
Parameters:
  myIndex - index of this ExpressionCommand in prog.
Parameters:
  buffer - string representation is placed here.



apply
public void apply(StackOfDouble stack, Cases cases)(Code)
Evaluate the function applied to argument values popped from the stack, and leave the result on the stack. The argument values have already been computed and placed on the stack when this is called. They should be popped off the stack in reverse order. This general method can't deal properly with "cases", so it will probably have to be overridden in subclasses.



compileDerivative
public void compileDerivative(ExpressionProgram prog, int myIndex, ExpressionProgram deriv, Variable wrt)(Code)
The function object occurs as a command at index myIndex in prog. The commands for computing its arguments can be found in prog in positions preceding myIndex. Generate commands for computing the derivative of the function reference with respect to the Variable wrt and add them to the deriv program. The computation of the derivative uses the chain rule.
Parameters:
  prog - program this function object occurs in.
Parameters:
  myIndex - index at which this function occurs.
Parameters:
  deriv - commands for computing the derivative are placed here.
Parameters:
  wrt - the derivative is taken with respect to this Variable.



doParse
public void doParse(Parser parser, ParserContext context)(Code)
If this ParserExtension is registered with a parser and the parser encounters the name of the function in the string it is parsing, then the parser will call this routine. This routine parses the function's parameter list and generates the code for evaluating the function, applied to those parameters. When this routine is called, the name of the function has already been read. The code that is generated consists of code to evalueate each of the parameters, leaving the results on the stack, followed by an application of the function.
Parameters:
  parser - parser that is parsing the string.
Parameters:
  context - the ParseContext in effect at the time this method is called.



extent
public int extent(ExpressionProgram prog, int myIndex)(Code)
Return the number of commands in prog that are part of this function reference, including the space occupied by the commands that compute the values of the function's arguments.
Parameters:
  prog - program to check commands against.
Parameters:
  myIndex - index in program. the number of commands in prog that are part of this function reference.



getName
public String getName()(Code)
Get the name of this MathObject.



setName
public void setName(String name)(Code)
Set the name of this object. It is not a good idea to do this if the object has been registered with a Parser.



setParensCanBeOptional
public void setParensCanBeOptional(boolean b)(Code)
Call this function with b = true if this is a function of one variable and you want it to behave like a standard function in that parentheses can be optional around the argument of the function. For the parentheses to be treated as optional, the option Parser.OPTIONAL_PARENS must ALSO be set in the parser. As an example, if you wanted to define the function sinh and allow the syntax "sinh x", you would turn this option on in the Function and turn OTPTIONAL_PARENS on in the Parser.
Parameters:
  b - set whether parenthesis are optional in one variable functions.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.