javax.swing.text.html
class: CSSParser [javadoc |
source]
java.lang.Object
javax.swing.text.html.CSSParser
A CSS parser. This works by way of a delegate that implements the
CSSParserCallback interface. The delegate is notified of the following
events:
- Import statement:
handleImport
- Selectors
handleSelector
. This is invoked for each
string. For example if the Reader contained p, bar , a {}, the delegate
would be notified 4 times, for 'p,' 'bar' ',' and 'a'.
- When a rule starts,
startRule
- Properties in the rule via the
handleProperty
. This
is invoked one per property/value key, eg font size: foo;, would
cause the delegate to be notified once with a value of 'font size'.
- Values in the rule via the
handleValue
, this is notified
for the total value.
- When a rule ends,
endRule
This will parse much more than CSS 1, and loosely implements the
recommendation for
Forward-compatible parsing in section
7.1 of the CSS spec found at:
http://www.w3.org/TR/REC-CSS1.
If an error results in parsing, a RuntimeException will be thrown.
This will preserve case. If the callback wishes to treat certain poritions
case insensitively (such as selectors), it should use toLowerCase, or
something similar.
Method from javax.swing.text.html.CSSParser Summary: |
---|
parse |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from javax.swing.text.html.CSSParser Detail: |
void parse(Reader reader,
CSSParserCallback callback,
boolean inRule) throws IOException {
this.callback = callback;
stackCount = tokenBufferLength = 0;
this.reader = reader;
encounteredRuleSet = false;
try {
if (inRule) {
parseDeclarationBlock();
}
else {
while (getNextStatement());
}
} finally {
callback = null;
reader = null;
}
}
|