1 /* |
1 /* |
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
151 |
151 |
152 /** |
152 /** |
153 * Scan an html file for {@literal <mlet>} tags. |
153 * Scan an html file for {@literal <mlet>} tags. |
154 */ |
154 */ |
155 public List<MLetContent> parse(URL url) throws IOException { |
155 public List<MLetContent> parse(URL url) throws IOException { |
156 String mth = "parse"; |
|
157 // Warning Messages |
156 // Warning Messages |
158 String requiresTypeWarning = "<arg type=... value=...> tag requires type parameter."; |
157 String requiresTypeWarning = "<arg type=... value=...> tag requires type parameter."; |
159 String requiresValueWarning = "<arg type=... value=...> tag requires value parameter."; |
158 String requiresValueWarning = "<arg type=... value=...> tag requires value parameter."; |
160 String paramOutsideWarning = "<arg> tag outside <mlet> ... </mlet>."; |
159 String paramOutsideWarning = "<arg> tag outside <mlet> ... </mlet>."; |
161 String requiresCodeWarning = "<mlet> tag requires either code or object parameter."; |
160 String requiresCodeWarning = "<mlet> tag requires either code or object parameter."; |
202 String nm = scanIdentifier(in); |
201 String nm = scanIdentifier(in); |
203 if (nm.equalsIgnoreCase("arg")) { |
202 if (nm.equalsIgnoreCase("arg")) { |
204 Map<String,String> t = scanTag(in); |
203 Map<String,String> t = scanTag(in); |
205 String att = t.get("type"); |
204 String att = t.get("type"); |
206 if (att == null) { |
205 if (att == null) { |
207 MLET_LOGGER.logp(Level.FINER, |
206 MLET_LOGGER.log(Level.TRACE, requiresTypeWarning); |
208 MLetParser.class.getName(), |
|
209 mth, requiresTypeWarning); |
|
210 throw new IOException(requiresTypeWarning); |
207 throw new IOException(requiresTypeWarning); |
211 } else { |
208 } else { |
212 if (atts != null) { |
209 if (atts != null) { |
213 types.add(att); |
210 types.add(att); |
214 } else { |
211 } else { |
215 MLET_LOGGER.logp(Level.FINER, |
212 MLET_LOGGER.log(Level.TRACE, paramOutsideWarning); |
216 MLetParser.class.getName(), |
|
217 mth, paramOutsideWarning); |
|
218 throw new IOException(paramOutsideWarning); |
213 throw new IOException(paramOutsideWarning); |
219 } |
214 } |
220 } |
215 } |
221 String val = t.get("value"); |
216 String val = t.get("value"); |
222 if (val == null) { |
217 if (val == null) { |
223 MLET_LOGGER.logp(Level.FINER, |
218 MLET_LOGGER.log(Level.TRACE, requiresValueWarning); |
224 MLetParser.class.getName(), |
|
225 mth, requiresValueWarning); |
|
226 throw new IOException(requiresValueWarning); |
219 throw new IOException(requiresValueWarning); |
227 } else { |
220 } else { |
228 if (atts != null) { |
221 if (atts != null) { |
229 values.add(val); |
222 values.add(val); |
230 } else { |
223 } else { |
231 MLET_LOGGER.logp(Level.FINER, |
224 MLET_LOGGER.log(Level.TRACE, paramOutsideWarning); |
232 MLetParser.class.getName(), |
|
233 mth, paramOutsideWarning); |
|
234 throw new IOException(paramOutsideWarning); |
225 throw new IOException(paramOutsideWarning); |
235 } |
226 } |
236 } |
227 } |
237 } else { |
228 } else { |
238 if (nm.equalsIgnoreCase(tag)) { |
229 if (nm.equalsIgnoreCase(tag)) { |
239 atts = scanTag(in); |
230 atts = scanTag(in); |
240 if (atts.get("code") == null && atts.get("object") == null) { |
231 if (atts.get("code") == null && atts.get("object") == null) { |
241 MLET_LOGGER.logp(Level.FINER, |
232 MLET_LOGGER.log(Level.TRACE, requiresCodeWarning); |
242 MLetParser.class.getName(), |
|
243 mth, requiresCodeWarning); |
|
244 throw new IOException(requiresCodeWarning); |
233 throw new IOException(requiresCodeWarning); |
245 } |
234 } |
246 if (atts.get("archive") == null) { |
235 if (atts.get("archive") == null) { |
247 MLET_LOGGER.logp(Level.FINER, |
236 MLET_LOGGER.log(Level.TRACE, requiresJarsWarning); |
248 MLetParser.class.getName(), |
|
249 mth, requiresJarsWarning); |
|
250 throw new IOException(requiresJarsWarning); |
237 throw new IOException(requiresJarsWarning); |
251 } |
238 } |
252 } |
239 } |
253 } |
240 } |
254 } |
241 } |