org.owasp.validator.css
Class CssHandler

java.lang.Object
  extended by org.owasp.validator.css.CssHandler
All Implemented Interfaces:
DocumentHandler

public class CssHandler
extends Object
implements DocumentHandler

A implementation of a SAC DocumentHandler for CSS validation. The appropriate validation method is called whenever the handler is invoked by the parser. The handler also builds a clean CSS document as the original CSS is scanned. NOTE: keeping state in this class is not ideal as handler style parsing a la SAX should generally be event driven. However, there is not a fully implemented "DOM" equivalent to CSS at this time. Java has a StyleSheet class that could accomplish this "DOM" like behavior but it has yet to be fully implemented

Author:
Jason Li
See Also:
StyleSheet

Constructor Summary
CssHandler(Policy policy, LinkedList embeddedStyleSheets)
          Constructs a handler for stylesheets using the given policy and queue for imported stylesheets.
CssHandler(Policy policy, LinkedList embeddedStyleSheets, String tagName)
          Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.
 
Method Summary
 void comment(String text)
           
 void endDocument(InputSource source)
           
 void endFontFace()
           
 void endMedia(SACMediaList media)
           
 void endPage(String name, String pseudoPage)
           
 void endSelector(SelectorList selectors)
           
 CleanResults getResults()
          Returns the encapsulated results generated by the handler during parsing.
 void ignorableAtRule(String atRule)
           
 void importStyle(String uri, SACMediaList media, String defaultNamespaceURI)
           
 void namespaceDeclaration(String prefix, String uri)
           
 void property(String name, LexicalUnit value, boolean important)
           
 void startDocument(InputSource arg0)
           
 void startFontFace()
           
 void startMedia(SACMediaList media)
           
 void startPage(String name, String pseudoPage)
           
 void startSelector(SelectorList selectors)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CssHandler

public CssHandler(Policy policy,
                  LinkedList embeddedStyleSheets)
Constructs a handler for stylesheets using the given policy and queue for imported stylesheets.

Parameters:
policy - the policy to use
embeddedStyleSheets - the queue of stylesheets imported

CssHandler

public CssHandler(Policy policy,
                  LinkedList embeddedStyleSheets,
                  String tagName)
Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.

Parameters:
policy - the policy to use
embeddedStyleSheets - the queue of stylesheets imported
tagName - the associated tag name with this inline style
Method Detail

getResults

public CleanResults getResults()
Returns the encapsulated results generated by the handler during parsing.

Returns:
the CleanResults object containing the results generated by the handler

comment

public void comment(String text)
             throws CSSException
Specified by:
comment in interface DocumentHandler
Throws:
CSSException

ignorableAtRule

public void ignorableAtRule(String atRule)
                     throws CSSException
Specified by:
ignorableAtRule in interface DocumentHandler
Throws:
CSSException

importStyle

public void importStyle(String uri,
                        SACMediaList media,
                        String defaultNamespaceURI)
                 throws CSSException
Specified by:
importStyle in interface DocumentHandler
Throws:
CSSException

namespaceDeclaration

public void namespaceDeclaration(String prefix,
                                 String uri)
                          throws CSSException
Specified by:
namespaceDeclaration in interface DocumentHandler
Throws:
CSSException

startDocument

public void startDocument(InputSource arg0)
                   throws CSSException
Specified by:
startDocument in interface DocumentHandler
Throws:
CSSException

endDocument

public void endDocument(InputSource source)
                 throws CSSException
Specified by:
endDocument in interface DocumentHandler
Throws:
CSSException

startFontFace

public void startFontFace()
                   throws CSSException
Specified by:
startFontFace in interface DocumentHandler
Throws:
CSSException

endFontFace

public void endFontFace()
                 throws CSSException
Specified by:
endFontFace in interface DocumentHandler
Throws:
CSSException

startMedia

public void startMedia(SACMediaList media)
                throws CSSException
Specified by:
startMedia in interface DocumentHandler
Throws:
CSSException

endMedia

public void endMedia(SACMediaList media)
              throws CSSException
Specified by:
endMedia in interface DocumentHandler
Throws:
CSSException

startPage

public void startPage(String name,
                      String pseudoPage)
               throws CSSException
Specified by:
startPage in interface DocumentHandler
Throws:
CSSException

endPage

public void endPage(String name,
                    String pseudoPage)
             throws CSSException
Specified by:
endPage in interface DocumentHandler
Throws:
CSSException

startSelector

public void startSelector(SelectorList selectors)
                   throws CSSException
Specified by:
startSelector in interface DocumentHandler
Throws:
CSSException

endSelector

public void endSelector(SelectorList selectors)
                 throws CSSException
Specified by:
endSelector in interface DocumentHandler
Throws:
CSSException

property

public void property(String name,
                     LexicalUnit value,
                     boolean important)
              throws CSSException
Specified by:
property in interface DocumentHandler
Throws:
CSSException