/*
* package-info.java
*
* Created on August 17, 2006, 11:35 AM
*
* Copyright 2006 Lee Lofgern and Accounting Enhancements Inc Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
/**
*BETA 9/10/2006
*The formula package is a string based interpreted scripting math and string manipulation language written in Java.
* It's intended to perform math and/or string concatination based on basic code segments that are
* stored in databases and work with dynamically created variables.
* In an effort to improve speed in loops where some variables are stable and other variables
* change, levels of volatility can be assigned to variables. When recalculating formulas, you
* can specify the level of volatility and the equations will only be re-evaluated if a variable
* above the specified volatility level was involved in the calculation.
*
* All data and script code is constructed and manipulated in text form. It can be used as a math engine and to concatinate strings.
* The language supports long, double, String, and Date type variables as well as code fragments and variable references.
* All of the variables and code segments are in string form.
* The language has some built in functions and you can add your own functions (in java) to extend the language.
*Special attention has been paid to dates to make date based comparisons easier.
* The easiest way to use the package is through the Formula class. Using this class, you can pretty much avoid interacting with the other classes in this package.
*This package has some built in functions such as iif(...), UCase(...), Len(...), etc. You can also write your own functions in java and add them to this package. This package contains an example of how to write a function that gets access to SQL.
*
*Examples:
*IIF(A="hi","Hi there","Bye") returns "Hi there" if A = "hi", else returns "Bye"
* UCase("Test String") returns "TEST STRING"
* Mid("A string segment",2,6) returns "string"
* 5+4 returns 9
*Code Example 1:
*Formula formula = new Formula();
*int level=1;
*formula.add("marStat=\"M\"",level);
*formula.add("MarriageStatement=\"You Are \"+IIF(marStat=\"M\",\"married\",\"single\")+\".\"");
*System.out.println(formula.solve("MarriageStatement",level).getString()); //Prints "You Are married"
*formula.get("marStat").setValue("S");
*System.out.println(formula.solve("MarriageStatement",level).getString()); //Prints "You Are married" even though we changed the value because the level handed to solve was 1. The solve method didn't re-eveluate the result since no variables higher than 1 were used in the original solution.
*System.out.println(formula.solve("MarriageStatement",0).getString()); //Prints "You Are single" because we specified a level of zero and marStat is a level 1 variable meaning that it should be recalculated.
*
*Code Example 2:
*System.out.println(Formula.getQuickValue("A+2","A=10")); //Prints 12. The returned class is String.
*System.out.println(Formula.getQuickValue("A+2","A=10.50")); //Prints 12.50. The returned class is Stirng.
*System.out.println(Formula.getQuickValue("iif(Birthdate>\"8/22/2006\",\"You were born after 8/22/2006\",\"You were born on or before 8/22/2006\")","BirthDate=9/28/2000")); //Prints "You were born on or before 8/22/2006"
*System.out.println(Formula.getQuickValue("iif(Birthdate>\"8/22/2006\",\"You were born after 8/22/2006\",\"You were born on or before 8/22/2006\")","BirthDate=9/28/2006")); //Prints "You were born after 8/22/2006"
*System.out.println(Formula.getQuickValue("8/2/3",null); //Prints "08/02/2003" because it interpreted this as a date
*System.out.println(Formula.getQuickValue("8/2/ 3",null); //Prints "1" because it now recognizes this is not a date
*
* Copyright 2006 Lee Lofgern and Accounting Enhancements Inc Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*lofgren_opensource@accountingenhancements.com
* @author Lee lofgren lofgren_opensource@accountingenhancements.com
* @version 0.1009102006
*/
package com.accountingenhancements.formula;