Class CssParserStateController
- java.lang.Object
-
- com.itextpdf.styledxmlparser.css.parse.syntax.CssParserStateController
-
public final class CssParserStateController extends java.lang.Object
State machine that will parse content into a style sheet.
-
-
Field Summary
Fields Modifier and Type Field Description private IParserState
atRuleBlockState
The At-rule block state.private java.lang.StringBuilder
buffer
A buffer to store temporary results.private IParserState
commendEndState
The commend end state.private IParserState
commendInnerState
The commend inner state.private IParserState
commentStartState
The comment start state.private static java.util.Set<java.lang.String>
CONDITIONAL_GROUP_RULES
Set of conditional group rules.private IParserState
conditionalGroupAtRuleBlockState
The conditional group at rule block state.private java.lang.String
currentSelector
The current selector.private IParserState
currentState
The current state.private boolean
isCurrentRuleSupported
Indicates if the current rule is supported.private static org.slf4j.Logger
LOGGER
private java.util.Stack<CssNestedAtRule>
nestedAtRules
The nested At-rules.private IParserState
previousActiveState
The previous active state (excluding comments).private IParserState
propertiesState
The properties state.private ResourceResolver
resourceResolver
The resource resolver.private IParserState
ruleState
The rule state.private java.util.Stack<java.util.List<CssDeclaration>>
storedPropertiesWithoutSelector
The stored properties without selector.private CssStyleSheet
styleSheet
The style sheet.private CssStyleSheet
styleSheetFromImport
The style sheet from import CSS rules.private static java.util.Set<java.lang.String>
SUPPORTED_RULES
Set of the supported rules.private IParserState
unknownState
The unknown state.
-
Constructor Summary
Constructors Modifier Constructor Description CssParserStateController()
Deprecated.useCssParserStateController(String)
constructorprivate
CssParserStateController(ResourceResolver resourceResolver)
CssParserStateController(java.lang.String baseUrl)
Creates a newCssParserStateController
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
appendToBuffer(char ch)
Appends a character to the buffer.private boolean
currentAtRuleIsConditionalGroupRule()
Checks if the current At-rule is a conditional group rule (or if it's unsupported).(package private) void
enterAtRuleBlockState()
Enter the At-rule block state.(package private) void
enterCommentEndState()
Enter the comment end state.(package private) void
enterCommentInnerState()
Enter the comment inner state.(package private) void
enterCommentStartState()
Enter the comment start state.(package private) void
enterConditionalGroupAtRuleBlockState()
Enter the conditional group At-rule block state.(package private) void
enterPreviousActiveState()
Enter the previous active state.(package private) void
enterPropertiesState()
Enter the properties state.(package private) void
enterRuleState()
Enter the rule state.(package private) void
enterRuleStateBasedOnItsType()
Enter the rule state, based on whether the current state is unsupported or conditional.(package private) void
enterUnknownState()
Enter the unknown state.(package private) void
enterUnknownStateIfNestedBlocksFinished()
Enter the unknown state if nested blocks are finished.(package private) void
finishAtRuleBlock()
Finish the At-rule block.(package private) java.lang.String
getBufferContents()
Gets the contents of the buffer.CssStyleSheet
getParsingResult()
Gets the resulting style sheet.private boolean
isCurrentRuleSupported()
Checks if is current rule is supported.private void
normalizeDeclarationURIs(java.util.List<CssDeclaration> declarations)
Normalizes the declaration URIs.private void
normalizeSingleDeclarationURI(CssDeclaration declaration)
void
process(char ch)
Process a character using the current state.private void
processFinishedAtRuleBlock(CssNestedAtRule atRule)
Processes the finished At-rule block.private void
processProperties(java.lang.String properties)
Processes the properties.private void
processProperties(java.lang.String selector, java.lang.String properties)
Processes the properties.private void
processSemicolonAtRule(java.lang.String ruleStr)
Processes the semicolon At-rule.(package private) void
pushBlockPrecedingAtRule()
Push the block preceding At-rule.(package private) void
resetBuffer()
Resets the buffer.private void
saveActiveState()
Save the active state.private void
setState(IParserState state)
Sets the current state.(package private) void
storeCurrentProperties()
Store the current properties.(package private) void
storeCurrentPropertiesWithoutSelector()
Store the current properties without selector.(package private) void
storeCurrentSelector()
Store the current selector.(package private) void
storeSemicolonAtRule()
Store the semicolon At-rule.
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
SUPPORTED_RULES
private static final java.util.Set<java.lang.String> SUPPORTED_RULES
Set of the supported rules.
-
CONDITIONAL_GROUP_RULES
private static final java.util.Set<java.lang.String> CONDITIONAL_GROUP_RULES
Set of conditional group rules.
-
currentState
private IParserState currentState
The current state.
-
isCurrentRuleSupported
private boolean isCurrentRuleSupported
Indicates if the current rule is supported.
-
previousActiveState
private IParserState previousActiveState
The previous active state (excluding comments).
-
buffer
private final java.lang.StringBuilder buffer
A buffer to store temporary results.
-
currentSelector
private java.lang.String currentSelector
The current selector.
-
styleSheet
private final CssStyleSheet styleSheet
The style sheet.
-
styleSheetFromImport
private final CssStyleSheet styleSheetFromImport
The style sheet from import CSS rules. It is used to store styles from import separately to avoidStyledXmlParserLogMessageConstant.IMPORT_MUST_COME_BEFORE
on check whether were styles before import or not.
-
nestedAtRules
private final java.util.Stack<CssNestedAtRule> nestedAtRules
The nested At-rules.
-
storedPropertiesWithoutSelector
private final java.util.Stack<java.util.List<CssDeclaration>> storedPropertiesWithoutSelector
The stored properties without selector.
-
commentStartState
private final IParserState commentStartState
The comment start state.
-
commendEndState
private final IParserState commendEndState
The commend end state.
-
commendInnerState
private final IParserState commendInnerState
The commend inner state.
-
unknownState
private final IParserState unknownState
The unknown state.
-
ruleState
private final IParserState ruleState
The rule state.
-
propertiesState
private final IParserState propertiesState
The properties state.
-
conditionalGroupAtRuleBlockState
private final IParserState conditionalGroupAtRuleBlockState
The conditional group at rule block state.
-
atRuleBlockState
private final IParserState atRuleBlockState
The At-rule block state.
-
resourceResolver
private final ResourceResolver resourceResolver
The resource resolver.
-
-
Constructor Detail
-
CssParserStateController
@Deprecated public CssParserStateController()
Deprecated.useCssParserStateController(String)
constructorCreates a newCssParserStateController
instance.
-
CssParserStateController
public CssParserStateController(java.lang.String baseUrl)
Creates a newCssParserStateController
instance.- Parameters:
baseUrl
- the base URL
-
CssParserStateController
private CssParserStateController(ResourceResolver resourceResolver)
-
-
Method Detail
-
process
public void process(char ch)
Process a character using the current state.- Parameters:
ch
- the character
-
getParsingResult
public CssStyleSheet 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
java.lang.String getBufferContents()
Gets the contents of the buffer.- Returns:
- the buffer contents
-
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
private void setState(IParserState state)
Sets the current state.- Parameters:
state
- the new state
-
processProperties
private void processProperties(java.lang.String selector, java.lang.String properties)
Processes the properties.- Parameters:
selector
- the selectorproperties
- the properties
-
processProperties
private void processProperties(java.lang.String properties)
Processes the properties.- Parameters:
properties
- the properties
-
normalizeDeclarationURIs
private void normalizeDeclarationURIs(java.util.List<CssDeclaration> declarations)
Normalizes the declaration URIs.- Parameters:
declarations
- the declarations
-
normalizeSingleDeclarationURI
private void normalizeSingleDeclarationURI(CssDeclaration declaration)
-
processSemicolonAtRule
private void processSemicolonAtRule(java.lang.String ruleStr)
Processes the semicolon At-rule.- Parameters:
ruleStr
- the rule str
-
processFinishedAtRuleBlock
private void processFinishedAtRuleBlock(CssNestedAtRule atRule)
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
-
-