001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.xpath.impl;
043:
044: import org.netbeans.modules.xml.xpath.LocationStep;
045: import org.netbeans.modules.xml.xpath.XPathLocationPath;
046: import org.netbeans.modules.xml.xpath.visitor.XPathVisitable;
047: import org.netbeans.modules.xml.xpath.visitor.XPathVisitor;
048:
049: /**
050: * @todo PUT DESCRIPTION HERE
051: *
052: * @author Enrico Lelina
053: * @version
054: */
055: public class XPathLocationPathImpl extends XPathExpressionImpl
056: implements XPathLocationPath {
057:
058: /** The steps. */
059: LocationStep[] mSteps;
060:
061: /** The absolute flag; defaults to false. */
062: boolean mAbsolute;
063:
064: /** Flag to figure out if it is a simple path
065: * Recognized paths formatted as foo/bar[3]/baz[@name = 'biz'] .
066: */
067: private boolean mIsSimplePath;
068:
069: /**
070: * Constructor.
071: * @param steps the steps
072: */
073: public XPathLocationPathImpl(LocationStep[] steps) {
074: this (steps, false, true);
075: }
076:
077: /**
078: * Constructor.
079: * @param steps the steps
080: * @param absolute flag
081: * @param isSimplePath flag whether path is simple
082: */
083: public XPathLocationPathImpl(LocationStep[] steps,
084: boolean absolute, boolean isSimplePath) {
085: super ();
086: setSteps(steps);
087: setAbsolute(absolute);
088: mIsSimplePath = isSimplePath;
089: }
090:
091: /**
092: * Gets the flag the tells whether this is an absolute path or not.
093: * @return flag
094: */
095: public boolean getAbsolute() {
096: return mAbsolute;
097: }
098:
099: /**
100: * Sets the flag that tells whether this is an absolute path or not.
101: * @param absolute flag
102: */
103: public void setAbsolute(boolean absolute) {
104: mAbsolute = absolute;
105: }
106:
107: /**
108: * Gets the steps of the location path.
109: * @return the steps
110: */
111: public LocationStep[] getSteps() {
112: return mSteps;
113: }
114:
115: /**
116: * Sets the steps of the location path.
117: * @param steps the steps
118: */
119: public void setSteps(LocationStep[] steps) {
120: mSteps = steps;
121: }
122:
123: /**
124: * Describe <code>isSimplePath</code> method here.
125: *
126: * @return a <code>boolean</code> value
127: */
128: public boolean isSimplePath() {
129: return mIsSimplePath;
130: }
131:
132: /**
133: * Describe <code>setSimplePath</code> method here.
134: *
135: * @param isSimplePath a <code>boolean</code> value
136: */
137: public void setSimplePath(boolean isSimplePath) {
138: mIsSimplePath = isSimplePath;
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: }
|