org.jhotdraw.xml.css
Class CSSParser

java.lang.Object
  extended by org.jhotdraw.xml.css.CSSParser

public class CSSParser
extends java.lang.Object

Parsers a Cascading Style Sheet (CSS).

 IDENT  {ident}
 ATKEYWORD  @{ident}
 STRING  {string}
 INVALID  {invalid}
 HASH  #{name}
 NUMBER  {num}
 PERCENTAGE  {num}%
 DIMENSION  {num}{ident}
 URI  url\({w}{string}{w}\)
 |url\({w}([!#$%&*-~]|{nonascii}|{escape})*{w}\)
 UNICODE-RANGE  U\+[0-9A-F?]{1,6}(-[0-9A-F]{1,6})?
 CDO  
 ;  ;
 {  \{
 }  \}
 (  \(
 )  \)
 [  \[
 ]  \]
 S  [ \t\r\n\f]+
 COMMENT  \/\*[^*]*\*+([^/*][^*]*\*+)*\/
 FUNCTION  {ident}\(
 INCLUDES  ~=
 DASHMATCH  |=
 DELIM  any other character not matched by the above rules, and neither a single nor a double quote


 stylesheet  : [ CDO | CDC | S | statement ]*;
 statement   : ruleset | at-rule;
 at-rule     : ATKEYWORD S* any* [ block | ';' S* ];
 block       : '{' S* [ any | block | ATKEYWORD S* | ';' S* ]* '}' S*;
 ruleset     : selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*;
 selector    : any+;
 declaration : DELIM? property S* ':' S* value;
 property    : IDENT;
 value       : [ any | block | ATKEYWORD S* ]+;
 any         : [ IDENT | NUMBER | PERCENTAGE | DIMENSION | STRING
 | DELIM | URI | HASH | UNICODE-RANGE | INCLUDES
 | DASHMATCH | FUNCTION S* any* ')'
 | '(' S* any* ')' | '[' S* any* ']' ] S*;
 

Version:
$Id: CSSParser.java 527 2009-06-07 14:28:19Z rawcoder $
Author:
Werner Randelshofer

Constructor Summary
CSSParser()
           
 
Method Summary
 void parse(java.io.Reader css, StyleManager rm)
           
 void parse(java.lang.String css, StyleManager rm)
           
private  java.util.Map<java.lang.String,java.lang.String> parseDeclarationMap(java.io.StreamTokenizer tt)
           
private  void parseRuleset(java.io.StreamTokenizer tt, StyleManager rm)
           
private  java.util.List<java.lang.String> parseSelectorList(java.io.StreamTokenizer tt)
           
private  void parseStylesheet(java.io.StreamTokenizer tt, StyleManager rm)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSSParser

public CSSParser()
Method Detail

parse

public void parse(java.lang.String css,
                  StyleManager rm)
           throws java.io.IOException
Throws:
java.io.IOException

parse

public void parse(java.io.Reader css,
                  StyleManager rm)
           throws java.io.IOException
Throws:
java.io.IOException

parseStylesheet

private void parseStylesheet(java.io.StreamTokenizer tt,
                             StyleManager rm)
                      throws java.io.IOException
Throws:
java.io.IOException

parseRuleset

private void parseRuleset(java.io.StreamTokenizer tt,
                          StyleManager rm)
                   throws java.io.IOException
Throws:
java.io.IOException

parseSelectorList

private java.util.List<java.lang.String> parseSelectorList(java.io.StreamTokenizer tt)
                                                    throws java.io.IOException
Throws:
java.io.IOException

parseDeclarationMap

private java.util.Map<java.lang.String,java.lang.String> parseDeclarationMap(java.io.StreamTokenizer tt)
                                                                      throws java.io.IOException
Throws:
java.io.IOException