// ignores spaces. private int _nextIgnoreSpaces(CSSScanner scanner) { int currentType = scanner.getNextToken(); while (currentType == CSSLexicalUnits.SPACE) { currentType = scanner.getNextToken(); } return currentType; }
public void parseCSSDocument(Reader in, SkinCSSDocumentHandler documentHandler) { try { CSSScanner scanner = new CSSScanner(in); documentHandler.startDocument(); List<String> selectorList = null; // start scanning the document // return comments /* xxx */ // return @rules, which end with ';' // return selectors, which end with a { // return properties, which end with a } int currentType = _nextIgnoreSpaces(scanner); while (currentType != CSSLexicalUnits.EOF) { if (currentType == CSSLexicalUnits.COMMENT) documentHandler.comment(scanner.getStringValue()); else if (currentType == CSSLexicalUnits.AT_KEYWORD) documentHandler.atRule(scanner.getStringValue()); else if (currentType == CSSLexicalUnits.LEFT_CURLY_BRACE) { documentHandler.startSelector(); selectorList = _parseSelectorString(scanner.getStringValue()); } else if (currentType == CSSLexicalUnits.RIGHT_CURLY_BRACE) { String properties = scanner.getStringValue(); _handlePropertiesString(documentHandler, properties); if (selectorList == null) { if (_LOG.isWarning()) { _LOG.warning("IGNORING_PROPERTIES_WITHOUT_SELECTOR", properties); } } documentHandler.endSelector(selectorList); } currentType = _nextIgnoreSpaces(scanner); } } finally { documentHandler.endDocument(); } }