|
SoftNet-Consult Java Utility Library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.softnetConsult.utils.collections.ArrayTools
public final class ArrayTools
A collection of static utility functions for array processing.
This product includes software developed by the
SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.
File: ArrayTools.java
Library API version: "2.02"
Java compliance version: "1.5"
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
SoftNet-Consult Java Utility Library project, the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library
project and its contributors.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Field Summary | |
---|---|
static java.lang.String |
arrayClose
Closing bracket when converting arrays to Strings. |
static java.lang.String |
arrayOpen
Opening bracket when converting arrays to Strings. |
static java.lang.String |
defaultArraySeparator
Default separator when converting arrays to Strings. |
static java.lang.String |
nullName
A String representing a null. |
Constructor Summary | |
---|---|
private |
ArrayTools()
Prevents instances of this class from being created as this class contains only static utility methods. |
Method Summary | ||
---|---|---|
static
|
arrayToString(AET[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static
|
arrayToString(AET[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static
|
arrayToString(AET[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as
start and end indicators, "null" as null element indicator and the
specified listSeparator } as element delimeter. |
|
private static
|
arrayToString(AET[] array,
java.lang.String listSeparator,
java.util.Set<java.lang.Object> seenSubarrays)
This private method is used internally by arrayToString(Object[], String) and
has an additional parameter used to keep track or recursively processed arrays in order
to avoid infinite recursion. |
|
static java.lang.String |
arrayToString(boolean[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(boolean[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(boolean[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(byte[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(byte[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(byte[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(char[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(char[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(char[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(double[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(double[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(double[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(float[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(float[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(float[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(int[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(int[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(int[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(long[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(long[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(long[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static java.lang.String |
arrayToString(java.lang.Object array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(java.lang.Object array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(java.lang.Object array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as
start and end indicators, "null" as null element indicator and the
specified listSeparator } as element delimeter. |
|
private static java.lang.String |
arrayToString(java.lang.Object array,
java.lang.String listSeparator,
java.util.Set<java.lang.Object> seenSubarrays)
This private method is used internally by arrayToString(Object, String) and
has an additional parameter used to keep track or recursively processed arrays in order
to avoid infinite recursion. |
|
static java.lang.String |
arrayToString(short[] array)
Converts the specified array to a string using ", " as delimeter. |
|
static java.lang.String |
arrayToString(short[] array,
char listSeparator)
Converts the specified array to a string using the specified character as delimeter. |
|
static java.lang.String |
arrayToString(short[] array,
java.lang.String listSeparator)
Converts the specified array to a string using '[' and ']' as start
and end indicators and the specified listSeparator } as element delimeter. |
|
static
|
iterate(AET[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorBoolean |
iterate(boolean[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorByte |
iterate(byte[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorChar |
iterate(char[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorDouble |
iterate(double[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorFloat |
iterate(float[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorInt |
iterate(int[] array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorLong |
iterate(long[] array)
Creates an array iterator over the specified array. |
|
static java.util.Iterator<?> |
iterate(java.lang.Object array)
Creates an array iterator over the specified array. |
|
static ArrayIteratorShort |
iterate(short[] array)
Creates an array iterator over the specified array. |
|
static java.lang.Boolean[] |
toWrapperArray(boolean[] arr)
Converts an array of primitive boolean values to an array of Boolean
objects wrapping the respective primitive values. |
|
static java.lang.Byte[] |
toWrapperArray(byte[] arr)
Converts an array of primitive byte values to an array of Byte
objects wrapping the respective primitive values. |
|
static java.lang.Character[] |
toWrapperArray(char[] arr)
Converts an array of primitive char values to an array of Character
objects wrapping the respective primitive values. |
|
static java.lang.Double[] |
toWrapperArray(double[] arr)
Converts an array of primitive double values to an array of Double
objects wrapping the respective primitive values. |
|
static java.lang.Float[] |
toWrapperArray(float[] arr)
Converts an array of primitive float values to an array of Float
objects wrapping the respective primitive values. |
|
static java.lang.Integer[] |
toWrapperArray(int[] arr)
Converts an array of primitive int values to an array of Integer
objects wrapping the respective primitive values. |
|
static java.lang.Long[] |
toWrapperArray(long[] arr)
Converts an array of primitive long values to an array of Long
objects wrapping the respective primitive values. |
|
static java.lang.Object[] |
toWrapperArray(java.lang.Object arr)
Converts an array of primitive values to an array of appropriate wrapper objects wrapping the respective primitive values. |
|
static java.lang.Short[] |
toWrapperArray(short[] arr)
Converts an array of primitive short values to an array of Short
objects wrapping the respective primitive values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String defaultArraySeparator
public static final java.lang.String arrayOpen
public static final java.lang.String arrayClose
public static final java.lang.String nullName
Constructor Detail |
---|
private ArrayTools()
Method Detail |
---|
public static <ET,AET extends ET> ArrayIterator<ET> iterate(AET[] array)
ET
- Type of iteration objects.AET
- Array elements' type.array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorBoolean iterate(boolean[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorByte iterate(byte[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorChar iterate(char[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorShort iterate(short[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorInt iterate(int[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorLong iterate(long[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorFloat iterate(float[] array)
array
- The array to iterate.
Iterator
over the specified array.public static ArrayIteratorDouble iterate(double[] array)
array
- The array to iterate.
Iterator
over the specified array.public static java.util.Iterator<?> iterate(java.lang.Object array)
array
- The array to iterate.
Iterator
over the specified array.
java.lang.NullPointerException
- If the specified parameter is null.
java.lang.NullPointerException
- If the specified parameter is not an array and not iterable.public static <AET> java.lang.String arrayToString(AET[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
AET
- Type of the array's elements.array
- The array to converto to a string.
public static <AET> java.lang.String arrayToString(AET[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
AET
- Type of the array's elements.array
- The array to converto to a string.listSeparator
- The values separator character.
public static <AET> java.lang.String arrayToString(AET[] array, java.lang.String listSeparator)
'['
and ']'
as
start and end indicators, "null"
as null element indicator and the
specified listSeparator
} as element delimeter. For instance,
arrayToString(new Integer[] {0, -5, null, 11}, "; ")
will create the
string "[0; -5; null, 11]"
.
AET
- Type of the array's elements.array
- The array to convert to a string.listSeparator
- The values separator.
private static <AET> java.lang.String arrayToString(AET[] array, java.lang.String listSeparator, java.util.Set<java.lang.Object> seenSubarrays)
arrayToString(Object[], String)
and
has an additional parameter used to keep track or recursively processed arrays in order
to avoid infinite recursion.
AET
- Type of the array's elements.array
- The array to convert to a string.listSeparator
- The values separator.seenSubarrays
- Arrays already processed bythis recursion.
public static java.lang.String arrayToString(java.lang.Object array)
", "
as delimeter.
If the specified parameter is not an array, a String representation of the
parameter is returned. This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(java.lang.Object array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(java.lang.Object array, java.lang.String listSeparator)
'['
and ']'
as
start and end indicators, "null"
as null element indicator and the
specified listSeparator
} as element delimeter. For instance,
arrayToString(new Integer[] {0, -5, null, 11}, "; ")
will create the
string "[0; -5; null, 11]"
.
If the specified parameter is not an array, a String representation of the
parameter is returned.
array
- The array to convert to a string.listSeparator
- The values separator.
private static java.lang.String arrayToString(java.lang.Object array, java.lang.String listSeparator, java.util.Set<java.lang.Object> seenSubarrays)
arrayToString(Object, String)
and
has an additional parameter used to keep track or recursively processed arrays in order
to avoid infinite recursion.
array
- The array to convert to a string.listSeparator
- The values separator.seenSubarrays
- Arrays already processed bythis recursion.
public static java.lang.String arrayToString(boolean[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(boolean[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(boolean[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(byte[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(byte[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(byte[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(char[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(char[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(char[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(short[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(short[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(short[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(int[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(int[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(int[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(long[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(long[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(long[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(float[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(float[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(float[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.String arrayToString(double[] array)
", "
as delimeter.
This is equivalent to arrayToString(array, ", ")
.
array
- The array to converto to a string.
public static java.lang.String arrayToString(double[] array, char listSeparator)
arrayToString(array, new String(new char[] {listSeparator}))
.
array
- The array to converto to a string.listSeparator
- The values separator character.
public static java.lang.String arrayToString(double[] array, java.lang.String listSeparator)
'['
and ']'
as start
and end indicators and the specified listSeparator
} as element delimeter.
array
- The array to convert to a string.listSeparator
- The values separator.
public static java.lang.Boolean[] toWrapperArray(boolean[] arr)
boolean
values to an array of Boolean
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Byte[] toWrapperArray(byte[] arr)
byte
values to an array of Byte
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Character[] toWrapperArray(char[] arr)
char
values to an array of Character
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Short[] toWrapperArray(short[] arr)
short
values to an array of Short
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Integer[] toWrapperArray(int[] arr)
int
values to an array of Integer
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Long[] toWrapperArray(long[] arr)
long
values to an array of Long
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Float[] toWrapperArray(float[] arr)
float
values to an array of Float
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Double[] toWrapperArray(double[] arr)
double
values to an array of Double
objects wrapping the respective primitive values.
arr
- An array.
null
if the specified array is null
.public static java.lang.Object[] toWrapperArray(java.lang.Object arr)
arr
- An array.
null
if the specified array is null
.
java.lang.IllegalArgumentException
- if the specified parameter if not an array or if it is an
array of non-primitive elements.
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |