001: /*
002: * Copyright 1999-2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.jxpath.ri;
017:
018: import java.util.Iterator;
019:
020: import org.apache.commons.jxpath.ri.compiler.Expression;
021: import org.apache.commons.jxpath.CompiledExpression;
022: import org.apache.commons.jxpath.JXPathContext;
023: import org.apache.commons.jxpath.Pointer;
024:
025: /**
026: *
027: *
028: * @author Dmitri Plotnikov
029: * @version $Revision: 1.9 $ $Date: 2004/02/29 14:17:45 $
030: */
031: public class JXPathCompiledExpression implements CompiledExpression {
032:
033: private String xpath;
034: private Expression expression;
035:
036: public JXPathCompiledExpression(String xpath, Expression expression) {
037: this .xpath = xpath;
038: this .expression = expression;
039: }
040:
041: protected String getXPath() {
042: return xpath;
043: }
044:
045: protected Expression getExpression() {
046: return expression;
047: }
048:
049: public String toString() {
050: return xpath;
051: }
052:
053: /**
054: * @see CompiledExpression#getValue(JXPathContext)
055: */
056: public Object getValue(JXPathContext context) {
057: return ((JXPathContextReferenceImpl) context).getValue(xpath,
058: expression);
059: }
060:
061: /**
062: * @see CompiledExpression#getValue(JXPathContext, Class)
063: */
064: public Object getValue(JXPathContext context, Class requiredType) {
065: return ((JXPathContextReferenceImpl) context).getValue(xpath,
066: expression, requiredType);
067: }
068:
069: /**
070: * @see CompiledExpression#setValue(JXPathContext, Object)
071: */
072: public void setValue(JXPathContext context, Object value) {
073: ((JXPathContextReferenceImpl) context).setValue(xpath,
074: expression, value);
075: }
076:
077: /**
078: * @see CompiledExpression#createPath(JXPathContext)
079: */
080: public Pointer createPath(JXPathContext context) {
081: return ((JXPathContextReferenceImpl) context).createPath(xpath,
082: expression);
083: }
084:
085: /**
086: * @see CompiledExpression#createPathAndSetValue(JXPathContext, Object)
087: */
088: public Pointer createPathAndSetValue(JXPathContext context,
089: Object value) {
090: return ((JXPathContextReferenceImpl) context)
091: .createPathAndSetValue(xpath, expression, value);
092: }
093:
094: /**
095: * @see CompiledExpression#iterate(JXPathContext)
096: */
097: public Iterator iterate(JXPathContext context) {
098: return ((JXPathContextReferenceImpl) context).iterate(xpath,
099: expression);
100: }
101:
102: /**
103: * @see CompiledExpression#getPointer(JXPathContext, String)
104: */
105: public Pointer getPointer(JXPathContext context, String xpath) {
106: return ((JXPathContextReferenceImpl) context).getPointer(xpath,
107: expression);
108: }
109:
110: /**
111: * @see CompiledExpression#iteratePointers(JXPathContext)
112: */
113: public Iterator iteratePointers(JXPathContext context) {
114: return ((JXPathContextReferenceImpl) context).iteratePointers(
115: xpath, expression);
116: }
117:
118: /**
119: * @see CompiledExpression#removePath(JXPathContext)
120: */
121: public void removePath(JXPathContext context) {
122: ((JXPathContextReferenceImpl) context).removePath(xpath,
123: expression);
124: }
125:
126: /**
127: * @see CompiledExpression#removeAll(JXPathContext)
128: */
129: public void removeAll(JXPathContext context) {
130: ((JXPathContextReferenceImpl) context).removeAll(xpath,
131: expression);
132: }
133: }
|