use of org.matheclipse.core.expression.Context in project symja_android_library by axkr.
the class ComplexFormFactory method convertSymbol.
public void convertSymbol(final StringBuilder buf, final ISymbol symbol) {
if (symbol == S.E) {
buf.append("Math.E");
return;
} else if (symbol == S.Pi) {
buf.append("Math.PI");
return;
} else if (symbol == S.False) {
buf.append("false");
return;
} else if (symbol == S.True) {
buf.append("true");
return;
} else if (symbol == S.Indeterminate) {
buf.append("Double.NaN");
return;
}
if (symbol.isConstantAttribute()) {
try {
double value = EvalEngine.get().evalDouble(symbol);
buf.append("(" + value + ")");
return;
} catch (RuntimeException rex) {
//
}
}
Context context = symbol.getContext();
if (context == Context.DUMMY) {
append(buf, symbol.getSymbolName());
return;
}
if (ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS && context.equals(Context.SYSTEM)) {
String str = AST2Expr.PREDEFINED_SYMBOLS_MAP.get(symbol.getSymbolName());
if (str != null) {
append(buf, str);
return;
}
}
if (EvalEngine.get().getContextPath().contains(context)) {
append(buf, symbol.getSymbolName());
} else {
append(buf, context.completeContextName() + symbol.getSymbolName());
}
}
use of org.matheclipse.core.expression.Context in project symja_android_library by axkr.
the class TeXFormFactory method convertSymbol.
public void convertSymbol(final StringBuilder buf, final ISymbol sym) {
Context context = sym.getContext();
if (context == Context.DUMMY) {
buf.append(sym.getSymbolName());
return;
}
String headStr = sym.getSymbolName();
if (headStr.length() == 1) {
String c = Characters.unicodeName(headStr.charAt(0));
if (c != null) {
final Object convertedSymbol = CONSTANT_SYMBOLS.get(c);
if (convertedSymbol != null) {
convertConstantSymbol(buf, sym, convertedSymbol);
return;
}
}
}
if (context.equals(Context.SYSTEM) || context.isGlobal()) {
if (ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS && context.equals(Context.SYSTEM)) {
String str = AST2Expr.PREDEFINED_SYMBOLS_MAP.get(headStr);
if (str != null) {
headStr = str;
}
}
final Object convertedSymbol = CONSTANT_SYMBOLS.get(headStr);
if (convertedSymbol == null) {
buf.append(headStr);
} else {
convertConstantSymbol(buf, sym, convertedSymbol);
}
return;
}
if (EvalEngine.get().getContextPath().contains(context)) {
buf.append(sym.getSymbolName());
} else {
buf.append(context.toString() + sym.getSymbolName());
}
}
use of org.matheclipse.core.expression.Context in project symja_android_library by axkr.
the class MathMLFormFactory method convertSymbol.
@Override
public void convertSymbol(final StringBuilder buf, final ISymbol sym) {
Context context = sym.getContext();
if (context == Context.DUMMY) {
tagStart(buf, "mi");
buf.append(sym.getSymbolName());
tagEnd(buf, "mi");
return;
}
String headStr = sym.getSymbolName();
if (context.equals(Context.SYSTEM) || context.isGlobal()) {
if (ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS) {
String str = AST2Expr.PREDEFINED_SYMBOLS_MAP.get(headStr);
if (str != null) {
headStr = str;
}
}
final Object convertedSymbol = CONSTANT_SYMBOLS.get(headStr);
if (convertedSymbol == null) {
tagStart(buf, "mi");
buf.append(headStr);
tagEnd(buf, "mi");
return;
}
if (convertedSymbol instanceof Operator) {
((Operator) convertedSymbol).convert(buf);
return;
}
tagStart(buf, "mi");
buf.append(convertedSymbol.toString());
tagEnd(buf, "mi");
return;
}
if (EvalEngine.get().getContextPath().contains(context)) {
tagStart(buf, "mi");
buf.append(sym.getSymbolName());
} else {
tagStart(buf, "mi");
buf.append(context.toString() + sym.getSymbolName());
}
tagEnd(buf, "mi");
}
use of org.matheclipse.core.expression.Context in project symja_android_library by axkr.
the class DoubleFormFactory method convertSymbol.
public void convertSymbol(final StringBuilder buf, final ISymbol symbol) {
if (symbol == S.E) {
buf.append("Math.E");
return;
} else if (symbol == S.Pi) {
buf.append("Math.PI");
return;
} else if (symbol == S.False) {
buf.append("false");
return;
} else if (symbol == S.True) {
buf.append("true");
return;
} else if (symbol == S.Indeterminate) {
buf.append("Double.NaN");
return;
}
if (symbol.isConstantAttribute()) {
try {
double value = EvalEngine.get().evalDouble(symbol);
buf.append("(" + value + ")");
return;
} catch (RuntimeException rex) {
//
}
}
Context context = symbol.getContext();
if (context == Context.DUMMY) {
append(buf, symbol.getSymbolName());
return;
}
if (ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS && context.equals(Context.SYSTEM)) {
String str = AST2Expr.PREDEFINED_SYMBOLS_MAP.get(symbol.getSymbolName());
if (str != null) {
append(buf, str);
return;
}
}
if (EvalEngine.get().getContextPath().contains(context)) {
append(buf, symbol.getSymbolName());
} else {
append(buf, context.completeContextName() + symbol.getSymbolName());
}
}
Aggregations