use of permafrost.tundra.lang.ObjectConvertMode in project Tundra by Permafrost.
the class xml method emit.
public static final void emit(IData pipeline) throws ServiceException {
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $node
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
Node node = IDataHelper.get(cursor, "$node", Node.class);
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
Object content = ObjectHelper.convert(NodeHelper.emit(node, charset), mode);
IDataHelper.put(cursor, "$content", content, 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 xml method canonicalize.
// ---( server methods )---
public static final void canonicalize(IData pipeline) throws ServiceException {
// --- <<IS-START(canonicalize)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $content
// [i] field:0:optional $encoding
// [i] field:0:optional $algorithm {"Canonical XML Version 1.0","Canonical XML Version 1.0 With Comments","Canonical XML Version 1.1","Canonical XML Version 1.1 With Comments","Exclusive Canonical XML Version 1.0","Exclusive Canonical XML Version 1.0 With Comments"}
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content.canonical
IDataCursor cursor = pipeline.getCursor();
try {
Object content = IDataHelper.get(cursor, "$content");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
XMLCanonicalizationAlgorithm algorithm = XMLCanonicalizationAlgorithm.normalize(IDataHelper.get(cursor, "$algorithm", String.class));
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
if (content != null)
IDataHelper.put(cursor, "$content.canonical", ObjectHelper.convert(XMLCanonicalizationHelper.canonicalize(BytesHelper.normalize(content, charset), charset, algorithm), 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 gzip method decompress.
public static final void decompress(IData pipeline) throws ServiceException {
// --- <<IS-START(decompress)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] object:0:optional $content.gzip
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string","base64"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
Object input = IDataHelper.get(cursor, "$content.gzip");
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
Object output = ObjectHelper.convert(GzipHelper.decompress(InputStreamHelper.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 hjson 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"}
// [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(IDataHjsonParser.getInstance().emit(document, charset), 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 html method emit.
public static final void emit(IData pipeline) throws ServiceException {
// --- <<IS-START(emit)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:1:optional $list
// [i] field:0:optional $encoding
// [i] field:0:optional $mode {"stream","bytes","string"}
// [o] object:0:optional $content
IDataCursor cursor = pipeline.getCursor();
try {
IData[] list = IDataHelper.get(cursor, "$list", IData[].class);
Charset charset = IDataHelper.get(cursor, "$encoding", Charset.class);
ObjectConvertMode mode = IDataHelper.get(cursor, "$mode", ObjectConvertMode.class);
if (list != null) {
IDataMap map = new IDataMap();
map.put("recordWithNoID", list);
IDataHelper.put(cursor, "$content", ObjectHelper.convert(IDataHTMLParser.getInstance().emit(map, charset), charset, mode));
}
} catch (IOException ex) {
ExceptionHelper.raise(ex);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations