- All Implemented Interfaces:
Encode
,ValidMediaFilter
,ValidMediaInput
,ValidMediaOutput
,Whitespace
,NoClose
,Closeable
,Flushable
,Appendable
,AutoCloseable
- Direct Known Subclasses:
JavaScriptWriter
,MysqlWriter
,PsqlWriter
,ShWriter
,StyleWriter
,TextWriter
,XhtmlAttributeWriter
,XhtmlWriter
- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
Fields inherited from class com.aoapps.encoding.MediaWriter
DEFAULT_CLOSER, DEFAULT_IS_NO_CLOSE
Fields inherited from class java.io.FilterWriter
out
Fields inherited from interface com.aoapps.encoding.Whitespace
INDENT_SPACES, NL, SPACE
-
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) decDepth()
Decrements the indentation depth, if enabled.Encodes the given nested type with proper encoding.Encodes the given nested type with proper encoding.Encodes the given nested type with proper encoding.<Ex extends Throwable>
WhitespaceWriterencode
(MediaType contentType, MediaWritable<Ex> content) Encodes the given nested type with proper encoding.<Ex extends Throwable>
WhitespaceWriterencode
(MediaType contentType, IOSupplierE<?, Ex> content) Encodes the given nested type with proper encoding.encode
(MediaType contentType, CharSequence csq) Encodes the given nested type with proper encoding.encode
(MediaType contentType, CharSequence csq, int start, int end) Encodes the given nested type with proper encoding.Encodes the given nested type with proper encoding.int
getDepth()
Gets the current indentation depth, which begins at zero.boolean
Gets if indentation is currently enabled, off by default.incDepth()
Increments the indentation depth, if enabled.indent()
Writes the current indentation when indentation enabled.indent
(int depthOffset) Writes the current indentation with a depth offset when indentation enabled.nl()
Writes a newline.nli()
Writes a newline, followed by current indentation when indentation enabled.nli
(int depthOffset) Writes a newline, followed by current indentation with a depth offset when indentation enabled.setDepth
(int depth) Sets the indentation depth.setIndent
(boolean indent) Enables or disabled indentation.sp()
Writes one space character.sp
(int count) Writes the given number of space characters.Methods inherited from class com.aoapps.encoding.MediaWriter
canSkipValidation, close, encode, getEncoder, getEncodingContext, getValidMediaInputType, getValidMediaOutputType, isNoClose, isValidatingMediaInputType
Methods inherited from class com.aoapps.lang.io.EncoderWriter
getOut, write, write, write, write, write, writePrefix, writeSuffix, writeSuffix
Methods inherited from class java.io.FilterWriter
flush
Methods inherited from class java.io.Writer
nullWriter
-
Method Details
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classMediaWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classMediaWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classMediaWriter
- Throws:
IOException
-
encode
Description copied from interface:Encode
Encodes the given nested type with proper encoding.- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
Description copied from interface:Encode
Encodes the given nested type with proper encoding.- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
public WhitespaceWriter encode(MediaType contentType, char[] cbuf, int offset, int len) throws IOException Description copied from interface:Encode
Encodes the given nested type with proper encoding.- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
Description copied from interface:Encode
Encodes the given nested type with proper encoding.Adds prefixes and suffixes by media type, such as
"…"
.If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.
- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
public WhitespaceWriter encode(MediaType contentType, CharSequence csq, int start, int end) throws IOException Description copied from interface:Encode
Encodes the given nested type with proper encoding.Adds prefixes and suffixes by media type, such as
"…"
.If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.
- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
Description copied from interface:Encode
Encodes the given nested type with proper encoding.Adds prefixes and suffixes by media type, such as
"…"
.If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.
- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Returns:
this
writer- Throws:
IOException
-
encode
public <Ex extends Throwable> WhitespaceWriter encode(MediaType contentType, IOSupplierE<?, Ex> content) throws IOException, ExDescription copied from interface:Encode
Encodes the given nested type with proper encoding.Adds prefixes and suffixes by media type, such as
"…"
.If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.
- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Returns:
this
writer- Throws:
IOException
Ex
-
encode
public <Ex extends Throwable> WhitespaceWriter encode(MediaType contentType, MediaWritable<Ex> content) throws IOException, Ex Description copied from interface:Encode
Encodes the given nested type with proper encoding.Adds prefixes and suffixes by media type, such as
"…"
.Does not perform any translation markups.
- Specified by:
encode
in interfaceEncode
- Overrides:
encode
in classMediaWriter
- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Returns:
this
writer- Throws:
IOException
Ex
-
nl
Description copied from interface:Whitespace
Writes a newline.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Specified by:
nl
in interfaceWhitespace
- Returns:
this
writer- Throws:
IOException
- See Also:
-
nli
Description copied from interface:Whitespace
Writes a newline, followed by current indentation when indentation enabled.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Specified by:
nli
in interfaceWhitespace
- Returns:
this
writer- Throws:
IOException
- See Also:
-
nli
Description copied from interface:Whitespace
Writes a newline, followed by current indentation with a depth offset when indentation enabled.This is
'\n'
on all platforms. If a different newline is required, such as"\r\n"
for email, filter the output.- Specified by:
nli
in interfaceWhitespace
- Parameters:
depthOffset
- A value added to the current indentation depth. For example, pass-1
when performing a newline before a closing tag or ending curly brace.- Returns:
this
writer- Throws:
IOException
- See Also:
-
indent
Description copied from interface:Whitespace
Writes the current indentation when indentation enabled.- Specified by:
indent
in interfaceWhitespace
- Returns:
this
writer- Throws:
IOException
- See Also:
-
indent
Description copied from interface:Whitespace
Writes the current indentation with a depth offset when indentation enabled.- Specified by:
indent
in interfaceWhitespace
- Parameters:
depthOffset
- A value added to the current indentation depth. For example, pass-1
when performing a newline before a closing tag or ending curly brace.- Returns:
this
writer- Throws:
IOException
- See Also:
-
getIndent
public boolean getIndent()Description copied from interface:Whitespace
Gets if indentation is currently enabled, off by default.- Specified by:
getIndent
in interfaceWhitespace
-
setIndent
Description copied from interface:Whitespace
Enables or disabled indentation.- Specified by:
setIndent
in interfaceWhitespace
- Returns:
this
writer
-
getDepth
public int getDepth()Description copied from interface:Whitespace
Gets the current indentation depth, which begins at zero. This value is not updated when indentation is disabled. Not all tags will trigger indentation.- Specified by:
getDepth
in interfaceWhitespace
-
setDepth
Description copied from interface:Whitespace
Sets the indentation depth.- Specified by:
setDepth
in interfaceWhitespace
- Returns:
this
writer
-
incDepth
Description copied from interface:Whitespace
Increments the indentation depth, if enabled.- Specified by:
incDepth
in interfaceWhitespace
- Returns:
this
writer
-
decDepth
Description copied from interface:Whitespace
Decrements the indentation depth, if enabled.- Specified by:
decDepth
in interfaceWhitespace
- Returns:
this
writer
-
sp
Description copied from interface:Whitespace
Writes one space character.- Specified by:
sp
in interfaceWhitespace
- Returns:
this
writer- Throws:
IOException
- See Also:
-
sp
Description copied from interface:Whitespace
Writes the given number of space characters.- Specified by:
sp
in interfaceWhitespace
- Parameters:
count
- Whencount <= 0
, nothing is written.- Returns:
this
writer- Throws:
IOException
- See Also:
-