@Test public void testReplace() { String str = "Akafist' Svatěj Velikomučenice Varvare"; OutputTemplate template = new OutputTemplate(); String escaped = template.escapedJavascriptString(str); Assert.assertEquals("Akafist\\' Svatěj Velikomučenice Varvare", escaped); }
public String escapedJavascriptString(String input) { List<Character> escaping = new ArrayList<Character>(); { escaping.add('\'');escaping.add('"');escaping.add('\n'); } Map<Character, String> replacemets = new HashMap<Character, String>(); { replacemets.put('\'', "\\'"); replacemets.put('"', "\\\""); replacemets.put('\n', "\\n"); } return escapeString(input, escaping, replacemets); }
OutputTemplate implements ProcessOutputTemplate { public String escapedJavascriptString(String input) { List<Character> escaping = new ArrayList<Character>(); { escaping.add('\'');escaping.add('"');escaping.add('\n'); } Map<Character, String> replacemets = new HashMap<Character, String>(); { replacemets.put('\'', "\\'"); replacemets.put('"', "\\\""); replacemets.put('\n', "\\n"); } return escapeString(input, escaping, replacemets); } }
OutputTemplate implements ProcessOutputTemplate { public String escapedJavascriptString(String input) { List<Character> escaping = new ArrayList<Character>(); { escaping.add('\'');escaping.add('"');escaping.add('\n'); } Map<Character, String> replacemets = new HashMap<Character, String>(); { replacemets.put('\'', "\\'"); replacemets.put('"', "\\\""); replacemets.put('\n', "\\n"); } return escapeString(input, escaping, replacemets); }  }
OutputTemplate implements ProcessOutputTemplate { public String escapedJavascriptString(String input) { List<Character> escaping = new ArrayList<Character>(); { escaping.add('\'');escaping.add('"');escaping.add('\n'); } Map<Character, String> replacemets = new HashMap<Character, String>(); { replacemets.put('\'', "\\'"); replacemets.put('"', "\\\""); replacemets.put('\n', "\\n"); } return escapeString(input, escaping, replacemets); }  @Override void renderOutput(LRProcess lrProcess, LRProcessDefinition definition, Writer writer); String escapedJavascriptString(String input); String escapeString(String str, List<Character> escapeCharatectes, Map<Character, String> replacements); void setErrorFlagAndMessage(LRProcess lrProcess, OutputContext ctx); @Override void renderName(LRProcess lrProcess, LRProcessDefinition definition, Writer writer); @Override String getOutputTemplateId(); }
OutputTemplate implements ProcessOutputTemplate { public String escapedJavascriptString(String input) { List<Character> escaping = new ArrayList<Character>(); { escaping.add('\'');escaping.add('"');escaping.add('\n'); } Map<Character, String> replacemets = new HashMap<Character, String>(); { replacemets.put('\'', "\\'"); replacemets.put('"', "\\\""); replacemets.put('\n', "\\n"); } return escapeString(input, escaping, replacemets); }  @Override void renderOutput(LRProcess lrProcess, LRProcessDefinition definition, Writer writer); String escapedJavascriptString(String input); String escapeString(String str, List<Character> escapeCharatectes, Map<Character, String> replacements); void setErrorFlagAndMessage(LRProcess lrProcess, OutputContext ctx); @Override void renderName(LRProcess lrProcess, LRProcessDefinition definition, Writer writer); @Override String getOutputTemplateId(); static String PROCESS_OUTPUT_ID; }