Source Code Cross Referenced for StandardFunction.java in  » Science » jcm1-source » edu » hws » jcm » data » 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.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*************************************************************************
002:         *                                                                        *
003:         *   1) This source code file, in unmodified form, and compiled classes   *
004:         *      derived from it can be used and distributed without restriction,  *
005:         *      including for commercial use.  (Attribution is not required       *
006:         *      but is appreciated.)                                              *
007:         *                                                                        *
008:         *    2) Modified versions of this file can be made and distributed       *
009:         *       provided:  the modified versions are put into a Java package     *
010:         *       different from the original package, edu.hws;  modified          *
011:         *       versions are distributed under the same terms as the original;   *
012:         *       and the modifications are documented in comments.  (Modification *
013:         *       here does not include simply making subclasses that belong to    *
014:         *       a package other than edu.hws, which can be done without any      *
015:         *       restriction.)                                                    *
016:         *                                                                        *
017:         *   David J. Eck                                                         *
018:         *   Department of Mathematics and Computer Science                       *
019:         *   Hobart and William Smith Colleges                                    *
020:         *   Geneva, New York 14456,   USA                                        *
021:         *   Email: eck@hws.edu          WWW: http://math.hws.edu/eck/            *
022:         *                                                                        *
023:         *************************************************************************/package edu.hws.jcm.data;
024:
025:        /**
026:         * This class exists to associate standard functions, such as sin and abs, with
027:         * their names.  Note that the functions are actually implemented in the
028:         * ExprsssionProgram class, where they are only represented by numerical operation
029:         * codes.  An object of type StandardFunction contains a name and the operation
030:         * code of the associated standard function.  A static routine, standardFunctionName,
031:         * gives the name associated with each operation code.
032:         */
033:        public class StandardFunction implements  MathObject {
034:
035:            private String name; // The name of this standard function.
036:            private int code; // The operation code for this function, from class ExpressionProgram.
037:
038:            /**
039:             * Create a StandardFunction object to represent the standard
040:             * function with the given operation code, where opCode is one
041:             * of the codes for standard functions defined in class ExpressionProgram.
042:             * The name is the one associated with the opCode by the 
043:             * static function standardFunctionName() in this class.  An error
044:             * will occur if opCode is not one of the valid standard function 
045:             * operation codes.
046:             */
047:            public StandardFunction(int opCode) {
048:                this (standardFunctionName(opCode), opCode);
049:            }
050:
051:            /**
052:             * Create a StandardFunction object to represent the standard
053:             * function with the given operation code, where opCode is one
054:             * of the codes for stadard functions defined in class ExpressionProgram.
055:             * Use the specified name for the standard function.  This allows you
056:             * to make alternative names, such as "log" instead of "log10".  An error
057:             * will occur if opCode is not one of the valid standard function 
058:             * operation codes.
059:             */
060:            public StandardFunction(String name, int opCode) {
061:                setName(name);
062:                code = opCode;
063:            }
064:
065:            /**
066:             * Return the operation code for this standard function.
067:             */
068:            public int getOpCode() {
069:                return code;
070:            }
071:
072:            //----------------------- Methods from interface MathObject --------------------
073:
074:            /**
075:             * Return the name of this StandardFunction oject.
076:             */
077:            public String getName() {
078:                return name;
079:            }
080:
081:            /**
082:             * Change the name of this StandardFunction.  This shouldn't be done
083:             * if this object is registered with a Parser.
084:             */
085:            public void setName(String name) {
086:                this .name = name;
087:            }
088:
089:            //-------------------------------------------------------------------------------
090:
091:            /**
092:             * Return the usual name for the standard function with the
093:             * specified opCode.  The opcodes are defined in the ExpressionProgram class.
094:             * Will throw an IllegalArgumentException if the specified oPcode is
095:             * not the opcode for any standard function.
096:             */
097:            public static String standardFunctionName(int opCode) {
098:                switch (opCode) {
099:                case ExpressionProgram.SIN:
100:                    return "sin";
101:                case ExpressionProgram.COS:
102:                    return "cos";
103:                case ExpressionProgram.TAN:
104:                    return "tan";
105:                case ExpressionProgram.COT:
106:                    return "cot";
107:                case ExpressionProgram.SEC:
108:                    return "sec";
109:                case ExpressionProgram.CSC:
110:                    return "csc";
111:                case ExpressionProgram.ARCSIN:
112:                    return "arcsin";
113:                case ExpressionProgram.ARCCOS:
114:                    return "arccos";
115:                case ExpressionProgram.ARCTAN:
116:                    return "arctan";
117:                case ExpressionProgram.ABS:
118:                    return "abs";
119:                case ExpressionProgram.SQRT:
120:                    return "sqrt";
121:                case ExpressionProgram.EXP:
122:                    return "exp";
123:                case ExpressionProgram.LN:
124:                    return "ln";
125:                case ExpressionProgram.LOG2:
126:                    return "log2";
127:                case ExpressionProgram.LOG10:
128:                    return "log10";
129:                case ExpressionProgram.TRUNC:
130:                    return "trunc";
131:                case ExpressionProgram.ROUND:
132:                    return "round";
133:                case ExpressionProgram.FLOOR:
134:                    return "floor";
135:                case ExpressionProgram.CEILING:
136:                    return "ceiling";
137:                case ExpressionProgram.CUBERT:
138:                    return "cubert";
139:                default:
140:                    throw new IllegalArgumentException(
141:                            "Internal Error: Unknown standard function code.");
142:                }
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.