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-2006 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: /*
043: * CLDCPlatformDescriptor.java
044: *
045: */
046: package org.netbeans.spi.mobility.cldcplatform;
047:
048: import java.util.Collections;
049: import java.util.List;
050:
051: /**
052: * CLDCPlatformDescriptor is used to describe a platform detected by CustomCLDCPlatformConfigurator.
053: * This class is only a holder of information about platform type, devices, classpath, command lines, etc...
054: * @author Adam Sotona
055: */
056: public final class CLDCPlatformDescriptor {
057:
058: /**
059: * CLDC Platform Device Profile Types Enumeration.
060: */
061: public static enum ProfileType {
062: /**
063: * Device Configuration (f.ex.: CLDC)
064: */
065: Configuration,
066: /**
067: * Device Profile (f.ex.: MIDP)
068: */
069: Profile,
070: /**
071: * Device Optional API (f.ex.: MMAPI)
072: */
073: Optional
074: };
075:
076: /**
077: * Display name of the platform.
078: * May never be null.
079: */
080: public final String displayName;
081: /**
082: * Home directory of the platform.
083: * May never be null.
084: */
085: public final String home;
086: /**
087: * Type of the platform (currently supported types are UEI-1.0, UEI-1.0.1, and CUSTOM).
088: * It is likely that CustomCLDCPlatformConfgigurator will provide CUSTOM platform type with all the necessary information to use the platform.
089: * May never be null.
090: */
091: public final String type;
092: /**
093: * Comma-separated list of platform source roots. Each of the root can be defined as a relative path prefixed with ${platform.home}
094: * Definition of source roots is optional and most of the platforms are provided without sources available however it is usefull for Java development to have direct access to all sources.
095: */
096: public final String srcPath;
097: /**
098: * Comma-separated list of platform JavaDoc roots (might also include zip and jar files with the platform JavaDoc). Each of the root can be defined as a relative path prefixed with ${platform.home}
099: * Definition of JavaDoc roots is optional however it is usefull for Java development to have direct access to JavaDoc.
100: */
101: public final String docPath;
102: /**
103: * Definition of preverify command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
104: *
105: * Sample preverify command line for all UEI compatible platforms is:
106: * "{platformhome}{/}bin{/}preverify" {classpath|-classpath "{classpath}"} -d "{destdir}" "{srcdir}"
107: *
108: * Parameters:
109: * platformhome - platform home filled above
110: * srcdir - source directory of classes to preverify
111: * destdir - destination directory for preverified classes
112: * classpath - platform classpath will be defined on the next wizard step
113: * / - OS specific directory separator
114: *
115: * Parameter formats:
116: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
117: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
118: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
119: */
120: public final String preverifyCmd;
121: /**
122: * Definition of run command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
123: *
124: * Sample run command line for UEI compatible platforms is:
125: * "{platformhome}{/}bin{/}emulator" {device|-Xdevice:"{device}"} {jadfile|-Xdescriptor:"{jadfile}"} {securitydomain|-Xdomain:{securitydomain}} {cmdoptions}
126: *
127: * Parameters:
128: * platformhome - platform home filled above
129: * device - device name filled above
130: * classpath - platform classpath will be defined on the next wizard step
131: * jadfile - jad file name
132: * jadurl - jad url for OTA execution
133: * securitydomain - security domain for OTA execution
134: * cmdoptions - command line options propagated from project settings
135: * / - OS specific directory separator
136: *
137: * Parameter formats:
138: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
139: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
140: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
141: */
142: public final String runCmd;
143:
144: /**
145: * Definition of debug command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
146: *
147: * Sample debug command line for UEI compatible platforms is:
148: * "{platformhome}{/}bin{/}emulator" {device|-Xdevice:"{device}"} {jadfile|-Xdescriptor:"{jadfile}"} {securitydomain|-Xdomain:{securitydomain}} {debug|-Xdebug -Xrunjdwp:transport={debugtransport},server={debugserver},suspend={debugsuspend},address={debugaddress}} {cmdoptions}
149: *
150: * Parameters:
151: * platformhome - platform home filled above
152: * device - device name filled above
153: * classpath - platform classpath will be defined on the next wizard step
154: * jadfile - jad file name
155: * jadurl - jad url for OTA execution
156: * securitydomain - security domain for OTA execution
157: * debug - this is just a condition indicating debug mode
158: * debugaddress - debug address
159: * debugtransport - debug transport
160: * debugserver - debug server mode - true by default
161: * debugsuspend - debug suspend mode - true by default
162: * cmdoptions - command line options propagated from project settings
163: * / - OS specific directory separator
164: *
165: * Parameter formats:
166: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
167: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
168: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
169: */
170: public final String debugCmd;
171: /**
172: * Fixed list of CLDCPlatformDescriptor.Device instances that describe platform devices.
173: * The list must always contain at least one device.
174: */
175: public final List<Device> devices;
176:
177: /**
178: * Creates a new instance of CLDCPlatformDescriptor
179: * @param displayName Display name of the platform.
180: * The argument is mandatory.
181: * @param home Home directory of the platform.
182: * The argument is mandatory.
183: * @param type Type of the platform (currently supported types are UEI-1.0, UEI-1.0.1, and CUSTOM).
184: * It is likely that CustomCLDCPlatformConfgigurator will provide CUSTOM platform type with all the necessary information to use the platform.
185: * The argument is mandatory.
186: * @param srcPath Comma-separated list of platform source roots. Each of the root can be defined as a relative path prefixed with ${platform.home}
187: * Definition of source roots is optional and most of the platforms are provided without sources available however it is usefull for Java development to have direct access to all sources.
188: * @param docPath Comma-separated list of platform JavaDoc roots (might also include zip and jar files with the platform JavaDoc). Each of the root can be defined as a relative path prefixed with ${platform.home}
189: * Definition of JavaDoc roots is optional however it is usefull for Java development to have direct access to JavaDoc.
190: * @param preverifyCmd Definition of preverify command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
191: *
192: * Sample preverify command line for all UEI compatible platforms is:
193: * "{platformhome}{/}bin{/}preverify" {classpath|-classpath "{classpath}"} -d "{destdir}" "{srcdir}"
194: *
195: * Parameters:
196: * platformhome - platform home filled above
197: * srcdir - source directory of classes to preverify
198: * destdir - destination directory for preverified classes
199: * classpath - platform classpath will be defined on the next wizard step
200: * / - OS specific directory separator
201: *
202: * Parameter formats:
203: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
204: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
205: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
206: * @param runCmd Definition of run command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
207: *
208: * Sample run command line for UEI compatible platforms is:
209: * "{platformhome}{/}bin{/}emulator" {device|-Xdevice:"{device}"} {jadfile|-Xdescriptor:"{jadfile}"} {securitydomain|-Xdomain:{securitydomain}} {cmdoptions}
210: *
211: * Parameters:
212: * platformhome - platform home filled above
213: * device - device name filled above
214: * classpath - platform classpath will be defined on the next wizard step
215: * jadfile - jad file name
216: * jadurl - jad url for OTA execution
217: * securitydomain - security domain for OTA execution
218: * cmdoptions - command line options propagated from project settings
219: * / - OS specific directory separator
220: *
221: * Parameter formats:
222: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
223: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
224: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
225: * @param debugCmd Definition of debug command line is mandatory for CUSTOM platofrm type. For other then CUSTOM platform types is this field ignored.
226: *
227: * Sample debug command line for UEI compatible platforms is:
228: * "{platformhome}{/}bin{/}emulator" {device|-Xdevice:"{device}"} {jadfile|-Xdescriptor:"{jadfile}"} {securitydomain|-Xdomain:{securitydomain}} {debug|-Xdebug -Xrunjdwp:transport={debugtransport},server={debugserver},suspend={debugsuspend},address={debugaddress}} {cmdoptions}
229: *
230: * Parameters:
231: * platformhome - platform home filled above
232: * device - device name filled above
233: * classpath - platform classpath will be defined on the next wizard step
234: * jadfile - jad file name
235: * jadurl - jad url for OTA execution
236: * securitydomain - security domain for OTA execution
237: * debug - this is just a condition indicating debug mode
238: * debugaddress - debug address
239: * debugtransport - debug transport
240: * debugserver - debug server mode - true by default
241: * debugsuspend - debug suspend mode - true by default
242: * cmdoptions - command line options propagated from project settings
243: * / - OS specific directory separator
244: *
245: * Parameter formats:
246: * {argument} is a simple replacement, so for example {jadfile} will be replaced by the real path to the jad file.
247: * {argument|command line part} is a condition, if argument is set to some value the command line part will be added to the command line.
248: * Combination of condition and simple replacement is allowed. For example: {jadfile|-Xdescriptor:"{jadfile}"} means that if the jadfile argument contains /myfolder/my.jad then -Xdescriptor:"/myfolder/my.jad" will be added to the command line.
249: * @param devices List of CLDCPlatformDescriptor.Device instances that describe platform devices.
250: * The list must always contain at least one device.
251: */
252: public CLDCPlatformDescriptor(String displayName, String home,
253: String type, String srcPath, String docPath,
254: String preverifyCmd, String runCmd, String debugCmd,
255: List<Device> devices) {
256: assert displayName != null;
257: assert home != null;
258: assert type != null;
259: assert devices != null;
260: assert devices.size() > 0;
261: this .displayName = displayName;
262: this .home = home;
263: this .type = type;
264: this .srcPath = srcPath;
265: this .docPath = docPath;
266: this .preverifyCmd = preverifyCmd;
267: this .runCmd = runCmd;
268: this .debugCmd = debugCmd;
269: this .devices = Collections.unmodifiableList(devices);
270: }
271:
272: /**
273: * CLDCPlatform.Device holds information about one particular device provided by the platform.
274: */
275: public static final class Device {
276: /**
277: * Device name as used for example in command line.
278: * May never be null.
279: */
280: public final String name;
281:
282: /**
283: * Device description.
284: */
285: public final String description;
286: /**
287: * List of device security domains.
288: */
289: public final List<String> securityDomains;
290: /**
291: * Fixed ist of all device profiles (it means configurations, profiles, and optional APIs).
292: * Each device must contains at least one configuration and one profile.
293: */
294: public final List<Profile> profiles;
295: /**
296: * Screen parameters record of the device.
297: * This field is optional and may be null.
298: */
299: public final Screen screen;
300:
301: /**
302: * Creates a new instance of CLDCPlatformDescriptor.Device
303: * @param name Device name as used for example in command line.
304: * The argument is mandatory.
305: * @param description Device description.
306: * @param securityDomains List of device security domains.
307: * @param profiles Fixed ist of all device profiles (it means configurations, profiles, and optional APIs).
308: * Each device must contains at least one configuration and one profile.
309: * @param screen Screen parameters record of the device.
310: * This field is optional and may be null.
311: */
312: public Device(String name, String description,
313: List<String> securityDomains, List<Profile> profiles,
314: Screen screen) {
315: assert name != null;
316: assert profiles != null;
317: this .name = name;
318: this .description = description;
319: this .securityDomains = securityDomains;
320: this .profiles = profiles;
321: this .screen = screen;
322: }
323: }
324:
325: /**
326: * CLDCPlatformDescriptor.Profile is used to describe one particular profile of one device.
327: */
328: public static final class Profile {
329: /**
330: * Profile name (for example MMAPI).
331: * This name is a key used for matching of device abilities.
332: * The name must not contain spaces nor other special characters.
333: * May never be null.
334: */
335: public final String name;
336: /**
337: * Profile version number (f.ex.: 1.0).
338: * May never be null.
339: */
340: public final String version;
341: /**
342: * Profile display name used during the customization (f.ex. Multimedia API).
343: */
344: public final String displayName;
345: /**
346: * Comma-separated list of dependencies on other profiles of this device.
347: * The exact format is <name>-<version>,<name>-<version>,...
348: */
349: public final String dependencies;
350:
351: /**
352: * Comma-separated classpath of the profile.
353: * Each of the path element can be defined as a relative path prefixed with ${platform.home}
354: * The same path element can be referenced by more profiles if they share the same jar or zip path element.
355: */
356: public final String classPath;
357: /**
358: * Profile type (Configuration, Profiles, or Optional API).
359: * May never be null.
360: */
361: public final ProfileType type;
362: /**
363: * True if the profile is a part of the device default classpath.
364: */
365: public final boolean def;
366:
367: /**
368: * Creates new instance of CLDCPlatformDescriptor.Profile
369: * @param name Profile name (for example MMAPI).
370: * This name is a key used for matching of device abilities.
371: * The name must not contain spaces nor other special characters.
372: * The argument is mandatory.
373: * @param version Profile version number (f.ex.: 1.0).
374: * The argument is mandatory.
375: * @param displayName Profile display name used during the customization (f.ex. Multimedia API).
376: * @param type Profile type (Configuration, Profiles, or Optional API).
377: * The argument is mandatory.
378: * @param dependencies Comma-separated list of dependencies on other profiles of this device.
379: * The exact format is <name>-<version>,<name>-<version>,...
380: * @param classPath Comma-separated classpath of the profile.
381: * Each of the path element can be defined as a relative path prefixed with ${platform.home}
382: * The same path element can be referenced by more profiles if they share the same jar or zip path element.
383: * @param def True if the profile is a part of the device default classpath.
384: */
385: public Profile(String name, String version, String displayName,
386: ProfileType type, String dependencies,
387: String classPath, boolean def) {
388: assert name != null;
389: assert version != null;
390: assert type != null;
391: this .name = name;
392: this .version = version;
393: this .displayName = displayName;
394: this .type = type;
395: this .dependencies = dependencies;
396: this .classPath = classPath;
397: this .def = def;
398: }
399: }
400:
401: /**
402: * CLDCPlatformDescriptor.Screen is used to describe screen attributes of the device.
403: */
404: public static final class Screen {
405: /**
406: * Screen width in pixels.
407: */
408: public final int width;
409: /**
410: * Screen height in pixels.
411: */
412: public final int height;
413:
414: /**
415: * Screen color bit depth.
416: */
417: public final int bitDepth;
418: /**
419: * True if the device has color display.
420: */
421: public final boolean color;
422: /**
423: * True if the device has touch screen.
424: */
425: public final boolean touch;
426:
427: /**
428: * Creates new instance of CLDCPlatformDescriptor.
429: * @param width Screen width in pixels.
430: * @param height Screen height in pixels.
431: * @param bitDepth Screen color bit depth.
432: * @param color True is the device has color display.
433: * @param touch True if the device has touch screen.
434: */
435: public Screen(int width, int height, int bitDepth,
436: boolean color, boolean touch) {
437: this.width = width;
438: this.height = height;
439: this.bitDepth = bitDepth;
440: this.color = color;
441: this.touch = touch;
442: }
443: }
444: }
|