use of permafrost.tundra.data.IDataCSVParser 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.data.IDataCSVParser in project Tundra by Permafrost.
the class csv method parse.
public static final void parse(IData pipeline) throws ServiceException {
// --- <<IS-START(parse)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $content
// [i] field:0:optional $delimiter
// [i] field:0:optional $encoding
// [o] record:0:optional $document
// [o] - record:1:optional recordWithNoID
IDataCursor cursor = pipeline.getCursor();
try {
Object content = IDataHelper.get(cursor, "$content");
String delimiter = IDataHelper.get(cursor, "$delimiter", String.class);
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
if (content != null) {
IDataHelper.put(cursor, "$document", new IDataCSVParser(delimiter).parse(InputStreamHelper.normalize(content, charset)));
}
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations