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.compapp.javaee.sunresources.tool.cmap;
043:
044: import java.util.ArrayList;
045: import java.util.Enumeration;
046: import java.util.Properties;
047:
048: /**
049: * @author echou
050: *
051: */
052: public class CMapNode {
053:
054: public enum CMapNodeType {
055: STATELESS, STATEFUL, MDB, SERVLET, RESOURCE
056: }
057:
058: protected String logicalName;
059: protected String cls; // class of this node
060: protected CMapNodeType type;
061: private Properties props = new Properties();
062: private ArrayList<EJBDepend> ejbDepends = new ArrayList<EJBDepend>();
063: private ArrayList<ResourceDepend> resDepends = new ArrayList<ResourceDepend>();
064:
065: public CMapNode() {
066: // default constructor
067: }
068:
069: public CMapNode(String logicalName, String cls, CMapNodeType type) {
070: this .logicalName = logicalName;
071: this .cls = cls;
072: this .type = type;
073: }
074:
075: public CMapNode(String cls, CMapNodeType type) {
076: this ("", cls, type); // NOI18N
077: }
078:
079: public CMapNodeType getType() {
080: return type;
081: }
082:
083: public void setType(CMapNodeType type) {
084: this .type = type;
085: }
086:
087: public Properties getProps() {
088: return this .props;
089: }
090:
091: public ArrayList<EJBDepend> getEjbDepends() {
092: return this .ejbDepends;
093: }
094:
095: public ArrayList<ResourceDepend> getResDepends() {
096: return this .resDepends;
097: }
098:
099: public String getNodeClass() {
100: return this .cls;
101: }
102:
103: public void setNodeClass(String cls) {
104: this .cls = cls;
105: }
106:
107: public String getLogicalName() {
108: return this .logicalName;
109: }
110:
111: public void setLogicalName(String logicalName) {
112: this .logicalName = logicalName;
113: }
114:
115: @Override
116: public String toString() {
117: StringBuffer sb = new StringBuffer();
118: sb.append("@" + this .hashCode() + ", "); // NOI18N
119: sb.append("logicalName=" + logicalName + ", "); // NOI18N
120: sb.append("type=" + type + ", "); // NOI18N
121: sb.append("class=" + cls + "\n"); // NOI18N
122: sb.append("\tprops=" + props + "\n"); // NOI18N
123: sb.append("\tejbDepends=" + ejbDepends + "\n"); // NOI18N
124: sb.append("\tresDepends=" + resDepends + "\n"); // NOI18N
125: return sb.toString();
126: }
127:
128: protected void mergeProperties(Properties input, boolean overwrite) {
129: for (Enumeration<?> e = input.propertyNames(); e
130: .hasMoreElements();) {
131: String key = (String) e.nextElement();
132: if (overwrite || this.props.getProperty(key) == null) {
133: this.props.setProperty(key, input.getProperty(key));
134: }
135: }
136: }
137: }
|