Package com.openhtmltopdf.css.parser
Class CSSParser
- java.lang.Object
-
- com.openhtmltopdf.css.parser.CSSParser
-
public class CSSParser extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCSSParser.NamespacePair
-
Field Summary
Fields Modifier and Type Field Description private CSSErrorHandler_errorHandlerprivate Lexer_lexerprivate java.util.Map<java.lang.String,java.lang.String>_namespacesprivate Token_savedprivate boolean_supportCMYKColorsprivate java.lang.String_URIprivate static java.util.Set<java.lang.String>CSS21_PSEUDO_ELEMENTSprivate static java.util.Set<java.lang.String>SUPPORTED_PSEUDO_ELEMENTS
-
Constructor Summary
Constructors Constructor Description CSSParser(CSSErrorHandler errorHandler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPseudoClassOrElement(Token t, Selector selector)private voidaddPseudoClassOrElementFunction(Token t, Selector selector)private voidaddPseudoElement(Token t, Selector selector)private voidattrib(Selector selector)private booleancheckCSSName(CSSName cssName, java.lang.String propertyName)private voidclass_selector(Selector selector)private Tokencombinator()private intconvertToInteger(char hexchar1)private intconvertToInteger(char hexchar1, char hexchar2)private FSCMYKColorcreateCMYKColorFromFunction(java.util.List<PropertyValue> params)private FSRGBColorcreateRGBColorFromFunction(java.util.List<PropertyValue> params)private voiddeclaration(Ruleset ruleset, boolean inFontFace)private voiddeclaration_list(Ruleset ruleset, boolean expectEOF, boolean expectAtRule, boolean inFontFace)private voiderror(CSSParseException e, java.lang.String what, boolean rethrowEOF)private java.util.List<PropertyValue>expr(boolean literal)private java.lang.StringextractNumber(Token t)private java.lang.StringextractUnit(Token t)private voidfont_face(Stylesheet stylesheet)private PropertyValuefunction()private intgetCurrentLine()CSSErrorHandlergetErrorHandler()private java.lang.StringgetRawTokenValue()private java.lang.StringgetTokenValue(Token t)private java.lang.StringgetTokenValue(Token t, boolean literal)private PropertyValuehexcolor()private voidimport_rule(Stylesheet stylesheet)private static booleanisHexChar(char c)private booleanisHexString(java.lang.String s)booleanisSupportCMYKColors()private Tokenla()private voidmargin(Stylesheet stylesheet, PageRule pageRule)private voidmedia(Stylesheet stylesheet)private java.lang.Stringmedium()private SelectormergeSimpleSelectors(java.util.List<Selector> selectors, java.util.List<Token> combinators)private voidnamespace()private Tokennext()private voidoperator()private voidpage(Stylesheet stylesheet)private floatparseCMYKColorComponent(PropertyValue value, int paramNo)RulesetparseDeclaration(int origin, java.lang.String text)PropertyValueparsePropertyValue(CSSName cssName, int origin, java.lang.String expr)StylesheetparseStylesheet(java.lang.String uri, int origin, java.io.Reader reader)private voidprio()private static java.lang.StringprocessEscapes(char[] ch, int start, int end)private java.lang.Stringproperty()private voidpseudo(Selector selector)private java.lang.Stringpseudo_page()private voidpush(Token t)private voidrecover(boolean needBlock, boolean stopBeforeBlockClose)voidreset(java.io.Reader r)private voidruleset(RulesetContainer container)private voidselector(Ruleset ruleset)voidsetErrorHandler(CSSErrorHandler errorHandler)voidsetSupportCMYKColors(boolean b)private java.lang.Stringsign(float sign)private Selectorsimple_selector(Ruleset ruleset)private voidskip_whitespace()private voidskip_whitespace_and_cdocdc()private voidstylesheet(Stylesheet stylesheet)private PropertyValueterm(boolean literal)private CSSParser.NamespacePairtyped_value(boolean matchAttribute)private intunary_operator()
-
-
-
Field Detail
-
SUPPORTED_PSEUDO_ELEMENTS
private static final java.util.Set<java.lang.String> SUPPORTED_PSEUDO_ELEMENTS
-
CSS21_PSEUDO_ELEMENTS
private static final java.util.Set<java.lang.String> CSS21_PSEUDO_ELEMENTS
-
_saved
private Token _saved
-
_lexer
private Lexer _lexer
-
_errorHandler
private CSSErrorHandler _errorHandler
-
_URI
private java.lang.String _URI
-
_namespaces
private java.util.Map<java.lang.String,java.lang.String> _namespaces
-
_supportCMYKColors
private boolean _supportCMYKColors
-
-
Constructor Detail
-
CSSParser
public CSSParser(CSSErrorHandler errorHandler)
-
-
Method Detail
-
parseStylesheet
public Stylesheet parseStylesheet(java.lang.String uri, int origin, java.io.Reader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parseDeclaration
public Ruleset parseDeclaration(int origin, java.lang.String text)
-
parsePropertyValue
public PropertyValue parsePropertyValue(CSSName cssName, int origin, java.lang.String expr)
-
stylesheet
private void stylesheet(Stylesheet stylesheet) throws java.io.IOException
- Throws:
java.io.IOException
-
import_rule
private void import_rule(Stylesheet stylesheet) throws java.io.IOException
- Throws:
java.io.IOException
-
namespace
private void namespace() throws java.io.IOException- Throws:
java.io.IOException
-
media
private void media(Stylesheet stylesheet) throws java.io.IOException
- Throws:
java.io.IOException
-
medium
private java.lang.String medium() throws java.io.IOException- Throws:
java.io.IOException
-
font_face
private void font_face(Stylesheet stylesheet) throws java.io.IOException
- Throws:
java.io.IOException
-
page
private void page(Stylesheet stylesheet) throws java.io.IOException
- Throws:
java.io.IOException
-
margin
private void margin(Stylesheet stylesheet, PageRule pageRule) throws java.io.IOException
- Throws:
java.io.IOException
-
pseudo_page
private java.lang.String pseudo_page() throws java.io.IOException- Throws:
java.io.IOException
-
operator
private void operator() throws java.io.IOException- Throws:
java.io.IOException
-
combinator
private Token combinator() throws java.io.IOException
- Throws:
java.io.IOException
-
unary_operator
private int unary_operator() throws java.io.IOException- Throws:
java.io.IOException
-
property
private java.lang.String property() throws java.io.IOException- Throws:
java.io.IOException
-
declaration_list
private void declaration_list(Ruleset ruleset, boolean expectEOF, boolean expectAtRule, boolean inFontFace) throws java.io.IOException
- Throws:
java.io.IOException
-
ruleset
private void ruleset(RulesetContainer container) throws java.io.IOException
- Throws:
java.io.IOException
-
selector
private void selector(Ruleset ruleset) throws java.io.IOException
- Throws:
java.io.IOException
-
mergeSimpleSelectors
private Selector mergeSimpleSelectors(java.util.List<Selector> selectors, java.util.List<Token> combinators)
-
simple_selector
private Selector simple_selector(Ruleset ruleset) throws java.io.IOException
- Throws:
java.io.IOException
-
typed_value
private CSSParser.NamespacePair typed_value(boolean matchAttribute) throws java.io.IOException
- Throws:
java.io.IOException
-
class_selector
private void class_selector(Selector selector) throws java.io.IOException
- Throws:
java.io.IOException
-
attrib
private void attrib(Selector selector) throws java.io.IOException
- Throws:
java.io.IOException
-
addPseudoClassOrElementFunction
private void addPseudoClassOrElementFunction(Token t, Selector selector) throws java.io.IOException
- Throws:
java.io.IOException
-
pseudo
private void pseudo(Selector selector) throws java.io.IOException
- Throws:
java.io.IOException
-
checkCSSName
private boolean checkCSSName(CSSName cssName, java.lang.String propertyName)
-
declaration
private void declaration(Ruleset ruleset, boolean inFontFace) throws java.io.IOException
- Throws:
java.io.IOException
-
prio
private void prio() throws java.io.IOException- Throws:
java.io.IOException
-
expr
private java.util.List<PropertyValue> expr(boolean literal) throws java.io.IOException
- Throws:
java.io.IOException
-
extractNumber
private java.lang.String extractNumber(Token t)
-
extractUnit
private java.lang.String extractUnit(Token t)
-
sign
private java.lang.String sign(float sign)
-
term
private PropertyValue term(boolean literal) throws java.io.IOException
- Throws:
java.io.IOException
-
function
private PropertyValue function() throws java.io.IOException
- Throws:
java.io.IOException
-
createCMYKColorFromFunction
private FSCMYKColor createCMYKColorFromFunction(java.util.List<PropertyValue> params)
-
parseCMYKColorComponent
private float parseCMYKColorComponent(PropertyValue value, int paramNo)
-
createRGBColorFromFunction
private FSRGBColor createRGBColorFromFunction(java.util.List<PropertyValue> params)
-
hexcolor
private PropertyValue hexcolor() throws java.io.IOException
- Throws:
java.io.IOException
-
isHexString
private boolean isHexString(java.lang.String s)
-
convertToInteger
private int convertToInteger(char hexchar1, char hexchar2)
-
convertToInteger
private int convertToInteger(char hexchar1)
-
skip_whitespace
private void skip_whitespace() throws java.io.IOException- Throws:
java.io.IOException
-
skip_whitespace_and_cdocdc
private void skip_whitespace_and_cdocdc() throws java.io.IOException- Throws:
java.io.IOException
-
next
private Token next() throws java.io.IOException
- Throws:
java.io.IOException
-
push
private void push(Token t)
-
la
private Token la() throws java.io.IOException
- Throws:
java.io.IOException
-
error
private void error(CSSParseException e, java.lang.String what, boolean rethrowEOF)
-
recover
private void recover(boolean needBlock, boolean stopBeforeBlockClose) throws java.io.IOException- Throws:
java.io.IOException
-
reset
public void reset(java.io.Reader r)
-
getErrorHandler
public CSSErrorHandler getErrorHandler()
-
setErrorHandler
public void setErrorHandler(CSSErrorHandler errorHandler)
-
getRawTokenValue
private java.lang.String getRawTokenValue()
-
getTokenValue
private java.lang.String getTokenValue(Token t)
-
getTokenValue
private java.lang.String getTokenValue(Token t, boolean literal)
-
getCurrentLine
private int getCurrentLine()
-
isHexChar
private static boolean isHexChar(char c)
-
processEscapes
private static java.lang.String processEscapes(char[] ch, int start, int end)
-
isSupportCMYKColors
public boolean isSupportCMYKColors()
-
setSupportCMYKColors
public void setSupportCMYKColors(boolean b)
-
-