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.uml.core.reverseengineering.reframework;
043:
044: import org.dom4j.Node;
045:
046: import org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.TokenDescriptor;
047: import org.netbeans.modules.uml.core.support.umlsupport.XMLManip;
048:
049: /**
050: */
051: public class XMLTokenDescriptor extends TokenDescriptor implements
052: IXMLTokenDescriptor {
053: private Node m_TokenDescriptorsNode;
054:
055: /* (non-Javadoc)
056: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IXMLTokenDescriptor#getTokenDescriptorNode()
057: */
058: public Node getTokenDescriptorNode() {
059: return m_TokenDescriptorsNode;
060: }
061:
062: /* (non-Javadoc)
063: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IXMLTokenDescriptor#setTokenDescriptorNode(org.dom4j.Node)
064: */
065: public void setTokenDescriptorNode(Node newVal) {
066: m_TokenDescriptorsNode = newVal;
067: }
068:
069: /**
070: * Retrieves an int attribute from the XML node that represents the descriptor.
071: * @param name [in] The attribute to retrieve.
072: * @param pVal [out] The value.
073: */
074: protected int getIntAttribute(String name) {
075: return XMLManip.getAttributeIntValue(m_TokenDescriptorsNode,
076: name);
077: }
078:
079: /**
080: * Sets an int attribute to the XML node that represents the descriptor.
081: * @param name [in] The attribute to set.
082: * @param pVal [out] The value.
083: */
084: protected void setIntAttribute(String name, int val) {
085: XMLManip.setAttributeValue(m_TokenDescriptorsNode, name, String
086: .valueOf(val));
087: }
088:
089: protected String getAttribute(String name) {
090: return XMLManip.getAttributeValue(m_TokenDescriptorsNode, name);
091: }
092:
093: protected void setAttribute(String name, String value) {
094: XMLManip.setAttributeValue(m_TokenDescriptorsNode, name, value);
095: }
096:
097: /* (non-Javadoc)
098: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setLine(int)
099: */
100: public void setLine(int value) {
101: setIntAttribute("line", value);
102: }
103:
104: /* (non-Javadoc)
105: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getLine()
106: */
107: public int getLine() {
108: return getIntAttribute("line");
109: }
110:
111: /* (non-Javadoc)
112: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setColumn(int)
113: */
114: public void setColumn(int value) {
115: setIntAttribute("column", value);
116: }
117:
118: /* (non-Javadoc)
119: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getColumn()
120: */
121: public int getColumn() {
122: return getIntAttribute("column");
123: }
124:
125: /* (non-Javadoc)
126: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setPosition(int)
127: */
128: public void setPosition(int value) {
129: setIntAttribute("position", value);
130: }
131:
132: /* (non-Javadoc)
133: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getPosition()
134: */
135: public long getPosition() {
136: return getIntAttribute("position");
137: }
138:
139: /* (non-Javadoc)
140: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setType(java.lang.String)
141: */
142: public void setType(String value) {
143: setAttribute("type", value);
144: }
145:
146: /* (non-Javadoc)
147: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getType()
148: */
149: public String getType() {
150: return getAttribute("type");
151: }
152:
153: /* (non-Javadoc)
154: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setValue(java.lang.String)
155: */
156: public void setValue(String value) {
157: setAttribute("value", value);
158: }
159:
160: /* (non-Javadoc)
161: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getValue()
162: */
163: public String getValue() {
164: return getAttribute("value");
165: }
166:
167: /* (non-Javadoc)
168: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#setLength(int)
169: */
170: public void setLength(int value) {
171: setIntAttribute("length", value);
172: }
173:
174: /* (non-Javadoc)
175: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.parsingframework.ITokenDescriptor#getLength()
176: */
177: public int getLength() {
178: return getIntAttribute("length");
179: }
180: }
|