001: /*****************************************************************************
002: * Java Plug-in Framework (JPF)
003: * Copyright (C) 2007 Dmitry Olshansky
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *****************************************************************************/package org.java.plugin.registry;
019:
020: /**
021: * Parameter definition type constants.
022: */
023: public enum ParameterType {
024: /**
025: * Parameter definition type constant.
026: */
027: STRING {
028: /**
029: * @see org.java.plugin.registry.ParameterType#toCode()
030: */
031: @Override
032: public String toCode() {
033: return "string"; //$NON-NLS-1$
034: }
035: },
036:
037: /**
038: * Parameter definition type constant.
039: */
040: BOOLEAN {
041: /**
042: * @see org.java.plugin.registry.ParameterType#toCode()
043: */
044: @Override
045: public String toCode() {
046: return "boolean"; //$NON-NLS-1$
047: }
048: },
049:
050: /**
051: * Parameter definition type constant.
052: */
053: NUMBER {
054: /**
055: * @see org.java.plugin.registry.ParameterType#toCode()
056: */
057: @Override
058: public String toCode() {
059: return "number"; //$NON-NLS-1$
060: }
061: },
062:
063: /**
064: * Parameter definition type constant.
065: */
066: DATE {
067: /**
068: * @see org.java.plugin.registry.ParameterType#toCode()
069: */
070: @Override
071: public String toCode() {
072: return "date"; //$NON-NLS-1$
073: }
074: },
075:
076: /**
077: * Parameter definition type constant.
078: */
079: TIME {
080: /**
081: * @see org.java.plugin.registry.ParameterType#toCode()
082: */
083: @Override
084: public String toCode() {
085: return "time"; //$NON-NLS-1$
086: }
087: },
088:
089: /**
090: * Parameter definition type constant.
091: */
092: DATE_TIME {
093: /**
094: * @see org.java.plugin.registry.ParameterType#toCode()
095: */
096: @Override
097: public String toCode() {
098: return "date-time"; //$NON-NLS-1$
099: }
100: },
101:
102: /**
103: * Parameter definition type constant.
104: */
105: NULL {
106: /**
107: * @see org.java.plugin.registry.ParameterType#toCode()
108: */
109: @Override
110: public String toCode() {
111: return "null"; //$NON-NLS-1$
112: }
113: },
114:
115: /**
116: * Parameter definition type constant.
117: */
118: ANY {
119: /**
120: * @see org.java.plugin.registry.ParameterType#toCode()
121: */
122: @Override
123: public String toCode() {
124: return "any"; //$NON-NLS-1$
125: }
126: },
127:
128: /**
129: * Parameter definition type constant.
130: */
131: PLUGIN_ID {
132: /**
133: * @see org.java.plugin.registry.ParameterType#toCode()
134: */
135: @Override
136: public String toCode() {
137: return "plugin-id"; //$NON-NLS-1$
138: }
139: },
140:
141: /**
142: * Parameter definition type constant.
143: */
144: EXTENSION_POINT_ID {
145: /**
146: * @see org.java.plugin.registry.ParameterType#toCode()
147: */
148: @Override
149: public String toCode() {
150: return "extension-point-id"; //$NON-NLS-1$
151: }
152: },
153:
154: /**
155: * Parameter definition type constant.
156: */
157: EXTENSION_ID {
158: /**
159: * @see org.java.plugin.registry.ParameterType#toCode()
160: */
161: @Override
162: public String toCode() {
163: return "extension-id"; //$NON-NLS-1$
164: }
165: },
166:
167: /**
168: * Parameter definition type constant.
169: */
170: FIXED {
171: /**
172: * @see org.java.plugin.registry.ParameterType#toCode()
173: */
174: @Override
175: public String toCode() {
176: return "fixed"; //$NON-NLS-1$
177: }
178: },
179:
180: /**
181: * Parameter definition type constant.
182: */
183: RESOURCE {
184: /**
185: * @see org.java.plugin.registry.ParameterType#toCode()
186: */
187: @Override
188: public String toCode() {
189: return "resource"; //$NON-NLS-1$
190: }
191: };
192:
193: /**
194: * @return constant code to be used in plug-in manifest
195: */
196: public abstract String toCode();
197:
198: /**
199: * Converts plug-in manifest string code to parameter type constant value.
200: * @param code code from plug-in manifest
201: * @return parameter type constant value
202: */
203: public static ParameterType fromCode(final String code) {
204: for (ParameterType item : ParameterType.values()) {
205: if (item.toCode().equals(code)) {
206: return item;
207: }
208: }
209: throw new IllegalArgumentException(
210: "unknown parameter type code " + code); //$NON-NLS-1$
211: }
212: }
|