Search in sources :

Example 6 with ObjectConvertMode

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>> ---
}
Also used : ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Node(org.w3c.dom.Node) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Example 7 with ObjectConvertMode

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>> ---
}
Also used : XMLCanonicalizationAlgorithm(permafrost.tundra.xml.XMLCanonicalizationAlgorithm) ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Example 8 with ObjectConvertMode

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>> ---
}
Also used : ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Example 9 with ObjectConvertMode

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>> ---
}
Also used : ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IOException(java.io.IOException)

Example 10 with ObjectConvertMode

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>> ---
}
Also used : ObjectConvertMode(permafrost.tundra.lang.ObjectConvertMode) Charset(java.nio.charset.Charset) IDataMap(permafrost.tundra.data.IDataMap) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)20 ObjectConvertMode (permafrost.tundra.lang.ObjectConvertMode)20 Charset (java.nio.charset.Charset)19 MessageDigest (java.security.MessageDigest)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Map (java.util.Map)1 Node (org.w3c.dom.Node)1 CaseInsensitiveIData (permafrost.tundra.data.CaseInsensitiveIData)1 IDataCSVParser (permafrost.tundra.data.IDataCSVParser)1 IDataJSONParser (permafrost.tundra.data.IDataJSONParser)1 IDataMap (permafrost.tundra.data.IDataMap)1 ImmutableIData (permafrost.tundra.data.ImmutableIData)1 XMLCanonicalizationAlgorithm (permafrost.tundra.xml.XMLCanonicalizationAlgorithm)1 ZipEntryWithData (permafrost.tundra.zip.ZipEntryWithData)1