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.support.umlsupport.XMLManip;
047: import org.netbeans.modules.uml.core.support.umlsupport.Log;
048:
049: /**
050: */
051: public class CreationEvent extends MethodDetailParserData implements
052: ICreationEvent {
053:
054: /* (non-Javadoc)
055: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.ICreationEvent#getREClass()
056: */
057: public IREClass getREClass() {
058: Node n = getXMLNode("UML:Class|UML:Interface|UML:Enumeration");
059: if (n != null) {
060: IREClass cl = new REClass();
061: cl.setEventData(getEventData());
062: return cl;
063: }
064: return null;
065: }
066:
067: /**
068: * Specifies whether or not the instance is a primitive data type.
069: *
070: * @param *pVal [out] true if a primitive, false otherwise.
071: */
072: public boolean getIsPrimitive() {
073: return Boolean.valueOf(getTokenDescriptorValue("IsPrimitive"))
074: .booleanValue();
075: }
076:
077: /* (non-Javadoc)
078: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.ICreationEvent#getIsStatic()
079: */
080: public boolean getIsStatic() {
081: // Ditto in C++ code.
082: return false;
083: }
084:
085: /**
086: * The instance name of the object.
087: *
088: * @param pVal [out] The name.
089: */
090: public String getInstanceName() {
091: Node outputPinNode = getXMLNode("UML:OutputPin");
092: return XMLManip.getAttributeValue(outputPinNode, "value");
093: }
094:
095: /**
096: * The type name of the instance. The instance type is the the
097: * type that was declared. As opposed to the instantiated type
098: * name which is the type that was used to create the object.
099: *
100: * Example: Foo f = new Bar();
101: *
102: * The instance name is Foo, instantiated type name is Bar
103: *
104: * <I>The instance name is Foo, instantiated type name is Bar
105: * Foo is the interface used when accessing the instance f.</I>
106: *
107: * @param pVal [out] The instance type name.
108: */
109: public String getInstanceTypeName() {
110: return XMLManip.getAttributeValue(getEventData(), "classifier");
111: }
112:
113: /**
114: * The instantiated type name of the instance. The instantiated
115: * type is the the type that was to create the instance.
116: * As opposed to the instance type name which is the type
117: * that was used when declaring the object.
118: *
119: * Example: Foo f = new Bar();
120: *
121: * <I>The instance name is Foo, instantiated type name is Bar
122: * Foo is the interface used when accessing the instance f.</I>
123: *
124: * @param *pVal [out] The instantiated type name.
125: */
126: public String getInstantiatedTypeName() {
127: return getDescriptorValue("InstantiatedTypeName");
128: }
129:
130: public IREClass getDeclaringClass() {
131: IREClass pClass = null;
132: try {
133: Node pParentNode = getXMLNode("DeclaringClass");
134: if (pParentNode != null) {
135: String query = "UML:Class|UML:Interface|UML:Enumeration";
136: Node pNode = pParentNode.selectSingleNode(query);
137: if (pNode != null) {
138: pClass = new REClass();
139: if (pClass != null) {
140: pClass.setEventData(pNode);
141: return pClass;
142: }
143: }
144: }
145: } catch (Exception e) {
146: Log.stackTrace(e);
147: }
148: return pClass;
149: }
150:
151: public IREOperation getConstructor() {
152: IREOperation pOper = null;
153: try {
154: Node pNode = getXMLNode("UML:Operation");
155: if (pNode != null) {
156: pOper = new REOperation();
157: if (pOper != null) {
158: pOper.setEventData(pNode);
159: return pOper;
160: }
161: }
162: } catch (Exception e) {
163: Log.stackTrace(e);
164: }
165: return pOper;
166: }
167:
168: }
|