@Test public void testReplace() throws Throwable { String[] src = new String[87]; src[0] = "x9"; src[1] = "testString"; src[2] = "testString"; src[3] = "testString"; src[4] = "D"; src[5] = "$vnwI &I=+SgEHrK:s<G@mEj*fv!.zH>ly({cw t"; src[6] = "testString"; src[7] = "preload-scripts"; src[8] = "4$%h\fZdi\\I"; src[9] = "testString"; src[10] = "6d_-4xsb?]^"; src[11] = "\uA4F9\u308C\u9793$\uE72F\u6318\uDDA2\u9353\u2DD9\u1499\uC0B1\uEFBF\u0677\uC801"; src[12] = "\uFDB5\uC8D8\u5CBD\u7FAD\u188E\u8209\u3EA8\u483C\u3038\u3729\uA8E3\u653B\uD1E0\u610B\u4C3D\u34EE\u7196\u43A5\u709E\u38EA\u1669\uA386\u3A10"; src[13] = "testString"; src[14] = "cfV"; src[15] = "fg"; src[16] = "testString"; src[17] = "\f7q\""; src[18] = "testString"; src[19] = "testString"; src[20] = "x"; src[21] = "testString"; src[22] = "testString"; src[23] = "testString"; src[24] = "testString"; src[25] = "1tx}czDv4UFdmi3\".z^,Fn2ijQ*ho$@5Gv8~J"; src[26] = "testString"; src[27] = "testString"; src[28] = "_\\2sTMdq6}\"%ue"; src[29] = "cf6"; src[30] = "$`WG;I:v 1$_~vS+#\t]v=V"; src[31] = "testString"; src[32] = "\n8,asxain:=uH.kRd"; src[33] = "testString"; src[34] = "testString"; src[35] = "ico$~vz#NKu\\jEF}+a1\\VBMMg>hwR^pzB[WUJW%d5Ua"; src[36] = "$~\f%\r\\?@e]kO5a-"; src[37] = "\u0EEF$\u4B77"; src[38] = "$\u8807"; src[39] = "cf`g"; src[40] = "\u611A$"; src[41] = "Su[7Fj"; src[42] = "testString"; src[43] = "testString"; src[44] = "testString"; src[45] = "cfg"; src[46] = "testString"; src[47] = "#*O32 hp1Wz&BtY^?;s+Eb*U$c=f)j?DxpRdMNE"; src[48] = "vX:$b"; src[49] = "$"; src[50] = "testString"; src[51] = "testString"; src[52] = "1_"; src[53] = "savmNameSpace"; src[54] = "testString"; src[55] = "$o"; src[56] = "testString"; src[57] = "testString"; src[58] = "$\u36B9"; src[59] = "testString"; src[60] = "$"; src[61] = "testString"; src[62] = "reloa"; src[63] = "testString"; src[64] = ""; src[65] = "$i"; src[66] = "Negative time"; src[67] = "\u07D4\u828F\u468A\u41C5$\u5474"; src[68] = "testString"; src[69] = "testString"; src[70] = "relad"; src[71] = "testString"; src[72] = "$?~\\7W}dT^^lA#jo$&:WGzIm?bV"; src[73] = "testString"; src[74] = "testString"; src[75] = "$lp"; src[76] = ""; src[77] = "r)load"; src[78] = "testString"; src[79] = "$n\t?-\u001C?1;F\u000E\u001F\t?Y5u(vv TLD"; src[80] = "realm"; src[81] = ""; src[82] = "testString"; src[83] = "testString"; src[84] = "event"; src[85] = "\n"; src[86] = "testString"; String[] patterns = new String[2]; patterns[0] = "testString"; patterns[1] = "v"; String[] to = new String[3]; String[] result = BSHLogListener.replace(src, patterns, to); assertEquals(87, result.length, "result.length"); assertEquals("x9", result[0], "result[0]"); }
protected static String[] replace(String[] src, String[] patterns, String[] to){ String[] ret = new String[src.length]; for(int i=0; i<src.length; i++){ StringBuilder buff = new StringBuilder(2*src[i].length()); int begin, end=0; while ((begin = src[i].indexOf('$',end))>=0 && begin<src[i].length()){ buff.append(src[i].substring(end, begin)); boolean patternFound = false; for(int k=0; k<patterns.length && !patternFound ; k++){ if(patternFound = src[i].indexOf(patterns[k], begin) == begin+1){ buff.append(to[k]); end = begin + patterns[k].length() + 1; } } if(!patternFound) end = begin + 1; } buff.append(src[i].substring(end)); ret[i] = buff.toString(); } return ret; }
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected static String[] replace(String[] src, String[] patterns, String[] to){ String[] ret = new String[src.length]; for(int i=0; i<src.length; i++){ StringBuilder buff = new StringBuilder(2*src[i].length()); int begin, end=0; while ((begin = src[i].indexOf('$',end))>=0 && begin<src[i].length()){ buff.append(src[i].substring(end, begin)); boolean patternFound = false; for(int k=0; k<patterns.length && !patternFound ; k++){ if(patternFound = src[i].indexOf(patterns[k], begin) == begin+1){ buff.append(to[k]); end = begin + patterns[k].length() + 1; } } if(!patternFound) end = begin + 1; } buff.append(src[i].substring(end)); ret[i] = buff.toString(); } return ret; } }
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected static String[] replace(String[] src, String[] patterns, String[] to){ String[] ret = new String[src.length]; for(int i=0; i<src.length; i++){ StringBuilder buff = new StringBuilder(2*src[i].length()); int begin, end=0; while ((begin = src[i].indexOf('$',end))>=0 && begin<src[i].length()){ buff.append(src[i].substring(end, begin)); boolean patternFound = false; for(int k=0; k<patterns.length && !patternFound ; k++){ if(patternFound = src[i].indexOf(patterns[k], begin) == begin+1){ buff.append(to[k]); end = begin + patterns[k].length() + 1; } } if(!patternFound) end = begin + 1; } buff.append(src[i].substring(end)); ret[i] = buff.toString(); } return ret; } BSHLogListener(); }
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected static String[] replace(String[] src, String[] patterns, String[] to){ String[] ret = new String[src.length]; for(int i=0; i<src.length; i++){ StringBuilder buff = new StringBuilder(2*src[i].length()); int begin, end=0; while ((begin = src[i].indexOf('$',end))>=0 && begin<src[i].length()){ buff.append(src[i].substring(end, begin)); boolean patternFound = false; for(int k=0; k<patterns.length && !patternFound ; k++){ if(patternFound = src[i].indexOf(patterns[k], begin) == begin+1){ buff.append(to[k]); end = begin + patterns[k].length() + 1; } } if(!patternFound) end = begin + 1; } buff.append(src[i].substring(end)); ret[i] = buff.toString(); } return ret; } BSHLogListener(); @Override void setConfiguration(org.jpos.core.Configuration cfg); @Override LogEvent log(LogEvent ev); }
BSHLogListener implements org.jpos.util.LogListener, org.jpos.core.Configurable { protected static String[] replace(String[] src, String[] patterns, String[] to){ String[] ret = new String[src.length]; for(int i=0; i<src.length; i++){ StringBuilder buff = new StringBuilder(2*src[i].length()); int begin, end=0; while ((begin = src[i].indexOf('$',end))>=0 && begin<src[i].length()){ buff.append(src[i].substring(end, begin)); boolean patternFound = false; for(int k=0; k<patterns.length && !patternFound ; k++){ if(patternFound = src[i].indexOf(patterns[k], begin) == begin+1){ buff.append(to[k]); end = begin + patterns[k].length() + 1; } } if(!patternFound) end = begin + 1; } buff.append(src[i].substring(end)); ret[i] = buff.toString(); } return ret; } BSHLogListener(); @Override void setConfiguration(org.jpos.core.Configuration cfg); @Override LogEvent log(LogEvent ev);  }