Class DefaultStyleFormattingContext
- All Implemented Interfaces:
DeclarationFormattingContext
,StyleFormattingContext
,Serializable
- Direct Known Subclasses:
InlineStyleFormattingContext
- See Also:
-
Constructor Summary
-
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
(org.w3c.dom.css.CSSRule rule) Notify this context that the style was serialized for the given rule.void
endInlinePropertyDeclaration
(io.sf.carte.util.SimpleWriter wri) End an inline property declaration.void
endPropertyDeclaration
(io.sf.carte.util.SimpleWriter wri) Ends a property declaration in a rule style (does not apply to inline styles).void
Ends the serialization of a rule.void
endRuleList
(io.sf.carte.util.SimpleWriter wri) Called after a list of rules is serialized.void
endStyleDeclaration
(io.sf.carte.util.SimpleWriter wri) End a style declaration.void
setParentContext
(org.w3c.dom.css.CSSRule rule) Sets the parent of the rule being serialized, if any, providing additional context for the serialization.void
Starts the serialization of a rule.void
startStyleDeclaration
(io.sf.carte.util.SimpleWriter wri) Start a style declaration (of either properties or descriptors).void
updateContext
(org.w3c.dom.css.CSSRule rule) Update this context for the given rule.void
writeComment
(io.sf.carte.util.SimpleWriter wri, String comment) Serialize a comment that precedes a rule, with the appropriate indent.void
writeFullIndent
(io.sf.carte.util.SimpleWriter wri) Serialize a full paragraph indent to aSimpleWriter
.void
writeImportantPriority
(io.sf.carte.util.SimpleWriter wri) Serialize animportant
priority declaration to aSimpleWriter
.void
writeLeftCurlyBracket
(io.sf.carte.util.SimpleWriter wri) Serialize a left curly bracket to aSimpleWriter
.void
writeLevelIndent
(io.sf.carte.util.SimpleWriter wri) Serialize one level of indentation to aSimpleWriter
.void
writeRightCurlyBracket
(io.sf.carte.util.SimpleWriter wri) Serialize a right curly bracket to aSimpleWriter
.void
writeSemiColon
(io.sf.carte.util.SimpleWriter wri) Serialize a semicolon to aSimpleWriter
.void
Serialize a URL/URI to aSimpleWriter
.Methods inherited from class io.sf.carte.doc.style.css.om.DefaultDeclarationFormattingContext
startPropertyDeclaration, writeColon, writeComma
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.DeclarationFormattingContext
startPropertyDeclaration, writeColon, writeComma, writeMinifiedValue, writeValue
Methods inherited from interface io.sf.carte.doc.style.css.StyleFormattingContext
writeShorthandValue
-
Constructor Details
-
DefaultStyleFormattingContext
public DefaultStyleFormattingContext()
-
-
Method Details
-
deepenCurrentContext
public void deepenCurrentContext()Description copied from interface:StyleFormattingContext
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.- Specified by:
deepenCurrentContext
in interfaceStyleFormattingContext
-
endCurrentContext
public void endCurrentContext(org.w3c.dom.css.CSSRule rule) Description copied from interface:StyleFormattingContext
Notify this context that the style was serialized for the given rule.It is called before
StyleFormattingContext.endStyleDeclaration(SimpleWriter)
.- Specified by:
endCurrentContext
in interfaceStyleFormattingContext
- Parameters:
rule
- the rule being serialized.
-
endPropertyDeclaration
Description copied from interface:DeclarationFormattingContext
Ends a property declaration in a rule style (does not apply to inline styles).It is called after
DeclarationFormattingContext.writeSemiColon(SimpleWriter)
.- Specified by:
endPropertyDeclaration
in interfaceDeclarationFormattingContext
- Overrides:
endPropertyDeclaration
in classDefaultDeclarationFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endInlinePropertyDeclaration
Description copied from interface:StyleFormattingContext
End an inline property declaration.Called after
DeclarationFormattingContext.writeSemiColon(SimpleWriter)
, only from inline styles.- Specified by:
endInlinePropertyDeclaration
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endRule
public void endRule(io.sf.carte.util.SimpleWriter wri, List<String> trailingComments) throws IOException Description copied from interface:StyleFormattingContext
Ends the serialization of a rule.It is called after
StyleFormattingContext.writeRightCurlyBracket(SimpleWriter)
.- Specified by:
endRule
in interfaceStyleFormattingContext
- 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
Description copied from interface:StyleFormattingContext
Called after a list of rules is serialized.May be used for indentation.
- Specified by:
endRuleList
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
endStyleDeclaration
Description copied from interface:StyleFormattingContext
End a style declaration.Called after
StyleFormattingContext.endCurrentContext(CSSRule)
and beforeStyleFormattingContext.writeRightCurlyBracket(SimpleWriter)
.- Specified by:
endStyleDeclaration
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
setParentContext
public void setParentContext(org.w3c.dom.css.CSSRule rule) Description copied from interface:StyleFormattingContext
Sets the parent of the rule being serialized, if any, providing additional context for the serialization.It is called before
StyleFormattingContext.startRule(SimpleWriter, List)
. However, this method being called does not guarantee thatstartRule()
will be called.- Specified by:
setParentContext
in interfaceStyleFormattingContext
- Parameters:
rule
- the parent rule. May benull
.
-
startRule
public void startRule(io.sf.carte.util.SimpleWriter wri, List<String> precedingComments) throws IOException Description copied from interface:StyleFormattingContext
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.
- Specified by:
startRule
in interfaceStyleFormattingContext
- 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
Description copied from interface:StyleFormattingContext
Start a style declaration (of either properties or descriptors).Called after
StyleFormattingContext.writeLeftCurlyBracket(SimpleWriter)
and before serializing the style declaration.- Specified by:
startStyleDeclaration
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer to write to.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
updateContext
public void updateContext(org.w3c.dom.css.CSSRule rule) Description copied from interface:StyleFormattingContext
Update this context for the given rule.For style rules, it is called after serializing the selector list and before
StyleFormattingContext.writeLeftCurlyBracket(SimpleWriter)
. At-rules call it after writing the rule name.May be used for indentation.
- Specified by:
updateContext
in interfaceStyleFormattingContext
- Parameters:
rule
- the rule being serialized.
-
writeComment
Description copied from interface:StyleFormattingContext
Serialize a comment that precedes a rule, with the appropriate indent.Trailing comments are generally written directly by
StyleFormattingContext.endRule(SimpleWriter, List)
because no indent is necessary.- Specified by:
writeComment
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer to write to.comment
- the comment to serialize.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeFullIndent
Description copied from interface:DeclarationFormattingContext
Serialize a full paragraph indent to aSimpleWriter
.- Specified by:
writeFullIndent
in interfaceDeclarationFormattingContext
- Overrides:
writeFullIndent
in classDefaultDeclarationFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeImportantPriority
Description copied from interface:StyleFormattingContext
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)
.- Specified by:
writeImportantPriority
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLeftCurlyBracket
Description copied from interface:StyleFormattingContext
Serialize a left curly bracket to aSimpleWriter
.Called after
StyleFormattingContext.updateContext(CSSRule)
and beforeStyleFormattingContext.startStyleDeclaration(SimpleWriter)
.- Specified by:
writeLeftCurlyBracket
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeLevelIndent
Description copied from interface:StyleFormattingContext
Serialize one level of indentation to aSimpleWriter
.- Specified by:
writeLevelIndent
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeRightCurlyBracket
Description copied from interface:StyleFormattingContext
Serialize a right curly bracket to aSimpleWriter
.Called after
StyleFormattingContext.endStyleDeclaration(SimpleWriter)
and beforeStyleFormattingContext.endRule(SimpleWriter, List)
.- Specified by:
writeRightCurlyBracket
in interfaceStyleFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeSemiColon
Description copied from interface:DeclarationFormattingContext
Serialize a semicolon to aSimpleWriter
.Called after writing the property name.
- Specified by:
writeSemiColon
in interfaceDeclarationFormattingContext
- Overrides:
writeSemiColon
in classDefaultDeclarationFormattingContext
- Parameters:
wri
- the writer.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-
writeURL
Description copied from interface:DeclarationFormattingContext
Serialize a URL/URI to aSimpleWriter
.- Specified by:
writeURL
in interfaceDeclarationFormattingContext
- Overrides:
writeURL
in classDefaultDeclarationFormattingContext
- Parameters:
wri
- the writer.href
- the URI.- Throws:
IOException
- if an I/O problem happens while writing to theSimpleWriter
.
-