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 int
count(String s, char x)
static String
escapeWhitespace(String s, boolean escapeSpaces)
static String
expandTabs(String s, int tabSize)
static <T> String
join(Iterator<T> iter, String separator)
static <T> String
join(T[] array, String separator)
static String
newlines(int n)
static int
numNonnull(Object[] data)
static char[]
readFile(String fileName)
static char[]
readFile(String fileName, String encoding)
static <T> void
removeAllElements(Collection<T> data, T value)
static String
sequence(int n, String s)
static String
spaces(int n)
static char[]
toCharArray(IntegerList data)
static Map<String,Integer>
toMap(String[] keys)
Convert array of strings to string→index map.static IntervalSet
toSet(BitSet bits)
static void
writeFile(String fileName, String content)
static void
writeFile(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
-
-