Search in sources :

Example 1 with IDataNamespaceContext

use of permafrost.tundra.xml.namespace.IDataNamespaceContext in project Tundra by Permafrost.

the class condition method choose.

// ---( server methods )---
public static final void choose(IData pipeline) throws ServiceException {
    // --- <<IS-START(choose)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $condition
    // [i] record:0:optional $scope
    // [i] record:0:optional $namespace
    // [i] - field:0:optional default
    // [i] object:0:optional $result.true
    // [i] object:0:optional $result.false
    // [o] object:0:optional $result
    IDataCursor cursor = pipeline.getCursor();
    try {
        String condition = IDataHelper.get(cursor, "$condition", String.class);
        IData scope = IDataHelper.get(cursor, "$scope", IData.class);
        IDataNamespaceContext namespace = IDataHelper.get(cursor, "$namespace", IDataNamespaceContext.class);
        Object trueResult = IDataHelper.get(cursor, "$result.true");
        Object falseResult = IDataHelper.get(cursor, "$result.false");
        if (trueResult != null || falseResult != null) {
            boolean result = ConditionEvaluator.evaluate(condition, scope == null ? pipeline : scope, namespace);
            IDataHelper.put(cursor, "$result", result ? trueResult : falseResult, false);
        }
    } finally {
        cursor.destroy();
    }
// --- <<IS-END>> ---
}
Also used : IDataNamespaceContext(permafrost.tundra.xml.namespace.IDataNamespaceContext)

Example 2 with IDataNamespaceContext

use of permafrost.tundra.xml.namespace.IDataNamespaceContext in project Tundra by Permafrost.

the class condition method evaluate.

public static final void evaluate(IData pipeline) throws ServiceException {
    // --- <<IS-START(evaluate)>> ---
    // @subtype unknown
    // @sigtype java 3.5
    // [i] field:0:optional $condition
    // [i] record:0:optional $scope
    // [i] record:0:optional $namespace
    // [i] - field:0:optional default
    // [o] field:0:required $result?
    IDataCursor cursor = pipeline.getCursor();
    try {
        String condition = IDataHelper.get(cursor, "$condition", String.class);
        IData scope = IDataHelper.get(cursor, "$scope", IData.class);
        IDataNamespaceContext namespace = IDataHelper.get(cursor, "$namespace", IDataNamespaceContext.class);
        IDataHelper.put(cursor, "$result?", ConditionEvaluator.evaluate(condition, scope == null ? pipeline : scope, namespace), String.class);
    } finally {
        cursor.destroy();
    }
// --- <<IS-END>> ---
}
Also used : IDataNamespaceContext(permafrost.tundra.xml.namespace.IDataNamespaceContext)

Aggregations

IDataNamespaceContext (permafrost.tundra.xml.namespace.IDataNamespaceContext)2