use of com.amazon.ion.IonClob in project ion-java by amzn.
the class IonReaderTextSystemX method getIonValue.
public IonValue getIonValue(IonSystem sys) {
if (isNullValue()) {
switch(_value_type) {
case NULL:
return sys.newNull();
case BOOL:
return sys.newNullBool();
case INT:
return sys.newNullInt();
case FLOAT:
return sys.newNullFloat();
case DECIMAL:
return sys.newNullDecimal();
case TIMESTAMP:
return sys.newNullTimestamp();
case SYMBOL:
return sys.newNullSymbol();
case STRING:
return sys.newNullString();
case CLOB:
return sys.newNullClob();
case BLOB:
return sys.newNullBlob();
case LIST:
return sys.newNullList();
case SEXP:
return sys.newNullSexp();
case STRUCT:
return sys.newNullString();
default:
throw new IonException("unrecognized type encountered");
}
}
switch(_value_type) {
case NULL:
return sys.newNull();
case BOOL:
return sys.newBool(booleanValue());
case INT:
return sys.newInt(longValue());
case FLOAT:
return sys.newFloat(doubleValue());
case DECIMAL:
return sys.newDecimal(decimalValue());
case TIMESTAMP:
IonTimestamp t = sys.newNullTimestamp();
Timestamp ti = timestampValue();
t.setValue(ti);
return t;
case SYMBOL:
return sys.newSymbol(stringValue());
case STRING:
return sys.newString(stringValue());
case CLOB:
IonClob clob = sys.newNullClob();
// FIXME inefficient: both newBytes and setBytes copy the data
clob.setBytes(newBytes());
return clob;
case BLOB:
IonBlob blob = sys.newNullBlob();
// FIXME inefficient: both newBytes and setBytes copy the data
blob.setBytes(newBytes());
return blob;
case LIST:
IonList list = sys.newNullList();
fillContainerList(sys, list);
return list;
case SEXP:
IonSexp sexp = sys.newNullSexp();
fillContainerList(sys, sexp);
return sexp;
case STRUCT:
IonStruct struct = sys.newNullStruct();
fillContainerStruct(sys, struct);
return struct;
default:
throw new IonException("unrecognized type encountered");
}
}
use of com.amazon.ion.IonClob in project ion-java by amzn.
the class IonWriterSystemTree method writeClob.
public void writeClob(byte[] value, int start, int len) throws IOException {
IonClob v = _factory.newClob(value, start, len);
append(v);
}
use of com.amazon.ion.IonClob in project ion-java by amzn.
the class _Private_CurriedValueFactory method newClob.
public IonClob newClob(byte[] value) {
IonClob v = myFactory.newClob(value);
handle(v);
return v;
}
use of com.amazon.ion.IonClob in project ion-java by amzn.
the class PrinterTest method testPrintingClob.
@Test
public void testPrintingClob() throws Exception {
IonClob value = system().newNullClob();
checkNullRendering("null.clob", value);
value.setBytes(ClobTest.SAMPLE_ASCII_AS_UTF8);
checkRendering("{{\"" + ClobTest.SAMPLE_ASCII + "\"}}", value);
// TODO test "real" UTF8 and other encodings.
value = (IonClob) oneValue("{{\"\"}}");
checkRendering("{{\"\"}}", value);
value.addTypeAnnotation("an");
checkRendering("an::{{\"\"}}", value);
myPrinter.setPrintClobAsString(true);
checkRendering("an::\"\"", value);
value.clearTypeAnnotations();
value.setBytes(ClobTest.SAMPLE_ASCII_AS_UTF8);
checkRendering("\"" + ClobTest.SAMPLE_ASCII + "\"", value);
value = (IonClob) oneValue("{{'''Ab\\0'''}}");
myPrinter.setPrintClobAsString(false);
checkRendering("{{\"Ab\\0\"}}", value);
myPrinter.setPrintClobAsString(true);
checkRendering("\"Ab\\0\"", value);
myPrinter.setPrintStringAsJson(true);
checkRendering("\"Ab\\u0000\"", value);
}
use of com.amazon.ion.IonClob in project ion-java by amzn.
the class _Private_CurriedValueFactory method newNullClob.
// -------------------------------------------------------------------------
public IonClob newNullClob() {
IonClob v = myFactory.newNullClob();
handle(v);
return v;
}
Aggregations