use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class duration method add.
// ---( server methods )---
public static final void add(IData pipeline) throws ServiceException {
// --- <<IS-START(add)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [i] field:0:optional $pattern.input {"xml","milliseconds","seconds","minutes","hours","days","weeks","months","years"}
// [i] field:0:optional $pattern.output {"xml","milliseconds","seconds","minutes","hours","days","weeks","months","years"}
// [o] field:0:required $duration
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
String inPattern = IDataHelper.get(cursor, "$pattern.input", String.class);
String outPattern = IDataHelper.get(cursor, "$pattern.output", String.class);
// support $duration.x and $duration.y inputs for backwards-compatibility
if (operands == null) {
String dx = IDataHelper.get(cursor, "$duration.x", String.class);
String dy = IDataHelper.get(cursor, "$duration.y", String.class);
IDataMap map = new IDataMap();
if (dx != null)
map.put("$duration.x", dx);
if (dy != null)
map.put("$duration.y", dy);
operands = map;
}
String result = DurationHelper.emit(DurationHelper.add(DurationHelper.normalize(IDataHelper.getLeafValues(operands), inPattern)), outPattern);
IDataHelper.put(cursor, "$duration", result, false);
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap 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>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class object method intersection.
/**
* Returns a new array which is the set intersection of the given arrays.
*
* @param pipeline The pipeline containing the arrays to be intersected.
* @param klass The array component class.
* @param <T> The array component class.
*/
public static <T> void intersection(IData pipeline, Class<T> klass) {
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $list.x and $list.y inputs for backwards-compatibility
if (operands == null) {
Object[] listX = IDataHelper.get(cursor, "$list.x", Object[].class);
Object[] listY = IDataHelper.get(cursor, "$list.y", Object[].class);
IDataMap map = new IDataMap();
if (listX != null)
map.put("$list.x", listX);
if (listY != null)
map.put("$list.y", listY);
operands = map;
}
if (IDataHelper.size(operands) > 0)
IDataHelper.put(cursor, "$list", ArrayHelper.intersect(operands, klass));
} finally {
cursor.destroy();
}
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class integer method minimum.
public static final void minimum(IData pipeline) throws ServiceException {
// --- <<IS-START(minimum)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [o] field:0:optional $minimum
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $integers input for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$integers", String[].class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$integers", list);
operands = map;
backwardsCompatiblityRequired = true;
}
BigInteger result = BigIntegerHelper.minimum(BigIntegerHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$integer", result, String.class, false);
} else {
IDataHelper.put(cursor, "$minimum", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class integer method average.
public static final void average(IData pipeline) throws ServiceException {
// --- <<IS-START(average)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [o] field:0:optional $average
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $integers input for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$integers", String[].class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$integers", list);
operands = map;
backwardsCompatiblityRequired = true;
}
BigInteger result = BigIntegerHelper.average(BigIntegerHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$integer", result, String.class, false);
} else {
IDataHelper.put(cursor, "$average", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations