use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class yaml method emit.
// ---( server methods )---
public static final void emit(IData pipeline) throws ServiceException {
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $document
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
IData document = IDataHelper.get(cursor, "$document", IData.class);
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
if (document != null) {
IDataHelper.put(cursor, "$content", ObjectHelper.convert(IDataYAMLParser.getInstance().emit(document, charset), charset, mode));
}
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class zip method decompress.
public static final void decompress(IData pipeline) throws ServiceException {
// --- <<IS-START(decompress)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $contents.zip
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string","base64"}
// [o] record:1:optional $contents
// [o] - field:0:required name
// [o] - object:0:required content
IDataCursor cursor = pipeline.getCursor();
try {
Object input = IDataHelper.get(cursor, "$contents.zip");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
ZipEntryWithData[] entries = ZipHelper.decompress(InputStreamHelper.normalize(input, charset));
IDataHelper.put(cursor, "$contents", ZipEntryWithData.toIDataArray(entries, charset, mode), false);
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class json method emit.
// ---( server methods )---
public static final void emit(IData pipeline) throws ServiceException {
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $document
// [i] - object:1:optional recordWithNoID
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [i] field:0:optional $minify? {"false","true"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
IData document = IDataHelper.get(cursor, "$document", IData.class);
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
boolean minify = IDataHelper.getOrDefault(cursor, "$minify?", Boolean.class, false);
if (document != null) {
IDataJSONParser parser = minify ? new IDataJSONParser(!minify) : IDataJSONParser.getInstance();
IDataHelper.put(cursor, "$content", ObjectHelper.convert(parser.emit(document, charset), charset, mode));
}
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class object method convert.
public static final void convert(IData pipeline) throws ServiceException {
// --- <<IS-START(convert)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $object
// [i] field:0:optional $mode {"stream","bytes","string"}
// [i] field:0:optional $encoding
// [o] object:0:optional $object
IDataCursor cursor = pipeline.getCursor();
try {
Object object = IDataHelper.get(cursor, "$object");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
IDataHelper.put(cursor, "$object", ObjectHelper.convert(object, charset, mode), false);
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class pipeline method emit.
public static final void emit(IData pipeline) throws ServiceException {
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
// remove input arguments so that they are not included in serialization of the pipeline
Charset charset = IDataHelper.remove(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.remove(cursor, "$mode", ObjectConvertMode.class);
IDataHelper.put(cursor, "$content", ObjectHelper.convert(IDataXMLParser.getInstance().emit(pipeline, charset), charset, mode));
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations