Package com.aspectran.core.util.apon
Class AponWriter
- java.lang.Object
-
- com.aspectran.core.util.apon.AponFormat
-
- com.aspectran.core.util.apon.AponWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class AponWriter extends AponFormat implements java.io.Flushable, java.io.Closeable
Converts a Parameters object to an APON formatted string.If pretty-printing is enabled, includes spaces, tabs to make the format more readable. By default, pretty-printing is enabled, and the indent string is a tab character.
-
-
Field Summary
-
Fields inherited from class com.aspectran.core.util.apon.AponFormat
COMMENT_LINE_START, CURLY_BRACKET_CLOSE, CURLY_BRACKET_OPEN, DOUBLE_QUOTE_CHAR, ESCAPE_CHAR, FALSE, INDENT_STRING, NAME_VALUE_SEPARATOR, NEW_LINE_CHAR, NO_CONTROL_CHAR, NULL, ROUND_BRACKET_CLOSE, ROUND_BRACKET_OPEN, SINGLE_QUOTE_CHAR, SPACE, SPACE_CHAR, SQUARE_BRACKET_CLOSE, SQUARE_BRACKET_OPEN, TEXT_LINE_START, TRUE
-
-
Constructor Summary
Constructors Constructor Description AponWriter(java.io.File file)
Instantiates a new AponWriter.AponWriter(java.io.File file, boolean append)
Instantiates a new AponWriter.AponWriter(java.io.Writer writer)
Instantiates a new AponWriter.AponWriter(java.io.Writer writer, boolean prettyPrint)
Instantiates a new AponWriter.AponWriter(java.io.Writer writer, java.lang.String indentString)
Instantiates a new AponWriter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the writer.void
comment(java.lang.String describe)
Writes a comment to the character-output stream.void
flush()
void
setIndentString(java.lang.String indentString)
void
setNoQuotes(boolean noQuotes)
Sets whether wrap a string in quotes.void
setNullWrite(boolean nullWrite)
Sets whether to write a null parameter.void
setPrettyPrint(boolean prettyPrint)
void
setTypeHintWrite(boolean typeHintWrite)
Sets whether write a type hint for values.static java.lang.String
stringify(Parameters parameters)
Converts a Parameters object to an APON formatted string.static java.lang.String
stringify(Parameters parameters, boolean prettyPrint)
Converts a Parameters object to an APON formatted string.static java.lang.String
stringify(Parameters parameters, java.lang.String indentString)
Converts a Parameters object to an APON formatted string.void
write(Parameter parameter)
Write a Parameter object to the character-output stream.void
write(Parameters parameters)
Write a Parameters object to the character-output stream.-
Methods inherited from class com.aspectran.core.util.apon.AponFormat
escape, unescape
-
-
-
-
Constructor Detail
-
AponWriter
public AponWriter(java.io.Writer writer)
Instantiates a new AponWriter. By default, pretty printing is enabled, and the indent string is a tab character.- Parameters:
writer
- the character-output stream
-
AponWriter
public AponWriter(java.io.Writer writer, boolean prettyPrint)
Instantiates a new AponWriter. If pretty-printing is enabled, includes spaces, tabs to make the format more readable. By default, the indent string is a tab character.- Parameters:
writer
- the character-output streamprettyPrint
- enables or disables pretty-printing
-
AponWriter
public AponWriter(java.io.Writer writer, java.lang.String indentString)
Instantiates a new AponWriter. If pretty-printing is enabled, includes spaces, tabs to make the format more readable.- Parameters:
writer
- the character-output streamindentString
- the string that should be used for indentation when pretty-printing is enabled
-
AponWriter
public AponWriter(java.io.File file) throws java.io.IOException
Instantiates a new AponWriter.- Parameters:
file
- a File object to write to- Throws:
java.io.IOException
- if an I/O error occurs
-
AponWriter
public AponWriter(java.io.File file, boolean append) throws java.io.IOException
Instantiates a new AponWriter.- Parameters:
file
- a File object to write toappend
- iftrue
, then bytes will be written to the end of the file rather than the beginning- Throws:
java.io.IOException
- if an I/O error occurs
-
-
Method Detail
-
setPrettyPrint
public void setPrettyPrint(boolean prettyPrint)
-
setIndentString
public void setIndentString(java.lang.String indentString)
-
setNoQuotes
public void setNoQuotes(boolean noQuotes)
Sets whether wrap a string in quotes.- Parameters:
noQuotes
- true, wrap a string in quotes
-
setNullWrite
public void setNullWrite(boolean nullWrite)
Sets whether to write a null parameter.- Parameters:
nullWrite
- true, write a null parameter
-
setTypeHintWrite
public void setTypeHintWrite(boolean typeHintWrite)
Sets whether write a type hint for values.- Parameters:
typeHintWrite
- true, write a type hint for values
-
write
public void write(Parameters parameters) throws java.io.IOException
Write a Parameters object to the character-output stream.- Parameters:
parameters
- the Parameters object to be converted- Throws:
java.io.IOException
- if an I/O error occurs
-
write
public void write(Parameter parameter) throws java.io.IOException
Write a Parameter object to the character-output stream.- Parameters:
parameter
- the Parameter object to be converted- Throws:
java.io.IOException
- if an I/O error occurs
-
comment
public void comment(java.lang.String describe) throws java.io.IOException
Writes a comment to the character-output stream.- Parameters:
describe
- the comment to write to a character-output stream- Throws:
java.io.IOException
- if an I/O error occurs
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Closes the writer.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- if an I/O error occurs
-
stringify
public static java.lang.String stringify(Parameters parameters)
Converts a Parameters object to an APON formatted string. By default, pretty printing is enabled, and the indent string is a tab character.- Parameters:
parameters
- the Parameters object to be converted- Returns:
- a string that contains the APON text
-
stringify
public static java.lang.String stringify(Parameters parameters, boolean prettyPrint)
Converts a Parameters object to an APON formatted string. If pretty-printing is enabled, includes spaces, tabs to make the format more readable. The default indentation string is a tab character.- Parameters:
parameters
- the Parameters object to be convertedprettyPrint
- enables or disables pretty-printing- Returns:
- a string that contains the APON text
-
stringify
public static java.lang.String stringify(Parameters parameters, java.lang.String indentString)
Converts a Parameters object to an APON formatted string. If pretty-printing is enabled, includes spaces, tabs to make the format more readable.- Parameters:
parameters
- the Parameters object to be convertedindentString
- the string that should be used for indentation when pretty-printing is enabled- Returns:
- a string that contains the APON text
-
-