MCPcopy Create free account
hub / github.com/apache/pig / fixNonEscapedDollarSign

Method fixNonEscapedDollarSign

src/org/apache/pig/scripting/Pig.java:324–345  ·  view source on GitHub ↗
(String s)

Source from the content-addressed store, hash-verified

322 // Escape the $ so that we can use the parameter substitution
323 // to perform bind operation. Parameter substitution will un-escape $
324 private static String fixNonEscapedDollarSign(String s) {
325 String[] tkns = s.split("\\$", -1);
326
327 if (tkns.length == 1) return s;
328
329 StringBuilder sb = new StringBuilder();
330
331 for (int i = 0; i < tkns.length -1; i++) {
332 if (tkns[i].isEmpty()) {
333 sb.append("\\\\");
334 } else {
335 sb.append(tkns[i]);
336 if (tkns[i].charAt(tkns[i].length()-1) != '\\') {
337 sb.append("\\\\");
338 }
339 }
340 sb.append("$");
341 }
342 sb.append(tkns[tkns.length - 1]);
343
344 return sb.toString();
345 }
346
347 //-------------------------------------------------------------------------
348

Callers 1

replaceParametersMethod · 0.95

Calls 5

splitMethod · 0.80
lengthMethod · 0.80
appendMethod · 0.65
isEmptyMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected