|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.ArgumentUtils
public class ArgumentUtils
An utility class for validating inputs.
| Field Summary | |
|---|---|
static String[] |
EMPTY_STRING_ARRAY
An empty String array. |
| Constructor Summary | |
|---|---|
ArgumentUtils()
|
|
| Method Summary | ||
|---|---|---|
static Object[] |
findMissingElements(Object[] array,
Collection<?> elements)
Searches for elements in a given array and returns the elements not found. |
|
static Object[] |
findMissingElements(Object[] array,
Object[] elements)
Searches for elements in a given array and returns the elements not found. |
|
static int[] |
indexesOf(Object[] array,
Object element)
Returns the indexes of an element in a given array. |
|
static int |
indexOf(Object[] array,
Object element)
Returns the index of an element in a given array. |
|
static int |
indexOf(String[] array,
String element,
FieldSelector fieldSelector)
Returns the index of a header, when headers are selected using a FieldSelector. |
|
static Reader |
newReader(File file)
Creates a Reader for a given a file |
|
static Reader |
newReader(File file,
Charset encoding)
Creates a Reader for a given a file |
|
static Reader |
newReader(File file,
String encoding)
Creates a Reader for a given a file |
|
static Reader |
newReader(InputStream input)
Creates a Reader from an input stream |
|
static Reader |
newReader(InputStream input,
Charset encoding)
Creates a Reader from an input stream |
|
static Reader |
newReader(InputStream input,
String encoding)
Creates a Reader from an input stream |
|
static Writer |
newWriter(File file)
Creates a Writer from a file |
|
static Writer |
newWriter(File file,
Charset encoding)
Creates a Writer from a file |
|
static Writer |
newWriter(File file,
String encoding)
Creates a Writer from a file |
|
static Writer |
newWriter(OutputStream output)
Creates a Writer from an output stream |
|
static Writer |
newWriter(OutputStream output,
Charset encoding)
Creates a Writer from an output stream |
|
static Writer |
newWriter(OutputStream output,
String encoding)
Creates a Writer from an output stream |
|
static
|
noNulls(String argDescription,
T... args)
Throws an IllegalArgumentException if the given array is null,empty, or contains null values |
|
static void |
normalize(Collection<String> strings)
Normalizes the Strings in a given array by trimming all elements and converting them to lower case. |
|
static String |
normalize(String string)
Normalizes a given String by trimming whitespaces and converting it to lower case. |
|
static String[] |
normalize(String[] strings)
Normalizes the Strings in a given array by trimming all elements and converting them to lower case. |
|
static
|
notEmpty(String argDescription,
T... args)
Throws an IllegalArgumentException if the given array is null or empty. |
|
static String |
restrictContent(int length,
CharSequence content)
|
|
static String |
restrictContent(int length,
Object content)
|
|
static void |
throwUnchecked(Throwable error)
Allows rethrowing a checked exception instead of wrapping it into a runtime exception. |
|
static String[] |
toArray(List<Enum> enums)
Converts a list of enumerations to an array of their Enum.toString() representation |
|
static byte[] |
toByteArray(int... ints)
Converts a sequence of int numbers into a byte array. |
|
static char[] |
toCharArray(Collection<Character> characters)
Converts any collection of Character into a char array. |
|
static int[] |
toIntArray(Collection<Integer> ints)
Converts any collection of Integer into an int array. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String[] EMPTY_STRING_ARRAY
| Constructor Detail |
|---|
public ArgumentUtils()
| Method Detail |
|---|
public static <T> void notEmpty(String argDescription,
T... args)
T - Type of arguments to be validatedargDescription - the description of the elementsargs - the elements to be validated.
public static <T> void noNulls(String argDescription,
T... args)
T - Type of arguments to be validatedargDescription - the description of the elementsargs - the elements to be validated.
public static int indexOf(String[] array,
String element,
FieldSelector fieldSelector)
FieldSelector.
array - the element arrayelement - the element to be looked for in the array.fieldSelector - a field selector that indicates which elements of the given array are selected.
public static int[] indexesOf(Object[] array,
Object element)
array - the element arrayelement - the element to be looked for in the array.
public static int indexOf(Object[] array,
Object element)
array - the element arrayelement - the element to be looked for in the array.
public static Object[] findMissingElements(Object[] array,
Collection<?> elements)
array - An array with elementselements - the elements to be found
public static Object[] findMissingElements(Object[] array,
Object[] elements)
array - An array with elementselements - the elements to be found
public static String[] normalize(String[] strings)
strings - a String array with elements to be normalized.
public static String normalize(String string)
string - a String to be normalized.
public static void normalize(Collection<String> strings)
strings - a String collection with elements to be normalized. The original contents of the collection will be modified.public static Writer newWriter(OutputStream output)
Writer from an output stream
output - the output stream
Writer wrapping the given output stream
public static Writer newWriter(OutputStream output,
String encoding)
Writer from an output stream
output - the output streamencoding - the encoding to use when writing to the output stream
Writer wrapping the given output stream
public static Writer newWriter(OutputStream output,
Charset encoding)
Writer from an output stream
output - the output streamencoding - the encoding to use when writing to the output stream
Writer wrapping the given output streampublic static Writer newWriter(File file)
Writer from a file
file - the file to be written
Writer for the given file
public static Writer newWriter(File file,
String encoding)
Writer from a file
file - the file to be writtenencoding - the encoding to use when writing to the file
Writer for the given file
public static Writer newWriter(File file,
Charset encoding)
Writer from a file
file - the file to be writtenencoding - the encoding to use when writing to the file
Writer for the given filepublic static Reader newReader(InputStream input)
Reader from an input stream
input - the input stream
Reader wrapping the given input stream
public static Reader newReader(InputStream input,
String encoding)
Reader from an input stream
input - the input streamencoding - the encoding to use when reading from the input stream
Reader wrapping the given input stream
public static Reader newReader(InputStream input,
Charset encoding)
Reader from an input stream
input - the input streamencoding - the encoding to use when reading from the input stream
Reader wrapping the given input streampublic static Reader newReader(File file)
Reader for a given a file
file - the file to be read
Reader for reading the given file
public static Reader newReader(File file,
String encoding)
Reader for a given a file
file - the file to be readencoding - the encoding to be used when reading from the file
Reader for reading the given file
public static Reader newReader(File file,
Charset encoding)
Reader for a given a file
file - the file to be readencoding - the encoding to be used when reading from the file
Reader for reading the given filepublic static String[] toArray(List<Enum> enums)
Enum.toString() representation
enums - a list of enumerations to convert
String with the values produced by each element's Enum.toString() method.public static int[] toIntArray(Collection<Integer> ints)
Integer into an int array.
ints - a collection of (boxed) integers.
int array with the unboxed integer values.public static char[] toCharArray(Collection<Character> characters)
Character into a char array.
characters - a collection of (boxed) characters.
char array with the unboxed character values.
public static String restrictContent(int length,
CharSequence content)
public static String restrictContent(int length,
Object content)
public static void throwUnchecked(Throwable error)
error - the (potentially checked) exception to the thrown.public static byte[] toByteArray(int... ints)
ints - the integers to be cast to by
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||