Source Code Cross Referenced for LocationStepImpl.java in  » IDE-Netbeans » xml » org » netbeans » modules » xml » xpath » ext » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » xml » org.netbeans.modules.xml.xpath.ext.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        package org.netbeans.modules.xml.xpath.ext.impl;
021:
022:        import javax.xml.namespace.QName;
023:        import org.netbeans.modules.xml.xpath.ext.LocationStep;
024:        import org.netbeans.modules.xml.xpath.ext.StepNodeTest;
025:        import org.netbeans.modules.xml.xpath.ext.StepNodeNameTest;
026:        import org.netbeans.modules.xml.xpath.ext.StepNodeTypeTest;
027:        import org.netbeans.modules.xml.xpath.ext.XPathUtils;
028:        import org.netbeans.modules.xml.xpath.ext.XPathAxis;
029:        import org.netbeans.modules.xml.xpath.ext.XPathModel;
030:        import org.netbeans.modules.xml.xpath.ext.XPathPredicateExpression;
031:        import org.netbeans.modules.xml.xpath.ext.XPathSchemaContext;
032:        import org.netbeans.modules.xml.xpath.ext.visitor.XPathVisitor;
033:
034:        /**
035:         * Represents a location path step.
036:         * 
037:         * @author Enrico Lelina
038:         * @author nk160297
039:         * @version 
040:         */
041:        public class LocationStepImpl extends XPathExpressionImpl implements 
042:                LocationStep {
043:
044:            private static XPathAxis[] int2Axis = new XPathAxis[] {
045:                    XPathAxis.SELF, XPathAxis.CHILD, XPathAxis.PARENT,
046:                    XPathAxis.ANCESTOR, XPathAxis.ATTRIBUTE,
047:                    XPathAxis.NAMESPACE, XPathAxis.PRECEDING,
048:                    XPathAxis.FOLLOWING, XPathAxis.DESCENDANT,
049:                    XPathAxis.ANCESTOR_OR_SELF, XPathAxis.DESCENDANT_OR_SELF,
050:                    XPathAxis.FOLLOWING_SIBLING, XPathAxis.PRECEDING_SIBLING };
051:
052:            /** The axis. */
053:            private XPathAxis mAxis;
054:
055:            /** The node test. */
056:            private StepNodeTest mNodeTest;
057:
058:            /** predicates */
059:            private XPathPredicateExpression[] mPredicates = null;
060:
061:            private XPathSchemaContext mSchemaContext;
062:
063:            /** Constructor. */
064:            public LocationStepImpl(XPathModel model) {
065:                this (model, 0, null, null);
066:            }
067:
068:            /**
069:             * Constructor.
070:             * @param axis the axis
071:             * @param nodeTest the node test
072:             */
073:            public LocationStepImpl(XPathModel model, int axis,
074:                    StepNodeTest nodeTest, XPathPredicateExpression[] predicates) {
075:                super (model);
076:                assert axis < int2Axis.length : "The index of axis " + axis
077:                        + " is out of possible values"; // NOI18N
078:                //
079:                setAxis(int2Axis[axis - 1]);
080:                setNodeTest(nodeTest);
081:                setPredicates(predicates);
082:            }
083:
084:            /**
085:             * Constructor.
086:             * @param axis the axis
087:             * @param nodeTest the node test
088:             */
089:            public LocationStepImpl(XPathModel model, XPathAxis axis,
090:                    StepNodeTest nodeTest, XPathPredicateExpression[] predicates) {
091:                super (model);
092:                //
093:                if (axis == null) {
094:                    axis = XPathAxis.CHILD;
095:                }
096:                //
097:                setAxis(axis);
098:                setNodeTest(nodeTest);
099:                setPredicates(predicates);
100:            }
101:
102:            /**
103:             * Gets the axis.
104:             * @return the axis
105:             */
106:            public XPathAxis getAxis() {
107:                return mAxis;
108:            }
109:
110:            /**
111:             * Sets the axis.
112:             * @param axis the axis
113:             */
114:            public void setAxis(XPathAxis axis) {
115:                mAxis = axis;
116:            }
117:
118:            /**
119:             * Gets the node test.
120:             * @return the node test
121:             */
122:            public StepNodeTest getNodeTest() {
123:                return mNodeTest;
124:            }
125:
126:            /**
127:             * Sets the node test.
128:             * @param nodeTest the node test
129:             */
130:            public void setNodeTest(StepNodeTest nodeTest) {
131:                mNodeTest = nodeTest;
132:            }
133:
134:            /**
135:             * Gets the Predicates
136:             * @return the predicates
137:             */
138:            public XPathPredicateExpression[] getPredicates() {
139:                return mPredicates;
140:            }
141:
142:            /**
143:             * Sets the Predicates
144:             * @param predicates list of predicates
145:             */
146:            public void setPredicates(XPathPredicateExpression[] predicates) {
147:                mPredicates = predicates;
148:            }
149:
150:            /**
151:             * Gets the string representation.
152:             * @return the string representation
153:             */
154:            public String getString() {
155:                StringBuilder sb = new StringBuilder();
156:                //
157:                StepNodeTest nodeTest = getNodeTest();
158:                if (nodeTest instanceof  StepNodeNameTest) {
159:                    sb.append(getAxis().getShortForm());
160:                    //
161:                    StepNodeNameTest snnt = (StepNodeNameTest) nodeTest;
162:                    if (snnt.isWildcard()) {
163:                        sb.append("*"); // NOI18N
164:                    } else {
165:                        QName nodeName = ((StepNodeNameTest) nodeTest)
166:                                .getNodeName();
167:                        sb.append(XPathUtils.qNameObjectToString(nodeName));
168:                    }
169:                } else if (nodeTest instanceof  StepNodeTypeTest) {
170:                    StepNodeTypeTest sntt = (StepNodeTypeTest) nodeTest;
171:                    switch (sntt.getNodeType()) {
172:                    case NODETYPE_NODE:
173:                        switch (getAxis()) {
174:                        case CHILD: // it means that the location step is "node()"
175:                            sb.append(sntt.getXPathText());
176:                            break;
177:                        case SELF: // it means that the location step is abbreviated step "."
178:                            sb.append("."); // NOI18N
179:                            break;
180:                        case PARENT: // it means that the location step is abbreviated step ".."
181:                            sb.append(".."); // NOI18N
182:                            break;
183:                        case DESCENDANT_OR_SELF: // it means that the location step is abbreviated step "//"
184:                            // It doesn't necessary to append anything here because 
185:                            // the double slash "//" abbreviated step is a kind of "empty" step.
186:                            // It is a step without a content between two slashes.
187:                            break;
188:                        default:
189:                            // other axis are not supported here
190:                        }
191:                        break;
192:                    case NODETYPE_COMMENT:
193:                    case NODETYPE_PI:
194:                    case NODETYPE_TEXT:
195:                        sb.append(sntt.getXPathText());
196:                        break;
197:                    }
198:                }
199:                //
200:                return sb.toString();
201:            }
202:
203:            @Override
204:            public void accept(XPathVisitor visitor) {
205:                visitor.visit(this );
206:            }
207:
208:            public XPathSchemaContext getSchemaContext() {
209:                if (mSchemaContext == null) {
210:                    if (myModel.getRootExpression() != null) {
211:                        myModel.resolveExtReferences(false);
212:                    } else {
213:                        myModel.resolveExpressionExtReferences(this );
214:                    }
215:                }
216:                return mSchemaContext;
217:            }
218:
219:            public void setSchemaContext(XPathSchemaContext newContext) {
220:                mSchemaContext = newContext;
221:            }
222:
223:            @Override
224:            public String toString() {
225:                return getString();
226:            }
227:
228:            @Override
229:            public boolean equals(Object obj) {
230:                if (obj instanceof  LocationStep) {
231:                    //
232:                    // Compare Node Test
233:                    LocationStep step2 = (LocationStep) obj;
234:                    StepNodeTest snt2 = step2.getNodeTest();
235:                    if (!snt2.equals(mNodeTest)) {
236:                        return false;
237:                    }
238:                    //
239:                    // Compare Axis
240:                    if (step2.getAxis() != mAxis) {
241:                        return false;
242:                    }
243:                    //
244:                    // Compare predicates
245:                    XPathPredicateExpression[] predicates2 = step2
246:                            .getPredicates();
247:                    if (!XPathUtils.samePredicatesArr(mPredicates, predicates2)) {
248:                        return false;
249:                    }
250:                    //
251:                    return true;
252:                }
253:                return false;
254:            }
255:        }
w_w_w__.ja_v___a__2s__.__c_o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.