Java Code Examples for com.helger.commons.string.StringHelper#containsAny()

The following examples show how to use com.helger.commons.string.StringHelper#containsAny() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonEscapeHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public static String jsonEscape (@Nullable final char [] aInput)
{
  if (aInput == null)
    return null;

  if (!StringHelper.containsAny (aInput, CHARS_TO_MASK))
    return new String (aInput);

  final StringBuilder aSB = new StringBuilder (aInput.length * 2);
  jsonEscapeToStringBuilder (aInput, aSB);
  return aSB.toString ();
}
 
Example 2
Source File: JsonEscapeHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public static void jsonEscape (@Nullable final String sInput, @Nonnull final StringBuilder aSB)
{
  ValueEnforcer.notNull (aSB, "StringBuilder");

  if (StringHelper.hasText (sInput))
  {
    final char [] aInput = sInput.toCharArray ();
    if (!StringHelper.containsAny (aInput, CHARS_TO_MASK))
      aSB.append (sInput);
    else
      jsonEscapeToStringBuilder (aInput, aSB);
  }
}
 
Example 3
Source File: JsonEscapeHelper.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public static void jsonEscapeToWriter (@Nullable final String sInput,
                                       @Nonnull @WillNotClose final Writer aWriter) throws IOException
{
  ValueEnforcer.notNull (aWriter, "Writer");

  if (StringHelper.hasText (sInput))
  {
    final char [] aInput = sInput.toCharArray ();
    if (!StringHelper.containsAny (aInput, CHARS_TO_MASK))
      aWriter.write (aInput, 0, aInput.length);
    else
      jsonEscapeToWriter (aInput, aWriter);
  }
}