/** * {@inheritDoc} Creates a new ASTNode object. */ @Override public SymbolNode createSymbol( final String symbolName ) { return new SymbolNode( symbolName ); }
/** * Check if the given symbol is a <code>SymbolNode</code> and test if the names are equal. * * @param symbol1 * @param symbol2 * @return */ public boolean isSymbol(SymbolNode symbol1, SymbolNode symbol2) { if (fRelaxedSyntax) { return symbol1.getString().equalsIgnoreCase(symbol2.getString()); } return symbol1.equals(symbol2); }
public int hashCode() { if (fSymbol != null) { return fSymbol.hashCode(); } return 11; }
/** * Check if the given symbol is a <code>SymbolNode</code> and test if the names are equal. * * @param symbol1 * @param symbol2Name * @return */ public boolean isSymbol(SymbolNode symbol1, String symbol2Name) { if (fRelaxedSyntax) { return symbol1.getString().equalsIgnoreCase(symbol2Name); } return symbol1.getString().equals(symbol2Name); }
public Complex visit(SymbolNode node) { ComplexVariable v = fVariableMap.get(node.toString()); if (v != null) { return v.getValue(); } Complex c = SYMBOL_MAP.get(node.toString()); if (c != null) { return c; } throw new MathException("ComplexEvalVisitor#visit(SymbolNode) not possible for: " + node.toString()); }
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (this.getClass().equals(obj.getClass())) { Pattern2Node pn = (Pattern2Node) obj; if (fSymbol == pn.fSymbol) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } else { if (fSymbol == null || pn.fSymbol == null) { return false; } if (fSymbol.equals(pn.fSymbol)) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } } } return false; }
/** * Internal helper using the mathclipse framework. * * @param aSymbolNodeA The node A to be processed. * @param aSymbolNodeB The node B to be processed. * @param aFunctionNodeC The node C to be processed. * * @return The {@link Criteria} (tree) extracted from the provided nodes. * * @throws ParseException Thrown in case there were problems working with * the given node. */ private Criteria toCriteria( SymbolNode aSymbolNodeA, SymbolNode aSymbolNodeB, FunctionNode aFunctionNodeC ) throws ParseException { if ( aSymbolNodeA.getString().equalsIgnoreCase( NODE ) ) { Criteria theCriteria = toCriteria( aFunctionNodeC ); if ( aSymbolNodeB.getString().equalsIgnoreCase( NOT ) ) { return not( theCriteria ); } } throw new ParseException( "Unable to parse: \"" + aSymbolNodeA.getString() + "\", \"" + aSymbolNodeB.getString() + "\" and/or \"" + aFunctionNodeC.getString() + "\"", 0 ); }
/** * Visit. * * @param node the node * @return the complex */ @Override public Complex visit( SymbolNode node ) { ComplexVariable v = fVariableMap.get( node.toString() ); if ( v != null ) { return v.getValue(); } Complex c = SYMBOL_MAP.get( node.toString() ); if ( c != null ) { return c; } throw new MathException( "ComplexEvalVisitor#visit(SymbolNode) not possible for: " + node.toString() ); }
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (this.getClass().equals(obj.getClass())) { Pattern3Node pn = (Pattern3Node) obj; if (fSymbol == pn.fSymbol) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } else { if (fSymbol == null || pn.fSymbol == null) { return false; } if (fSymbol.equals(pn.fSymbol)) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } } } return false; }
/** * Internal helper using the mathclipse framework. * * @param aSymbolNodeA The node A to be processed. * @param aFunctionNodeB The node B to be processed. * @param aSymbolNodeC The node C to be processed. * * @return The {@link Criteria} (tree) extracted from the provided nodes. * * @throws ParseException Thrown in case there were problems working with * the given node. */ private Criteria toCriteria( SymbolNode aSymbolNodeA, FunctionNode aFunctionNodeB, SymbolNode aSymbolNodeC ) throws ParseException { if ( aSymbolNodeA.getString().equalsIgnoreCase( NODE ) ) { Criteria theCriteria = toCriteria( aFunctionNodeB ); if ( aSymbolNodeC.getString().equalsIgnoreCase( OR ) ) { return or( theCriteria ); } else if ( aSymbolNodeC.getString().equalsIgnoreCase( AND ) ) { return and( theCriteria ); } else if ( aSymbolNodeC.getString().equalsIgnoreCase( INTERSECT ) ) { return intersectWith( theCriteria ); } else if ( aSymbolNodeC.getString().equalsIgnoreCase( NOT ) ) { return not( theCriteria ); } } throw new ParseException( "Unable to parse: \"" + aSymbolNodeA.getString() + "\", \"" + aFunctionNodeB.getString() + "\" and/or \"" + aSymbolNodeC.getString() + "\"", 0 ); }
public String toString() { final StringBuffer buff = new StringBuffer(); if (fSymbol != null) { buff.append(fSymbol.toString()); } buff.append("___"); if (fDefault) { buff.append('.'); } if (fConstraint != null) { buff.append(fConstraint.toString()); } return buff.toString(); }
/** * Hash code. * * @return the int */ @Override public int hashCode() { if ( fSymbol != null ) { fSymbol.hashCode(); } return 0; }
public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (this.getClass().equals(obj.getClass())) { PatternNode pn = (PatternNode) obj; if (fSymbol == pn.fSymbol) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } else { if (fSymbol == null || pn.fSymbol == null) { return false; } if (fSymbol.equals(pn.fSymbol)) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } } } return false; }
public SymbolNode createSymbol(final String symbolName) { return new SymbolNode(symbolName); }
String theUnEscapedKey = toUnEscapedKey( aSymbolNodeB.getString() ); Object theUnEscapedValue = toUnEscapedValue( aSymbolNodeC.getString() ); if ( aSymbolNodeA.getString().equalsIgnoreCase( EQUAL_WITH ) ) { return equalWith( theUnEscapedKey, theUnEscapedValue ); else if ( aSymbolNodeA.getString().equalsIgnoreCase( NOT_EQUAL_WITH ) ) { return notEqualWith( theUnEscapedKey, theUnEscapedValue ); else if ( aSymbolNodeA.getString().equalsIgnoreCase( GREATER_THAN ) ) { return greaterThan( theUnEscapedKey, theUnEscapedValue ); else if ( aSymbolNodeA.getString().equalsIgnoreCase( GREATER_OR_EQUAL_THAN ) ) { return greaterOrEqualThan( theUnEscapedKey, theUnEscapedValue ); else if ( aSymbolNodeA.getString().equalsIgnoreCase( LESS_THAN ) ) { return lessThan( theUnEscapedKey, theUnEscapedValue ); else if ( aSymbolNodeA.getString().equalsIgnoreCase( LESS_OR_EQUAL_THAN ) ) { return lessOrEqualThan( theUnEscapedKey, theUnEscapedValue ); throw new ParseException( toUnEscapedKey( "Unable to parse: " + aSymbolNodeA.getString() ) + "\", \"" + theUnEscapedKey + "\" and/or \"" + theUnEscapedValue + "\"", 0 );
public String toString() { final StringBuffer buff = new StringBuffer(); if (fSymbol != null) { buff.append(fSymbol.toString()); } buff.append("__"); if (fDefault) { buff.append('.'); } if (fConstraint != null) { buff.append(fConstraint.toString()); } return buff.toString(); }
public int hashCode() { if (fSymbol != null) { return fSymbol.hashCode() * 41; } return 19; } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (this.getClass().equals(obj.getClass())) { PatternNode pn = (PatternNode) obj; if (fSymbol == pn.fSymbol) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } else { if (fSymbol == null || pn.fSymbol == null) { return false; } if (fSymbol.equals(pn.fSymbol)) { if (fConstraint == null || pn.fConstraint == null) { return fConstraint == pn.fConstraint; } return fConstraint.equals(pn.fConstraint); } } } return false; }
@Override public SymbolNode createSymbol(final String symbolName, final String context) { String name = symbolName; if (fIgnoreCase) { name = symbolName.toLowerCase(); } if (Config.RUBI_CONVERT_SYMBOLS) { name = toRubiString(name); } // if (fIgnoreCase) { // return new SymbolNode(symbolName.toLowerCase()); // } return new SymbolNode(name); }
/** * Internal helper using the mathclipse framework. * * @param aSymbolNodeA The node A to be processed. * @param aFunctionNodeB The node B to be processed. * @param aFunctionNodeC The node C to be processed. * * @return The {@link Criteria} (tree) extracted from the provided nodes. * * @throws ParseException Thrown in case there were problems working with * the given node. */ private Criteria toCriteria( SymbolNode aSymbolNodeA, FunctionNode aFunctionNodeB, FunctionNode aFunctionNodeC ) throws ParseException { if ( aSymbolNodeA.getString().equalsIgnoreCase( NODE ) ) { Criteria theCriteriaB = toCriteria( aFunctionNodeB ); Criteria theCriteriaC = toCriteria( aFunctionNodeC ); if ( theCriteriaB instanceof CriteriaNode ) { CriteriaNode theCriteriaNode = (CriteriaNode) theCriteriaB; theCriteriaNode.addChild( theCriteriaC ); return theCriteriaNode; } } throw new ParseException( "Unable to parse: \"" + aSymbolNodeA.getString() + "\", \"" + aFunctionNodeB.getString() + "\" and/or \"" + aFunctionNodeC.getString() + "\"", 0 ); }