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.visualweb.gravy.model.project;
043:
044: import org.netbeans.modules.visualweb.gravy.Bundle;
045: import org.netbeans.modules.visualweb.gravy.model.Descriptor;
046:
047: import java.util.Hashtable;
048:
049: /**
050: * Descriptor for projects.
051: */
052:
053: public class ProjectDescriptor implements Descriptor {
054:
055: private final static String bundle = "org.netbeans.modules.visualweb.gravy.model.project.Bundle";
056:
057: public final static String J2EE13 = Bundle.getStringTrimmed(Bundle
058: .getStringTrimmed(bundle, "ProjectWizardBundle"), Bundle
059: .getStringTrimmed(bundle, "J2EE13"));
060:
061: public final static String J2EE14 = Bundle.getStringTrimmed(Bundle
062: .getStringTrimmed(bundle, "ProjectWizardBundle"), Bundle
063: .getStringTrimmed(bundle, "J2EE14"));
064:
065: public final static String JavaEE5 = Bundle.getStringTrimmed(Bundle
066: .getStringTrimmed(bundle, "ProjectWizardBundle"), Bundle
067: .getStringTrimmed(bundle, "JavaEE5"));
068:
069: /**
070: * Key for getting project's name property from properties.
071: */
072: public static final String NAME_KEY = "projectName";
073:
074: /**
075: * Key for getting project's location property from properties.
076: */
077: public static final String LOCATION_KEY = "projectLocation";
078:
079: /**
080: * Key for getting project's J2EE version property from properties.
081: */
082: public static final String J2EEVERSION_KEY = "J2EEVersion";
083:
084: /**
085: * Key for getting project's target server property from properties.
086: */
087: public static final String SERVER_KEY = "targetServer";
088:
089: /**
090: * Project's properties.
091: */
092: private Hashtable properties = new Hashtable();
093:
094: /**
095: * Create descriptor of the project with default J2EE version (1.4).
096: * @param projectName Name of the project.
097: * @param projectLocation Location of the project.
098: */
099: public ProjectDescriptor(String projectName, String projectLocation) {
100: this (projectName, projectLocation, J2EE14);
101: }
102:
103: /**
104: * Create descriptor of the project.
105: * @param projectName Name of the project.
106: * @param projectLocation Location of the project.
107: * @param J2EEVersion Version of J2EE (can be "J2EE 1.3", "J2EE 1.4", "Java EE 5").
108: */
109: public ProjectDescriptor(String projectName,
110: String projectLocation, String J2EEVersion) {
111: this (projectName, projectLocation, J2EEVersion, null);
112: }
113:
114: /**
115: * Create descriptor of the project.
116: * @param projectName Name of the project.
117: * @param projectLocation Location of the project.
118: * @param J2EEVersion Version of J2EE (can be "J2EE 1.3", "J2EE 1.4", "Java EE 5").
119: * @param targetServer Target Server for deploying of application.
120: */
121: public ProjectDescriptor(String projectName,
122: String projectLocation, String J2EEVersion,
123: String targetServer) {
124: properties.put(NAME_KEY, projectName);
125: properties.put(LOCATION_KEY, projectLocation);
126: properties.put(J2EEVERSION_KEY, J2EEVersion);
127: properties.put(SERVER_KEY, targetServer);
128: }
129:
130: /**
131: * Get project's properties.
132: * @return Hashtable of properties.
133: */
134: public Hashtable getProperties() {
135: return properties;
136: }
137:
138: /**
139: * Get value of specified project's property.
140: * @param propertyName Name of necessary property.
141: * @return String value of property.
142: */
143: public String getProperty(String propertyName) {
144: return properties.get(propertyName).toString();
145: }
146: }
|