286 // fixed to handle the bad syntax, but the fallback is
287 // to handle the exception here. Uncaught, the exception can cause
288 // problems like RT-20311
289 reportException(ex);
290 }
291 stylesheet.getRules().addAll(rules);
292 }
293
294 // don't retain reference to the styleable
295 setInputSource((Styleable) null);
296
297 return stylesheet;
298 }
299
300 /**
301 * Convenience method for unit tests.
302 * @param property the property
303 * @param expr the expression
304 * @return the parsed value
305 */
306 public ParsedValue parseExpr(String property, String expr) {
307 if (property == null || expr == null) return null;
308
309 ParsedValueImpl value = null;
310 setInputSource(null, property + ": " + expr);
311 char buf[] = new char[expr.length() + 1];
312 System.arraycopy(expr.toCharArray(), 0, buf, 0, expr.length());
313 buf[buf.length-1] = ';';
314
315 try (Reader reader = new CharArrayReader(buf)) {
316 CssLexer lex = new CssLexer();
317 lex.setReader(reader);
318
319 currentToken = nextToken(lex);
320 CssParser.Term term = this.expr(lex);
321 value = valueFor(property, term, lex);
322 } catch (IOException ioe) {
323 } catch (ParseException e) {
324 if (LOGGER.isLoggable(Level.WARNING)) {
325 LOGGER.warning("\"" +property + ": " + expr + "\" " + e.toString());
326 }
|
286 // fixed to handle the bad syntax, but the fallback is
287 // to handle the exception here. Uncaught, the exception can cause
288 // problems like RT-20311
289 reportException(ex);
290 }
291 stylesheet.getRules().addAll(rules);
292 }
293
294 // don't retain reference to the styleable
295 setInputSource((Styleable) null);
296
297 return stylesheet;
298 }
299
300 /**
301 * Convenience method for unit tests.
302 * @param property the property
303 * @param expr the expression
304 * @return the parsed value
305 */
306 ParsedValue parseExpr(String property, String expr) {
307 if (property == null || expr == null) return null;
308
309 ParsedValueImpl value = null;
310 setInputSource(null, property + ": " + expr);
311 char buf[] = new char[expr.length() + 1];
312 System.arraycopy(expr.toCharArray(), 0, buf, 0, expr.length());
313 buf[buf.length-1] = ';';
314
315 try (Reader reader = new CharArrayReader(buf)) {
316 CssLexer lex = new CssLexer();
317 lex.setReader(reader);
318
319 currentToken = nextToken(lex);
320 CssParser.Term term = this.expr(lex);
321 value = valueFor(property, term, lex);
322 } catch (IOException ioe) {
323 } catch (ParseException e) {
324 if (LOGGER.isLoggable(Level.WARNING)) {
325 LOGGER.warning("\"" +property + ": " + expr + "\" " + e.toString());
326 }
|