Commit [r93] Maximize Restore History

fathzer 2014-05-26

added /trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/AbstractTokenizer.java
added /trunk/javaluator-parent/javaluator/src/test/java/com/fathzer/soft/javaluator/junit/examples/ExamplesTest.java
added /trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/LocalizedEvaluator.java
changed /trunk/javaluator-parent/javaluator-examples/pom.xml
changed /trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/AbstractEvaluator.java
changed /trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/BooleanSetEvaluator.java
changed /trunk/javaluator-parent/javaluator/pom.xml
changed /trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/Tokenizer.java
changed /trunk/javaluator-parent/javaluator-deploy/relnotes.txt
copied /trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/Extending.java -> /trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/ExtendedDoubleEvaluator.java
/trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/AbstractTokenizer.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator/src/test/java/com/fathzer/soft/javaluator/junit/examples/ExamplesTest.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/LocalizedEvaluator.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator-examples/pom.xml Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/AbstractEvaluator.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/BooleanSetEvaluator.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator/pom.xml Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator/src/main/java/com/fathzer/soft/javaluator/Tokenizer.java Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator-deploy/relnotes.txt Diff Switch to side-by-side view
Loading...
/trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/Extending.java to /trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/ExtendedDoubleEvaluator.java
--- a/trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/Extending.java
+++ b/trunk/javaluator-parent/javaluator-examples/src/main/java/com/fathzer/soft/javaluator/examples/ExtendedDoubleEvaluator.java
@@ -1,38 +1,44 @@
-package com.fathzer.soft.javaluator.examples;
-
-import java.util.Iterator;
-
-import com.fathzer.soft.javaluator.*;
-
-/** An example of how to extend an existing evaluator by adding support for a new function.
- */
-public class Extending {
-	/** Defines the new function (square root).*/
-	private static final Function SQRT = new Function("sqrt", 1);
-	
-	public static void main(String[] args) {
-		// Gets the default DoubleEvaluator's parameters
-		Parameters params = DoubleEvaluator.getDefaultParameters();
-		// add the new sqrt function to these parameters
-		params.add(SQRT);
-		
-		// Create a new subclass of DoubleEvaluator that support the new function
-		AbstractEvaluator<Double> evaluator = new DoubleEvaluator(params) {
-			@Override
-			protected Double evaluate(Function function, Iterator<Double> arguments, Object evaluationContext) {
-				if (function == SQRT) {
-					// Implements the new function
-					return Math.sqrt(arguments.next());
-				} else {
-					// If it's another function, pass it to DoubleEvaluator
-					return super.evaluate(function, arguments, evaluationContext);
-				}
-			}
-		};
-		
-		// Test that all this stuff is ok
-		String expression = "sqrt(abs(-2))^2";
-		System.out.println (expression+" = "+evaluator.evaluate(expression));
-	}
-
-}
+package com.fathzer.soft.javaluator.examples;
+
+import java.util.Iterator;
+
+import com.fathzer.soft.javaluator.DoubleEvaluator;
+import com.fathzer.soft.javaluator.Function;
+import com.fathzer.soft.javaluator.Parameters;
+
+/** A subclass of DoubleEvaluator that supports SQRT function.
+ */
+public class ExtendedDoubleEvaluator extends DoubleEvaluator {
+	/** Defines the new function (square root).*/
+	private static final Function SQRT = new Function("sqrt", 1);
+	private static final Parameters PARAMS;
+	
+	static {
+		// Gets the default DoubleEvaluator's parameters
+		PARAMS = DoubleEvaluator.getDefaultParameters();
+		// add the new sqrt function to these parameters
+		PARAMS.add(SQRT);
+	}
+
+	public ExtendedDoubleEvaluator() {
+		super(PARAMS);
+	}
+
+	@Override
+	protected Double evaluate(Function function, Iterator<Double> arguments, Object evaluationContext) {
+		if (function == SQRT) {
+			// Implements the new function
+			return Math.sqrt(arguments.next());
+		} else {
+			// If it's another function, pass it to DoubleEvaluator
+			return super.evaluate(function, arguments, evaluationContext);
+		}
+	}
+	
+	public static void main(String[] args) {
+		// Test that all this stuff is ok
+		String expression = "sqrt(abs(-2))^2";
+		System.out.println (expression+" = "+new ExtendedDoubleEvaluator().evaluate(expression));
+	}
+
+}