Top Description Inners Fields Constructors Methods
com.amazon.ion.util

public Class Printer

extends Object
Class Inheritance
Annotations
@Deprecated
Static Imports
com.amazon.ion.SystemSymbols.IMPORTS, .SystemSymbols.ION_1_0_SID, .SystemSymbols.ION_SYMBOL_TABLE, .SystemSymbols.SYMBOLS

Deprecated

Use IonValue#writeTo(IonWriter) instead.

Renders 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.

See Also
IonWriter, IonTextWriterBuilder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public class
public static class

Field Summary

Modifier and TypeField and Description
protected Printer.Options

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private void
_print(IonValue value, Printer.PrinterVisitor pv)
References Deprecated Printer.PrinterVisitor is deprecated or references (maybe indirectly) at least one deprecated element.

public synchronized boolean
getPrintBlobAsString()

Indicates whether this printer renders blobs as Base64 strings.

public synchronized boolean
getPrintClobAsString()

Indicates whether this printer renders clobs as ASCII strings.

public synchronized boolean
getPrintDatagramAsList()

Indicates whether this printer renders datagrams as lists.

public synchronized boolean
getPrintDecimalAsFloat()

Indicates whether this printer renders decimals as floats, thus using 'e' notation for all real values.

public synchronized boolean
getPrintSexpAsList()

Indicates whether this printer renders sexps as lists.

public synchronized boolean
getPrintStringAsJson()

Indicates whether this printer renders strings using JSON escapes.

public synchronized boolean
getPrintSymbolAsString()

Indicates whether this printer renders symbols as strings.

public synchronized boolean
getPrintTimestampAsMillis()

Indicates whether this printer renders timestamps as millisecond values.

public synchronized boolean
getPrintTimestampAsString()

Indicates whether this printer renders timestamps as strings.

public synchronized boolean
getPrintUntypedNulls()

Indicates whether this printer renders all null values as null (i.e., the same as an IonNull).

public synchronized boolean
getSkipAnnotations()

Indicates whether this printer skips (i.e., doesn't print) annotations.

public synchronized boolean
getSkipSystemValues()

Indicates whether this printer skips (i.e., doesn't print) system IDs and local symbol tables.

protected Printer.PrinterVisitor

Returns:

the visitor to invoke for printing.
makeVisitor
(Printer.Options
is a fresh copy of the Printer's options instance, not null.
options
,
Appendable
is not null.
out
)
References Deprecated Printer.PrinterVisitor is deprecated or references (maybe indirectly) at least one deprecated element.

Subclasses can override this if they wish to construct a specialization of the PrinterVisitor.

public synchronized void
setJsonMode()

Configures this printer's options to render legal JSON text.

public synchronized void
setPrintBlobAsString(boolean blobAsString)

Sets whether this printer renders blobs as Base64 strings.

public synchronized void
setPrintClobAsString(boolean clobAsString)

Sets whether this printer renders clobs as ASCII strings.

public synchronized void
setPrintDatagramAsList(boolean datagramAsList)

Sets whether this printer renders datagrams as lists.

public synchronized void
setPrintDecimalAsFloat(boolean decimalAsFloat)

Sets whether this printer renders decimals as floats, thus using 'e' notation for all real values.

public synchronized void
setPrintSexpAsList(boolean sexpAsList)

Sets whether this printer renders sexps as lists.

public synchronized void
setPrintStringAsJson(boolean stringAsJson)

Sets whether this printer renders strings using JSON escapes.

public synchronized void
setPrintSymbolAsString(boolean symbolAsString)

Sets whether this printer renders symbols as strings.

public synchronized void
setPrintTimestampAsMillis(boolean timestampAsMillis)

Sets whether this printer renders timestamps as millisecond values.

public synchronized void
setPrintTimestampAsString(boolean timestampAsString)

Sets whether this printer renders timestamps as strings.

public synchronized void
setPrintUntypedNulls(boolean untypedNulls)

Sets whether this printer renders all null values as null (i.e., the same as an IonNull).

public synchronized void
setSkipAnnotations(boolean skip)

Sets whether this printer skips (i.e., doesn't print) annotations.

public synchronized void
setSkipSystemValues(boolean skip)

Sets whether this printer skips (i.e., doesn't print) system IDs and local symbol tables.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

myOptionsback to summary
protected Printer.Options myOptions

Constructor Detail

Printerback to summary
public Printer()
Printerback to summary
public Printer(Printer.Options options)

Method Detail

_printback to summary
private void _print(IonValue value, Printer.PrinterVisitor pv) throws IOException

References Deprecated

Printer.PrinterVisitor is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

getPrintBlobAsStringback to summary
public synchronized boolean getPrintBlobAsString()

Indicates whether this printer renders blobs as Base64 strings. By default, this is false.

getPrintClobAsStringback to summary
public synchronized boolean getPrintClobAsString()

Indicates whether this printer renders clobs as ASCII strings. By default, this is false.

getPrintDatagramAsListback to summary
public synchronized boolean getPrintDatagramAsList()

Indicates whether this printer renders datagrams as lists. By default, this property is false.

getPrintDecimalAsFloatback to summary
public synchronized boolean getPrintDecimalAsFloat()

Indicates whether this printer renders decimals as floats, thus using 'e' notation for all real values. By default, this is false.

getPrintSexpAsListback to summary
public synchronized boolean getPrintSexpAsList()

Indicates whether this printer renders sexps as lists. By default, this is false.

getPrintStringAsJsonback to summary
public synchronized boolean getPrintStringAsJson()

Indicates whether this printer renders strings using JSON escapes. By default, this is false.

getPrintSymbolAsStringback to summary
public synchronized boolean getPrintSymbolAsString()

Indicates whether this printer renders symbols as strings. By default, this is false.

getPrintTimestampAsMillisback to summary
public synchronized boolean getPrintTimestampAsMillis()

Indicates whether this printer renders timestamps as millisecond values. By default, this is false.

getPrintTimestampAsStringback to summary
public synchronized boolean getPrintTimestampAsString()

Indicates whether this printer renders timestamps as strings. By default, this is false.

getPrintUntypedNullsback to summary
public synchronized boolean getPrintUntypedNulls()

Indicates whether this printer renders all null values as null (i.e., the same as an IonNull). By default, this is false.

getSkipAnnotationsback to summary
public synchronized boolean getSkipAnnotations()

Indicates whether this printer skips (i.e., doesn't print) annotations. By default, this property is false.

getSkipSystemValuesback to summary
public synchronized boolean getSkipSystemValues()

Indicates whether this printer skips (i.e., doesn't print) system IDs and local symbol tables. By default, this property is false.

makeVisitorback to summary
protected Printer.PrinterVisitor makeVisitor(Printer.Options options, Appendable out)

References Deprecated

Printer.PrinterVisitor is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Subclasses can override this if they wish to construct a specialization of the PrinterVisitor.

Parameters
options:Printer.Options

is a fresh copy of the Printer's options instance, not null.

out:Appendable

is not null.

Returns:Printer.PrinterVisitor

the visitor to invoke for printing.

setJsonModeback to summary
public synchronized void setJsonMode()

Configures this printer's options to render legal JSON text. The following options are modified so that:

All other options are left as is.
setPrintBlobAsStringback to summary
public synchronized void setPrintBlobAsString(boolean blobAsString)

Sets whether this printer renders blobs as Base64 strings. By default, this is false.

setPrintClobAsStringback to summary
public synchronized void setPrintClobAsString(boolean clobAsString)

Sets whether this printer renders clobs as ASCII strings. By default, this is false.

setPrintDatagramAsListback to summary
public synchronized void setPrintDatagramAsList(boolean datagramAsList)

Sets whether this printer renders datagrams as lists. By default, this property is false.

setPrintDecimalAsFloatback to summary
public synchronized void setPrintDecimalAsFloat(boolean decimalAsFloat)

Sets whether this printer renders decimals as floats, thus using 'e' notation for all real values. By default, this is false.

setPrintSexpAsListback to summary
public synchronized void setPrintSexpAsList(boolean sexpAsList)

Sets whether this printer renders sexps as lists. By default, this is false.

setPrintStringAsJsonback to summary
public synchronized void setPrintStringAsJson(boolean stringAsJson)

Sets whether this printer renders strings using JSON escapes. By default, this is false.

setPrintSymbolAsStringback to summary
public synchronized void setPrintSymbolAsString(boolean symbolAsString)

Sets whether this printer renders symbols as strings. By default, this is false.

setPrintTimestampAsMillisback to summary
public synchronized void setPrintTimestampAsMillis(boolean timestampAsMillis)

Sets whether this printer renders timestamps as millisecond values. By default, this is false.

setPrintTimestampAsStringback to summary
public synchronized void setPrintTimestampAsString(boolean timestampAsString)

Sets whether this printer renders timestamps as strings. By default, this is false.

setPrintUntypedNullsback to summary
public synchronized void setPrintUntypedNulls(boolean untypedNulls)

Sets whether this printer renders all null values as null (i.e., the same as an IonNull). By default, this is false.

setSkipAnnotationsback to summary
public synchronized void setSkipAnnotations(boolean skip)

Sets whether this printer skips (i.e., doesn't print) annotations. By default, this property is false.

setSkipSystemValuesback to summary
public synchronized void setSkipSystemValues(boolean skip)

Sets whether this printer skips (i.e., doesn't print) system IDs and local symbol tables. By default, this property is false.

com.amazon.ion.util back to summary

private Class Printer.BasicSymbolTableProvider

extends Object
implements SymbolTableProvider
Class Inheritance
All Implemented Interfaces
com.amazon.ion.impl._Private_IonValue.SymbolTableProvider

Field Summary

Modifier and TypeField and Description
private final SymbolTable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public SymbolTable
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

symbolTableback to summary
private final SymbolTable symbolTable

Constructor Detail

BasicSymbolTableProviderback to summary
public BasicSymbolTableProvider(SymbolTable symbolTable)

Method Detail

getSymbolTableback to summary
public SymbolTable getSymbolTable()

Implements com.amazon.ion.impl._Private_IonValue.SymbolTableProvider.getSymbolTable.

com.amazon.ion.util back to summary

public Class Printer.Options

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable

Field Summary

Modifier and TypeField and Description
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Printer.Options
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blobAsStringback to summary
public boolean blobAsString
clobAsStringback to summary
public boolean clobAsString
datagramAsListback to summary
public boolean datagramAsList
decimalAsFloatback to summary
public boolean decimalAsFloat
sexpAsListback to summary
public boolean sexpAsList
simplifySystemValuesback to summary
public boolean simplifySystemValues
skipAnnotationsback to summary
public boolean skipAnnotations
skipSystemValuesback to summary
public boolean skipSystemValues
stringAsJsonback to summary
public boolean stringAsJson
symbolAsStringback to summary
public boolean symbolAsString
timestampAsMillisback to summary
public boolean timestampAsMillis
timestampAsStringback to summary
public boolean timestampAsString
untypedNullsback to summary
public boolean untypedNulls

Constructor Detail

Optionsback to summary
public Options()

Method Detail

cloneback to summary
public Printer.Options clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Printer.Options

a clone of this instance.

Annotations
@Override
com.amazon.ion.util back to summary

public Class Printer.PrinterVisitor

extends AbstractValueVisitor
Class Inheritance

Deprecated

Use IonValue#writeTo(IonWriter) instead.

Field Summary

Modifier and TypeField and Description
protected final Printer.Options
protected final Appendable
private boolean
myQuoteOperators

Should we quote operators at the current level of the hierarchy?

private _Private_IonValue.SymbolTableProvider

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
defaultVisit(IonValue
the value to visit.
value
)

Overrides com.amazon.ion.util.AbstractValueVisitor.defaultVisit.

Default visitation behavior, called by all visit methods in AbstractValueVisitor.

pack-priv void
private final IonValue
simplify(IonValue child, SymbolTable previous_symbols)

private static final boolean
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
protected void
writeChild(IonValue value, boolean
replaces the current value of myQuoteOperators during the recursive visitation.
quoteOperators
)

Recurse down into a container, we push the current value of myQuoteOperators onto the stack and replace it with the given value.

public void
public void
writeSequenceContent(IonSequence value, boolean quoteOperators, char open, char separator, char close)

public void
writeString(String
may be null
text
)

public void
public void

Field Detail

myOptionsback to summary
protected final Printer.Options myOptions
myOutback to summary
protected final Appendable myOut
myQuoteOperatorsback to summary
private boolean myQuoteOperators

Should we quote operators at the current level of the hierarchy? As we recurse down into containers, this value is pushed on the stack by writeChild(IonValue, boolean).

mySymbolTableProviderback to summary
private _Private_IonValue.SymbolTableProvider mySymbolTableProvider

Constructor Detail

PrinterVisitorback to summary
public PrinterVisitor(Printer.Options options, Appendable out)

Method Detail

defaultVisitback to summary
protected void defaultVisit(IonValue value)

Overrides com.amazon.ion.util.AbstractValueVisitor.defaultVisit.

Doc from com.amazon.ion.util.AbstractValueVisitor.defaultVisit.

Default visitation behavior, called by all visit methods in AbstractValueVisitor. Subclasses should override this unless they override all visit methods.

This implementation always throws UnsupportedOperationException.

Parameters
value:IonValue

the value to visit.

Annotations
@Override
setSymbolTableProviderback to summary
pack-priv void setSymbolTableProvider(_Private_IonValue.SymbolTableProvider symbolTableProvider)
simplifyback to summary
private final IonValue simplify(IonValue child, SymbolTable previous_symbols)
symbol_table_struct_has_importsback to summary
private static final boolean symbol_table_struct_has_imports(IonValue child)
visitback to summary
public void visit(IonBlob value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonBool value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonClob value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonDatagram value) throws IOException, Exception

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonDecimal value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonFloat value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonInt value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonList value) throws IOException, Exception

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonNull value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonSexp value) throws IOException, Exception

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonString value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonStruct value) throws IOException, Exception

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonSymbol value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
visitback to summary
public void visit(IonTimestamp value) throws IOException

Overrides com.amazon.ion.util.AbstractValueVisitor.visit.

Implements com.amazon.ion.ValueVisitor.visit.

Annotations
@Override
writeAnnotationsback to summary
public void writeAnnotations(IonValue value) throws IOException
writeChildback to summary
protected void writeChild(IonValue value, boolean quoteOperators) throws Exception

Recurse down into a container, we push the current value of myQuoteOperators onto the stack and replace it with the given value.

Parameters
quoteOperators:boolean

replaces the current value of myQuoteOperators during the recursive visitation.

Exceptions
Exception:
propagated from visitation of value.
NullPointerException:
if value is null.
writeNullback to summary
public void writeNull(String type) throws IOException
writeSequenceContentback to summary
public void writeSequenceContent(IonSequence value, boolean quoteOperators, char open, char separator, char close) throws IOException, Exception
writeStringback to summary
public void writeString(String text) throws IOException
Parameters
text:String

may be null

writeSymbolback to summary
public void writeSymbol(String text) throws IOException
writeSymbolTokenback to summary
public void writeSymbolToken(SymbolToken sym) throws IOException