use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class zip method compress.
// ---( server methods )---
public static final void compress(IData pipeline) throws ServiceException {
// --- <<IS-START(compress)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:1:optional $contents
// [i] - field:0:required name
// [i] - object:0:required content
// [i] - field:0:optional encoding
// [i] field:0:optional $mode {"stream","bytes","string","base64"}
// [o] object:0:optional $contents.zip
IDataCursor cursor = pipeline.getCursor();
try {
IData[] contents = IDataHelper.get(cursor, "$contents", IData[].class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
Object output = ObjectHelper.convert(ZipHelper.compress(ZipEntryWithData.valueOf(contents)), mode);
IDataHelper.put(cursor, "$contents.zip", output, 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 document method emit.
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(IDataXMLParser.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 csv 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] - record:1:optional recordWithNoID
// [i] field:0:optional $delimiter
// [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);
String delimiter = IDataHelper.get(cursor, "$delimiter", String.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(new IDataCSVParser(delimiter).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 base64 method decode.
// ---( server methods )---
public static final void decode(IData pipeline) throws ServiceException {
// --- <<IS-START(decode)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $base64
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
Object input = IDataHelper.get(cursor, "$base64");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
Object output = ObjectHelper.convert(BytesHelper.base64Decode(StringHelper.normalize(input, charset)), charset, mode);
IDataHelper.put(cursor, "$content", output, 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 base64 method encode.
public static final void encode(IData pipeline) throws ServiceException {
// --- <<IS-START(encode)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $content
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $base64
IDataCursor cursor = pipeline.getCursor();
try {
Object input = IDataHelper.get(cursor, "$content");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
Object output = ObjectHelper.convert(BytesHelper.base64Encode(BytesHelper.normalize(input, charset)), charset, mode);
IDataHelper.put(cursor, "$base64", output, false);
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations