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: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common
009: * Development and Distribution License("CDDL") (collectively, the
010: * "License"). You may not use this file except in compliance with the
011: * License. You can obtain a copy of the License at
012: * http://www.netbeans.org/cddl-gplv2.html
013: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
014: * specific language governing permissions and limitations under the
015: * License. When distributing the software, include this License Header
016: * Notice in each file and include the License file at
017: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
018: * particular file as subject to the "Classpath" exception as provided
019: * by Sun in the GPL Version 2 section of the License file that
020: * accompanied this code. If applicable, add the following below the
021: * License Header, with the fields enclosed by brackets [] replaced by
022: * your own identifying information:
023: * "Portions Copyrighted [year] [name of copyright owner]"
024: *
025: * Contributor(s):
026: *
027: * The Original Software is NetBeans. The Initial Developer of the Original
028: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
029: * Microsystems, Inc. All Rights Reserved.
030: *
031: * If you wish your version of this file to be governed by only the CDDL
032: * or only the GPL Version 2, indicate your decision by adding
033: * "[Contributor] elects to include this software in this distribution
034: * under the [CDDL or GPL Version 2] license." If you do not indicate a
035: * single choice of license, a recipient has the option to distribute
036: * your version of this file under either the CDDL, the GPL Version 2 or
037: * to extend the choice of license to its licensees as provided above.
038: * However, if you add GPL Version 2 code and therefore, elected the GPL
039: * Version 2 license, then the option applies only if the new code is
040: * made subject to such option by the copyright holder.
041: */
042:
043: package org.netbeans.modules.j2me.cdc.project.ricoh.dalp;
044:
045: import java.io.File;
046: import java.util.Properties;
047: import org.openide.filesystems.FileObject;
048: import org.openide.filesystems.FileUtil;
049: import org.xml.sax.*;
050:
051: public class DalpParserHandlerImpl implements DalpParserHandler {
052:
053: public static final boolean DEBUG = false;
054: private Properties p;
055: private FileObject projectRoot;
056:
057: public DalpParserHandlerImpl(FileObject projectRoot, Properties p) {
058: this .p = p;
059: this .projectRoot = projectRoot;
060: }
061:
062: public void handle_application_ver(final java.lang.String data,
063: final Attributes meta) throws SAXException {
064: if (DEBUG)
065: System.err.println("handle_application_ver: " + data);
066: }
067:
068: public void handle_jar(final Attributes meta) throws SAXException {
069: if (DEBUG)
070: System.err.println("handle_jar: " + meta);
071: }
072:
073: public void handle_dsdk(final Attributes meta) throws SAXException {
074: if (DEBUG)
075: System.err.println("handle_dsdk: " + meta);
076: }
077:
078: public void handle_vendor(final java.lang.String data,
079: final Attributes meta) throws SAXException {
080: if (DEBUG)
081: System.err.println("handle_vendor: " + data);
082: p.put("application.vendor", data);
083: }
084:
085: public void handle_install(final Attributes meta)
086: throws SAXException {
087: if (DEBUG)
088: System.err.println("handle_install: " + meta);
089: }
090:
091: public void handle_encode_file(final java.lang.String data,
092: final Attributes meta) throws SAXException {
093: if (DEBUG)
094: System.err.println("handle_encode_file: " + data);
095: }
096:
097: public void start_dalp(final Attributes meta) throws SAXException {
098: if (DEBUG)
099: System.err.println("start_dalp: " + meta);
100: }
101:
102: public void end_dalp() throws SAXException {
103: if (DEBUG)
104: System.err.println("end_dalp()");
105: }
106:
107: public void handle_title(final java.lang.String data,
108: final Attributes meta) throws SAXException {
109: if (DEBUG)
110: System.err.println("handle_title: " + data);
111: p.put("application.name", data);
112: }
113:
114: public void start_resources(final Attributes meta)
115: throws SAXException {
116: if (DEBUG)
117: System.err.println("start_resources: " + meta);
118: }
119:
120: public void end_resources() throws SAXException {
121: if (DEBUG)
122: System.err.println("end_resources()");
123: }
124:
125: public void handle_telephone(final java.lang.String data,
126: final Attributes meta) throws SAXException {
127: if (DEBUG)
128: System.err.println("handle_telephone: " + data);
129: p.put("ricoh.application.telephone", data);
130: }
131:
132: public void handle_offline_allowed(final Attributes meta)
133: throws SAXException {
134: if (DEBUG)
135: System.err.println("handle_offline_allowed: " + meta);
136: }
137:
138: public void handle_application_desc(final Attributes meta)
139: throws SAXException {
140: if (DEBUG)
141: System.err.println("handle_application_desc: " + meta);
142: if (meta.getValue("main-class") != null) {
143: p.put("main.class.class", "xlet");
144: p.put("main.class", meta.getValue("main-class"));
145: }
146: }
147:
148: public void handle_fax(final java.lang.String data,
149: final Attributes meta) throws SAXException {
150: if (DEBUG)
151: System.err.println("handle_fax: " + data);
152: p.put("ricoh.application.fax", data);
153: }
154:
155: public void handle_all_permissions(final Attributes meta)
156: throws SAXException {
157: if (DEBUG)
158: System.err.println("handle_all_permissions: " + meta);
159: }
160:
161: public void handle_e_mail(final java.lang.String data,
162: final Attributes meta) throws SAXException {
163: if (DEBUG)
164: System.err.println("handle_e_mail: " + data);
165: p.put("ricoh.application.email", data);
166: }
167:
168: public void handle_product_id(final java.lang.String data,
169: final Attributes meta) throws SAXException {
170: if (DEBUG)
171: System.err.println("handle_product_id: " + data);
172: }
173:
174: public void start_information(final Attributes meta)
175: throws SAXException {
176: if (DEBUG)
177: System.err.println("start_information: " + meta);
178: }
179:
180: public void end_information() throws SAXException {
181: if (DEBUG)
182: System.err.println("end_information()");
183: }
184:
185: public void handle_icon(final java.lang.String data,
186: final Attributes meta) throws SAXException {
187: if (DEBUG)
188: System.err.println("handle_icon: " + data);
189: if (data != null && data.length() != 0) {
190: File f = new File(FileUtil.toFile(projectRoot), "src/"
191: + data); //NOI18N
192: if (f.exists())
193: p.put("ricoh.application.icon", f);
194: }
195: }
196:
197: public void handle_description(final java.lang.String data,
198: final Attributes meta) throws SAXException {
199: if (DEBUG)
200: System.err.println("handle_description: " + data);
201: if ("detail".equalsIgnoreCase(meta.getValue("type"))) {
202: p.put("application.description.detail", data);
203: } else {
204: p.put("application.description", data);
205: }
206: }
207:
208: public void start_security(final Attributes meta)
209: throws SAXException {
210: if (DEBUG)
211: System.err.println("start_security: " + meta);
212: }
213:
214: public void end_security() throws SAXException {
215: if (DEBUG)
216: System.err.println("end_security()");
217: }
218:
219: public void handle_argument(final String data, Attributes attrs)
220: throws SAXException {
221: String args = p.getProperty("application.args");
222: p.put("application.args", args != null ? (args + " " + data)
223: : data);
224: }
225: }
|