Exemplo n.º 1
0
 public static void jsonEscape(@Nullable final String sInput, @Nonnull final StringBuilder aSB) {
   if (StringHelper.hasText(sInput)) {
     final char[] aInput = sInput.toCharArray();
     if (!StringHelper.containsAny(aInput, CHARS_TO_MASK)) aSB.append(sInput);
     else _escape(aInput, aSB);
   }
 }
Exemplo n.º 2
0
 public static void jsonEscape(
     @Nullable final String sInput, @Nonnull @WillNotClose final Writer aWriter)
     throws IOException {
   if (StringHelper.hasText(sInput)) {
     final char[] aInput = sInput.toCharArray();
     if (!StringHelper.containsAny(aInput, CHARS_TO_MASK)) aWriter.write(aInput, 0, aInput.length);
     else _escape(aInput, aWriter);
   }
 }
Exemplo n.º 3
0
  @Nullable
  public static String jsonEscape(@Nullable final String sInput) {
    if (StringHelper.hasNoText(sInput)) return sInput;

    final char[] aInput = sInput.toCharArray();
    if (!StringHelper.containsAny(aInput, CHARS_TO_MASK)) return sInput;

    final StringBuilder aSB = new StringBuilder(aInput.length * 2);
    _escape(aInput, aSB);
    return aSB.toString();
  }