|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.infinityloop.util.style.CSS2Parser
public class CSS2Parser
Encapsulates a SAC CSS2 parser for convenient use in the using application.
Field Summary | |
---|---|
static long |
ctor_calls
|
java.lang.String |
errorContext
Attempt to provide some context information for a potential error. |
static long |
parse_calls
|
Constructor Summary | |
---|---|
CSS2Parser()
Creates and initializes a CSS2 parser object. |
Method Summary | |
---|---|
void |
addMediaFilter(java.lang.String filterName)
Adds a media filter. |
void |
comment(java.lang.String t)
noop implementation, see SAC |
void |
endDocument(org.w3c.css.sac.InputSource is)
noop implementation, see SAC |
void |
endFontFace()
noop implementation, see SAC |
void |
endMedia(org.w3c.css.sac.SACMediaList l)
endMedia implementation, see SAC Decrement skip counter, if needed. |
void |
endPage(java.lang.String name,
java.lang.String pseudo)
endPage implementation, see SAC |
void |
endSelector(org.w3c.css.sac.SelectorList selectors)
endSelector implementation, see SAC |
void |
error(org.w3c.css.sac.CSSParseException e)
Handle an error, see SAC |
static java.lang.String |
extractPropertyValue(java.lang.String propString,
java.lang.String propName,
java.lang.String unit)
Extracts a single value from a CSS property string's property with the name propName. |
void |
fatalError(org.w3c.css.sac.CSSParseException e)
Handle a fatal error, see SAC |
static java.util.Stack |
filterProperties(java.util.Stack props,
CSSPropertyFilter f)
Filters a Stack of properties against a property filter. |
static java.lang.String |
filterPropertyString(java.lang.String propertyString,
CSSPropertyFilter f)
Filters a CSS string of properties against a custom defined property name filter. |
java.util.Stack |
getErrors()
Retrieves a Stack of errors that may have been occurred during parsing. |
void |
ignorableAtRule(java.lang.String r)
noop implementation, see SAC |
void |
importStyle(java.lang.String uri,
org.w3c.css.sac.SACMediaList l,
java.lang.String ns)
import external stylesheet implementation, see SAC |
static void |
main(java.lang.String[] args)
Class testing, parses the stylesheet in args[0] and prints the result to System.out . |
static java.lang.String |
makePropertyStringFromStack(java.util.Stack props,
CSSPropertyDefaultUnits unitTable)
Makes a property list string from a stack of properties. |
void |
namespaceDeclaration(java.lang.String pref,
java.lang.String uri)
noop implementation, see SAC |
java.util.Stack |
parsePropertyList(java.lang.String plist)
Parse a style declaration, passed as string. |
static org.w3c.css.sac.LexicalUnit |
parsePropertyValue(java.lang.String pval)
Parse a property value, passed as string. |
java.util.Stack |
parseStylesheet(InputProxy ip)
Parses a complete external stylesheet. |
void |
property(java.lang.String name,
org.w3c.css.sac.LexicalUnit value,
boolean important)
property implementation, see SAC |
void |
startDocument(org.w3c.css.sac.InputSource is)
noop implementation, see SAC |
void |
startFontFace()
noop implementation, see SAC |
void |
startMedia(org.w3c.css.sac.SACMediaList l)
startMedia implementation, see SAC We check if one of the media in the media list is in the mediaFilter. |
void |
startPage(java.lang.String name,
java.lang.String pseudo)
startPage implementation, see SAC |
void |
startSelector(org.w3c.css.sac.SelectorList selectors)
startSelector implementation, see SAC |
void |
warning(org.w3c.css.sac.CSSParseException e)
Handle a warning, see SAC |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static long ctor_calls
public static long parse_calls
public java.lang.String errorContext
Constructor Detail |
---|
public CSS2Parser()
Method Detail |
---|
public void addMediaFilter(java.lang.String filterName)
filterName
- media identifier to filter (e.g. "print")public java.util.Stack parseStylesheet(InputProxy ip) throws java.lang.Exception
ip
- the source of the stylesheet
java.lang.Exception
- of appropriate typepublic java.util.Stack parsePropertyList(java.lang.String plist)
plist
- style declaration as CSS string
public static org.w3c.css.sac.LexicalUnit parsePropertyValue(java.lang.String pval) throws ILException
pval
- the property value to parse
ILException
public java.util.Stack getErrors()
public void startPage(java.lang.String name, java.lang.String pseudo)
startPage
in interface org.w3c.css.sac.DocumentHandler
public void endPage(java.lang.String name, java.lang.String pseudo)
endPage
in interface org.w3c.css.sac.DocumentHandler
public void startSelector(org.w3c.css.sac.SelectorList selectors)
startSelector
in interface org.w3c.css.sac.DocumentHandler
public void endSelector(org.w3c.css.sac.SelectorList selectors)
endSelector
in interface org.w3c.css.sac.DocumentHandler
public void property(java.lang.String name, org.w3c.css.sac.LexicalUnit value, boolean important)
property
in interface org.w3c.css.sac.DocumentHandler
public void importStyle(java.lang.String uri, org.w3c.css.sac.SACMediaList l, java.lang.String ns)
importStyle
in interface org.w3c.css.sac.DocumentHandler
public void startMedia(org.w3c.css.sac.SACMediaList l)
We check if one of the media in the media list is in the mediaFilter. If it is, we parse it, otherwise we skip everything in it by incrementing the skip variable.
startMedia
in interface org.w3c.css.sac.DocumentHandler
public void endMedia(org.w3c.css.sac.SACMediaList l)
Decrement skip counter, if needed.
endMedia
in interface org.w3c.css.sac.DocumentHandler
public void error(org.w3c.css.sac.CSSParseException e)
error
in interface org.w3c.css.sac.ErrorHandler
public void warning(org.w3c.css.sac.CSSParseException e)
warning
in interface org.w3c.css.sac.ErrorHandler
public void fatalError(org.w3c.css.sac.CSSParseException e)
fatalError
in interface org.w3c.css.sac.ErrorHandler
public void comment(java.lang.String t)
comment
in interface org.w3c.css.sac.DocumentHandler
public void ignorableAtRule(java.lang.String r)
ignorableAtRule
in interface org.w3c.css.sac.DocumentHandler
public void namespaceDeclaration(java.lang.String pref, java.lang.String uri)
namespaceDeclaration
in interface org.w3c.css.sac.DocumentHandler
public void startDocument(org.w3c.css.sac.InputSource is)
startDocument
in interface org.w3c.css.sac.DocumentHandler
public void endDocument(org.w3c.css.sac.InputSource is)
endDocument
in interface org.w3c.css.sac.DocumentHandler
public void startFontFace()
startFontFace
in interface org.w3c.css.sac.DocumentHandler
public void endFontFace()
endFontFace
in interface org.w3c.css.sac.DocumentHandler
public static java.util.Stack filterProperties(java.util.Stack props, CSSPropertyFilter f)
props
- the Stack of propertiesf
- a CSSPropertyFilter object configured as desired
CSSPropertyFilter
public static java.lang.String makePropertyStringFromStack(java.util.Stack props, CSSPropertyDefaultUnits unitTable)
props
- the Stack of propertiesunitTable
- a CSSPropertyDefaultUnits object
CSSPropertyDefaultUnits
public static java.lang.String filterPropertyString(java.lang.String propertyString, CSSPropertyFilter f)
propertyString
- the String you wish to have filteredf
- the CSSPropertyFilter object describing which filter action should be performed.
CSSPropertyFilter
public static java.lang.String extractPropertyValue(java.lang.String propString, java.lang.String propName, java.lang.String unit)
propString
- the property stringpropName
- name of the property to extract, e.g. 'width' or 'list-style-type'.unit
- the unit name of the value should be converted to (only for properties of type length), e.g. "in" or "px"
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |