public class Printer extends Object
IonValues to text.
By default, output is in a compact format with minimal whitespace. For example:
annot::{f1:["hello","goodbye"],'another field':long::0}
The format can be tuned through various properties on the Printer instance,
as well as through the Printer.Options structure.
Instances of this class are safe for use by multiple threads.
While printers are inexpensive to create, their configuration facilities
make them useful as shared resources. Changes to configuration settings
(e.g., setJsonMode()) do not affect concurrently-running
calls to print(software.amazon.ion.IonValue, java.lang.Appendable).
IonWriter,
IonTextWriterBuilder| Modifier and Type | Class and Description |
|---|---|
class |
Printer.Options |
static class |
Printer.PrinterVisitor |
| Modifier and Type | Field and Description |
|---|---|
protected Printer.Options |
myOptions |
| Constructor and Description |
|---|
Printer() |
Printer(Printer.Options options) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getPrintBlobAsString()
Indicates whether this printer renders blobs as Base64 strings.
|
boolean |
getPrintClobAsString()
Indicates whether this printer renders clobs as ASCII strings.
|
boolean |
getPrintDatagramAsList()
Indicates whether this printer renders datagrams as lists.
|
boolean |
getPrintDecimalAsFloat()
Indicates whether this printer renders decimals as floats, thus using 'e'
notation for all real values.
|
boolean |
getPrintSexpAsList()
Indicates whether this printer renders sexps as lists.
|
boolean |
getPrintStringAsJson()
Indicates whether this printer renders strings using JSON escapes.
|
boolean |
getPrintSymbolAsString()
Indicates whether this printer renders symbols as strings.
|
boolean |
getPrintTimestampAsMillis()
Indicates whether this printer renders timestamps as millisecond values.
|
boolean |
getPrintTimestampAsString()
Indicates whether this printer renders timestamps as strings.
|
boolean |
getPrintUntypedNulls()
Indicates whether this printer renders all null values as
null
(i.e., the same as an IonNull). |
boolean |
getSkipAnnotations()
Indicates whether this printer skips (i.e., doesn't print)
annotations.
|
boolean |
getSkipSystemValues()
Indicates whether this printer skips (i.e., doesn't print)
system IDs and local symbol tables.
|
protected Printer.PrinterVisitor |
makeVisitor(Printer.Options options,
Appendable out)
Subclasses can override this if they wish to construct a specialization
of the
Printer.PrinterVisitor. |
void |
print(IonValue value,
Appendable out) |
void |
setJsonMode()
Configures this printer's options to render legal JSON text.
|
void |
setPrintBlobAsString(boolean blobAsString)
Sets whether this printer renders blobs as Base64 strings.
|
void |
setPrintClobAsString(boolean clobAsString)
Sets whether this printer renders clobs as ASCII strings.
|
void |
setPrintDatagramAsList(boolean datagramAsList)
Sets whether this printer renders datagrams as lists.
|
void |
setPrintDecimalAsFloat(boolean decimalAsFloat)
Sets whether this printer renders decimals as floats, thus using 'e'
notation for all real values.
|
void |
setPrintSexpAsList(boolean sexpAsList)
Sets whether this printer renders sexps as lists.
|
void |
setPrintStringAsJson(boolean stringAsJson)
Sets whether this printer renders strings using JSON escapes.
|
void |
setPrintSymbolAsString(boolean symbolAsString)
Sets whether this printer renders symbols as strings.
|
void |
setPrintTimestampAsMillis(boolean timestampAsMillis)
Sets whether this printer renders timestamps as millisecond values.
|
void |
setPrintTimestampAsString(boolean timestampAsString)
Sets whether this printer renders timestamps as strings.
|
void |
setPrintUntypedNulls(boolean untypedNulls)
Sets whether this printer renders all null values as
null
(i.e., the same as an IonNull). |
void |
setSkipAnnotations(boolean skip)
Sets whether this printer skips (i.e., doesn't print)
annotations.
|
void |
setSkipSystemValues(boolean skip)
Sets whether this printer skips (i.e., doesn't print)
system IDs and local symbol tables.
|
protected Printer.Options myOptions
public Printer()
public Printer(Printer.Options options)
public boolean getSkipSystemValues()
false.public void setSkipSystemValues(boolean skip)
false.public boolean getSkipAnnotations()
false.public void setSkipAnnotations(boolean skip)
false.public boolean getPrintBlobAsString()
false.public void setPrintBlobAsString(boolean blobAsString)
false.public boolean getPrintClobAsString()
false.public void setPrintClobAsString(boolean clobAsString)
false.public boolean getPrintDatagramAsList()
false.public void setPrintDatagramAsList(boolean datagramAsList)
false.public boolean getPrintDecimalAsFloat()
false.public void setPrintDecimalAsFloat(boolean decimalAsFloat)
false.public boolean getPrintSexpAsList()
false.public void setPrintSexpAsList(boolean sexpAsList)
false.public boolean getPrintStringAsJson()
false.public void setPrintStringAsJson(boolean stringAsJson)
false.public boolean getPrintSymbolAsString()
false.public void setPrintSymbolAsString(boolean symbolAsString)
false.public boolean getPrintTimestampAsMillis()
false.public void setPrintTimestampAsMillis(boolean timestampAsMillis)
false.public boolean getPrintTimestampAsString()
false.public void setPrintTimestampAsString(boolean timestampAsString)
false.public boolean getPrintUntypedNulls()
null
(i.e., the same as an IonNull).
By default, this is false.public void setPrintUntypedNulls(boolean untypedNulls)
null
(i.e., the same as an IonNull).
By default, this is false.public void setJsonMode()
Printer.Options.blobAsString is truePrinter.Options.clobAsString is truePrinter.Options.datagramAsList is truePrinter.Options.decimalAsFloat is truePrinter.Options.sexpAsList is truePrinter.Options.skipAnnotations is truePrinter.Options.skipSystemValues is truePrinter.Options.stringAsJson is truePrinter.Options.symbolAsString is truePrinter.Options.timestampAsString is falsePrinter.Options.timestampAsMillis is truePrinter.Options.untypedNulls is truepublic void print(IonValue value, Appendable out) throws IOException
IOExceptionprotected Printer.PrinterVisitor makeVisitor(Printer.Options options, Appendable out)
Printer.PrinterVisitor.options - is a fresh copy of the Printer's options instance,
not null.out - is not null.