@NotThreadSafe public class CSSWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_OPTIMIZED_OUTPUT
By default optimized output is disabled
|
| Constructor and Description |
|---|
CSSWriter()
Constructor for creating non-optimized output.
|
CSSWriter(CSSWriterSettings aSettings)
Constructor
|
CSSWriter(ECSSVersion eVersion)
Constructor for creating non-optimized output.
|
CSSWriter(ECSSVersion eVersion,
boolean bOptimizedOutput)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getContentCharset() |
String |
getCSSAsString(CascadingStyleSheet aCSS)
Create the CSS without a specific charset.
|
String |
getCSSAsString(ICSSWriteable aCSS)
Get the string representation of the passed CSS object.
|
String |
getFooterText() |
String |
getHeaderText() |
CSSWriterSettings |
getSettings() |
boolean |
isWriteFooterText()
Check if the footer text should be emitted.
|
boolean |
isWriteHeaderText()
Check if the header text should be emitted.
|
CSSWriter |
setContentCharset(String sContentCharset)
Define the content charset to be used.
|
CSSWriter |
setFooterText(String sFooterText)
Set a custom footer text that should be emitted.
|
CSSWriter |
setHeaderText(String sHeaderText)
Set a custom header text that should be emitted.
|
CSSWriter |
setWriteFooterText(boolean bWriteFooterText)
Determine whether the file footer should be written or not.
|
CSSWriter |
setWriteHeaderText(boolean bWriteHeaderText)
Determine whether the file header should be written or not.
|
void |
writeCSS(CascadingStyleSheet aCSS,
Writer aWriter)
Write the CSS content to the passed writer.
|
void |
writeCSS(ICSSWriteable aCSS,
Writer aWriter)
Write the CSS content to the passed writer.
|
public static final boolean DEFAULT_OPTIMIZED_OUTPUT
public CSSWriter()
public CSSWriter(@Nonnull ECSSVersion eVersion)
eVersion - The CSS version to emit the code for. May not be null .public CSSWriter(@Nonnull ECSSVersion eVersion, boolean bOptimizedOutput)
eVersion - The CSS version to emit the code for. May not be null .bOptimizedOutput - If true the number of bytes emitted by this writer is
minimized. Also style rules having no declarations are omitted.public CSSWriter(@Nonnull CSSWriterSettings aSettings)
aSettings - The settings to be used. May not be null.public boolean isWriteHeaderText()
true if the header text should be emitted,
false if not.@Nonnull public CSSWriter setWriteHeaderText(boolean bWriteHeaderText)
bWriteHeaderText - If true the header text will be written, if
false the text will not be written.@Nullable public String getHeaderText()
null.@Nonnull public CSSWriter setHeaderText(@Nullable String sHeaderText)
isWriteHeaderText() returns true.sHeaderText - The header text to be emitted. May be null.public boolean isWriteFooterText()
true if the footer text should be emitted,
false if not.@Nonnull public CSSWriter setWriteFooterText(boolean bWriteFooterText)
bWriteFooterText - If true the footer text will be written, if
false the text will not be written.@Nullable public String getFooterText()
null.@Nonnull public CSSWriter setFooterText(@Nullable String sFooterText)
isWriteFooterText() returns true.sFooterText - The footer text to be emitted. May be null.@Nullable public String getContentCharset()
null.@Nonnull public CSSWriter setContentCharset(@Nullable String sContentCharset)
null and not
empty, the @charset element is emitted into the CSS. By
default no charset is defined.sContentCharset - The content charset to be used. May be null to indicate
that no special charset name should be emitted into the CSS.@Nonnull @ReturnsMutableObject(value="Design") public CSSWriterSettings getSettings()
null.public void writeCSS(@Nonnull CascadingStyleSheet aCSS, @Nonnull @WillClose Writer aWriter) throws IOException
aCSS - The CSS to write. May not be null.aWriter - The write to write the text to. May not be null. Is
automatically closed after the writing!IOException - In case writing fails.IllegalStateException - In case some elements cannot be written in the version supplied in
the constructor.getCSSAsString(CascadingStyleSheet)@Nonnull public String getCSSAsString(@Nonnull CascadingStyleSheet aCSS)
aCSS - The CSS object to be converted to text. May not be null
.writeCSS(CascadingStyleSheet, Writer)public void writeCSS(@Nonnull ICSSWriteable aCSS, @Nonnull @WillClose Writer aWriter) throws IOException
aCSS - The CSS to write. May not be null.aWriter - The write to write the text to. May not be null. Is
automatically closed after the writing!IOException - In case writing fails.IllegalStateException - In case some elements cannot be written in the version supplied in
the constructor.getCSSAsString(ICSSWriteable)@Nonnull public String getCSSAsString(@Nonnull ICSSWriteable aCSS)
ICSSWriteable.aCSS - The CSS object to be converted to text. May not be null
.writeCSS(ICSSWriteable, Writer)Copyright © 2014–2022 Philip Helger. All rights reserved.