net.sf.mmm.util.lang.api
Interface BasicUtil

All Known Implementing Classes:
BasicUtilImpl

@ComponentSpecification
public interface BasicUtil

This is the interface for a collection of utility functions for very general operations especially for dealing with Arrays.

Since:
1.0.2
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
BasicUtilImpl.getInstance(), Arrays, Array, ReflectionUtil

Field Summary
static int[] EMPTY_INT_ARRAY
          An empty int array.
 
Method Summary
 boolean compare(CharIterator charIterator1, CharIterator charIterator2)
          This method compares the given CharIterator instances char by char.
 int findInArray(Object value, Object[] array, boolean checkEqual)
          This method returns the index of the first element in the given array that equals (see checkEqual) to the given value.
 int findInArray(Object value, Object array, boolean checkEqual)
          This method returns the index of the first element in the given array that equals (see checkEqual) to the given value.
 boolean isDeepEqual(Object o1, Object o2)
          This method checks if two given objects are equal to each other.
 boolean isEqual(Object[] array1, Object[] array2)
          This method checks if two given arrays are structurally equal to each other.
 boolean isEqual(Object o1, Object o2)
          This method checks if two given objects are equal to each other.
 boolean isInArray(Object value, Object[] array, boolean checkEqual)
          This method determines if the given array contains an element that equals (see checkEqual) to the given value.
 boolean isInArray(Object value, Object array, boolean checkEqual)
          This method determines if the given array contains an element that equals (see checkEqual) to the given value.
 

Field Detail

EMPTY_INT_ARRAY

static final int[] EMPTY_INT_ARRAY
An empty int array.

Method Detail

isEqual

boolean isEqual(Object o1,
                Object o2)
This method checks if two given objects are equal to each other. In advance to Object.equals(Object) the objects may be null.

Parameters:
o1 - the first object to compare. It may be null.
o2 - the second object to compare. It may be null.
Returns:
true if both objects are null or the first is NOT null and o1.equals(o2), false otherwise.
See Also:
isDeepEqual(Object, Object)

isEqual

boolean isEqual(Object[] array1,
                Object[] array2)
This method checks if two given arrays are structurally equal to each other. On arrays the equals-method only checks for identity. This method checks that both arrays have the same length and if so that the objects contained in the arrays are equal. Additionally the given arrays may be null.

Parameters:
array1 - the first array to compare. It may be null.
array2 - the second array to compare. It may be null.
Returns:
true if both arrays are null or the first is NOT null and both arrays have the same length and equal content, false otherwise.

isDeepEqual

boolean isDeepEqual(Object o1,
                    Object o2)
This method checks if two given objects are equal to each other. In advance to Object.equals(Object) the objects may be null and arrays are compared structural recursively.

Parameters:
o1 - the first object to compare. It may be null.
o2 - the second object to compare. It may be null.
Returns:
true if both objects are null or the first is NOT null and o1.equals(o2), false otherwise.

findInArray

int findInArray(Object value,
                Object[] array,
                boolean checkEqual)
This method returns the index of the first element in the given array that equals (see checkEqual) to the given value.

Parameters:
value - is the value to check. It may be null.
array - is the array to check.
checkEqual - - if true the value only needs to be equal to an element, if false it needs to be the same (==).
Returns:
the according index or -1 if value is NOT contained in array.

findInArray

int findInArray(Object value,
                Object array,
                boolean checkEqual)
This method returns the index of the first element in the given array that equals (see checkEqual) to the given value.
Unlike findInArray(Object, Object[], boolean) this method also works for primitive arrays (such as int[]). In such case you need to supply the according object-type for value.

Parameters:
value - is the value to check. It may be null.
array - is the array to check.
checkEqual - - if true the value only needs to be equal to an element, if false it needs to be the same (==).
Returns:
the according index or -1 if value is NOT contained in array.

isInArray

boolean isInArray(Object value,
                  Object[] array,
                  boolean checkEqual)
This method determines if the given array contains an element that equals (see checkEqual) to the given value.

Parameters:
value - is the value to check. It may be null.
array - is the array to check.
checkEqual - - if true the value only needs to be equal to an element, if false it needs to be the same (==).
Returns:
true if the array contains value.
See Also:
findInArray(Object, Object[], boolean)

isInArray

boolean isInArray(Object value,
                  Object array,
                  boolean checkEqual)
This method determines if the given array contains an element that equals (see checkEqual) to the given value.

Parameters:
value - is the value to check. It may be null.
array - is the array to check.
checkEqual - - if true the value only needs to be equal to an element, if false it needs to be the same (==).
Returns:
true if the array contains value.
See Also:
findInArray(Object, Object, boolean)

compare

boolean compare(CharIterator charIterator1,
                CharIterator charIterator2)
This method compares the given CharIterator instances char by char.

Parameters:
charIterator1 - is the first CharIterator.
charIterator2 - is the second CharIterator.
Returns:
true if both CharIterators produced the same next chars until both ended at the same time.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.