Class Utils

java.lang.Object
org.antlr.v4.runtime.misc.Utils

public class Utils extends Object
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • join

      public static <T> String join(Iterator<T> iter, String separator)
    • join

      public static <T> String join(T[] array, String separator)
    • numNonnull

      public static int numNonnull(Object[] data)
    • removeAllElements

      public static <T> void removeAllElements(Collection<T> data, T value)
    • escapeWhitespace

      public static String escapeWhitespace(String s, boolean escapeSpaces)
    • writeFile

      public static void writeFile(String fileName, String content) throws IOException
      Throws:
      IOException
    • writeFile

      public static void writeFile(String fileName, String content, String encoding) throws IOException
      Throws:
      IOException
    • readFile

      public static char[] readFile(String fileName) throws IOException
      Throws:
      IOException
    • readFile

      public static char[] readFile(String fileName, String encoding) throws IOException
      Throws:
      IOException
    • toMap

      public static Map<String,Integer> toMap(String[] keys)
      Convert array of strings to string→index map. Useful for converting rulenames to name→ruleindex map.
    • toCharArray

      public static char[] toCharArray(IntegerList data)
    • toSet

      public static IntervalSet toSet(BitSet bits)
    • expandTabs

      public static String expandTabs(String s, int tabSize)
      Since:
      4.6
    • spaces

      public static String spaces(int n)
      Since:
      4.6
    • newlines

      public static String newlines(int n)
      Since:
      4.6
    • sequence

      public static String sequence(int n, String s)
      Since:
      4.6
    • count

      public static int count(String s, char x)
      Since:
      4.6