Class CssParserStateController
java.lang.Object
com.itextpdf.styledxmlparser.css.parse.syntax.CssParserStateController
State machine that will parse content into a style sheet.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IParserStateThe At-rule block state.private final StringBuilderA buffer to store temporary results.private final IParserStateThe commend end state.private final IParserStateThe commend inner state.private final IParserStateThe comment start state.Set of conditional group rules.private final IParserStateThe conditional group at rule block state.private StringThe current selector.private IParserStateThe current state.private booleanIndicates if the current rule is supported.private static final org.slf4j.Loggerprivate final Stack<CssNestedAtRule> The nested At-rules.private IParserStateThe previous active state (excluding comments).private final IParserStateThe properties state.private final ResourceResolverThe resource resolver.private final IParserStateThe rule state.private final Stack<List<CssDeclaration>> The stored properties without selector.private final CssStyleSheetThe style sheet.private final CssStyleSheetThe style sheet from import CSS rules.Set of the supported rules.private final IParserStateThe unknown state. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.privateCssParserStateController(ResourceResolver resourceResolver) CssParserStateController(String baseUrl) Creates a newCssParserStateControllerinstance. -
Method Summary
Modifier and TypeMethodDescription(package private) voidappendToBuffer(char ch) Appends a character to the buffer.private booleanChecks if the current At-rule is a conditional group rule (or if it's unsupported).(package private) voidEnter the At-rule block state.(package private) voidEnter the comment end state.(package private) voidEnter the comment inner state.(package private) voidEnter the comment start state.(package private) voidEnter the conditional group At-rule block state.(package private) voidEnter the previous active state.(package private) voidEnter the properties state.(package private) voidEnter the rule state.(package private) voidEnter the rule state, based on whether the current state is unsupported or conditional.(package private) voidEnter the unknown state.(package private) voidEnter the unknown state if nested blocks are finished.(package private) voidFinish the At-rule block.(package private) StringGets the contents of the buffer.Gets the resulting style sheet.private booleanChecks if is current rule is supported.private voidnormalizeDeclarationURIs(List<CssDeclaration> declarations) Normalizes the declaration URIs.private voidnormalizeSingleDeclarationURI(CssDeclaration declaration) voidprocess(char ch) Process a character using the current state.private voidProcesses the finished At-rule block.private voidprocessProperties(String properties) Processes the properties.private voidprocessProperties(String selector, String properties) Processes the properties.private voidprocessSemicolonAtRule(String ruleStr) Processes the semicolon At-rule.(package private) voidPush the block preceding At-rule.(package private) voidResets the buffer.private voidSave the active state.private voidsetState(IParserState state) Sets the current state.(package private) voidStore the current properties.(package private) voidStore the current properties without selector.(package private) voidStore the current selector.(package private) voidStore the semicolon At-rule.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
SUPPORTED_RULES
-
CONDITIONAL_GROUP_RULES
-
currentState
The current state. -
isCurrentRuleSupported
private boolean isCurrentRuleSupportedIndicates if the current rule is supported. -
previousActiveState
The previous active state (excluding comments). -
buffer
A buffer to store temporary results. -
currentSelector
The current selector. -
styleSheet
The style sheet. -
styleSheetFromImport
The style sheet from import CSS rules. It is used to store styles from import separately to avoidStyledXmlParserLogMessageConstant.IMPORT_MUST_COME_BEFOREon check whether were styles before import or not. -
nestedAtRules
The nested At-rules. -
storedPropertiesWithoutSelector
The stored properties without selector. -
commentStartState
The comment start state. -
commendEndState
The commend end state. -
commendInnerState
The commend inner state. -
unknownState
The unknown state. -
ruleState
The rule state. -
propertiesState
The properties state. -
conditionalGroupAtRuleBlockState
The conditional group at rule block state. -
atRuleBlockState
The At-rule block state. -
resourceResolver
The resource resolver.
-
-
Constructor Details
-
CssParserStateController
Deprecated.useCssParserStateController(String)constructorCreates a newCssParserStateControllerinstance. -
CssParserStateController
Creates a newCssParserStateControllerinstance.- Parameters:
baseUrl- the base URL
-
CssParserStateController
-
-
Method Details
-
process
public void process(char ch) Process a character using the current state.- Parameters:
ch- the character
-
getParsingResult
Gets the resulting style sheet.- Returns:
- the resulting style sheet
-
appendToBuffer
void appendToBuffer(char ch) Appends a character to the buffer.- Parameters:
ch- the character
-
getBufferContents
-
resetBuffer
void resetBuffer()Resets the buffer. -
enterPreviousActiveState
void enterPreviousActiveState()Enter the previous active state. -
enterCommentStartState
void enterCommentStartState()Enter the comment start state. -
enterCommentEndState
void enterCommentEndState()Enter the comment end state. -
enterCommentInnerState
void enterCommentInnerState()Enter the comment inner state. -
enterRuleState
void enterRuleState()Enter the rule state. -
enterUnknownStateIfNestedBlocksFinished
void enterUnknownStateIfNestedBlocksFinished()Enter the unknown state if nested blocks are finished. -
enterRuleStateBasedOnItsType
void enterRuleStateBasedOnItsType()Enter the rule state, based on whether the current state is unsupported or conditional. -
enterUnknownState
void enterUnknownState()Enter the unknown state. -
enterAtRuleBlockState
void enterAtRuleBlockState()Enter the At-rule block state. -
enterConditionalGroupAtRuleBlockState
void enterConditionalGroupAtRuleBlockState()Enter the conditional group At-rule block state. -
enterPropertiesState
void enterPropertiesState()Enter the properties state. -
storeCurrentSelector
void storeCurrentSelector()Store the current selector. -
storeCurrentProperties
void storeCurrentProperties()Store the current properties. -
storeCurrentPropertiesWithoutSelector
void storeCurrentPropertiesWithoutSelector()Store the current properties without selector. -
storeSemicolonAtRule
void storeSemicolonAtRule()Store the semicolon At-rule. -
finishAtRuleBlock
void finishAtRuleBlock()Finish the At-rule block. -
pushBlockPrecedingAtRule
void pushBlockPrecedingAtRule()Push the block preceding At-rule. -
saveActiveState
private void saveActiveState()Save the active state. -
setState
-
processProperties
-
processProperties
Processes the properties.- Parameters:
properties- the properties
-
normalizeDeclarationURIs
Normalizes the declaration URIs.- Parameters:
declarations- the declarations
-
normalizeSingleDeclarationURI
-
processSemicolonAtRule
Processes the semicolon At-rule.- Parameters:
ruleStr- the rule str
-
processFinishedAtRuleBlock
Processes the finished At-rule block.- Parameters:
atRule- the at rule
-
isCurrentRuleSupported
private boolean isCurrentRuleSupported()Checks if is current rule is supported.- Returns:
- true, if the current rule is supported
-
currentAtRuleIsConditionalGroupRule
private boolean currentAtRuleIsConditionalGroupRule()Checks if the current At-rule is a conditional group rule (or if it's unsupported).- Returns:
- true, if the current At-rule is unsupported or conditional
-
CssParserStateController(String)constructor