|
Project Wonder 2.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object er.extensions.ERXArrayUtilities
Collection of NSArray
utilities.
Field Summary | |
static String |
NULL_GROUPING_KEY
Holds the null grouping key for use when grouping objects based on a key that might return null and nulls are allowed |
Constructor Summary | |
ERXArrayUtilities()
|
Method Summary | |
static void |
addObjectsFromArrayWithoutDuplicates(NSMutableArray a1,
NSArray a2)
Adds all of the non-duplicate elements from the second array to the mutable array. |
static NSArray |
arrayByAddingObjectsFromArrayWithoutDuplicates(NSArray a1,
NSArray a2)
Creates an array preserving order by adding all of the non-duplicate values from the second array to the first. |
static boolean |
arrayContainsAnyObjectFromArray(NSArray array,
NSArray objects)
Function to determine if an array contains any of the elements of another array. |
static boolean |
arrayContainsArray(NSArray array,
NSArray objects)
Function to determine if an array contains all of the elements of another array. |
static NSArray |
arrayForKeysPath(NSArray array,
NSArray keys)
Returns an array of dictionaries containing the key/value pairs for the given paths. |
static NSArray |
arrayFromPropertyList(String name,
NSBundle bundle)
Creates an NSArray from a resource associated with a given bundle that is in property list format. |
static NSDictionary |
arrayGroupedByKeyPath(NSArray objects,
String keyPath)
Groups an array of objects by a given key path. |
static NSDictionary |
arrayGroupedByKeyPath(NSArray eos,
String keyPath,
boolean includeNulls,
String extraKeyPathForValues)
Groups an array of objects by a given key path. |
static NSDictionary |
arrayGroupedByToManyKeyPath(NSArray eos,
String keyPath,
boolean includeNulls)
Groups an array of objects by a given to-many key path, where every single item in the to-many will put the object in the corresponding group. |
static NSArray |
arrayMinusArray(NSArray main,
NSArray minus)
Subtracts the contents of one array from another. |
static NSArray |
arrayMinusObject(NSArray main,
Object object)
Subtracts a single object from an array. |
static boolean |
arraysAreIdenticalSets(NSArray a1,
NSArray a2)
Simple comparision method to see if two array objects are identical sets. |
static NSArray |
arrayWithoutDuplicateKeyValue(NSArray eos,
String key)
Filters out duplicates of an array of enterprise objects based on the value of the given key off of those objects. |
static NSArray |
arrayWithoutDuplicates(NSArray anArray)
Filters out all of the duplicate objects in a given array. |
static NSArray |
batchedArrayWithSize(NSArray array,
int batchSize)
Batches an NSArray into sub-arrays of the given size. |
static NSArray |
filteredArrayWithEntityFetchSpecification(NSArray array,
String fetchSpec,
String entity)
Filters a given array with a named fetch specification. |
static NSArray |
filteredArrayWithEntityFetchSpecification(NSArray array,
String entity,
String fetchSpec,
NSDictionary bindings)
Filters a given array with a named fetch specification and bindings. |
static NSArray |
filteredArrayWithFetchSpecificationNamedEntityNamed(NSArray array,
String fetchSpec,
String entity)
Deprecated. |
static NSArray |
filteredArrayWithFetchSpecificationNamedEntityNamedBindings(NSArray array,
String fetchSpec,
String entity,
NSDictionary bindings)
Deprecated. |
static NSArray |
filteredArrayWithQualifierEvaluation(Enumeration enumeration,
EOQualifierEvaluation qualifier)
Filters any kinds of collections that implements Enumeration
interface such as NSArray , NSSet , Vector
and Hashtable using the EOQualifierEvaluation interface. |
static NSArray |
filteredArrayWithQualifierEvaluation(Iterator iterator,
EOQualifierEvaluation qualifier)
Filters any kind of collections that implements Iterator
interface such as ArrayList , HashMap , SortedSet
and TreeSet using the EOQualifierEvaluation interface. |
static NSArray |
filteredArrayWithQualifierEvaluation(NSArray array,
EOQualifierEvaluation qualifier)
Filters an array using the EOQualifierEvaluation interface. |
static NSArray |
flatten(NSArray array)
Recursively flattens an array of arrays into a single array of elements. |
static NSArray |
flatten(NSArray array,
boolean filterDuplicates)
Recursively flattens an array of arrays into a single array of elements. |
static String |
friendlyDisplayForKeyPath(NSArray list,
String attribute,
String nullArrayDisplay,
String separator,
String finalSeparator)
Displays a list of attributes off of objects in a 'friendly' manner. |
static void |
initialize()
Will register new NSArray operators sort, sortAsc, sortDesc, sortInsensitiveAsc, sortInsensitiveDesc, unique, flatten, reverse and fetchSpec |
static NSArray |
intersectingElements(NSArray array1,
NSArray array2)
Intersects the elements of two arrays. |
static String |
objectArraysToString(NSArray a)
pretty prints a NSArray of two dimensional Object array which is ugly when using toString |
static String |
objectArrayToString(Object[] o)
pretty prints an Object array which is ugly when using toString |
static String |
objectArrayToString(Object[][] o)
pretty prints a two dimensional Object array which is ugly when using toString |
static NSArray |
removeNullValues(NSArray a)
Removes all occurencies of NSKeyValueCoding.NullValue in the provided array |
static NSArray |
removeNullValuesFromEnd(NSArray array)
removes all occurencies of NSKeyValueCoding.Null from the end of the array |
static NSArray |
reverse(NSArray array)
Reverses the elements of an array |
static NSSet |
setFromArray(NSArray array)
Simply utility method to create a concreate set object from an array |
static void |
shiftObjectLeft(NSMutableArray array,
Object object)
shifts a given object in an array one value to the left (index--). |
static void |
shiftObjectRight(NSMutableArray array,
Object object)
shifts a given object in an array one value to the right (index++). |
static void |
sortArrayWithKey(NSMutableArray array,
String key)
Sorts a given mutable array with a key in place. |
static void |
sortArrayWithKey(NSMutableArray array,
String key,
NSSelector selector)
Sorts a given mutable array with a key in place. |
static NSArray |
sortedArraySortedWithKey(NSArray array,
String key)
Sorts a given array with a key in ascending fashion. |
static NSArray |
sortedArraySortedWithKey(NSArray array,
String key,
NSSelector selector)
Sorts a given array with a key in ascending fashion. |
static NSArray |
sortedArraySortedWithKeys(NSArray array,
NSArray keys,
NSSelector selector)
Sorts a given array with a set of keys according to the given selector. |
static NSMutableArray |
sortedMutableArraySortedWithKey(NSArray array,
String key)
Sorts a given array with a key in ascending fashion and returns a mutable clone of the result. |
static NSSelector |
sortSelectorWithKey(String key)
The qualifiers EOSortOrdering.CompareAscending.. and friends are actually 'special' and processed in a different/faster way when sorting than a selector that would be created by new NSSelector("compareAscending", ObjectClassArray). |
static String[] |
toStringArray(NSArray a)
|
static NSArray |
valuesForKeyPaths(Object array,
NSArray paths)
Performs multiple key-value coding calls against an 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 NULL_GROUPING_KEY
Constructor Detail |
public ERXArrayUtilities()
Method Detail |
public static NSSet setFromArray(NSArray array)
array
- of elements
public static NSSelector sortSelectorWithKey(String key)
key
- sort keypublic static NSDictionary arrayGroupedByKeyPath(NSArray objects, String keyPath)
ERXGenericRecord
if interested.
objects
- array of objects to be groupedkeyPath
- path used to group the objects.
public static NSDictionary arrayGroupedByKeyPath(NSArray eos, String keyPath, boolean includeNulls, String extraKeyPathForValues)
ERXGenericRecord
if interested.
eos
- array of objects to be groupedkeyPath
- path used to group the objects.includeNulls
- determines if keyPaths that resolve to null
should be allowed into the group.extraKeyPathForValues
- allows a selected object to include
more objects in the group. This is going away in the
future.
public static NSDictionary arrayGroupedByToManyKeyPath(NSArray eos, String keyPath, boolean includeNulls)
ERXGenericRecord
if interested.
eos
- array of objects to be groupedkeyPath
- path used to group the objects.includeNulls
- determines if keyPaths that resolve to null
should be allowed into the group.
public static boolean arraysAreIdenticalSets(NSArray a1, NSArray a2)
a1
- first arraya2
- second array
public static NSArray filteredArrayWithQualifierEvaluation(NSArray array, EOQualifierEvaluation qualifier)
EOQualifierEvaluation
interface.
array
- to be filteredqualifier
- to do the filtering
public static NSArray filteredArrayWithQualifierEvaluation(Enumeration enumeration, EOQualifierEvaluation qualifier)
Enumeration
interface such as NSArray
, NSSet
, Vector
and Hashtable
using the EOQualifierEvaluation
interface.
enumeration
- to be filtered; to obtain an enumeration,
use objectEnumerator() for the collections in
com.webobjects.foundation package
and use elements() for the Vector and Hashtablequalifier
- to do the filtering
public static NSArray filteredArrayWithQualifierEvaluation(Iterator iterator, EOQualifierEvaluation qualifier)
Iterator
interface such as ArrayList
, HashMap
, SortedSet
and TreeSet
using the EOQualifierEvaluation
interface.
iterator
- to be filtered; use iterator() to obtain
an iterator from the collectionsqualifier
- to do the filtering
public static NSArray arrayWithoutDuplicateKeyValue(NSArray eos, String key)
eos
- array of enterprise objectskey
- key path to be evaluated off of every enterprise
object
public static NSArray arrayMinusArray(NSArray main, NSArray minus)
main
- array to have values removed from it.minus
- array of values to remove from the main array
public static NSArray arrayMinusObject(NSArray main, Object object)
main
- array to have value removed from it.
public static NSArray arrayByAddingObjectsFromArrayWithoutDuplicates(NSArray a1, NSArray a2)
a1
- first arraya2
- second array
public static void addObjectsFromArrayWithoutDuplicates(NSMutableArray a1, NSArray a2)
a1
- mutable array where non-duplicate objects are
addeda2
- array to be added to a1public static NSArray flatten(NSArray array)
NSArray foos;
//Assume existsNSArray bars = (NSArray)foos.valueForKey("toBars");
In this case if foos
contained five elements
then the array bars
will contain five arrays
each corresponding to what aFoo.toBars
would
return. To have the entire collection of bars
in one single array you would call:
NSArray allBars = flatten(bars)
array
- to be flattened
public static NSArray flatten(NSArray array, boolean filterDuplicates)
NSArray foos;
//Assume existsNSArray bars = (NSArray)foos.valueForKey("toBars");
In this case if foos
contained five elements
then the array bars
will contain five arrays
each corresponding to what aFoo.toBars
would
return. To have the entire collection of bars
in one single array you would call:
NSArray allBars = flatten(bars)
array
- to be flattenedfilterDuplicates
- determines if the duplicate values
should be filtered
public static NSArray arrayFromPropertyList(String name, NSBundle bundle)
name
- name of the file or resource.bundle
- NSBundle to which the resource belongs.
public static NSArray valuesForKeyPaths(Object array, NSArray paths)
array
- object to be acted upon.paths
- array of keypaths.
public static NSMutableArray sortedMutableArraySortedWithKey(NSArray array, String key)
array
- array to be sorted.key
- sort key.
public static NSArray sortedArraySortedWithKey(NSArray array, String key)
array
- array to be sorted.key
- sort key.
public static NSArray sortedArraySortedWithKey(NSArray array, String key, NSSelector selector)
array
- array to be sorted.key
- sort key.selector
- sort order selector to use, if null, then sort will be ascending.
public static NSArray sortedArraySortedWithKeys(NSArray array, NSArray keys, NSSelector selector)
array
- array to be sorted.keys
- sort keysselector
- sort order selector to use, if null, then sort will be ascending.
public static void sortArrayWithKey(NSMutableArray array, String key)
array
- array to be sorted.key
- sort key.public static void sortArrayWithKey(NSMutableArray array, String key, NSSelector selector)
array
- array to be sorted.key
- sort key.selector
- sort order selector to use, if null, then sort will be ascending.public static void initialize()
public static NSArray arrayWithoutDuplicates(NSArray anArray)
anArray
- to be filtered
public static NSArray batchedArrayWithSize(NSArray array, int batchSize)
array
- array to batchbatchSize
- number of items in each batch
public static NSArray filteredArrayWithEntityFetchSpecification(NSArray array, String entity, String fetchSpec, NSDictionary bindings)
array
- array to be filtered.fetchSpec
- name of the EOQualifierEvaluation
.entity
- name of the EOEntity
to which the fetch specification is associated.bindings
- bindings dictionary for qualifier variable substitution.
public static NSArray filteredArrayWithFetchSpecificationNamedEntityNamedBindings(NSArray array, String fetchSpec, String entity, NSDictionary bindings)
public static NSArray filteredArrayWithEntityFetchSpecification(NSArray array, String fetchSpec, String entity)
array
- array to be filtered.fetchSpec
- name of the EOQualifierEvaluation
.entity
- name of the EOEntity
to which the fetch specification is associated.
public static NSArray filteredArrayWithFetchSpecificationNamedEntityNamed(NSArray array, String fetchSpec, String entity)
public static void shiftObjectLeft(NSMutableArray array, Object object)
array
- array to be modified.object
- the object that should be movedpublic static void shiftObjectRight(NSMutableArray array, Object object)
array
- array to be modified.object
- the object that should be movedpublic static boolean arrayContainsAnyObjectFromArray(NSArray array, NSArray objects)
array
- to test if it contains any of the objectsobjects
- array of objects to test if the first array
contains any of
public static boolean arrayContainsArray(NSArray array, NSArray objects)
array
- to test if it contains all of the objects of another arrayobjects
- array of objects to test if the first array
contains all of
public static NSArray intersectingElements(NSArray array1, NSArray array2)
array1
- the first arrayarray2
- the second array
public static NSArray reverse(NSArray array)
array
- to be reversed
public static String friendlyDisplayForKeyPath(NSArray list, String attribute, String nullArrayDisplay, String separator, String finalSeparator)
list
- of objects to be displayed in a friendly
mannerattribute
- key to be called on each object in
the listnullArrayDisplay
- string to be returned if the
list is null or emptyseparator
- string to be used for the first itemsfinalSeparator
- used between the last items
public static NSArray arrayForKeysPath(NSArray array, NSArray keys)
array
- array of objectskeys
- array of keys
public static NSArray removeNullValues(NSArray a)
a
- the array from which the NullValue should be removed
public static String objectArrayToString(Object[] o)
o
- the object which one wants to print as a String
log.info("my array = "+ERXArrayUtilities.objectArrayToString(myArray));
public static String objectArrayToString(Object[][] o)
o
- the object which one wants to print as a String
log.info("my array = "+ERXArrayUtilities.objectArrayToString(myArray));
public static String objectArraysToString(NSArray a)
log.info("my array = "+ERXArrayUtilities.objectArrayToString(myArray));
public static NSArray removeNullValuesFromEnd(NSArray array)
array
- the array from which the values should be removed
public static String[] toStringArray(NSArray a)
|
Last updated: Do, Dez 9, 2004 12:46 PM CET | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |