Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.any23.util
Class StringUtils

    java.lang.Object
      org.apache.any23.util.StringUtils

    public class StringUtils

extends Object

This class provides a set of string utility methods.

Author:
  Michele Mostarda (mostarda@fbk.eu)

Method Summary
`static int` | `countNL(String in)` Counts the number of `NL` in the given in string.
`static int` | `countOccurrences(String container, String content)` Counts how many times `content` appears within `container` without string overlapping.
`static String` | `escapeAsJSONString(String in)` Escapes the `in` string as JSON string to let it being embeddable within a string field.
`static String` | `escapeDoubleQuotes(String in)` Escapes all the unescaped double quotes when needed.
`static boolean` | `isPrefix(String candidatePrefix, String container)` Check whether string `candidatePrefix` is prefix of string `container`.
`static boolean` | `isSuffix(String candidateSuffix, String container)` Check whether string `candidateSuffix` is suffix of string `container`.
`static String` | `join(String delimiter, String... data)` Joins the given input sting `data` list using the specified `delimiter`.
`static String` | `multiply(char c, int times)` Builds a string composed of the given char `c`` `n` times.`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### join

    public static String join(String delimiter,
                              String... data)

  Joins the given input sting `data` list using the specified `delimiter`.

  Parameters:
    `delimiter` - string delimiter.
    `data` - list of data to be joined.
  Returns:
    the joined string.

### countOccurrences

    public static int countOccurrences(String container,
                                       String content)

  Counts how many times `content` appears within `container` without string overlapping.

  Parameters:
    `container` - container string.
    `content` - content string.
  Returns:
    occurrences count.

### countNL

    public static int countNL(String in)

  Counts the number of `NL` in the given in string.

  Parameters:
    `in` - input string.
  Returns:
    the number of new line chars.

### isPrefix

    public static boolean isPrefix(String candidatePrefix,
                                   String container)

  Check whether string `candidatePrefix` is prefix of string `container`.

  Parameters:
    `candidatePrefix` -
    `container` -
  Returns:

### isSuffix

    public static boolean isSuffix(String candidateSuffix,
                                   String container)

  Check whether string `candidateSuffix` is suffix of string `container`.

  Parameters:
    `candidateSuffix` -
    `container` -
  Returns:

### escapeDoubleQuotes

    public static String escapeDoubleQuotes(String in)

  Escapes all the unescaped double quotes when needed.

  Parameters:
    `in` - input string.
  Returns:
    unescaped output.

### escapeAsJSONString

    public static String escapeAsJSONString(String in)

  Escapes the `in` string as JSON string to let it being embeddable within a string field.

  Parameters:
    `in` - string to be escaped.
  Returns:
    escaped string.

### multiply

    public static String multiply(char c,
                                  int times)

  Builds a string composed of the given char `c`` `n` times.

  `
  Parameters:
    `c` - char to be multiplied.
    `times` - number of times.
  Returns:
    the string containing the multiplied char.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.