/** * 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 ); }
/** * 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 ); }
/** * 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 ); }
/** * Internal helper using the mathclipse framework. * * @param aFunctionNode The node to be processed. * * @return The {@link Criteria} (tree) extracted from the provided node. * * @throws ParseException Thrown in case there were problems working with * the given node. */ private Criteria toCriteria( FunctionNode aFunctionNode ) throws ParseException { if ( aFunctionNode.size() == 3 ) { if ( (aFunctionNode.get( 0 ) instanceof SymbolNode) && (aFunctionNode.get( 1 ) instanceof SymbolNode) && (aFunctionNode.get( 2 ) instanceof SymbolNode) ) { return toCriteria( (SymbolNode) aFunctionNode.get( 0 ), (SymbolNode) aFunctionNode.get( 1 ), aFunctionNode.get( 2 ) ); } else if ( (aFunctionNode.get( 0 ) instanceof SymbolNode) && (aFunctionNode.get( 1 ) instanceof SymbolNode) && (aFunctionNode.get( 2 ) instanceof NumberNode) ) { return toCriteria( (SymbolNode) aFunctionNode.get( 0 ), (SymbolNode) aFunctionNode.get( 1 ), aFunctionNode.get( 2 ) ); } else if ( (aFunctionNode.get( 0 ) instanceof SymbolNode) && (aFunctionNode.get( 1 ) instanceof FunctionNode) && (aFunctionNode.get( 2 ) instanceof SymbolNode) ) { return toCriteria( (SymbolNode) aFunctionNode.get( 0 ), (FunctionNode) aFunctionNode.get( 1 ), (SymbolNode) aFunctionNode.get( 2 ) ); } else if ( (aFunctionNode.get( 0 ) instanceof SymbolNode) && (aFunctionNode.get( 1 ) instanceof FunctionNode) && (aFunctionNode.get( 2 ) instanceof FunctionNode) ) { return toCriteria( (SymbolNode) aFunctionNode.get( 0 ), (FunctionNode) aFunctionNode.get( 1 ), (FunctionNode) aFunctionNode.get( 2 ) ); } else if ( (aFunctionNode.get( 0 ) instanceof SymbolNode) && (aFunctionNode.get( 1 ) instanceof SymbolNode) && (aFunctionNode.get( 2 ) instanceof FunctionNode) ) { return toCriteria( (SymbolNode) aFunctionNode.get( 0 ), (SymbolNode) aFunctionNode.get( 1 ), (FunctionNode) aFunctionNode.get( 2 ) ); } } throw new ParseException( aFunctionNode.getString(), 0 ); }