KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xpath > impl > XPathExpressionPathImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * Created on Sep 12, 2005
22  *
23  * To change the template for this generated file go to
24  * Window - Preferences - Java - Code Generation - Code and Comments
25  */

26 package org.netbeans.modules.xml.xpath.impl;
27
28 import org.netbeans.modules.xml.xpath.LocationStep;
29 import org.netbeans.modules.xml.xpath.XPathExpression;
30 import org.netbeans.modules.xml.xpath.XPathExpressionPath;
31 import org.netbeans.modules.xml.xpath.visitor.XPathVisitor;
32 import org.netbeans.modules.xml.xpath.visitor.impl.ExpressionWriter;
33
34
35 /**
36  * @author radval
37  *
38  * To change the template for this generated type comment go to
39  * Window - Preferences - Java - Code Generation - Code and Comments
40  */

41 public class XPathExpressionPathImpl extends XPathExpressionImpl
42     implements XPathExpressionPath {
43     
44     /** The steps. */
45     private LocationStep[] mSteps;
46     
47     
48     private XPathExpression mRootExpression;
49     
50     /** The absolute flag; defaults to false. */
51     private boolean mAbsolute;
52
53     /** Flag to figure out if it is a simple path
54      * Recognized paths formatted as foo/bar[3]/baz[@name = 'biz'] .
55      */

56     private boolean mIsSimplePath;
57     
58     
59     /**
60      * Constructor.
61      * @param steps the steps
62      * @param isSimplePath flag whether path is simple
63      */

64     public XPathExpressionPathImpl(XPathExpression rootExpression,
65                                    LocationStep[] steps,
66                                    boolean isSimplePath) {
67         super();
68         setSteps(steps);
69         setRootExpression(rootExpression);
70         setSimplePath(isSimplePath);
71     }
72
73     /**
74      * Gets the steps of the location path.
75      * @return the steps
76      */

77     public LocationStep[] getSteps() {
78         return mSteps;
79     }
80     
81     
82     /**
83      * Sets the steps of the location path.
84      * @param steps the steps
85      */

86     public void setSteps(LocationStep[] steps) {
87         mSteps = steps;
88     }
89     
90     /**
91      * set root expression of this expression path.
92      * @param rootExpression root expression of this expression path.
93      */

94     public void setRootExpression(XPathExpression rootExpression) {
95         this.mRootExpression = rootExpression;
96     }
97     
98     /**
99      * get root expression of this expression path.
100      * @return root expression of this expression path
101      * @return root expression
102      */

103     public XPathExpression getRootExpression() {
104         return this.mRootExpression;
105     }
106     
107     /**
108      * Describe <code>isSimplePath</code> method here.
109      *
110      * @return a <code>boolean</code> value
111      */

112     public boolean isSimplePath() {
113         return mIsSimplePath;
114     }
115
116     /**
117      * Describe <code>setSimplePath</code> method here.
118      *
119      * @param isSimplePath a <code>boolean</code> value
120      */

121     public void setSimplePath(boolean isSimplePath) {
122         mIsSimplePath = isSimplePath;
123     }
124
125     /**
126      * get expression exclusing root expression
127      * @return
128      */

129     public String JavaDoc getExpressionStringExcludingRootExpression() {
130         XPathVisitor visitor = new ExpressionWriter();
131         LocationStep[] steps = getSteps();
132         if(steps != null) {
133             for(int i = 0; i < steps.length; i++) {
134                 visitor.visit(steps[i]);
135             }
136         }
137         
138         return ((ExpressionWriter) visitor).getString();
139     }
140     
141     /**
142      * Calls the visitor.
143      * @param visitor the visitor
144      */

145     public void accept(XPathVisitor visitor) {
146          visitor.visit(this);
147         
148     }
149 }
150
Popular Tags