- All Superinterfaces:
DeclarationFormattingContext
- All Known Implementing Classes:
DefaultStyleFormattingContext
,InlineStyleFormattingContext
Different implementations of this interface can provide different style text formatting.
If the rule does not contain a style declaration (of either properties or descriptors), the methods in this interface are not called.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This auxiliary method can be used to deepen the indentation at places where the general serialization flow does not give the desired results.void
endCurrentContext
(CSSRule rule) Notify this context that the style was serialized for the given rule.void
End an inline property declaration.void
endRule
(SimpleWriter wri, List<String> trailingComments) Ends the serialization of a rule.void
endRuleList
(SimpleWriter wri) Called after a list of rules is serialized.void
End a style declaration.void
setParentContext
(CSSRule rule) Sets the parent of the rule being serialized, if any, providing additional context for the serialization.void
startRule
(SimpleWriter wri, List<String> precedingComments) Starts the serialization of a rule.void
Start a style declaration (of either properties or descriptors).void
updateContext
(CSSRule rule) Update this context for the given rule.void
writeComment
(SimpleWriter wri, String comment) Serialize a comment that precedes a rule, with the appropriate indent.void
Serialize animportant
priority declaration to aSimpleWriter
.void
Serialize a left curly bracket to aSimpleWriter
.void
Serialize one level of indentation to aSimpleWriter
.void
Serialize a right curly bracket to aSimpleWriter
.default void
writeShorthandValue
(SimpleWriter wri, String shorthandName, CSSShorthandValue value) Serialize a css shorthand value to the given writer.Methods inherited from interface io.sf.carte.doc.style.css.DeclarationFormattingContext
endPropertyDeclaration, startPropertyDeclaration, writeColon, writeComma, writeFullIndent, writeMinifiedValue, writeSemiColon, writeURL, writeValue
-
Method Details
-
deepenCurrentContext
void deepenCurrentContext()This auxiliary method can be used to deepen the indentation at places where the general serialization flow does not give the desired results.It is used only by the
@font-feature-values
rule. -
endCurrentContext
Notify this context that the style was serialized for the given rule.It is called before
endStyleDeclaration(SimpleWriter)
.- Parameters:
rule
- the rule being serialized.
-
endInlinePropertyDeclaration
End an inline property declaration.Called after
DeclarationFormattingContext.writeSemiColon(SimpleWriter)
, only from inline styles.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endRule
Ends the serialization of a rule.It is called after
writeRightCurlyBracket(SimpleWriter)
.- Parameters:
wri
- the writer to write to.trailingComments
- the comments that go after the rule.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endRuleList
Called after a list of rules is serialized.May be used for indentation.
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endStyleDeclaration
End a style declaration.Called after
endCurrentContext(CSSRule)
and beforewriteRightCurlyBracket(SimpleWriter)
.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
setParentContext
Sets the parent of the rule being serialized, if any, providing additional context for the serialization.It is called before
startRule(SimpleWriter, List)
. However, this method being called does not guarantee thatstartRule()
will be called.- Parameters:
rule
- the parent rule. May benull
.
-
startRule
Starts the serialization of a rule.It is the first stage of the serialization of a rule. For example, in the case of style rules it is called before serializing the rule selector list. At-rules call it before writing the @-rule name.
- Parameters:
wri
- the writer to write to.precedingComments
- the comments that precede the rule.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
startStyleDeclaration
Start a style declaration (of either properties or descriptors).Called after
writeLeftCurlyBracket(SimpleWriter)
and before serializing the style declaration.- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
updateContext
Update this context for the given rule.For style rules, it is called after serializing the selector list and before
writeLeftCurlyBracket(SimpleWriter)
. At-rules call it after writing the rule name.May be used for indentation.
- Parameters:
rule
- the rule being serialized.
-
writeComment
Serialize a comment that precedes a rule, with the appropriate indent.Trailing comments are generally written directly by
endRule(SimpleWriter, List)
because no indent is necessary.- Parameters:
wri
- the writer to write to.comment
- the comment to serialize.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeImportantPriority
Serialize animportant
priority declaration to aSimpleWriter
.If the property declaration has
important
priority, it is called after the value is written and beforeDeclarationFormattingContext.writeSemiColon(SimpleWriter)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLeftCurlyBracket
Serialize a left curly bracket to aSimpleWriter
.Called after
updateContext(CSSRule)
and beforestartStyleDeclaration(SimpleWriter)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLevelIndent
Serialize one level of indentation to aSimpleWriter
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeRightCurlyBracket
Serialize a right curly bracket to aSimpleWriter
.Called after
endStyleDeclaration(SimpleWriter)
and beforeendRule(SimpleWriter, List)
.- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeShorthandValue
default void writeShorthandValue(SimpleWriter wri, String shorthandName, CSSShorthandValue value) throws IOException Serialize a css shorthand value to the given writer.Although the
CSSShorthandValue
type contains priority information, this method only writes the value.The default implementation just writes
CSSValue.getCssText()
.- Parameters:
wri
- the writer.shorthandName
- the name of the shorthand property whose value is being printed.value
- the value to write.- Throws:
IOException
- if an error happened while writing.
-