Class SerializerWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
- Direct Known Subclasses:
- CsvWriter,- JsonWriter,- UonWriter,- XmlWriter
Writer with additional methods.
 Modeled after the Java ProcessBuilder class so that you can chain commands to reduce the need for string concatenation for performance reasons.
Example:
   
See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final intMax indentation levels.protected final WriterThe underlying writer.protected final charThe quote character being used by this writer.protected final booleanTrim strings flag.protected final UriResolverThe URI resolver of the request.protected final booleanUse-whitespace flag.
- 
Constructor SummaryConstructorsConstructorDescriptionSerializerWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, char quoteChar, UriResolver uriResolver) Copy Constructor
- 
Method SummaryModifier and TypeMethodDescriptionappend(char c) append(char[] value) Appends the specified characters to this writer.append(int indent, char value) Writes an indent (if theuseWhitespacesetting is enabled), followed by text.Writes an indent (if theuseWhitespacesetting is enabled), followed by text.Writes the specified text to the writer if it isn'tnull .Writes the specified text to the writer if it isn'tnull .appendIf(boolean flag, char value) Writes the specified text to the writer if b is true.Writes the specified text to the writer if b is true.Writes an indent (if theuseWhitespacesetting is enabled), followed by text, followed by a newline (if theuseWhitespacesetting is enabled).Writes the specified text followed by a newline (if theuseWhitespacesetting is enabled).Appends the specified object as a URI.voidclose()cr(int depth) Performs a carriage return.cre(int depth) Performs a carriage return at the end of a line.voidflush()i(int indent) Writes an indent to the writer if theuseWhitespacesetting is enabled.ie(int indent) Writes an end-of-line indent to the writer if theuseWhitespacesetting is enabled.nl(int indent) Writes a newline to the writer if theuseWhitespacesetting is enabled.nlIf(boolean flag, int indent) Writes a newline to the writer if theuseWhitespacesetting is enabled and the boolean flag is true.q()Adds the quote character specified by thequoteCharsetting to the output.s()Adds a whitespace character to the output if theuseWhitespacesetting is enabled.sIf(boolean flag) Writes a space if the boolean expression istrue anduseWhitespaceis false.w(char value) Writes the specified character to the writer.Writes the specified string to the writer.voidwrite(char[] cbuf, int off, int len) 
- 
Field Details- 
outThe underlying writer.
- 
useWhitespaceUse-whitespace flag.
- 
maxIndentMax indentation levels.
- 
trimStringsTrim strings flag.
- 
quoteCharThe quote character being used by this writer.
- 
uriResolverThe URI resolver of the request.
 
- 
- 
Constructor Details- 
SerializerWriterpublic SerializerWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, char quoteChar, UriResolver uriResolver) - Parameters:
- out- The writer being wrapped.
- useWhitespace- If- true , calling- cr(int)will create an indentation and calling- s()will write a space character.
- maxIndent- The maximum indentation level.
- trimStrings- If- true , strings should be trimmed before they're serialized.
- quoteChar- The character to write when- q()is called.
- uriResolver- The URI resolver for resolving URIs to absolute or root-relative form.
 
- 
SerializerWriterCopy Constructor- Parameters:
- w- Writer being copied.
 
 
- 
- 
Method Details- 
crPerforms a carriage return.Adds a newline and the specified number of tabs (if the useWhitespacesetting is enabled) to the output.- Parameters:
- depth- The indentation.
- Returns:
- This object.
 
- 
crePerforms a carriage return at the end of a line.Adds a newline and the specified number of tabs (if the useWhitespacesetting is enabled) to the output.- Parameters:
- depth- The indentation.
- Returns:
- This object.
 
- 
appendlnWrites an indent (if theuseWhitespacesetting is enabled), followed by text, followed by a newline (if theuseWhitespacesetting is enabled).- Parameters:
- indent- The number of tabs to indent.
- value- The text to write.
- Returns:
- This object.
 
- 
appendlnWrites the specified text followed by a newline (if theuseWhitespacesetting is enabled).- Parameters:
- value- The text to write.
- Returns:
- This object.
 
- 
appendWrites an indent (if theuseWhitespacesetting is enabled), followed by text.- Parameters:
- indent- The number of tabs to indent.
- value- The text to write.
- Returns:
- This object.
 
- 
appendWrites an indent (if theuseWhitespacesetting is enabled), followed by text.- Parameters:
- indent- The number of tabs to indent.
- value- The character to write.
- Returns:
- This object.
 
- 
appendUriAppends the specified object as a URI.Object is converted to a String usingtoString() , so this will work onURLorURIobjects, or any other type that returns a URI via it'stoString() method.The URI is resolved based on the Serializer.Builder.uriRelativity(UriRelativity)andSerializer.Builder.uriResolution(UriResolution)settings and theUriContextthat's part of the session.- Parameters:
- value- The URI to serialize.
- Returns:
- This object.
 
- 
appendAppends the specified characters to this writer.- Parameters:
- value- The characters to append to this writer.
- Returns:
- This object.
 
- 
sAdds a whitespace character to the output if theuseWhitespacesetting is enabled.- Returns:
- This object.
 
- 
qAdds the quote character specified by thequoteCharsetting to the output.- Returns:
- This object.
 
- 
iWrites an indent to the writer if theuseWhitespacesetting is enabled.- Parameters:
- indent- The number of tabs to indent.
- Returns:
- This object.
 
- 
ieWrites an end-of-line indent to the writer if theuseWhitespacesetting is enabled.- Parameters:
- indent- The number of tabs to indent.
- Returns:
- This object.
 
- 
nlWrites a newline to the writer if theuseWhitespacesetting is enabled.- Parameters:
- indent- The current indentation level.
- Returns:
- This object.
 
- 
sIfWrites a space if the boolean expression istrue anduseWhitespaceis false.Intended for cases in XML where text should be separated by either a space or newline. This ensures the text is separated by a space if whitespace is disabled. - Parameters:
- flag- The boolean flag.
- Returns:
- This object.
 
- 
nlIfWrites a newline to the writer if theuseWhitespacesetting is enabled and the boolean flag is true.- Parameters:
- flag- The boolean flag.
- indent- The current indentation level.
- Returns:
- This object.
 
- 
appendWrites the specified text to the writer if it isn'tnull .- Parameters:
- value- The text to write.
- Returns:
- This object.
 
- 
appendWrites the specified text to the writer if it isn'tnull .- Parameters:
- value- The text to write.
- Returns:
- This object.
 
- 
appendIfWrites the specified text to the writer if b is true.- Parameters:
- flag- Boolean flag.
- value- The text to write.
- Returns:
- This object.
 
- 
appendIfWrites the specified text to the writer if b is true.- Parameters:
- flag- Boolean flag.
- value- The text to write.
- Returns:
- This object.
 
- 
wWrites the specified character to the writer.- Parameters:
- value- The character to write.
- Returns:
- This object.
 
- 
wWrites the specified string to the writer.- Parameters:
- value- The string to write.
- Returns:
- This object.
 
- 
append- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- Writer
 
- 
write
- 
flush- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin class- Writer
- Throws:
- IOException
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein class- Writer
- Throws:
- IOException
 
 
-