Class _Private_MarkupCallback
- java.lang.Object
-
- com.amazon.ion.impl._Private_MarkupCallback
-
public abstract class _Private_MarkupCallback extends java.lang.ObjectNOT FOR APPLICATION USE! Callback for giving users the ability to inject markup into their Ion documents.Customers who want to inject markup into their Ion documents will need to extend
_Private_MarkupCallback, implement_Private_CallbackBuilderto build new instances, and pass an instance of their_Private_CallbackBuilderintoIonTextWriterBuilder#setCallbackBuilder(_Private_CallbackBuilder)orIonTextWriterBuilder#withCallbackBuilder(_Private_CallbackBuilder)Note: It is only necessary for subclasses to implement methods they're using to inject markup.
When all method are called, they are called with (at least) an
IonTypethat represents either the type of data being written or the container type that the writer is writing, or currently inside. before/afterFieldName and before/afterEachAnnotation get, respectively, the field name and annotation that is being written. Methods can usemyAppendableaccess the output stream.Example Calls
Here are some example call patterns, using the following syntax to show where calls will be executed (whitespace is used to increase readability):
<methodName TYPE>
Input:
{ cookies:"Chocolate Chip" }Output:<beforeData STRUCT>{<afterStepIn STRUCT> <beforeFieldName STRING "cookies"> cookies <afterFieldName STRING "cookies">:<beforeData STRING> "Chocolate Chip" <afterData STRING> <beforeStepOut STRUCT>}<afterData STRUCT>Input:
anno1::anno2::{ fname:"John", lname:"Smith", age:32.785 }Output:<beforeAnnotations STRUCT> <beforeEachAnnotation STRUCT "anno1">anno1<afterEachAnnotation STRUCT "anno1">:: <beforeEachAnnotation STRUCT "anno2">anno2<afterEachAnnotation STRUCT "anno2">:: <afterAnnotations STRUCT> <beforeData STRUCT>{<afterStepIn STRUCT> <beforeFieldName STRING "fname">fname<afterFieldName STRING "fname">:<beforeData STRING>"John"<afterData STRING><beforeSeparator STRUCT>,<afterSeparator STRUCT> <beforeFieldName STRING "lname">lname<afterFieldName STRING "lname">:<beforeData STRING>"Smith"<afterData STRING><beforeSeparator STRUCT>,<afterSeparator STRUCT> <beforeFieldName DECIMAL "age">age<afterFieldName DECIMAL "age">:<beforeData DECIMAL>32.785<afterData DECIMAL> <beforeStepOut STRUCT>}<afterData STRUCT>Input:
(where (field (this) result) (== (field (curr) majorVersionString) "1.0"))
Output:<beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>where<afterData SYMBOL><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>field<afterData SYMBOL><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>this<afterData SYMBOL> <beforeStepOut SEXP>)<afterData SEXP><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SYMBOL>result<afterData SYMBOL> <beforeStepOut SEXP>)<afterData SEXP><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>==<afterData SYMBOL><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>field<afterData SYMBOL><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SEXP>(<afterStepIn SEXP> <beforeData SYMBOL>curr<afterData SYMBOL> <beforeStepOut SEXP>)<afterData SEXP><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData SYMBOL>majorVersionString<afterData SYMBOL> <beforeStepOut SEXP>)<afterData SEXP><beforeSeparator SEXP> <afterSeparator SEXP> <beforeData STRING>"1.0"<afterData STRING> <beforeStepOut SEXP>)<afterData SEXP> <beforeStepOut SEXP>)<afterData SEXP>Input:
1 5 "Cheesecake" 3.2 true null 'baby tigers' 47e1
Output:<beforeData INT>1<afterData INT><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData INT>5<afterData INT><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData STRING>"Cheesecake"<afterData STRING><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData DECIMAL>3.2<afterData DECIMAL><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData BOOL>true<afterData BOOL><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData NULL>null<afterData NULL><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData SYMBOL>'baby tigers'<afterData SYMBOL><beforeSeparator DATAGRAM> <afterSeparator DATAGRAM> <beforeData FLOAT>470.0e0<afterData FLOAT>
Input:
[true, 3.4, 3d6, 2.3e8, "string", '''multi-''' '''string''',Symbol, 'qSymbol', {{"clob data"}}, {{YmxvYiBkYXRh}}, 1970-06-06, null.struct]Output:<beforeData LIST>[<afterStepIn LIST> <beforeData BOOL>true<afterData BOOL><beforeSeparator LIST>,<afterSeparator LIST> <beforeData DECIMAL>3.4<afterData DECIMAL><beforeSeparator LIST>,<afterSeparator LIST> <beforeData DECIMAL>3d6<afterData DECIMAL><beforeSeparator LIST>,<afterSeparator LIST> <beforeData FLOAT>2.3E8<afterData FLOAT><beforeSeparator LIST>,<afterSeparator LIST> <beforeData STRING>"string"<afterData STRING><beforeSeparator LIST>,<afterSeparator LIST> <beforeData STRING>"multi-string"<afterData STRING><beforeSeparator LIST>,<afterSeparator LIST> <beforeData SYMBOL>Symbol<afterData SYMBOL><beforeSeparator LIST>,<afterSeparator LIST> <beforeData SYMBOL>qSymbol<afterData SYMBOL><beforeSeparator LIST>,<afterSeparator LIST> <beforeData CLOB>{{"clob data"}}<afterData CLOB><beforeSeparator LIST>,<afterSeparator LIST> <beforeData BLOB>{{YmxvYiBkYXRh}}<afterData BLOB><beforeSeparator LIST>,<afterSeparator LIST> <beforeData TIMESTAMP>1970-06-06<afterData TIMESTAMP><beforeSeparator LIST>,<afterSeparator LIST> <beforeData NULL>null.struct<afterData NULL> <beforeStepOut LIST>]<afterData LIST>
-
-
Constructor Summary
Constructors Constructor Description _Private_MarkupCallback(_Private_FastAppendable appendable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAnnotations(IonType iType)Callback to be executed after annotations are written.voidafterEachAnnotation(IonType iType, SymbolToken annotation)Callback to be executed after each annotation is written.voidafterFieldName(IonType iType, SymbolToken name)Callback to be executed after a field name is written.voidafterSeparator(IonType containerType)Callback to be executed after a separator has been written.voidafterStepIn(IonType containerType)Callback to be executed after the opening delimiter of a container is written.voidafterValue(IonType iType)Callback to be executed after an Ion value is written.voidbeforeAnnotations(IonType iType)Callback to be executed before annotations are written.voidbeforeEachAnnotation(IonType iType, SymbolToken annotation)Callback to be executed before each annotation is written.voidbeforeFieldName(IonType iType, SymbolToken name)Callback to be executed before a field name is written.voidbeforeSeparator(IonType containerType)Callback to be executed before a separator is written.voidbeforeStepOut(IonType containerType)Callback to be executed before the closing delimiter of a container is written.voidbeforeValue(IonType iType)Callback to be executed before an Ion value is written._Private_FastAppendablegetAppendable()Gets the_Private_FastAppendablethat IonWriter will use to write its output.
-
-
-
Constructor Detail
-
_Private_MarkupCallback
public _Private_MarkupCallback(_Private_FastAppendable appendable)
-
-
Method Detail
-
getAppendable
public final _Private_FastAppendable getAppendable()
Gets the_Private_FastAppendablethat IonWriter will use to write its output.
-
beforeValue
public void beforeValue(IonType iType) throws java.io.IOException
Callback to be executed before an Ion value is written. If iType is a container type, this is executed before the container's opening delimiter. To write data after the opening delimiter useafterStepIn(IonType).- Parameters:
iType- The type of data that will be written.- Throws:
java.io.IOException
-
afterValue
public void afterValue(IonType iType) throws java.io.IOException
Callback to be executed after an Ion value is written. If iType is a container type, this is executed after the container's closing delimiter. To write data before the closing delimiter, usebeforeStepOut(IonType).- Parameters:
iType- The type of data that was written.- Throws:
java.io.IOException
-
beforeFieldName
public void beforeFieldName(IonType iType, SymbolToken name) throws java.io.IOException
Callback to be executed before a field name is written.- Parameters:
iType- The type of data in the field name's corresponding value.name- The field name that is being written.- Throws:
java.io.IOException
-
afterFieldName
public void afterFieldName(IonType iType, SymbolToken name) throws java.io.IOException
Callback to be executed after a field name is written.- Parameters:
iType- The type of data in the field name's corresponding value.name- The field name that is being written.- Throws:
java.io.IOException
-
afterStepIn
public void afterStepIn(IonType containerType) throws java.io.IOException
Callback to be executed after the opening delimiter of a container is written. To write data before the opening delimiter, usebeforeValue(IonType).- Parameters:
containerType- The type of container that was just stepped into.- Throws:
java.io.IOException
-
beforeStepOut
public void beforeStepOut(IonType containerType) throws java.io.IOException
Callback to be executed before the closing delimiter of a container is written. To write data after the closing delimiter, useafterValue(IonType).- Parameters:
containerType- The type of container that is about to be stepped out of.- Throws:
java.io.IOException
-
beforeSeparator
public void beforeSeparator(IonType containerType) throws java.io.IOException
Callback to be executed before a separator is written. Called after the data has been written, and before the separator. It is called when inside all container types, including Sexp, and when not inside a container. It is not called after the last element in a container.- Parameters:
containerType- The type of container the writer is currently in. When writing top-level values, the type is DATAGRAM.- Throws:
java.io.IOException
-
afterSeparator
public void afterSeparator(IonType containerType) throws java.io.IOException
Callback to be executed after a separator has been written. Called just after the separator is written. It is called when inside all container types, including Sexp, and when not inside a container. It is not called after the last element in a container.- Parameters:
containerType- The type of container the writer is currently in. When writing top-level values, the type is DATAGRAM.- Throws:
java.io.IOException
-
beforeAnnotations
public void beforeAnnotations(IonType iType) throws java.io.IOException
Callback to be executed before annotations are written. It is executed once per set of annotations.- Parameters:
iType- The type of the data whose annotations are being written.- Throws:
java.io.IOException
-
afterAnnotations
public void afterAnnotations(IonType iType) throws java.io.IOException
Callback to be executed after annotations are written. It is executed once per set of annotations.- Parameters:
iType- The type of the data whose annotations are being written.- Throws:
java.io.IOException
-
beforeEachAnnotation
public void beforeEachAnnotation(IonType iType, SymbolToken annotation) throws java.io.IOException
Callback to be executed before each annotation is written. It is executed once per annotation.- Parameters:
iType- The type of the data whose annotation is being written.annotation- The annotation that is being written.- Throws:
java.io.IOException
-
afterEachAnnotation
public void afterEachAnnotation(IonType iType, SymbolToken annotation) throws java.io.IOException
Callback to be executed after each annotation is written. It is executed once per annotation, before the delimiter.- Parameters:
iType- The type of the data whose annotation is being written.annotation- The annotation that is being written.- Throws:
java.io.IOException
-
-