// remove non-word characters and everything after ":::" from the // program point name, leaving PackageName.ClassName.MethodName private static String cleanup_pptname(String pptname) { int index; if ((index = pptname.indexOf("(")) > 0) { pptname = pptname.substring(0, index); } if (pptname.endsWith(".")) pptname = pptname.substring(0, pptname.length() - 2); Matcher m = non_word_pattern.matcher(pptname); return m.replaceAll("."); }
public static void main(String[] args) { String[] msgs = { "Java has regular expressions in 1.4", "regular expressions now expressing in Java", "Java represses oracular expressions" }; Pattern p = Pattern.compile("re\\w*"); Matcher matcher = null; for (int i = 0; i < msgs.length; i++) { if (matcher == null) { matcher = p.matcher(msgs[i]); } else { matcher.reset(msgs[i]); } System.out.println(matcher.replaceAll("¹þ¹þ\2")); } }
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>> --- }