Package org.antlr.v4.runtime.misc
Class Utils
- java.lang.Object
-
- org.antlr.v4.runtime.misc.Utils
-
public class Utils extends Object
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcount(String s, char x)static StringescapeWhitespace(String s, boolean escapeSpaces)static StringexpandTabs(String s, int tabSize)static <T> Stringjoin(Iterator<T> iter, String separator)static <T> Stringjoin(T[] array, String separator)static Stringnewlines(int n)static intnumNonnull(Object[] data)static char[]readFile(String fileName)static char[]readFile(String fileName, String encoding)static <T> voidremoveAllElements(Collection<T> data, T value)static Stringsequence(int n, String s)static Stringspaces(int n)static char[]toCharArray(IntegerList data)static Map<String,Integer>toMap(String[] keys)Convert array of strings to string→index map.static IntervalSettoSet(BitSet bits)static voidwriteFile(String fileName, String content)static voidwriteFile(String fileName, String content, String encoding)
-
-
-
Method Detail
-
numNonnull
public static int numNonnull(Object[] data)
-
removeAllElements
public static <T> void removeAllElements(Collection<T> data, T value)
-
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)
-
spaces
public static String spaces(int n)
- Since:
- 4.6
-
newlines
public static String newlines(int n)
- Since:
- 4.6
-
count
public static int count(String s, char x)
- Since:
- 4.6
-
-