Module separation
This commit is contained in:
		@@ -30,6 +30,11 @@
 | 
			
		||||
            <artifactId>annotations</artifactId>
 | 
			
		||||
        </dependency>
 | 
			
		||||
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.solovyev</groupId>
 | 
			
		||||
            <artifactId>jscl</artifactId>
 | 
			
		||||
        </dependency>
 | 
			
		||||
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,16 @@
 | 
			
		||||
package org.solovyev.android.calculator;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User: Solovyev_S
 | 
			
		||||
 * Date: 20.09.12
 | 
			
		||||
 * Time: 12:45
 | 
			
		||||
 */
 | 
			
		||||
public interface CalculatorLocator {
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    JCalculatorEngine getCalculatorEngine();
 | 
			
		||||
 | 
			
		||||
    void setCalculatorEngine(@NotNull JCalculatorEngine calculatorEngine);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
package org.solovyev.android.calculator;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User: Solovyev_S
 | 
			
		||||
 * Date: 20.09.12
 | 
			
		||||
 * Time: 12:45
 | 
			
		||||
 */
 | 
			
		||||
public class CalculatorLocatorImpl implements CalculatorLocator {
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private JCalculatorEngine calculatorEngine;
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    private static final CalculatorLocator instance = new CalculatorLocatorImpl();
 | 
			
		||||
 | 
			
		||||
    private CalculatorLocatorImpl() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    public static CalculatorLocator getInstance() {
 | 
			
		||||
        return instance;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    @Override
 | 
			
		||||
    public JCalculatorEngine getCalculatorEngine() {
 | 
			
		||||
        return calculatorEngine;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setCalculatorEngine(@NotNull JCalculatorEngine calculatorEngine) {
 | 
			
		||||
        this.calculatorEngine = calculatorEngine;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
 * or visit http://se.solovyev.org
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
package org.solovyev.android.calculator.history;
 | 
			
		||||
package org.solovyev.android.calculator;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
 | 
			
		||||
@@ -9,7 +9,7 @@ package org.solovyev.android.calculator;
 | 
			
		||||
import jscl.math.Generic;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.calculator.history.Editor;
 | 
			
		||||
import org.solovyev.android.calculator.Editor;
 | 
			
		||||
import org.solovyev.android.calculator.jscl.JsclOperation;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -0,0 +1,34 @@
 | 
			
		||||
package org.solovyev.android.calculator;
 | 
			
		||||
 | 
			
		||||
import jscl.MathEngine;
 | 
			
		||||
import jscl.math.function.Function;
 | 
			
		||||
import jscl.math.function.IConstant;
 | 
			
		||||
import jscl.math.operator.Operator;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.solovyev.common.math.MathRegistry;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User: Solovyev_S
 | 
			
		||||
 * Date: 20.09.12
 | 
			
		||||
 * Time: 12:43
 | 
			
		||||
 */
 | 
			
		||||
public interface JCalculatorEngine {
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    String getMultiplicationSign();
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    MathRegistry<IConstant> getVarsRegistry();
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    MathRegistry<Function> getFunctionsRegistry();
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    MathRegistry<Operator> getOperatorsRegistry();
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    MathRegistry<Operator> getPostfixFunctionsRegistry();
 | 
			
		||||
 | 
			
		||||
    @NotNull
 | 
			
		||||
    MathEngine getEngine();
 | 
			
		||||
}
 | 
			
		||||
@@ -9,7 +9,7 @@ package org.solovyev.android.calculator.jscl;
 | 
			
		||||
import jscl.math.Generic;
 | 
			
		||||
import jscl.text.ParseException;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.solovyev.android.calculator.model.CalculatorEngine;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorLocatorImpl;
 | 
			
		||||
import org.solovyev.android.calculator.model.DummyTextProcessor;
 | 
			
		||||
import org.solovyev.android.calculator.model.FromJsclSimplifyTextProcessor;
 | 
			
		||||
import org.solovyev.android.calculator.model.TextProcessor;
 | 
			
		||||
@@ -42,11 +42,11 @@ public enum JsclOperation {
 | 
			
		||||
	public final String evaluate(@NotNull String expression) throws ParseException {
 | 
			
		||||
		switch (this) {
 | 
			
		||||
			case simplify:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().simplify(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().simplify(expression);
 | 
			
		||||
			case elementary:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().elementary(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().elementary(expression);
 | 
			
		||||
			case numeric:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().evaluate(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().evaluate(expression);
 | 
			
		||||
			default:
 | 
			
		||||
				throw new UnsupportedOperationException();
 | 
			
		||||
		}
 | 
			
		||||
@@ -56,11 +56,11 @@ public enum JsclOperation {
 | 
			
		||||
	public final Generic evaluateGeneric(@NotNull String expression) throws ParseException {
 | 
			
		||||
		switch (this) {
 | 
			
		||||
			case simplify:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().simplifyGeneric(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().simplifyGeneric(expression);
 | 
			
		||||
			case elementary:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().elementaryGeneric(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().elementaryGeneric(expression);
 | 
			
		||||
			case numeric:
 | 
			
		||||
				return CalculatorEngine.instance.getEngine().evaluateGeneric(expression);
 | 
			
		||||
				return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getEngine().evaluateGeneric(expression);
 | 
			
		||||
			default:
 | 
			
		||||
				throw new UnsupportedOperationException();
 | 
			
		||||
		}
 | 
			
		||||
@@ -10,9 +10,9 @@ import jscl.NumeralBase;
 | 
			
		||||
import jscl.math.function.Constants;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorLocatorImpl;
 | 
			
		||||
import org.solovyev.common.JPredicate;
 | 
			
		||||
import org.solovyev.common.StartsWithFinder;
 | 
			
		||||
import org.solovyev.android.calculator.model.CalculatorEngine;
 | 
			
		||||
import org.solovyev.android.calculator.model.CalculatorParseException;
 | 
			
		||||
import org.solovyev.common.collections.CollectionsUtils;
 | 
			
		||||
 | 
			
		||||
@@ -26,10 +26,7 @@ public enum MathType {
 | 
			
		||||
		private final List<String> tokens = new ArrayList<String>(10);
 | 
			
		||||
		{
 | 
			
		||||
			for (NumeralBase numeralBase : NumeralBase.values()) {
 | 
			
		||||
				final String jsclPrefix = numeralBase.getJsclPrefix();
 | 
			
		||||
				if (jsclPrefix != null) {
 | 
			
		||||
					tokens.add(jsclPrefix);
 | 
			
		||||
				}
 | 
			
		||||
                tokens.add(numeralBase.getJsclPrefix());
 | 
			
		||||
            }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -60,7 +57,7 @@ public enum MathType {
 | 
			
		||||
		@NotNull
 | 
			
		||||
		@Override
 | 
			
		||||
		public List<String> getTokens() {
 | 
			
		||||
			return CalculatorEngine.instance.getPostfixFunctionsRegistry().getNames();
 | 
			
		||||
			return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getPostfixFunctionsRegistry().getNames();
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -104,7 +101,7 @@ public enum MathType {
 | 
			
		||||
		@NotNull
 | 
			
		||||
		@Override
 | 
			
		||||
		public List<String> getTokens() {
 | 
			
		||||
			return CalculatorEngine.instance.getFunctionsRegistry().getNames();
 | 
			
		||||
			return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getFunctionsRegistry().getNames();
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -112,7 +109,7 @@ public enum MathType {
 | 
			
		||||
		@NotNull
 | 
			
		||||
		@Override
 | 
			
		||||
		public List<String> getTokens() {
 | 
			
		||||
			return CalculatorEngine.instance.getOperatorsRegistry().getNames();
 | 
			
		||||
			return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getOperatorsRegistry().getNames();
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -120,7 +117,7 @@ public enum MathType {
 | 
			
		||||
		@NotNull
 | 
			
		||||
		@Override
 | 
			
		||||
		public List<String> getTokens() {
 | 
			
		||||
			return CalculatorEngine.instance.getVarsRegistry().getNames();
 | 
			
		||||
			return CalculatorLocatorImpl.getInstance().getCalculatorEngine().getVarsRegistry().getNames();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
@@ -6,10 +6,8 @@
 | 
			
		||||
 | 
			
		||||
package org.solovyev.android.calculator.model;
 | 
			
		||||
 | 
			
		||||
import android.app.Application;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.msg.AndroidMessage;
 | 
			
		||||
import org.solovyev.common.exceptions.SersoException;
 | 
			
		||||
import org.solovyev.common.msg.Message;
 | 
			
		||||
import org.solovyev.common.msg.MessageType;
 | 
			
		||||
@@ -39,14 +37,17 @@ public class CalculatorParseException extends SersoException implements Message
 | 
			
		||||
		this.position = jsclParseException.getPosition();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public CalculatorParseException(@NotNull Integer messageId, @NotNull Application application, @Nullable Integer position, @NotNull String expression, Object... parameters) {
 | 
			
		||||
		this.message = new AndroidMessage(messageId, MessageType.error, application, parameters);
 | 
			
		||||
	public CalculatorParseException(@Nullable Integer position,
 | 
			
		||||
                                    @NotNull String expression,
 | 
			
		||||
                                    @NotNull Message message) {
 | 
			
		||||
		this.message = message;
 | 
			
		||||
		this.expression = expression;
 | 
			
		||||
		this.position = position;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public CalculatorParseException(@NotNull Integer messageId, @NotNull Application application, @NotNull String expression, Object... parameters) {
 | 
			
		||||
		this(messageId, application, null, expression, parameters);
 | 
			
		||||
	public CalculatorParseException(@NotNull String expression,
 | 
			
		||||
                                    @NotNull Message message) {
 | 
			
		||||
        this(null, expression, message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@NotNull
 | 
			
		||||
@@ -3,6 +3,8 @@ package org.solovyev.android.calculator.model;
 | 
			
		||||
import jscl.math.Generic;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorLocator;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorLocatorImpl;
 | 
			
		||||
import org.solovyev.android.calculator.math.MathType;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
@@ -55,7 +57,7 @@ public class FromJsclSimplifyTextProcessor implements TextProcessor<String, Gene
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (needMultiplicationSign(mathTypeBefore == null ? null : mathTypeBefore.getMathType(), mathTypeAfter == null ? null : mathTypeAfter.getMathType())) {
 | 
			
		||||
					sb.append(CalculatorEngine.instance.getMultiplicationSign());
 | 
			
		||||
					sb.append(CalculatorLocatorImpl.getInstance().getCalculatorEngine().getMultiplicationSign());
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			} else {
 | 
			
		||||
@@ -82,13 +82,6 @@
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.solovyev</groupId>
 | 
			
		||||
            <artifactId>jscl</artifactId>
 | 
			
		||||
            <version>0.0.2</version>
 | 
			
		||||
            <exclusions>
 | 
			
		||||
                <exclusion>
 | 
			
		||||
                    <artifactId>xercesImpl</artifactId>
 | 
			
		||||
                    <groupId>xerces</groupId>
 | 
			
		||||
                </exclusion>
 | 
			
		||||
            </exclusions>
 | 
			
		||||
        </dependency>
 | 
			
		||||
 | 
			
		||||
        <!--OTHER-->
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,8 @@ public class CalculatorApplication extends android.app.Application {
 | 
			
		||||
	public void onCreate() {
 | 
			
		||||
		super.onCreate();
 | 
			
		||||
 | 
			
		||||
        CalculatorLocatorImpl.getInstance().setCalculatorEngine(CalculatorEngine.instance);
 | 
			
		||||
 | 
			
		||||
		AdsController.getInstance().init(ADMOB_USER_ID, AD_FREE_PRODUCT_ID, new BillingController.IConfiguration() {
 | 
			
		||||
 | 
			
		||||
			@Override
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ package org.solovyev.android.calculator.history;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.simpleframework.xml.Element;
 | 
			
		||||
import org.simpleframework.xml.Root;
 | 
			
		||||
import org.solovyev.android.calculator.Editor;
 | 
			
		||||
import org.solovyev.android.calculator.ICalculatorDisplay;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.simpleframework.xml.Element;
 | 
			
		||||
import org.simpleframework.xml.Root;
 | 
			
		||||
import org.solovyev.android.calculator.Editor;
 | 
			
		||||
 | 
			
		||||
@Root
 | 
			
		||||
public class EditorHistoryState implements Cloneable{
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ import android.widget.EditText;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.calculator.Editor;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User: serso
 | 
			
		||||
 
 | 
			
		||||
@@ -16,13 +16,16 @@ import jscl.text.ParseInterruptedException;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorApplication;
 | 
			
		||||
import org.solovyev.android.calculator.JCalculatorEngine;
 | 
			
		||||
import org.solovyev.android.calculator.R;
 | 
			
		||||
import org.solovyev.android.calculator.jscl.JsclOperation;
 | 
			
		||||
import org.solovyev.android.msg.AndroidMessage;
 | 
			
		||||
import org.solovyev.android.prefs.BooleanPreference;
 | 
			
		||||
import org.solovyev.android.prefs.Preference;
 | 
			
		||||
import org.solovyev.android.prefs.StringPreference;
 | 
			
		||||
import org.solovyev.common.MutableObject;
 | 
			
		||||
import org.solovyev.common.msg.MessageRegistry;
 | 
			
		||||
import org.solovyev.common.msg.MessageType;
 | 
			
		||||
import org.solovyev.common.text.EnumMapper;
 | 
			
		||||
import org.solovyev.common.text.NumberMapper;
 | 
			
		||||
import org.solovyev.common.text.StringUtils;
 | 
			
		||||
@@ -40,7 +43,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
 * Time: 11:38 PM
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public enum CalculatorEngine {
 | 
			
		||||
public enum CalculatorEngine implements JCalculatorEngine {
 | 
			
		||||
 | 
			
		||||
	instance;
 | 
			
		||||
 | 
			
		||||
@@ -130,6 +133,7 @@ public enum CalculatorEngine {
 | 
			
		||||
		this.engine.setUseGroupingSeparator(true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public String getMultiplicationSign() {
 | 
			
		||||
		return multiplicationSign;
 | 
			
		||||
@@ -229,10 +233,12 @@ public enum CalculatorEngine {
 | 
			
		||||
						evalException.setObject(new CalculatorEvalException(e, e, jsclExpression));
 | 
			
		||||
					} catch (ArithmeticException e) {
 | 
			
		||||
						//System.out.println(e.getMessage());
 | 
			
		||||
						parseException.setObject(new CalculatorParseException(R.string.msg_1, CalculatorApplication.getInstance(), jsclExpression, e.getMessage()));
 | 
			
		||||
                        final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_1, MessageType.error, CalculatorApplication.getInstance(), e.getMessage());
 | 
			
		||||
                        parseException.setObject(new CalculatorParseException(jsclExpression, androidMessage));
 | 
			
		||||
					} catch (StackOverflowError e) {
 | 
			
		||||
						//System.out.println(StringUtils.fromStackTrace(e.getStackTrace()));
 | 
			
		||||
						parseException.setObject(new CalculatorParseException(R.string.msg_2, CalculatorApplication.getInstance(), jsclExpression));
 | 
			
		||||
                        final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_2, MessageType.error, CalculatorApplication.getInstance());
 | 
			
		||||
                        parseException.setObject(new CalculatorParseException(jsclExpression, androidMessage));
 | 
			
		||||
					} catch (jscl.text.ParseException e) {
 | 
			
		||||
						//System.out.println(e.getMessage());
 | 
			
		||||
						parseException.setObject(new CalculatorParseException(e));
 | 
			
		||||
@@ -278,11 +284,13 @@ public enum CalculatorEngine {
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if (calculationResultLocal == null) {
 | 
			
		||||
					throw new CalculatorParseException(R.string.msg_3, CalculatorApplication.getInstance(), jsclExpression);
 | 
			
		||||
                    final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_3, MessageType.error, CalculatorApplication.getInstance());
 | 
			
		||||
                    throw new CalculatorParseException(jsclExpression, androidMessage);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			} catch (InterruptedException e) {
 | 
			
		||||
				throw new CalculatorParseException(R.string.msg_4, CalculatorApplication.getInstance(), jsclExpression);
 | 
			
		||||
                final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_4, MessageType.error, CalculatorApplication.getInstance());
 | 
			
		||||
                throw new CalculatorParseException(jsclExpression, androidMessage);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			final Generic genericResult = calculationResult.getObject();
 | 
			
		||||
@@ -356,26 +364,31 @@ public enum CalculatorEngine {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public AndroidMathRegistry<IConstant> getVarsRegistry() {
 | 
			
		||||
		return varsRegistry;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public AndroidMathRegistry<Function> getFunctionsRegistry() {
 | 
			
		||||
		return functionsRegistry;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public AndroidMathRegistry<Operator> getOperatorsRegistry() {
 | 
			
		||||
		return operatorsRegistry;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public AndroidMathRegistry<Operator> getPostfixFunctionsRegistry() {
 | 
			
		||||
		return postfixFunctionsRegistry;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
    @NotNull
 | 
			
		||||
	public MathEngine getEngine() {
 | 
			
		||||
		return engine;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,9 +10,11 @@ import jscl.math.function.IConstant;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.solovyev.android.calculator.CalculatorApplication;
 | 
			
		||||
import org.solovyev.android.calculator.R;
 | 
			
		||||
import org.solovyev.android.msg.AndroidMessage;
 | 
			
		||||
import org.solovyev.common.StartsWithFinder;
 | 
			
		||||
import org.solovyev.android.calculator.math.MathType;
 | 
			
		||||
import org.solovyev.common.collections.CollectionsUtils;
 | 
			
		||||
import org.solovyev.common.msg.MessageType;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -75,7 +77,8 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
 | 
			
		||||
			if (mathTypeBefore != null &&
 | 
			
		||||
					(mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) &&
 | 
			
		||||
						CollectionsUtils.find(MathType.openGroupSymbols, startsWithFinder) != null) {
 | 
			
		||||
				throw new CalculatorParseException(R.string.msg_5, CalculatorApplication.getInstance(), i, s, mathTypeBefore.getMatch());
 | 
			
		||||
                final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_5, MessageType.error, CalculatorApplication.getInstance(), mathTypeBefore.getMatch());
 | 
			
		||||
                throw new CalculatorParseException(i, s, androidMessage);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			i = mathTypeResult.processToJscl(result, i);
 | 
			
		||||
@@ -86,7 +89,8 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St
 | 
			
		||||
	@NotNull
 | 
			
		||||
	private static PreparedExpression replaceVariables(@NotNull final String s, int depth, @NotNull List<IConstant> undefinedVars) throws CalculatorParseException {
 | 
			
		||||
		if (depth >= MAX_DEPTH) {
 | 
			
		||||
			throw new CalculatorParseException(R.string.msg_6, CalculatorApplication.getInstance(), s);
 | 
			
		||||
            final AndroidMessage androidMessage = new AndroidMessage(R.string.msg_6, MessageType.error, CalculatorApplication.getInstance());
 | 
			
		||||
            throw new CalculatorParseException(s, androidMessage);
 | 
			
		||||
		} else {
 | 
			
		||||
			depth++;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ import junit.framework.Assert;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import org.jetbrains.annotations.Nullable;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.solovyev.android.calculator.Editor;
 | 
			
		||||
import org.solovyev.android.calculator.ICalculatorDisplay;
 | 
			
		||||
import org.solovyev.android.calculator.jscl.JsclOperation;
 | 
			
		||||
import org.solovyev.common.equals.CollectionEqualizer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								pom.xml
									
									
									
									
									
								
							@@ -72,6 +72,18 @@
 | 
			
		||||
                <version>1.0.0</version>
 | 
			
		||||
            </dependency>
 | 
			
		||||
 | 
			
		||||
            <dependency>
 | 
			
		||||
                <groupId>org.solovyev</groupId>
 | 
			
		||||
                <artifactId>jscl</artifactId>
 | 
			
		||||
                <version>0.0.2</version>
 | 
			
		||||
                <exclusions>
 | 
			
		||||
                    <exclusion>
 | 
			
		||||
                        <artifactId>xercesImpl</artifactId>
 | 
			
		||||
                        <groupId>xerces</groupId>
 | 
			
		||||
                    </exclusion>
 | 
			
		||||
                </exclusions>
 | 
			
		||||
            </dependency>
 | 
			
		||||
 | 
			
		||||
            <dependency>
 | 
			
		||||
                <groupId>org.solovyev.android</groupId>
 | 
			
		||||
                <artifactId>android-common-other</artifactId>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user