public abstract class AbstractCSSParser extends Object
| Constructor and Description |
|---|
AbstractCSSParser() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
addEscapes(String str)
Escapes some chars in the given string.
|
protected Locator |
createLocator(com.gargoylesoftware.css.parser.javacc.Token t)
Returns a new locator for the given token.
|
protected CSSParseException |
createSkipWarning(String messageKey,
CSSParseException e) |
protected double |
doubleValue(char op,
String s)
Parses the sting into an double.
|
protected abstract LexicalUnit |
expr()
Process an expression.
|
protected LexicalUnit |
functionInternal(LexicalUnit prev,
String funct,
LexicalUnit params)
Process a function decl.
|
protected DocumentHandler |
getDocumentHandler() |
protected CSSErrorHandler |
getErrorHandler() |
protected InputSource |
getInputSource() |
protected int |
getLastNumPos(String s)
Returns the pos of the last numeric char in the given string.
|
protected String |
getParserMessage(String key) |
abstract String |
getParserVersion() |
protected void |
handleCharset(String characterEncoding,
Locator locator)
charset handler.
|
protected void |
handleEndDocument()
end document handler.
|
protected void |
handleEndFontFace()
end font face handler.
|
protected void |
handleEndMedia(MediaQueryList media)
end media handler.
|
protected void |
handleEndPage(String name,
String pseudoPage)
end page handler.
|
protected void |
handleEndSelector(SelectorList selectors)
selector end handler.
|
protected void |
handleIgnorableAtRule(String s,
Locator locator)
ignorable at rule handler.
|
protected void |
handleImportStyle(String uri,
MediaQueryList media,
String defaultNamespaceURI,
Locator locator)
import style handler.
|
protected void |
handleProperty(String name,
LexicalUnit value,
boolean important,
Locator locator)
property handler.
|
protected void |
handleStartDocument()
start document handler.
|
protected void |
handleStartFontFace(Locator locator)
start font face handler.
|
protected void |
handleStartMedia(MediaQueryList media,
Locator locator)
start media handler.
|
protected void |
handleStartPage(String name,
String pseudoPage,
Locator locator)
start page handler.
|
protected void |
handleStartSelector(SelectorList selectors,
Locator locator)
selector start handler.
|
protected LexicalUnit |
hexColorInternal(LexicalUnit prev,
com.gargoylesoftware.css.parser.javacc.Token t)
Processes a hexadecimal color definition.
|
protected LexicalUnit |
hslColorInternal(LexicalUnit prev,
String funct,
LexicalUnit param) |
protected int |
intValue(char op,
String s)
Parses the sting into an integer.
|
protected abstract void |
mediaList(MediaQueryList ml)
Process a media list.
|
protected String |
normalizeAndValidatePagePseudoClass(com.gargoylesoftware.css.parser.javacc.Token t) |
MediaQueryList |
parseMedia(InputSource source)
Parse the given input source and return the media list.
|
boolean |
parsePriority(InputSource source)
Parse a CSS priority value (e.g.
|
LexicalUnit |
parsePropertyValue(InputSource source)
Parse a CSS property value.
|
void |
parseRule(InputSource source)
Parse a CSS rule.
|
SelectorList |
parseSelectors(InputSource source)
Parse a comma separated list of selectors.
|
protected abstract SelectorList |
parseSelectorsInternal()
Process a selector list.
|
void |
parseStyleDeclaration(InputSource source)
Parse a CSS style declaration (without '{' and '}').
|
void |
parseStyleSheet(InputSource source)
Parse a CSS document.
|
protected abstract boolean |
prio()
Process a prio.
|
protected abstract void |
ReInit(com.gargoylesoftware.css.parser.javacc.CharStream charStream)
Re intit the stream.
|
protected LexicalUnit |
rgbColorInternal(LexicalUnit prev,
String funct,
LexicalUnit param) |
void |
setDocumentHandler(DocumentHandler handler)
Allow an application to register a document event handler.
|
void |
setErrorHandler(CSSErrorHandler handler)
Allow an application to register an error event handler.
|
protected abstract void |
styleDeclaration()
Process a style sheet declaration.
|
protected abstract void |
styleSheet()
Process a style sheet.
|
protected abstract void |
styleSheetRuleSingle()
Process a style sheet rule.
|
protected CSSParseException |
toCSSParseException(DOMException e) |
protected CSSParseException |
toCSSParseException(String messageKey,
Object[] msgParams,
Locator locator) |
protected CSSParseException |
toCSSParseException(String key,
com.gargoylesoftware.css.parser.javacc.ParseException e) |
protected CSSParseException |
toCSSParseException(com.gargoylesoftware.css.parser.javacc.TokenMgrError e) |
String |
unescape(String s,
boolean unescapeDoubleQuotes)
Unescapes escaped characters in the specified string, according to the
CSS specification.
|
protected DocumentHandler getDocumentHandler()
public void setDocumentHandler(DocumentHandler handler)
If the application does not register a document handler, all document events reported by the CSS parser will be silently ignored (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the CSS parser must begin using the new handler immediately.
handler - The document handler.DocumentHandlerprotected CSSErrorHandler getErrorHandler()
public void setErrorHandler(CSSErrorHandler handler)
If the application does not register an error event handler, all error events reported by the CSS parser will be silently ignored, except for fatalError, which will throw a CSSException (this is the default behaviour implemented by HandlerBase).
Applications may register a new or different handler in the middle of a parse, and the CSS parser must begin using the new handler immediately.
handler - The error handler.CSSErrorHandler,
CSSExceptionprotected InputSource getInputSource()
protected String getParserMessage(String key)
key - the lookup keyprotected Locator createLocator(com.gargoylesoftware.css.parser.javacc.Token t)
t - the token to generate the locator forprotected String addEscapes(String str)
str - the inputprotected CSSParseException toCSSParseException(String key, com.gargoylesoftware.css.parser.javacc.ParseException e)
key - the message lookup keye - the parse exceptionprotected CSSParseException toCSSParseException(DOMException e)
e - the DOMExceptionprotected CSSParseException toCSSParseException(com.gargoylesoftware.css.parser.javacc.TokenMgrError e)
e - the TokenMgrErrorprotected CSSParseException toCSSParseException(String messageKey, Object[] msgParams, Locator locator)
messageKey - the message keymsgParams - the paramslocator - the locatorprotected CSSParseException createSkipWarning(String messageKey, CSSParseException e)
messageKey - the message keye - a CSSParseExceptionpublic void parseStyleSheet(InputSource source) throws IOException
The application can use this method to instruct the CSS parser to begin parsing an CSS document from any valid input source (a character stream, a byte stream, or a URI).
Applications may not invoke this method while a parse is in progress (they should create a new Parser instead for each additional CSS document). Once a parse is complete, an application may reuse the same Parser object, possibly with a different input source.
source - The input source for the top-level of the
CSS document.CSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.InputSource,
setDocumentHandler(com.gargoylesoftware.css.parser.DocumentHandler),
setErrorHandler(com.gargoylesoftware.css.parser.CSSErrorHandler)public void parseStyleDeclaration(InputSource source) throws IOException
source - source to be parsedCSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public void parseRule(InputSource source) throws IOException
source - source to be parsedCSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public SelectorList parseSelectors(InputSource source) throws IOException
source - source to be parsedCSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public LexicalUnit parsePropertyValue(InputSource source) throws IOException
source - source to be parsedCSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public boolean parsePriority(InputSource source) throws IOException
source - source to be parsedCSSException - Any CSS exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public MediaQueryList parseMedia(InputSource source) throws IOException
source - the input sourceIOException - in case of errorspublic abstract String getParserVersion()
protected abstract void ReInit(com.gargoylesoftware.css.parser.javacc.CharStream charStream)
charStream - the streamprotected abstract void styleSheet()
throws CSSParseException,
com.gargoylesoftware.css.parser.javacc.ParseException
CSSParseException - in case of errorcom.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract void styleDeclaration()
throws com.gargoylesoftware.css.parser.javacc.ParseException
com.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract void styleSheetRuleSingle()
throws com.gargoylesoftware.css.parser.javacc.ParseException
com.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract SelectorList parseSelectorsInternal() throws com.gargoylesoftware.css.parser.javacc.ParseException
com.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract LexicalUnit expr() throws com.gargoylesoftware.css.parser.javacc.ParseException
com.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract boolean prio()
throws com.gargoylesoftware.css.parser.javacc.ParseException
com.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected abstract void mediaList(MediaQueryList ml) throws com.gargoylesoftware.css.parser.javacc.ParseException
ml - the media listcom.gargoylesoftware.css.parser.javacc.ParseException - in case of errorprotected void handleStartDocument()
protected void handleEndDocument()
protected void handleIgnorableAtRule(String s, Locator locator)
s - the rulelocator - the locatorprotected void handleCharset(String characterEncoding, Locator locator)
characterEncoding - the encodinglocator - the locatorprotected void handleImportStyle(String uri, MediaQueryList media, String defaultNamespaceURI, Locator locator)
uri - the urimedia - the media query listdefaultNamespaceURI - the namespace urilocator - the locatorprotected void handleStartMedia(MediaQueryList media, Locator locator)
media - the media query listlocator - the locatorprotected void handleEndMedia(MediaQueryList media)
media - the media query listprotected void handleStartPage(String name, String pseudoPage, Locator locator)
name - the namepseudoPage - the pseudo pagelocator - the locatorprotected void handleEndPage(String name, String pseudoPage)
name - the namepseudoPage - the pseudo pageprotected void handleStartFontFace(Locator locator)
locator - the locatorprotected void handleEndFontFace()
protected void handleStartSelector(SelectorList selectors, Locator locator)
selectors - the selector listlocator - the locatorprotected void handleEndSelector(SelectorList selectors)
selectors - the selector listprotected void handleProperty(String name, LexicalUnit value, boolean important, Locator locator)
name - the namevalue - the valueimportant - important flaglocator - the locatorprotected LexicalUnit functionInternal(LexicalUnit prev, String funct, LexicalUnit params)
prev - the previous lexical unitfunct - the functionparams - the paramsprotected LexicalUnit rgbColorInternal(LexicalUnit prev, String funct, LexicalUnit param)
protected LexicalUnit hslColorInternal(LexicalUnit prev, String funct, LexicalUnit param)
protected LexicalUnit hexColorInternal(LexicalUnit prev, com.gargoylesoftware.css.parser.javacc.Token t)
prev - the previous lexical unitt - the tokenprotected int intValue(char op,
String s)
op - the sign chars - the string to parseprotected double doubleValue(char op,
String s)
op - the sign chars - the string to parseprotected int getLastNumPos(String s)
s - the string to parsepublic String unescape(String s, boolean unescapeDoubleQuotes)
s - the string to unescapeunescapeDoubleQuotes - if true unescape double quotes alsoprotected String normalizeAndValidatePagePseudoClass(com.gargoylesoftware.css.parser.javacc.Token t)
Copyright © 2023. All rights reserved.