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.umlutils.ETList;
048:
049: /**
050: */
051: public class MethodEvent extends MethodDetailParserData implements
052: IMethodEvent {
053: /* (non-Javadoc)
054: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getDeclaringClassName()
055: */
056: public String getDeclaringClassName() {
057: IREClass rec = getREClass();
058: return rec != null ? rec.getName()
059: : getTokenDescriptorValue("DeclaringType");
060: }
061:
062: public String getFullQNameOfOwner() {
063:
064: String retVal = null;
065: IREClass rec = getREClass();
066:
067: if (rec != null) {
068: retVal = rec.getPackage();
069: retVal += "::";
070: retVal += rec.getName();
071: }
072:
073: return retVal;
074: }
075:
076: /* (non-Javadoc)
077: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getArguments()
078: */
079: public ETList<IREArgument> getArguments() {
080: REXMLCollection<IREArgument> args = new REXMLCollection<IREArgument>(
081: REArgument.class,
082: "UML:PrimitiveAction.argument/UML:InputPin");
083: try {
084: args.setDOMNode(getEventData());
085: } catch (Exception e) {
086: e.printStackTrace();
087: }
088: return args;
089: }
090:
091: /* (non-Javadoc)
092: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getResult()
093: */
094: public String getResult() {
095: Node n = getXMLNode("UML:Operation/UML:Element.ownedElement/"
096: + "UML:Parameter[@direction='result']");
097: return n != null ? XMLManip.getAttributeValue(n, "type") : null;
098: }
099:
100: /* (non-Javadoc)
101: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getInstanceName()
102: */
103: public String getInstanceName() {
104: return XMLManip.getAttributeValue(getEventData(), "instance");
105: }
106:
107: /* (non-Javadoc)
108: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getMethodName()
109: */
110: public String getMethodName() {
111: return XMLManip.getAttributeValue(getEventData(), "name");
112: }
113:
114: /* (non-Javadoc)
115: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getREClass()
116: */
117: public IREClass getREClass() {
118: Node node = getXMLNode("UML:Class|UML:Interface|UML:Enumeration");
119: if (node != null) {
120: IREClass cl = new REClass();
121: cl.setEventData(node);
122: return cl;
123: }
124: return null;
125: }
126:
127: /* (non-Javadoc)
128: * @see org.netbeans.modules.uml.core.reverseengineering.reframework.IMethodEvent#getOperation()
129: */
130: public IREOperation getOperation() {
131: Node n = getXMLNode("UML:Operation");
132: if (n != null) {
133: IREOperation op = new REOperation();
134: op.setEventData(n);
135: return op;
136: }
137: return null;
138: }
139: }
|