KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > tasks > JNLPGeneratorTask


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * G&H Softwareentwicklung GmbH - internationalization implementation (bug 150933)
11  *******************************************************************************/

12 package org.eclipse.pde.internal.build.tasks;
13
14 import java.util.Locale JavaDoc;
15
16 import org.apache.tools.ant.BuildException;
17 import org.apache.tools.ant.Task;
18
19 public class JNLPGeneratorTask extends Task {
20
21     private String JavaDoc feature;
22     private String JavaDoc jnlp = null;
23     private String JavaDoc codebase = null;
24     private String JavaDoc j2se;
25     private Locale JavaDoc locale = Locale.getDefault();
26     private boolean generateOfflineAllowed = true;
27     private String JavaDoc configs = null;
28     
29     /**
30      * The URL location of a feature.xml file. This can be either a jar: URL to the feature.xml,
31      * or a file: url to the feature.
32      * @param value
33      */

34     public void setFeature(String JavaDoc value) {
35         feature = value;
36     }
37
38     /**
39      * The location the output jnlp file. The value may be null (or simply not set). If it is
40      * null then the output file will be placed beside the feature dir or jar (as appropriate)
41      * and its name will be derived from the feature id and version. If this is set
42      * it must be a file path. If it ends in a "/" or "\" then the output file is places in this
43      * directory with the file name derived as described. Finally, if the value is a file name,
44      * the output is placed in that file.
45      * @param value the location to write the output or null if the default
46      * computed location is to be used.
47      */

48     public void setJNLP(String JavaDoc value) {
49         jnlp = value;
50     }
51
52     /**
53      * The codebase of the output. This shoudl be a URL that will be used as the
54      * root of all relative URLs in the output. Typically this is the root of the application
55      * deployment website.
56      * @param value the URL root of for the application content.
57      */

58     public void setCodebase(String JavaDoc value) {
59         codebase = value;
60     }
61
62     /**
63      * The j2se spec of the output
64      * @param value the JNLP j2se spec to use in the output.
65      */

66     public void setJ2SE(String JavaDoc value) {
67         j2se = value;
68     }
69
70     /**
71      * The locale in which the jnlp file generated should be translated into.
72      *The translation values are read from the feature_<locale>.properties file.
73      * @param the locale in which to generate the jnlp files.
74      * */

75     public void setLocale(String JavaDoc nlsString) {
76         String JavaDoc[] strings = nlsString.split("_"); //$NON-NLS-1$
77
if (nlsString.charAt(0) == '$')
78             return;
79         
80         if (strings != null) {
81             switch (strings.length) {
82                 case 1:
83                     locale = new Locale JavaDoc(strings[0]);
84                     break;
85                 case 2:
86                     locale = new Locale JavaDoc(strings[0], strings[1]);
87                     break;
88                 case 3:
89                     locale = new Locale JavaDoc(strings[0], strings[1], strings[2]);
90                     break;
91             }
92         }
93     }
94
95     public void execute() throws BuildException {
96         JNLPGenerator generator = new JNLPGenerator(feature, jnlp, codebase, j2se, locale, generateOfflineAllowed, configs);
97         generator.process();
98     }
99     
100     public void setGenerateOfflineAllowed(String JavaDoc generateOfflineAllowed) {
101         if (generateOfflineAllowed.equalsIgnoreCase("false")) //$NON-NLS-1$
102
this.generateOfflineAllowed = false;
103         if (generateOfflineAllowed.equalsIgnoreCase("true")) //$NON-NLS-1$
104
this.generateOfflineAllowed = false;
105     }
106     
107     public void setConfigInfo(String JavaDoc configs) {
108         this.configs = configs;
109     }
110     
111 }
112
Popular Tags