public static final void getCurrentDateString(IData pipeline) throws ServiceException { // --- <<IS-START(getCurrentDateString)>> --- // @subtype unknown // @sigtype java 3.5 // [i] field:0:required pattern // [i] field:0:optional timezone // [i] field:0:optional locale // [o] field:0:required value IDataCursor idcPipeline = pipeline.getCursor(); try { String inPattern = ""; if (idcPipeline.first("pattern")) { inPattern = (String) idcPipeline.getValue(); } else { throw new ServiceException("Input parameter 'pattern' was not found."); } IData output = Service.doInvoke("pub.date", "getCurrentDateString", pipeline); IDataCursor outCur = output.getCursor(); String stDate = IDataUtil.getString(outCur, "value"); IDataUtil.remove(outCur, "value"); outCur.destroy(); if (inPattern.endsWith("Z")) { Matcher matcher = specialTimezonePattern.matcher(stDate); if (matcher.find()) { stDate = matcher.replaceAll(":" + matcher.group(1)); } } idcPipeline.insertAfter("value", stDate); } catch (Exception e) { throw new ServiceException(e.getMessage()); } idcPipeline.destroy(); // --- <<IS-END>> --- }
// opens a file for reading, appending, or writing, and processes it by calling the given service // with the resulting $stream public static IData process( java.io.File file, String mode, String service, String input, IData pipeline) throws ServiceException { if (file != null) { if (input == null) input = "$stream"; Object stream = null; try { if (mode == null || mode.equals("read")) { stream = new java.io.BufferedInputStream( new java.io.FileInputStream(file), tundra.support.constant.DEFAULT_BUFFER_SIZE); } else { if (!exists(file)) create(file); stream = new java.io.BufferedOutputStream( new java.io.FileOutputStream(file, mode.equals("append")), tundra.support.constant.DEFAULT_BUFFER_SIZE); } IDataCursor cursor = pipeline.getCursor(); IDataUtil.put(cursor, input, stream); cursor.destroy(); pipeline = tundra.service.invoke(service, pipeline); } catch (java.io.IOException ex) { tundra.exception.raise(ex); } finally { tundra.stream.close(stream); IDataCursor cursor = pipeline.getCursor(); IDataUtil.remove(cursor, input); cursor.destroy(); } } return pipeline; }