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.soa.mapper.basicmapper.methoid;
021:
022: import java.util.Collections;
023: import java.util.List;
024: import java.util.Vector;
025:
026: import javax.swing.Icon;
027:
028: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IField;
029: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IMethoid;
030:
031: /**
032: * <p>
033: *
034: * Title:BasicMethoid </p> <p>
035: *
036: * Description: BasicMethoid implements IMethoid to provide basic
037: * functionalities as a methoid. </p> <p>
038: *
039: * Copyright: Copyright (c) 2002 </p> <p>
040: *
041: * Company: </p>
042: *
043: * @author Un Seng Leong
044: * @created December 26, 2002
045: * @version 1.0
046: */
047: public class BasicMethoid implements IMethoid {
048:
049: /**
050: * the data object of this methoid.
051: */
052: private Object mData;
053:
054: /**
055: * the icon of this methoid
056: */
057: private Icon mIcon;
058:
059: /**
060: * storage of the input fields.
061: */
062: private List mInput;
063:
064: /**
065: * the name of this methoid
066: */
067: private String mName;
068:
069: /**
070: * the namespace field of this methoid.
071: */
072: private IField mNamespace;
073:
074: /**
075: * storage of the output fields.
076: */
077: private List mOutput;
078:
079: /**
080: * storge of PropertyChangeListener of this field
081: */
082: private List mPropertyListeners;
083:
084: /**
085: * the tooltip of this methoid
086: */
087: private String mTooltip;
088:
089: /**
090: * if the methoid input can grow
091: */
092: private boolean mIsAccumulative;
093:
094: /**
095: * if the methoid is a literal
096: */
097: private boolean mIsLiteral;
098:
099: /**
100: * Construct a methoid object with specified all properties.
101: *
102: * @param icon the icon of this methoid.
103: * @param name the name of this funcotid.
104: * @param tooltip the tooltip of this methoid.
105: * @param data the data of this methoid.
106: * @param namespace the namespace of this methoid.
107: * @param inputFields the input fields of this methoid.
108: * @param outputFields the output fields of this methoid.
109: * @param isAccumulative whether the input fields can grow dynamically
110: */
111: public BasicMethoid(Icon icon, String name, String tooltip,
112: Object data, IField namespace, List inputFields,
113: List outputFields, boolean isAccumulative, boolean isLiteral) {
114: this .mIcon = icon;
115: this .mName = name;
116: this .mTooltip = tooltip;
117: this .mData = data;
118: this .mNamespace = namespace;
119: this .mIsAccumulative = isAccumulative;
120: this .mIsLiteral = isLiteral;
121:
122: if (inputFields == null) {
123: this .mInput = new Vector();
124: } else {
125: this .mInput = new Vector(inputFields);
126: }
127:
128: if (outputFields == null) {
129: this .mOutput = new Vector();
130: } else {
131: this .mOutput = new Vector(outputFields);
132: }
133: }
134:
135: /**
136: * Return the data object of this methoid.
137: *
138: * @return the data object of this methoid.
139: */
140: public Object getData() {
141: return mData;
142: }
143:
144: public void setData(Object data) {
145: mData = data;
146: }
147:
148: /**
149: * Return the icon of this methoid.
150: *
151: * @return the icon of this methoid
152: */
153: public Icon getIcon() {
154: return mIcon;
155: }
156:
157: public void setIcon(Icon icon) {
158: mIcon = icon;
159: }
160:
161: /**
162: * Retrun the index of the specified field in this funcotid input fields.
163: *
164: * @param field the field to be matched.
165: * @return the index of the specified field.
166: */
167: public int getIndexOfInputField(IField field) {
168: return mInput.indexOf(field);
169: }
170:
171: /**
172: * Retrun the index of the specified field in this funcotid output fields.
173: *
174: * @param field the field to be matched.
175: * @return the index of the specified field.
176: */
177: public int getIndexOfOutputField(IField field) {
178: return mInput.indexOf(mOutput);
179: }
180:
181: /**
182: * Return the input fields of this methoid.
183: *
184: * @return the input fields of this methoid.
185: */
186: public List getInput() {
187: return Collections.unmodifiableList(mInput);
188: }
189:
190: /**
191: * Return the number of input fields in this methoid.
192: *
193: * @return the number of input fields in this methoid.
194: */
195: public int getInputCount() {
196: return mInput.size();
197: }
198:
199: /**
200: * Return the name of this methoid.
201: *
202: * @return the name of this methoid.
203: */
204: public String getName() {
205: return mName;
206: }
207:
208: public void setName(String name) {
209: mName = name;
210: }
211:
212: /**
213: * Return the namespace field of this methoid.
214: *
215: * @return the namespace field of this methoid.
216: */
217: public IField getNamespace() {
218: return mNamespace;
219: }
220:
221: /**
222: * Return the output fields of this methoid.
223: *
224: * @return the output fields of this methoid.
225: */
226: public List getOutput() {
227: return Collections.unmodifiableList(mOutput);
228: }
229:
230: /**
231: * Return the number of output fields in this methoid.
232: *
233: * @return the number of output fields in this methoid.
234: */
235: public int getOutputCount() {
236: return mOutput.size();
237: }
238:
239: /**
240: * Return the tooltip text of this methoid.
241: *
242: * @return the tooltip text of this methoid.
243: */
244: public String getToolTipText() {
245: return mTooltip;
246: }
247:
248: public void setToolTipText(String text) {
249: mTooltip = text;
250: }
251:
252: public boolean isAccumulative() {
253: return mIsAccumulative;
254: }
255:
256: public boolean isLiteral() {
257: return mIsLiteral;
258: }
259: }
|