Class _Private_IonWriterBase
- java.lang.Object
-
- com.amazon.ion.impl._Private_IonWriterBase
-
- All Implemented Interfaces:
Faceted,_Private_ReaderWriter,IonWriter,java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
_Private_IonBinaryWriterImpl
public abstract class _Private_IonWriterBase extends java.lang.Object implements IonWriter, _Private_ReaderWriter
NOT FOR APPLICATION USE!Base type for Ion writers. This handles the writeIonEvents and provides default handlers for the list forms of write. This also resolves symbols if a symbol table is available (which it will not be if the underlying writer is a system writer).
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringERROR_MISSING_FIELD_NAME
-
Constructor Summary
Constructors Constructor Description _Private_IonWriterBase(boolean requireSymbolValidation)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> TasFacet(java.lang.Class<T> facetType)Returns a facet of this subject if supported.protected abstract intgetDepth()Returns the current depth of containers the writer is at.abstract booleanisFieldNameSet()Returns true if the field name has been set either through setFieldName or setFieldId.booleanisStreamCopyOptimized()SymbolTablepop_passed_symbol_table()abstract voidsetSymbolTable(SymbolTable symbols)Sets the symbol table to use for encoding to be the passed in symbol table.voidwriteBlob(byte[] value)write the byte array out as an IonBlob value.voidwriteClob(byte[] value)write the byte array out as an IonClob value.abstract voidwriteDecimal(java.math.BigDecimal value)Writes a BigDecimal value as an Ion decimal.voidwriteFloat(float value)voidwriteNull()Writes a value of Ion's null type (nullakanull.null).voidwriteSymbolToken(SymbolToken tok)Writes the content of an Ion symbol value.voidwriteTimestampUTC(java.util.Date value)writes the passed in Date (in milliseconds since the epoch) as an IonTimestamp.voidwriteValue(IonReader reader)Overrides can optimize special cases.voidwriteValue(IonValue value)Deprecated.voidwriteValues(IonReader reader)Writes a reader's current value, and all following values until the end of the current container.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.amazon.ion.IonWriter
addTypeAnnotation, close, finish, flush, getSymbolTable, isInStruct, setFieldName, setFieldNameSymbol, setTypeAnnotations, setTypeAnnotationSymbols, stepIn, stepOut, writeBlob, writeBool, writeClob, writeFloat, writeInt, writeInt, writeNull, writeString, writeSymbol, writeTimestamp
-
-
-
-
Field Detail
-
ERROR_MISSING_FIELD_NAME
protected static final java.lang.String ERROR_MISSING_FIELD_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
_Private_IonWriterBase
public _Private_IonWriterBase(boolean requireSymbolValidation)
- Parameters:
requireSymbolValidation- true if SID validation should be performed; otherwise, false. See_Private_IonTextWriterBuilder.withInvalidSidsAllowed(boolean)
-
-
Method Detail
-
getDepth
protected abstract int getDepth()
Returns the current depth of containers the writer is at. This is 0 if the writer is at top-level.- Returns:
- int depth of container nesting
-
setSymbolTable
public abstract void setSymbolTable(SymbolTable symbols) throws java.io.IOException
Sets the symbol table to use for encoding to be the passed in symbol table. The can only be done between top-level values. As symbols are written this symbol table is used to resolve them. If the symbols are undefined this symbol table is updated to include them as local symbols. The updated symbol table will be written before any of the local values are emitted.If the symbol table is the system symbol table an Ion version marker will be written to the output. If symbols not in the system symbol table are written a local symbol table will be created and written before the current top level value.
- Parameters:
symbols- base symbol table for encoding. Must not be null.- Throws:
java.lang.IllegalArgumentException- if symbols is null or a shared symbol table, or if this writer isn't at top level.java.io.IOException
-
isFieldNameSet
public abstract boolean isFieldNameSet()
Returns true if the field name has been set either through setFieldName or setFieldId. This is generally more efficient than calling getFieldName or getFieldId and checking the return type as it does not need to resolve the name through a symbol table. This returns false if the field name has not been set.- Returns:
- true if a field name has been set false otherwise
-
writeBlob
public void writeBlob(byte[] value) throws java.io.IOExceptionDescription copied from interface:IonWriterwrite the byte array out as an IonBlob value. This copies the byte array.
-
writeClob
public void writeClob(byte[] value) throws java.io.IOExceptionDescription copied from interface:IonWriterwrite the byte array out as an IonClob value. This copies the byte array.
-
writeDecimal
public abstract void writeDecimal(java.math.BigDecimal value) throws java.io.IOExceptionDescription copied from interface:IonWriterWrites a BigDecimal value as an Ion decimal. Ion uses an arbitrarily long sign/value and an arbitrarily long signed exponent to write the value. This preserves all of the BigDecimal digits, the number of significant digits.To write a negative zero value, pass this method a
Decimalinstance.- Specified by:
writeDecimalin interfaceIonWriter- Parameters:
value- may be null to representnull.decimal.- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float value) throws java.io.IOException- Throws:
java.io.IOException
-
writeNull
public void writeNull() throws java.io.IOExceptionDescription copied from interface:IonWriterWrites a value of Ion's null type (nullakanull.null).
-
writeSymbolToken
public final void writeSymbolToken(SymbolToken tok) throws java.io.IOException
Description copied from interface:IonWriterWrites the content of an Ion symbol value.- Specified by:
writeSymbolTokenin interfaceIonWriter- Parameters:
tok- may be null to representnull.symbol.- Throws:
java.io.IOException
-
writeTimestampUTC
public void writeTimestampUTC(java.util.Date value) throws java.io.IOExceptionDescription copied from interface:IonWriterwrites the passed in Date (in milliseconds since the epoch) as an IonTimestamp. The Date value is treated as a UTC value with an unknown timezone offset (a z value).- Specified by:
writeTimestampUTCin interfaceIonWriter- Parameters:
value- java.util Date holding the UTC timestamp; may be null to representnull.timestamp.- Throws:
java.io.IOException
-
writeValue
@Deprecated public void writeValue(IonValue value) throws java.io.IOException
Deprecated.Description copied from interface:IonWriterwrites the contents of the passed in Ion value to the output.This method also writes annotations and field names (if in a struct), and performs a deep write, including the contents of any containers encountered.
- Specified by:
writeValuein interfaceIonWriter- Parameters:
value- may be null, in which case this method does nothing.- Throws:
java.io.IOException
-
writeValues
public void writeValues(IonReader reader) throws java.io.IOException
Description copied from interface:IonWriterWrites a reader's current value, and all following values until the end of the current container. If there's no current value then this method callsIonReader.next()to get going.This method iterates until
IonReader.next()returnsnulland does not step out to the container of the current cursor position.This method also writes annotations and field names (if in a struct), and performs a deep write, including the contents of any containers encountered.
- Specified by:
writeValuesin interfaceIonWriter- Throws:
java.io.IOException
-
isStreamCopyOptimized
public boolean isStreamCopyOptimized()
-
writeValue
public void writeValue(IonReader reader) throws java.io.IOException
Overrides can optimize special cases.- Specified by:
writeValuein interfaceIonWriter- Throws:
java.io.IOException
-
pop_passed_symbol_table
public final SymbolTable pop_passed_symbol_table()
- Specified by:
pop_passed_symbol_tablein interface_Private_ReaderWriter
-
asFacet
public <T> T asFacet(java.lang.Class<T> facetType)
Description copied from interface:FacetedReturns a facet of this subject if supported.- Specified by:
asFacetin interfaceFaceted- Type Parameters:
T- The requested facet type.- Parameters:
facetType- The type token of the requested facet type.- Returns:
- An instance of T representing the facet of the subject, or null if the facet is not supported by the subject.
- See Also:
Facets.asFacet(Class, Faceted),Facets.assumeFacet(Class, Faceted)
-
-