/** * Converts the current lexical unit to a float. */ protected float number(boolean positive) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); nextIgnoreSpaces(); return sgn * Float.parseFloat(val); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a float. */ protected float number(boolean positive) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); nextIgnoreSpaces(); return sgn * Float.parseFloat(val); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a float. */ protected float number(boolean positive) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); nextIgnoreSpaces(); return sgn * Float.parseFloat(val); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Converts the current lexical unit to a dimension. */ protected LexicalUnit dimension(boolean positive, LexicalUnit prev) { try { float sgn = (positive) ? 1 : -1; String val = scanner.getStringValue(); int i; loop: for (i = 0; i < val.length(); i++) { switch (val.charAt(i)) { default: break loop; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': } } nextIgnoreSpaces(); return CSSLexicalUnit.createDimension (sgn * Float.parseFloat(val.substring(0, i)), val.substring(i), prev); } catch (NumberFormatException e) { throw createCSSParseException("number.format"); } }
/** * Parses an unknown rule. */ protected void parseAtRule() { scanner.scanAtRule(); documentHandler.ignorableAtRule(scanner.getStringValue()); nextIgnoreSpaces(); }
/** * Parses an unknown rule. */ protected void parseAtRule() { scanner.scanAtRule(); documentHandler.ignorableAtRule(scanner.getStringValue()); nextIgnoreSpaces(); }
/** * Parses an unknown rule. */ protected void parseAtRule() { scanner.scanAtRule(); documentHandler.ignorableAtRule(scanner.getStringValue()); nextIgnoreSpaces(); }
/** * Parses a media list. */ protected CSSSACMediaList parseMediaList() { CSSSACMediaList result = new CSSSACMediaList(); result.append(scanner.getStringValue()); nextIgnoreSpaces(); while (current == LexicalUnits.COMMA) { nextIgnoreSpaces(); switch (current) { default: reportError("identifier"); break; case LexicalUnits.IDENTIFIER: result.append(scanner.getStringValue()); nextIgnoreSpaces(); } } return result; }
/** * Parses a media list. */ protected CSSSACMediaList parseMediaList() { CSSSACMediaList result = new CSSSACMediaList(); result.append(scanner.getStringValue()); nextIgnoreSpaces(); while (current == LexicalUnits.COMMA) { nextIgnoreSpaces(); switch (current) { default: reportError("identifier"); break; case LexicalUnits.IDENTIFIER: result.append(scanner.getStringValue()); nextIgnoreSpaces(); } } return result; }
/** * Parses a media list. */ protected CSSSACMediaList parseMediaList() { CSSSACMediaList result = new CSSSACMediaList(); result.append(scanner.getStringValue()); nextIgnoreSpaces(); while (current == LexicalUnits.COMMA) { nextIgnoreSpaces(); switch (current) { default: reportError("identifier"); break; case LexicalUnits.IDENTIFIER: result.append(scanner.getStringValue()); nextIgnoreSpaces(); } } return result; }
/** * Advances to the next token, ignoring comments. */ protected int next() { try { for (;;) { scanner.clearBuffer(); current = scanner.next(); if (current == LexicalUnits.COMMENT) { documentHandler.comment(scanner.getStringValue()); } else { break; } } return current; } catch (ParseException e) { reportError(e.getMessage()); return current; } }
/** * Advances to the next token, ignoring comments. */ protected int next() { try { for (;;) { scanner.clearBuffer(); current = scanner.next(); if (current == LexicalUnits.COMMENT) { documentHandler.comment(scanner.getStringValue()); } else { break; } } return current; } catch (ParseException e) { reportError(e.getMessage()); return current; } }
/** * Advances to the next token, ignoring comments. */ protected int next() { try { for (;;) { scanner.clearBuffer(); current = scanner.next(); if (current == LexicalUnits.COMMENT) { documentHandler.comment(scanner.getStringValue()); } else { break; } } return current; } catch (ParseException e) { reportError(e.getMessage()); return current; } }
/** * Advances to the next token and skip the spaces, ignoring comments. */ protected int nextIgnoreSpaces() { try { loop: for (;;) { scanner.clearBuffer(); current = scanner.next(); switch (current) { case LexicalUnits.COMMENT: documentHandler.comment(scanner.getStringValue()); break; default: break loop; case LexicalUnits.SPACE: } } return current; } catch (ParseException e) { errorHandler.error(createCSSParseException(e.getMessage())); return current; } }
/** * Advances to the next token and skip the spaces, ignoring comments. */ protected int nextIgnoreSpaces() { try { loop: for (;;) { scanner.clearBuffer(); current = scanner.next(); switch (current) { case LexicalUnits.COMMENT: documentHandler.comment(scanner.getStringValue()); break; default: break loop; case LexicalUnits.SPACE: } } return current; } catch (ParseException e) { errorHandler.error(createCSSParseException(e.getMessage())); return current; } }
/** * Advances to the next token and skip the spaces, ignoring comments. */ protected int nextIgnoreSpaces() { try { loop: for (;;) { scanner.clearBuffer(); current = scanner.next(); switch (current) { case LexicalUnits.COMMENT: documentHandler.comment(scanner.getStringValue()); break; default: break loop; case LexicalUnits.SPACE: } } return current; } catch (ParseException e) { errorHandler.error(createCSSParseException(e.getMessage())); return current; } }
/** * Parses an import rule. Assumes the current token is '@import'. */ protected void parseImportRule() { String uri = null; switch (current) { default: reportError("string.or.uri"); return; case LexicalUnits.STRING: case LexicalUnits.URI: uri = scanner.getStringValue(); nextIgnoreSpaces(); } CSSSACMediaList ml; if (current != LexicalUnits.IDENTIFIER) { ml = new CSSSACMediaList(); ml.append("all"); } else { ml = parseMediaList(); } documentHandler.importStyle(uri, ml, null); if (current != LexicalUnits.SEMI_COLON) { reportError("semicolon"); } else { next(); } }
/** * Parses an import rule. Assumes the current token is '@import'. */ protected void parseImportRule() { String uri = null; switch (current) { default: reportError("string.or.uri"); return; case LexicalUnits.STRING: case LexicalUnits.URI: uri = scanner.getStringValue(); nextIgnoreSpaces(); } CSSSACMediaList ml; if (current != LexicalUnits.IDENTIFIER) { ml = new CSSSACMediaList(); ml.append("all"); } else { ml = parseMediaList(); } documentHandler.importStyle(uri, ml, null); if (current != LexicalUnits.SEMI_COLON) { reportError("semicolon"); } else { next(); } }