Package rife.tools
Class ArrayUtils
java.lang.Object
rife.tools.ArrayUtils
General purpose class containing common array manipulation methods.
- Since:
- 1.0
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]
createBooleanArray
(Object[] array) Creates an array of booleans from an array of objects.static byte[]
createByteArray
(Object[] array) Creates an array of bytes from an array of objects.static char[]
createCharArray
(Object[] array) Creates an array of chars from an array of objects.static double[]
createDoubleArray
(Object[] array) Creates an array of doubles from an array of objects.static float[]
createFloatArray
(Object[] array) Creates an array of floats from an array of objects.static int[]
createIntArray
(Object[] array) Creates an array of ints from an array of objects.static long[]
createLongArray
(Object[] array) Creates an array of longs from an array of objects.static short[]
createShortArray
(Object[] array) Creates an array of shorts from an array of objects.static String[]
createStringArray
(boolean[] array) Creates a new string array containing formatted string values of the input boolean array.static String[]
createStringArray
(boolean[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input boolean array.static String[]
createStringArray
(byte[] array) Creates a new string array containing formatted string values of the input byte array.static String[]
createStringArray
(byte[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input byte array.static String[]
createStringArray
(char[] array) Creates a new string array containing formatted string values of the input char array.static String[]
createStringArray
(char[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input char array.static String[]
createStringArray
(double[] array) Creates a new string array containing formatted string values of the input double array.static String[]
createStringArray
(double[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input double array.static String[]
createStringArray
(float[] array) Creates a new string array containing formatted string values of the input float array.static String[]
createStringArray
(float[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input float array.static String[]
createStringArray
(int[] array) Creates a new string array containing formatted string values of the input int array.static String[]
createStringArray
(int[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input int array.static String[]
createStringArray
(long[] array) Creates a new string array containing formatted string values of the input long array.static String[]
createStringArray
(long[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input long array.static String[]
createStringArray
(short[] array) Creates a new string array containing formatted string values of the input short array.static String[]
createStringArray
(short[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input short array.static String[]
createStringArray
(Object[] array) Creates a new string array containing formatted string values of the input object array.static String[]
createStringArray
(Object[] array, ConstrainedProperty constrainedProperty) Creates a new string array containing formatted string values of the input object array.static String[]
createStringArray
(Object source, ConstrainedProperty constrainedProperty) Convert anObject
to a textual representation in aString
array.static ArrayUtils.ArrayType
getArrayType
(Object object) Determines the type of the array based on the object's class name.static boolean[]
join
(boolean[] first, boolean second) Joins a single boolean and a boolean array into a new array containing all elements.static boolean[]
join
(boolean[] first, boolean[] second) Joins two boolean arrays into a new array containing all elements from both arrays.static byte[]
join
(byte[] first, byte second) Joins a single byte and a byte array into a new array containing all elements.static byte[]
join
(byte[] first, byte[] second) Joins two byte arrays into a new array containing all elements from both arrays.static char[]
join
(char[] first, char second) Joins a single char and a char array into a new array containing all elements.static char[]
join
(char[] first, char[] second) Joins two char arrays into a new array containing all elements from both arrays.static double[]
join
(double[] first, double second) Joins a single double and a double array into a new array containing all elements.static double[]
join
(double[] first, double[] second) Joins two double arrays into a new array containing all elements from both arrays.static float[]
join
(float[] first, float second) Joins a single float and a float array into a new array containing all elements.static float[]
join
(float[] first, float[] second) Joins two float arrays into a new array containing all elements from both arrays.static int[]
join
(int[] first, int second) Joins a single int and an int array into a new array containing all elements.static int[]
join
(int[] first, int[] second) Joins two int arrays into a new array containing all elements from both arrays.static long[]
join
(long[] first, long second) Joins a single long and a long array into a new array containing all elements.static long[]
join
(long[] first, long[] second) Joins two long arrays into a new array containing all elements from both arrays.static short[]
join
(short[] first, short second) Joins a single short and a short array into a new array containing all elements.static short[]
join
(short[] first, short[] second) Joins two short arrays into a new array containing all elements from both arrays.static String[]
Joins a single String and a String array into a new array containing all elements.static String[]
Joins two String arrays into a new array containing all elements from both arrays.
-
Method Details
-
getArrayType
Determines the type of the array based on the object's class name.- Parameters:
object
- the object to check if it is an array- Returns:
- an ArrayType value indicating the type of the array, or NO_ARRAY if object is not an array
- Throws:
NullPointerException
- if object is null- Since:
- 1.0
-
createStringArray
Convert anObject
to a textual representation in aString
array.Note that array of type byte[] are explicitly not converted since that would result in many binary data to create OutOfMemoryError exceptions.
- Parameters:
source
- TheObject
to convert.- Returns:
- The resulting
String
array; ornull
ifsource
isnull
. - Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input object array.- Parameters:
array
- the input object array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input object array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input object array.- Parameters:
array
- the input object array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input object array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input boolean array.- Parameters:
array
- the input boolean array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input boolean array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input boolean array.- Parameters:
array
- the input boolean array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input boolean array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input byte array.- Parameters:
array
- the input byte array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input byte array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input byte array.- Parameters:
array
- the input byte array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input byte array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input char array.- Parameters:
array
- the input char array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input char array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input char array.- Parameters:
array
- the input char array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input char array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input short array.- Parameters:
array
- the input short array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input short array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input short array.- Parameters:
array
- the input short array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input short array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input int array.- Parameters:
array
- the input int array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input int array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input int array.- Parameters:
array
- the input int array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input int array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input long array.- Parameters:
array
- the input long array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input long array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input long array.- Parameters:
array
- the input long array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input long array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input float array.- Parameters:
array
- the input float array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input float array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input float array.- Parameters:
array
- the input float array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input float array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input double array.- Parameters:
array
- the input double array, can be empty ornull
- Returns:
- a new string array containing formatted string values of the input double array
- Since:
- 1.0
-
createStringArray
Creates a new string array containing formatted string values of the input double array.- Parameters:
array
- the input double array, can be empty ornull
constrainedProperty
- the optionalConstrainedProperty
object containing constraints for formatting the property value- Returns:
- a new string array containing formatted string values of the input double array
- Since:
- 1.0
-
createBooleanArray
Creates an array of booleans from an array of objects.- Parameters:
array
- the array to create a boolean array from- Returns:
- a new boolean array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createByteArray
Creates an array of bytes from an array of objects.- Parameters:
array
- the array to create a byte array from- Returns:
- a new byte array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createCharArray
Creates an array of chars from an array of objects.- Parameters:
array
- the array to create a char array from- Returns:
- a new char array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createShortArray
Creates an array of shorts from an array of objects.- Parameters:
array
- the array to create a short array from- Returns:
- a new short array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createIntArray
Creates an array of ints from an array of objects.- Parameters:
array
- the array to create an int array from- Returns:
- a new int array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createLongArray
Creates an array of longs from an array of objects.- Parameters:
array
- the array to create a long array from- Returns:
- a new long array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createFloatArray
Creates an array of floats from an array of objects.- Parameters:
array
- the array to create a float array from- Returns:
- a new float array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
createDoubleArray
Creates an array of doubles from an array of objects.- Parameters:
array
- the array to create a double array from- Returns:
- a new double array that contains the converted values of the original array, or null if the original array is null
- Since:
- 1.0
-
join
Joins two String arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first String array to joinsecond
- the second String array to join- Returns:
- a new String array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
Joins a single String and a String array into a new array containing all elements.- Parameters:
first
- the String array to which to append the second Stringsecond
- the String to append to the first array- Returns:
- a new String array with every element of the input array and the appended String, or a new array containing only the second String if the input array is null
- Since:
- 1.0
-
join
public static byte[] join(byte[] first, byte[] second) Joins two byte arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first byte array to joinsecond
- the second byte array to join- Returns:
- a new byte array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static byte[] join(byte[] first, byte second) Joins a single byte and a byte array into a new array containing all elements.- Parameters:
first
- the byte array to which to append the second bytesecond
- the byte to append to the first array- Returns:
- a new byte array with every element of the input array and the appended byte, or a new array containing only the second byte if the input array is null
- Since:
- 1.0
-
join
public static char[] join(char[] first, char[] second) Joins two char arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first char array to joinsecond
- the second char array to join- Returns:
- a new char array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static char[] join(char[] first, char second) Joins a single char and a char array into a new array containing all elements.- Parameters:
first
- the char array to which to append the second charsecond
- the char to append to the first array- Returns:
- a new char array with every element of the input array and the appended char, or a new array containing only the second char if the input array is null
- Since:
- 1.0
-
join
public static short[] join(short[] first, short[] second) Joins two short arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first short array to joinsecond
- the second short array to join- Returns:
- a new short array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static short[] join(short[] first, short second) Joins a single short and a short array into a new array containing all elements.- Parameters:
first
- the short array to which to append the second shortsecond
- the short to append to the first array- Returns:
- a new short array with every element of the input array and the appended short, or a new array containing only the second short if the input array is null
- Since:
- 1.0
-
join
public static int[] join(int[] first, int[] second) Joins two int arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first int array to joinsecond
- the second int array to join- Returns:
- a new int array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static int[] join(int[] first, int second) Joins a single int and an int array into a new array containing all elements.- Parameters:
first
- the int array to which to append the second intsecond
- the int to append to the first array- Returns:
- a new int array with every element of the input array and the appended int, or a new array containing only the second int if the input array is null
- Since:
- 1.0
-
join
public static long[] join(long[] first, long[] second) Joins two long arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first long array to joinsecond
- the second long array to join- Returns:
- a new long array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static long[] join(long[] first, long second) Joins a single long and a long array into a new array containing all elements.- Parameters:
first
- the long array to which to append the second longsecond
- the long to append to the first array- Returns:
- a new long array with every element of the input array and the appended long, or a new array containing only the second long if the input array is null
- Since:
- 1.0
-
join
public static float[] join(float[] first, float[] second) Joins two float arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first float array to joinsecond
- the second float array to join- Returns:
- a new float array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static float[] join(float[] first, float second) Joins a single float and a float array into a new array containing all elements.- Parameters:
first
- the float array to which to append the second floatsecond
- the float to append to the first array- Returns:
- a new float array with every element of the input array and the appended float, or a new array containing only the second float if the input array is null
- Since:
- 1.0
-
join
public static double[] join(double[] first, double[] second) Joins two double arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first double array to joinsecond
- the second double array to join- Returns:
- a new double array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static double[] join(double[] first, double second) Joins a single double and a double array into a new array containing all elements.- Parameters:
first
- the double array to which to append the second doublesecond
- the double to append to the first array- Returns:
- a new double array with every element of the input array and the appended double, or a new array containing only the second double if the input array is null
- Since:
- 1.0
-
join
public static boolean[] join(boolean[] first, boolean[] second) Joins two boolean arrays into a new array containing all elements from both arrays.- Parameters:
first
- the first boolean array to joinsecond
- the second boolean array to join- Returns:
- a new boolean array with every element of both input arrays, or null if both inputs are null
- Since:
- 1.0
-
join
public static boolean[] join(boolean[] first, boolean second) Joins a single boolean and a boolean array into a new array containing all elements.- Parameters:
first
- the boolean array to which to append the second booleansecond
- the boolean to append to the first array- Returns:
- a new boolean array with every element of the input array and the appended boolean, or a new array containing only the second boolean if the input array is null
- Since:
- 1.0
-