home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.html;
-
- import java.io.IOException;
- import java.io.Reader;
- import java.io.StringReader;
- import java.net.URL;
- import java.util.Vector;
- import javax.swing.text.AttributeSet;
- import javax.swing.text.MutableAttributeSet;
- import javax.swing.text.SimpleAttributeSet;
-
- class StyleSheet$CssParser implements CSSParser.CSSParserCallback {
- Vector selectors;
- Vector selectorTokens;
- String propertyName;
- MutableAttributeSet declaration;
- boolean parsingDeclaration;
- boolean isLink;
- URL base;
- CSSParser parser;
- // $FF: synthetic field
- private final StyleSheet this$0;
-
- StyleSheet$CssParser(StyleSheet var1) {
- this.this$0 = var1;
- this.selectors = new Vector();
- this.selectorTokens = new Vector();
- this.declaration = new SimpleAttributeSet();
- this.parser = new CSSParser();
- }
-
- public AttributeSet parseDeclaration(String var1) {
- try {
- return this.parseDeclaration((Reader)(new StringReader(var1)));
- } catch (IOException var3) {
- return null;
- }
- }
-
- public AttributeSet parseDeclaration(Reader var1) throws IOException {
- this.parse(this.base, var1, true, false);
- return this.declaration.copyAttributes();
- }
-
- public void parse(URL var1, Reader var2, boolean var3, boolean var4) throws IOException {
- this.base = var1;
- this.isLink = var4;
- this.parsingDeclaration = var3;
- this.declaration.removeAttributes(this.declaration);
- this.selectorTokens.removeAllElements();
- this.selectors.removeAllElements();
- this.propertyName = null;
- this.parser.parse(var2, this, var3);
- }
-
- public void handleImport(String var1) {
- URL var2 = CSS.getURL(this.base, var1);
- if (var2 != null) {
- this.this$0.importStyleSheet(var2);
- }
-
- }
-
- public void handleSelector(String var1) {
- int var2 = var1.length();
- if (var1.endsWith(",")) {
- if (var2 > 1) {
- var1 = var1.substring(0, var2 - 1);
- this.selectorTokens.addElement(var1);
- }
-
- this.addSelector();
- } else if (var2 > 0) {
- this.selectorTokens.addElement(var1);
- }
-
- }
-
- public void startRule() {
- if (this.selectorTokens.size() > 0) {
- this.addSelector();
- }
-
- this.propertyName = null;
- }
-
- public void handleProperty(String var1) {
- this.propertyName = var1;
- }
-
- public void handleValue(String var1) {
- if (this.propertyName != null) {
- CSS.Attribute var2 = CSS.getAttribute(this.propertyName);
- if (var2 != null) {
- this.this$0.addCSSAttribute(this.declaration, var2, var1);
- }
-
- this.propertyName = null;
- }
-
- }
-
- public void endRule() {
- int var1 = this.selectors.size();
-
- for(int var2 = 0; var2 < var1; ++var2) {
- String[] var3 = (String[])this.selectors.elementAt(var2);
- if (var3.length > 0) {
- this.this$0.addRule(var3, this.declaration, this.isLink);
- }
- }
-
- this.declaration.removeAttributes(this.declaration);
- this.selectors.removeAllElements();
- }
-
- private void addSelector() {
- String[] var1 = new String[this.selectorTokens.size()];
- this.selectorTokens.copyInto(var1);
- this.selectors.addElement(var1);
- this.selectorTokens.removeAllElements();
- }
- }
-