Package org.owasp.validator.css
Class CssHandler
- java.lang.Object
-
- org.owasp.validator.css.CssHandler
-
- All Implemented Interfaces:
org.w3c.css.sac.DocumentHandler
public class CssHandler extends java.lang.Object implements org.w3c.css.sac.DocumentHandlerA 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
Constructors Constructor Description CssHandler(Policy policy, java.util.LinkedList embeddedStyleSheets, java.util.List<java.lang.String> errorMessages, java.lang.String tagName, java.util.ResourceBundle messages)Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.CssHandler(Policy policy, java.util.LinkedList embeddedStyleSheets, java.util.List<java.lang.String> errorMessages, java.util.ResourceBundle messages)Constructs a handler for stylesheets using the given policy and queue for imported stylesheets.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomment(java.lang.String text)voidendDocument(org.w3c.css.sac.InputSource source)voidendFontFace()voidendMedia(org.w3c.css.sac.SACMediaList media)voidendPage(java.lang.String name, java.lang.String pseudoPage)voidendSelector(org.w3c.css.sac.SelectorList selectors)java.lang.StringgetCleanStylesheet()Returns the cleaned stylesheet.java.util.CollectiongetErrorMessages()Returns the error messages generated during parsing.voidignorableAtRule(java.lang.String atRule)voidimportStyle(java.lang.String uri, org.w3c.css.sac.SACMediaList media, java.lang.String defaultNamespaceURI)voidnamespaceDeclaration(java.lang.String prefix, java.lang.String uri)voidproperty(java.lang.String name, org.w3c.css.sac.LexicalUnit value, boolean important)voidstartDocument(org.w3c.css.sac.InputSource arg0)voidstartFontFace()voidstartMedia(org.w3c.css.sac.SACMediaList media)voidstartPage(java.lang.String name, java.lang.String pseudoPage)voidstartSelector(org.w3c.css.sac.SelectorList selectors)
-
-
-
Constructor Detail
-
CssHandler
public CssHandler(Policy policy, java.util.LinkedList embeddedStyleSheets, java.util.List<java.lang.String> errorMessages, java.util.ResourceBundle messages)
Constructs a handler for stylesheets using the given policy and queue for imported stylesheets.- Parameters:
policy- the policy to useembeddedStyleSheets- the queue of stylesheets imported
-
CssHandler
public CssHandler(Policy policy, java.util.LinkedList embeddedStyleSheets, java.util.List<java.lang.String> errorMessages, java.lang.String tagName, java.util.ResourceBundle messages)
Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.- Parameters:
policy- the policy to useembeddedStyleSheets- the queue of stylesheets importedtagName- the associated tag name with this inline style
-
-
Method Detail
-
getCleanStylesheet
public java.lang.String getCleanStylesheet()
Returns the cleaned stylesheet.- Returns:
- the cleaned styesheet
-
getErrorMessages
public java.util.Collection getErrorMessages()
Returns the error messages generated during parsing.- Returns:
- the error messages generated during parsing
-
comment
public void comment(java.lang.String text) throws org.w3c.css.sac.CSSException- Specified by:
commentin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
ignorableAtRule
public void ignorableAtRule(java.lang.String atRule) throws org.w3c.css.sac.CSSException- Specified by:
ignorableAtRulein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
importStyle
public void importStyle(java.lang.String uri, org.w3c.css.sac.SACMediaList media, java.lang.String defaultNamespaceURI) throws org.w3c.css.sac.CSSException- Specified by:
importStylein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
namespaceDeclaration
public void namespaceDeclaration(java.lang.String prefix, java.lang.String uri) throws org.w3c.css.sac.CSSException- Specified by:
namespaceDeclarationin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
startDocument
public void startDocument(org.w3c.css.sac.InputSource arg0) throws org.w3c.css.sac.CSSException- Specified by:
startDocumentin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
endDocument
public void endDocument(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException- Specified by:
endDocumentin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
startFontFace
public void startFontFace() throws org.w3c.css.sac.CSSException- Specified by:
startFontFacein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
endFontFace
public void endFontFace() throws org.w3c.css.sac.CSSException- Specified by:
endFontFacein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
startMedia
public void startMedia(org.w3c.css.sac.SACMediaList media) throws org.w3c.css.sac.CSSException- Specified by:
startMediain interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
endMedia
public void endMedia(org.w3c.css.sac.SACMediaList media) throws org.w3c.css.sac.CSSException- Specified by:
endMediain interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
startPage
public void startPage(java.lang.String name, java.lang.String pseudoPage) throws org.w3c.css.sac.CSSException- Specified by:
startPagein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
endPage
public void endPage(java.lang.String name, java.lang.String pseudoPage) throws org.w3c.css.sac.CSSException- Specified by:
endPagein interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
startSelector
public void startSelector(org.w3c.css.sac.SelectorList selectors) throws org.w3c.css.sac.CSSException- Specified by:
startSelectorin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
endSelector
public void endSelector(org.w3c.css.sac.SelectorList selectors) throws org.w3c.css.sac.CSSException- Specified by:
endSelectorin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
property
public void property(java.lang.String name, org.w3c.css.sac.LexicalUnit value, boolean important) throws org.w3c.css.sac.CSSException- Specified by:
propertyin interfaceorg.w3c.css.sac.DocumentHandler- Throws:
org.w3c.css.sac.CSSException
-
-