internal ChildQuery(IQuery qyInput, String name, String prefix, XPathNodeType type) : base (qyInput, name, prefix, type) { }
internal BaseAxisQuery(IQuery queryInput) { this.queryInput = queryInput; }
internal GroupQuery(IQuery queryInput): base(queryInput) { }
internal AttributeQuery(IQuery qyParent, String name, String prefix, XPathNodeType type) : base(qyParent, name, prefix, type) { }
internal BooleanFunctions(IQuery qy, FT ftype) { _qy = qy; _FuncType = ftype; }
IQuery ProcessFunction(Function root, IQuery qyInput) { IQuery qy = null; switch (root.TypeOfFunction) { case FT.FuncPosition : qy = new MethodOperand(null, root.TypeOfFunction); return qy; // we should be able to count how many attributes case FT.FuncCount : qy = ProcessNode((AstNode)(root.ArgumentList[0]), null); if (qy is AttributeQuery) { return new MethodOperand(qy, FT.FuncCount); } //none attribute count funciton result in error. break; case FT.FuncLocalName : case FT.FuncNameSpaceUri : case FT.FuncName : if (root.ArgumentList != null && root.ArgumentList.Count > 0) { return new MethodOperand( ProcessNode((AstNode)(root.ArgumentList[0]),null), root.TypeOfFunction); } else{ return new MethodOperand(null, root.TypeOfFunction); } case FT.FuncString: case FT.FuncConcat: case FT.FuncStartsWith: case FT.FuncContains: case FT.FuncSubstringBefore: case FT.FuncSubstringAfter: case FT.FuncSubstring: case FT.FuncStringLength: case FT.FuncNormalize: case FT.FuncTranslate: ArrayList ArgList = null; if (root.ArgumentList != null) { int count = 0; ArgList = new ArrayList(); while (count < root.ArgumentList.Count) ArgList.Add(ProcessNode((AstNode)root.ArgumentList[count++], null)); } return new StringFunctions(ArgList, root.TypeOfFunction); case FT.FuncNumber: //case FT.FuncSum: case FT.FuncFloor: case FT.FuncCeiling: case FT.FuncRound: if (root.ArgumentList != null) { return new NumberFunctions(ProcessNode((AstNode)root.ArgumentList[0], null), root.TypeOfFunction); } else { return new NumberFunctions(null); } case FT.FuncTrue: case FT.FuncFalse: return new BooleanFunctions(null, root.TypeOfFunction); case FT.FuncNot: case FT.FuncLang: case FT.FuncBoolean: return new BooleanFunctions(ProcessNode((AstNode)root.ArgumentList[0], null), root.TypeOfFunction); // Unsupport functions case FT.FuncID : // Last Function is not supported, because we don't know // how many we get in the list // <Root> <e a="1"/> <e a="2"/></Root> // /Root/e[last()=2] // we will not return the first one because // we don't if we have two e elements. case FT.FuncLast : //qy = new MethodOperand(null, root.TypeOfFunction); //return qy; default : throw new XPathReaderException("The XPath query is not supported."); } return null; }
internal LogicalExpr(Operator.Op op, IQuery opnd1, IQuery opnd2){ this.opnd1= opnd1; this.opnd2= opnd2; this.op= op; }
public NumberFunctions(IQuery qy, FT ftype) { _qy = qy; _FuncType = ftype; }
// // The operand needs to use the number function // to covert to numbers internal NumericExpr(Operator.Op op, IQuery opnd1, IQuery opnd2) { if (opnd1.ReturnType() != XPathResultType.Number) { this.opnd1= new NumberFunctions(opnd1); } else { this.opnd1 = opnd1; } if (opnd2 != null && (opnd2.ReturnType() != XPathResultType.Number)) { this.opnd2= new NumberFunctions(opnd2); } else{ this.opnd2 = opnd2; } this.op= op; }
internal AndExpr(IQuery opnd1, IQuery opnd2) { this.opnd1 = new BooleanFunctions(opnd1); this.opnd2 = new BooleanFunctions(opnd2); }
private IQuery ProcessNode(AstNode root, IQuery qyInput) { IQuery result = null; if (root == null) return null; switch (root.TypeOfAst) { case AstNode.QueryType.Axis: Axis axis = (Axis)root; result = ProcessAxis(axis, ProcessNode(axis.Input, qyInput)); break; case AstNode.QueryType.Operator: result = ProcessOperator((Operator)root, null); break; case AstNode.QueryType.Filter: result = ProcessFilter((Filter)root); break; case AstNode.QueryType.ConstantOperand: result = ProcessOperand((Operand)root); break; case AstNode.QueryType.Function: result = ProcessFunction((Function)root, qyInput); break; case AstNode.QueryType.Root: result = new AbsoluteQuery(); break; case AstNode.QueryType.Group: result = new GroupQuery(ProcessNode(((Group)root).GroupNode, qyInput)); break; default: Debug.Assert(false, "Unknown QueryType encountered!!"); break; } return result; }
// /// /// private IQuery ProcessAxis(Axis root , IQuery qyInput) { IQuery result = null; switch (root.TypeOfAxis) { case Axis.AxisType.Attribute: result = new AttributeQuery(qyInput, root.Name, root.Prefix, root.Type); break; case Axis.AxisType.Self: result = new XPathSelfQuery(qyInput, root.Name, root.Prefix, root.Type); break; case Axis.AxisType.Child: result = new ChildQuery( qyInput, root.Name, root.Prefix, root.Type); break; case Axis.AxisType.Descendant: case Axis.AxisType.DescendantOrSelf: result = new DescendantQuery(qyInput, root.Name, root.Prefix, root.Type); break; default: throw new XPathReaderException("xpath is not supported!"); } return result; }
// // Operator: Or, and, | // +, -, *, div, // >, >=, <, <=, =, != // private IQuery ProcessOperator(Operator root, IQuery qyInput) { IQuery ret = null; switch (root.OperatorType) { case Operator.Op.OR: ret = new OrExpr(ProcessNode(root.Operand1, null), ProcessNode(root.Operand2, null)); return ret; case Operator.Op.AND : ret = new AndExpr(ProcessNode(root.Operand1, null), ProcessNode(root.Operand2, null)); return ret; } switch (root.ReturnType) { case XPathResultType.Number: ret = new NumericExpr(root.OperatorType, ProcessNode(root.Operand1, null), ProcessNode(root.Operand2, null)); return ret; case XPathResultType.Boolean: ret = new LogicalExpr(root.OperatorType, ProcessNode(root.Operand1, null), ProcessNode(root.Operand2, null)); return ret; } return ret; }
internal BaseAxisQuery(IQuery queryInput, string name, string prefix, XPathNodeType nodeType) { this.prefix = prefix; this.queryInput = queryInput; this.name = name; this.nodeType = nodeType; }
internal XPathSelfQuery(IQuery queryInput, string name, string prefix, XPathNodeType type) : base(queryInput, name, prefix, type) { }
internal MethodOperand(IQuery opnd, FT funcType){ this.funcType = funcType; this.opnd = opnd; }
public DescendantQuery(IQuery qyInput, String name, String prefix, XPathNodeType type) : base(qyInput, name, prefix, type) { }
public NumberFunctions(IQuery qy) { _qy = qy; _FuncType = FT.FuncNumber; }
internal UnionQuery(IQuery query1, IQuery query2) { this.query1 = query1; this.query2 = query2; }
internal BooleanFunctions(IQuery qy) { _qy = qy; _FuncType = FT.FuncBoolean; }
internal FilterQuery(IQuery axisQuery, IQuery predicate) { base.QueryInput = ((BaseAxisQuery)axisQuery).QueryInput; this.predicate = predicate; this.axis = axisQuery; }