|
WebObjects 5.4 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.webobjects.foundation.NSArray<E>
public class NSArray<E>
NSArray and its subclass NSMutableArray manage ordered collections of objects. NSArray creates immutable arrays and NSMutableArray creates mutable arrays.
The following table describes the NSArray methods that provide the basis for all NSArray's other methods; that is, all other methods are implemented in terms of these three. If you create a subclass of NSArray, you need only ensure that these base methods work properly. Having done so, you can be sure that all your subclass's inherited methods operate properly.
Method |
Description |
count |
Returns the number of elements in the array. |
objectAtIndex |
Provides access to the array elements by index. |
objectsNoCopy |
Returns a natural language array containing the NSArray's objects. |
The methods objectEnumerator and reverseObjectEnumerator grant sequential access to the elements of the array, differing only in the direction of travel through the elements. These methods are provided so that arrays can be traversed in a manner similar to that used
for objects of other collection classes in both the Java API and in the Foundation framework, such as java.util.Hashtable or NSDictionary. See the objectEnumerator method description for a code excerpt that shows how to use these methods to access the elements of an array.
NSArray provides methods for querying the elements of the array. indexOfObject searches the array for the object that matches its argument. To determine whether the search is successful, each element of the array is sent an equals message. Another method,
indexOfIdenticalObject, is provided for the less common case of determining whether a specific object is present in the array. indexOfIdenticalObject tests each element in the array to see if it is the exact same instance as the argument.
To act on the array as a whole, a variety of other methods are defined. You can extract a subset of the array (subarrayWithRange) or concatenate the elements of an array of Strings into a single string (componentsJoinedByString). In addition, you can compare two
arrays using the equals and firstObjectCommonWithArray methods. Finally, you can create new arrays that contain the objects in an existing array and one or more additional objects with arrayByAddingObject and arrayByAddingObjectsFromArray.
List,
ArrayList,
Vector,
count(),
objectAtIndex(int),
indexOfObject,
arrayByAddingObjectsFromArray(com.webobjects.foundation.NSArray) ,
componentsJoinedByString(java.lang.String),
objectEnumerator(),
Serialized Form| Nested Class Summary | |
|---|---|
static interface |
NSArray.Operator
Objects implementing NSArray.Operator are used to perform operations on an array's elements. |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSCoding |
|---|
NSCoding.Support |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
|---|
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
| Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding |
|---|
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor |
| Field Summary | |
|---|---|
static String |
AverageOperatorName
A key representing the operator ( NSArray.Operator) that computes the average of the elements in an array. |
static boolean |
CheckForNull
Convenience for the constructor methods |
static String |
CountOperatorName
A key representing the operator ( NSArray.Operator) that computes the number of elements in an array. |
static NSArray |
EmptyArray
A constant representation of an empty array. |
static boolean |
IgnoreNull
Convenience for the constructor methods |
static String |
MaximumOperatorName
A key representing the operator ( NSArray.Operator) that computes the largest element in an array. |
static String |
MinimumOperatorName
A key representing the operator ( NSArray.Operator) that computes the smallest element in an array. |
static int |
NotFound
This constant is returned by several search methods, indicating that no matching object was found. |
static String |
SumOperatorName
A key representing the operator ( NSArray.Operator) that computes the sum of the elements in an array. |
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
|---|
KeyPathSeparator |
| Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
|---|
NullValue |
| Constructor Summary | |
|---|---|
|
NSArray()
Creates an empty, immutable array. |
|
NSArray(Collection<? extends E> collection)
Creates a NSArray from objects that implement the java.util.Collection interface. |
|
NSArray(Collection<? extends E> collection,
boolean checkForNull)
Creates a NSArray from objects that implement the java.util.Collection interface. |
|
NSArray(E object)
Creates an array containing the single element object. |
|
NSArray(E[] objects)
Creates an array containing the elements from objects. |
|
NSArray(E[] objects,
NSRange range)
Creates an array containing the objects from objects in the range specified by range. |
|
NSArray(List<? extends E> list,
NSRange range,
boolean ignoreNull)
Creates an array containing the objects from list in the range specified by range. |
|
NSArray(NSArray<? extends E> otherArray)
One should use immutableClone instead. |
protected |
NSArray(Object[] objects,
int rangeLocation,
int rangeLength,
boolean checkForNull)
|
| Method Summary | ||
|---|---|---|
boolean |
add(E element)
add is not a supported operation in NSArray |
|
void |
add(int index,
E element)
add is not a supported operation in NSArray |
|
boolean |
addAll(Collection<? extends E> collection)
addAll is not a supported operation in NSArray |
|
boolean |
addAll(int index,
Collection<? extends E> collection)
addAll is not a supported operation in NSArray |
|
NSArray<E> |
arrayByAddingObject(E object)
Returns a new NSArray which contains the values from this array, and appends the object argument. |
|
NSArray<E> |
arrayByAddingObjectsFromArray(NSArray<E> otherArray)
Returns a new NSArray which contains the values from this array, and appends values from the otherArray argument. |
|
ArrayList<E> |
arrayList()
Creates a java.util.ArrayList with the same contents as this object. |
|
Class |
classForCoder()
Conformance to the NSCoding interface. |
|
void |
clear()
Operation not supported |
|
Object |
clone()
Clones this array Object Since NSArrays are immutable, there's no need to make an actual clone. |
|
String |
componentsJoinedByString(String separator)
This method concatenates the String representation of each element in this array together in order from lowest index to highest. |
|
static NSArray<String> |
componentsSeparatedByString(String string,
String separator)
This static method tokenizes the string argument into a series of substrings according to separator It creates a new NSArray which contains the substrings in the order they appeared in string. |
|
boolean |
contains(Object element)
Returns true if NSArray contains the specified element. |
|
boolean |
containsAll(Collection c)
|
|
boolean |
containsObject(Object object)
This method determines whether object is present in this array by comparing it to each of the array's objects using equals |
|
int |
count()
|
|
static Object |
decodeObject(NSCoder coder)
Creates a new NSArray from the data in coder. |
|
static
|
emptyArray()
Returns the empty NSArray (immutable). |
|
void |
encodeWithCoder(NSCoder coder)
Encodes the receiver using coder. |
|
boolean |
equals(Object object)
Compares this array to object, returning true if object satisfies instanceof NSArray and its elements are equal to the elements of this array, otherwise it returns false. |
|
Object |
firstObjectCommonWithArray(NSArray otherArray)
This method searches for the first object in this array which is contained within otherArray. |
|
E |
get(int index)
|
|
void |
getObjects(Object[] objects)
Deprecated. use public Object[] objects() instead |
|
void |
getObjects(Object[] objects,
NSRange range)
Deprecated. use public Object[] objects() in NSRange instead |
|
int |
hashCode()
|
|
NSArray<E> |
immutableClone()
Since an NSArray is immutable, NSArray's implementation simply returns this. |
|
int |
indexOf(Object element)
|
|
int |
indexOfIdenticalObject(Object object)
Searches all objects in this array for object. |
|
int |
indexOfIdenticalObject(Object object,
NSRange range)
Searches the specified subset within this array for object (testing for equality by directly comparing Object references with ==) and returns the first (lowest) index whose corresponding element is identical to object. |
|
int |
indexOfObject(Object object)
Searches this array for object and returns the first (lowest) index whose corresponding element is equal to object. |
|
int |
indexOfObject(Object object,
NSRange range)
Searches the specified subset within this array for object and returns the first (lowest) index whose corresponding element is equal to object. |
|
boolean |
isEmpty()
Returns true if this list contains no elements. |
|
boolean |
isEqualToArray(NSArray otherArray)
Included for backward compatibility. |
|
Iterator<E> |
iterator()
|
|
int |
lastIndexOf(Object element)
|
|
E |
lastObject()
|
|
ListIterator<E> |
listIterator()
|
|
ListIterator<E> |
listIterator(int index)
|
|
void |
makeObjectsPerformSelector(NSSelector selector,
Object[] parameters)
Invokes the method specified by selector on each object in this array. |
|
NSMutableArray<E> |
mutableClone()
NSArray's implementation creates a new NSMutableArray with this array's elements, not copies. |
|
E |
objectAtIndex(int index)
Returns the Object reference stored at index within this NSArray. |
|
Enumeration<E> |
objectEnumerator()
This method creates a java.util.Enumeration which can used to iterate through the array's elements. |
|
E[] |
objects()
|
|
Object[] |
objects(NSRange range)
Copies a subset of this array into a Java array. |
|
protected E[] |
objectsNoCopy()
This method should only be used by subclasses. |
|
static NSArray.Operator |
operatorForKey(String operatorName)
|
|
static NSArray<String> |
operatorNames()
Returns the names of the operations that can be performed on array elements. |
|
E |
remove(int index)
Operation not supported |
|
boolean |
remove(Object element)
Operation not supported |
|
boolean |
removeAll(Collection<?> collection)
Operation not supported |
|
static void |
removeOperatorForKey(String operatorName)
Removes the operator identified by operatorName from the list of operators that can be performed on array elements. |
|
boolean |
retainAll(Collection<?> collection)
Operation not supported |
|
Enumeration<E> |
reverseObjectEnumerator()
This method creates a java.util.Enumeration which can used to iterate through the array's elements in reverse. |
|
E |
set(int index,
E element)
|
|
static void |
setOperatorForKey(String operatorName,
NSArray.Operator arrayOperator)
Registers an operator with a String. |
|
int |
size()
|
|
NSArray<E> |
sortedArrayUsingComparator(NSComparator comparator)
This method creates a new array with this array's element which have been sorted in an order based on the comparator operation. |
|
NSArray |
sortedArrayUsingSelector(NSSelector selector)
Deprecated. use sortedArrayUsingComparator instead |
|
NSArray<E> |
subarrayWithRange(NSRange range)
This method creates a new array from a subset of this array. |
|
List<E> |
subList(int fromIndex,
int toIndex)
|
|
void |
takeValueForKey(Object value,
String key)
Conformance to the NSKeyValueCoding interface. |
|
void |
takeValueForKeyPath(Object value,
String keyPath)
Sets the value for the property identified by keyPath
to value. |
|
Object[] |
toArray()
|
|
|
toArray(T[] objects)
|
|
String |
toString()
|
|
Object |
valueForKey(String key)
Conformance to the NSKeyValueCoding interface. |
|
Object |
valueForKeyPath(String keyPath)
Conformance to the NSKeyValueCodingAdditions interface. |
|
Vector<E> |
vector()
Creates a java.util.Vector with the same contents as this object. |
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NotFound
public static final NSArray EmptyArray
public static final String CountOperatorName
NSArray.Operator) that computes the number of elements in an array.
public static final String MaximumOperatorName
NSArray.Operator) that computes the largest element in an array.
public static final String MinimumOperatorName
NSArray.Operator) that computes the smallest element in an array.
public static final String SumOperatorName
NSArray.Operator) that computes the sum of the elements in an array.
public static final String AverageOperatorName
NSArray.Operator) that computes the average of the elements in an array.
public static final boolean CheckForNull
public static final boolean IgnoreNull
| Constructor Detail |
|---|
public NSArray()
EmptyArraypublic NSArray(E object)
object. object is not permitted to be null
object - the single element within the new NSArray
IllegalArgumentException - java.lang.IllegalArgumentException if object is null
protected NSArray(Object[] objects,
int rangeLocation,
int rangeLength,
boolean checkForNull)
public NSArray(E[] objects)
objects. objects must not be null, but this method ignores any null values within objects.
objects - a Java array containing the initial values for the newly created NSArray
public NSArray(E[] objects,
NSRange range)
objects in the range specified by range. Ignores any null values it encounters in objects.
objects - a Java array containing initial values for the newly created NSArrayrange - specifies which elements of the objects array are to be addedpublic NSArray(NSArray<? extends E> otherArray)
immutableClone instead. Creates a new array that contains the same object references as
otherArray. otherArray must not be null.
otherArray - the array to be duplicatedimmutableClone()
public NSArray(Collection<? extends E> collection,
boolean checkForNull)
java.util.Collection interface.
collection - object that implements the Collection interfacecheckForNull - whether to check for null values in List or throw exception
IllegalArgumentException - if a null element exists in Collection or java.lang.NullPointerException if the Collection parameter is null.Listpublic NSArray(Collection<? extends E> collection)
java.util.Collection interface.
collection - object that implements the Collection interface
IllegalArgumentException - if a null element exists in Collection or java.lang.NullPointerException if the Collection parameter is null.Collection
public NSArray(List<? extends E> list,
NSRange range,
boolean ignoreNull)
list in the range specified by range. The ignoreNull parameter controls the method's behavior when it encounters a null value in the list. If ignoreNull is
true, then null values are simply ignored. If ignoreNull is false, the method raises an IllegalArgumentException when it encounters a null value.
list - object that implements the List interfacerange - the range of objects to includeignoreNull - whether to ignore null values in vector or throw exception
IllegalArgumentException - if a null element exists in vector.Vector| Method Detail |
|---|
public static NSArray<String> operatorNames()
| Key | Operator Description |
count |
Returns the number of elements in an array. |
max |
Returns the element in the array with the highest value. |
min |
Returns the element in the array with the lowest value. |
avg |
Returns the average of the array's elements' values. |
sum |
Returns the sum of the array's element's values. |
public static void setOperatorForKey(String operatorName,
NSArray.Operator arrayOperator)
IllegalArgumentException if either operatorName or arrayOperator are null.
operatorName - the human-readable name for the operator instancearrayOperator - the operator instance
IllegalArgumentException - if either operatorName or arrayOperator are nullpublic static NSArray.Operator operatorForKey(String operatorName)
operatorName - the human-readable name for the operator instance
operatorName if one exists, null otherwiseNSArraypublic static void removeOperatorForKey(String operatorName)
operatorName from the list of operators that can be performed on array elements.
operatorName - the human-readable name for the operator instance to be removedprotected E[] objectsNoCopy()
public int count()
public E objectAtIndex(int index)
index within this NSArray. If the array is empty or if index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an
IllegalArgumentException is thrown. Negative index arguments are similarly illegal.
index - the location of the object
index
IllegalArgumentException - when index is not greater than or equal to 0 and less than count_countpublic NSArray<E> arrayByAddingObject(E object)
object argument. If object is null, an IllegalArgumentException is thrown.
object - the object to be appended
object appended
IllegalArgumentException - IllegalArgumentException if object is null.NSMutableArray#addObjectpublic NSArray<E> arrayByAddingObjectsFromArray(NSArray<E> otherArray)
otherArray argument.
otherArray - the array to be appended
otherArray appended.NSMutableArray#addObjectsFromArraypublic E[] objects()
public Object[] objects(NSRange range)
range - the range specifying a subset to copy
public Vector<E> vector()
public ArrayList<E> arrayList()
public boolean containsObject(Object object)
object is present in this array by comparing it to each of the array's objects using equals
object - the searched for object
true if this array contains an object equal to object, otherwise falsepublic Object firstObjectCommonWithArray(NSArray otherArray)
otherArray. It uses equals to check for equality.
otherArray - the input array
otherArray, or null if no such object is found@Deprecated public void getObjects(Object[] objects)
public Object[] objects() instead
objects - the destination buffer to copy this array into. It must be large enough to hold count Object references.objects()
@Deprecated
public void getObjects(Object[] objects,
NSRange range)
public Object[] objects() in NSRange instead
objects - the destination buffer to copy a subset of this array into. It must be large enough to hold count Object references.range - the subset of entries to copy into objectsobjects(NSRange range)public int indexOfObject(Object object)
object and returns the first (lowest) index whose corresponding element is equal to object. Objects are considered equal if equals returns true. If none of the specified objects are equal to
object, returns NotFound.
object - the search's target
anObjectNotFound
public int indexOfObject(Object object,
NSRange range)
object and returns the first (lowest) index whose corresponding element is equal to object. Objects are considered equal if equals returns true. If none of the specified objects are equal to
object, returns NotFound. Throws an IllegalArgumentException if aRange is out of bounds.
object - the search's targetrange - the subset to search
equals to object
IllegalArgumentException - if aRange is out of bounds.public int indexOfIdenticalObject(Object object)
object. The method tests for equality by comparing object references directly using the == operator, and not the equals method, and returns the first (lowest) index whose corresponding element is identical to
object. If none of the objects in the receiver are identical to object, this method returns NotFound.
object - the search's target
objectNotFound
public int indexOfIdenticalObject(Object object,
NSRange range)
object (testing for equality by directly comparing Object references with ==) and returns the first (lowest) index whose corresponding element is identical to object. If none of the objects in the range match,
then this method returns NotFound. Throws an IllegalArgumentException if range is out of bounds.
object - the search's targetrange - the subset to search
object
IllegalArgumentException - java.lang.IllegalArgumentException if range is out of boundsNotFoundpublic NSArray<E> subarrayWithRange(NSRange range)
range - the subset of elements to be included in the new array
range
IndexOutOfBoundsException - java.lang.IndexOutOfBoundsException when input range is outside the bounds of this arraypublic E lastObject()
null if the array is emptypublic boolean isEqualToArray(NSArray otherArray)
equals instead.
otherArray - the array to be compared against
true if otherArray and this array are equal else falseequals(java.lang.Object)public boolean equals(Object object)
object, returning true if object satisfies instanceof NSArray and its elements are equal to the elements of this array, otherwise it returns false. Two arrays have equal contents if they each
hold the same number of objects and objects at corresponding indices in each array satisfy the equals test.
equals in interface Collection<E>equals in interface List<E>equals in class Objectobject - the object to compare this array against
true if object is an NSArray and its contents are equal to this array or false otherwiseObject.equals(java.lang.Object)public Enumeration<E> objectEnumerator()
<blockquote>
java.util.Enumeration enumerator = myArray.objectEnumerator();
while (enumerator.hasMoreElements()) {
Object anObject = enumerator.nextElement();
//code to act on each element
}
</blockquote>
When this method is used with mutable subclasses of NSArray, your code shouldn't modify the array during enumeration.
reverseObjectEnumerator()public Enumeration<E> reverseObjectEnumerator()
<blockquote>
java.util.Enumeration enumerator = myArray.reverseObjectEnumerator();
while (enumerator.hasMoreElements()) {
Object anObject = enumerator.nextElement();
//code to act on each element
}
</blockquote>
When this method is used with mutable subclasses of NSArray, your code shouldn't modify the array during enumeration.
objectEnumerator()
@Deprecated
public NSArray sortedArrayUsingSelector(NSSelector selector)
throws NSComparator.ComparisonException
sortedArrayUsingComparator instead
selector - an NSSelector for the method to compare the elements during the sort
NSComparator.ComparisonExceptionsortedArrayUsingComparator(com.webobjects.foundation.NSComparator)
public NSArray<E> sortedArrayUsingComparator(NSComparator comparator)
throws NSComparator.ComparisonException
comparator operation.
comparator - It determines the ordering in the new sorted array by comparing two elements at a time and returning one of OrderedAscending, OrderedSame or OrderedDescending
comparator
NSComparator.ComparisonException - if the comparator's compare method throws for any reasonNSComparator#comparepublic String componentsJoinedByString(String separator)
separator String is placed in between each element. This is in all aspects the inverse function of componentsSeparatedByString For
example, this code excerpt writes the path System/Developer to the console:
<blockquote>
NSArray pathArray = new NSArray(new Object [] {{"System ","Developer "});
System.out.println("The path is "+pathArray.componentsJoinedByString("/")+".");
</blockquote>
Each element in the receiver's array must handle either description, or if it is not implemented, toString. If the receiver has no elements, a String representing the empty string is returned.
separator - the string to be inserted inbetween each element. It may be any String object, including null or an empty String
separator between the elements of this arraycomponentsSeparatedByString(java.lang.String, java.lang.String)
public static NSArray<String> componentsSeparatedByString(String string,
String separator)
string argument into a series of substrings according to separator It creates a new NSArray which contains the substrings in the order they appeared in string. If string begins or ends with
separator, then the first or last substring, respectively, is an empty String. If string is null, or an empty String, then this method returns an NSArray with 0 elements. If separator is null, or an empty String,
then it returns an NSArray with 1 element, the string Object. This method is in all aspects the inverse function of componentsJoinedByString A code excerpt:
<blockquote>
String list ="wrenches, hammers, saws";
NSArray listItems = NSArray.componentsSeparatedByString (list, ", ");
</blockquote>
produces an array with these contents:
Index |
Substring |
| 0 | wrenches |
| 1 | hammers |
| 2 | saws |
If list is instead
<blockquote>
String list =", wrenches, hammers, saws";
</blockquote>
then the result is:
Index |
Substring |
| 0 | (empty string) |
| 1 | wrenches |
| 2 | hammers |
| 3 | saws |
If list has no separators, for example, "wrenches" the array contains the string itself, in this case "wrenches".
string - the input string to be parsedseparator - the string that is to separate the substrings
string that have been divided by separatorcomponentsJoinedByString(java.lang.String)public Object valueForKey(String key)
key indicates an operation that doesn't require an argument, valueForKey performs the operation and returns the result. key indicates an operation if its first character is "@". For example, if key is
"@count", valueForKey invokes compute on the "count" operator. This has the effect of computing and returning the number of elements in the receiver. Don't use valueForKey for operations that take arguments; instead use
valueForKeyPath.valueForKey creates a new array with the same number of elements as this array. For each element, the corresponding element in the new array is the result of invoking valueForKeyPath with key as
the key path on the element. For example, if key is "firstName", this method returns an array containing the firstName values for each of the array's elements. The key argument can be a key path of the form relationship.property. For
example, "department.name". valueForKey replaces null values with an instance of NSKeyValueCoding.Null.
valueForKey in interface NSKeyValueCodingkey - the input key
valueForKeyPath on each element of this arrayNSKeyValueCoding#valueForKey,
operatorNames(),
valueForKeyPath(java.lang.String),
NSKeyValueCoding.Null
public void takeValueForKey(Object value,
String key)
takeValueForKeyPath on each element in this array with the arguments value and key For example, if key is "firstName" and value is "Unknown", this method sets the
firstName property of each element to "Unknown".
takeValueForKey in interface NSKeyValueCodingvalue - each element's new value for the keypathkey - the keypath for the property to set on each elementNSKeyValueCoding#takeValueForKeypublic Object valueForKeyPath(String keyPath)
keyPath indicates an operation takes an argument (such as computing an average), valueForKeyPath performs the operation and returns the result. key indicates an aggregate operation if its first character is "@". For example, if
key is "@avg.salary", valueForKey invokes compute on the "avg" operator specifying the array and "salary" as arguments. This has the effect of computing and returning the average salary of the array's elements.valueForKeyPath behaves similarly to valueForKey and produces a new NSArray whose elements correspond to the results of invoking valueForKeyPath on each element of this array.
valueForKeyPath in interface NSKeyValueCodingAdditionskeyPath - the keypath to the elements in the input array
valueForKeyPath on each element of this arrayvalueForKey(java.lang.String),
NSKeyValueCodingAdditions#valueForKeyPath,
operatorNames()
public void takeValueForKeyPath(Object value,
String keyPath)
NSKeyValueCodingAdditionskeyPath
to value. A key path has the form relationship.property
(with one or more relationships); for example "movieRole.roleName"
or "movieRole.talent.lastName". The default implementation of
this method (provided by NSKeyValueCodingAdditions.DefaultImplementation)
gets the destination object for each relationship using valueForKey,
and sends the final object a takeValueForKey message with value
and property.
takeValueForKeyPath in interface NSKeyValueCodingAdditionsvalue - the property identified by keyPath is set to thiskeyPath - identifies the property of an objectNSKeyValueCoding#takeValueForKey,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String),
NSKeyValueCodingAdditions.DefaultImplementationpublic Class classForCoder()
classForCoder in interface NSCodingNSCoding.Support.classForCoder(java.lang.Object),
NSCoding,
NSMutableArraypublic static Object decodeObject(NSCoder coder)
coder. This is the inverse function of encodeWithCoder
coder - the coder from which to retrieve the array's data
NSCodingpublic void encodeWithCoder(NSCoder coder)
NSCodingcoder. Object type information along with an object's data is stored.
encodeWithCoder in interface NSCodingcoder - an NSCoder object that will be used to encode object of classes that implement this interfaceNSCoder
public void makeObjectsPerformSelector(NSSelector selector,
Object[] parameters)
selector on each object in this array. The method is invoked each time with the values in parametersas the method's arguments. The method should not, as a side effect, modify this array or its elements.
selector - the method to invoke. selector must not be nullparameters - the arguments to that methodNSSelector#invoke( Object target, Object[] arguments)public int hashCode()
hashCode in interface Collection<E>hashCode in interface List<E>hashCode in class ObjectObject.hashCode()public Object clone()
clone in class ObjectthisNSMutableArray,
immutableClone(),
mutableClone(),
Object.clone()public NSArray<E> immutableClone()
this. Subclasses such as NSMutableArray should override this method to create an immutable copy of this array.
NSMutableArray,
mutableClone(),
clone()public NSMutableArray<E> mutableClone()
NSMutableArray,
immutableClone(),
clone()public String toString()
toString in class Objectpublic static final <T> NSArray<T> emptyArray()
This example illustrates the type-safe way to obtain an empty list:
List<String> s = NSArray.emptyArray();Implementation note: Implementations of this method need not create a separate NSArray object for each call. Using this method is likely to have comparable cost to using the like-named field. (Unlike this method, the field does not provide type safety.)
EmptyArray
public void add(int index,
E element)
add in interface List<E>UnsupportedOperationExceptionList.add(int, Object)public boolean add(E element)
add in interface Collection<E>add in interface List<E>element - -
object to add
UnsupportedOperationExceptionList.add(Object)public boolean addAll(Collection<? extends E> collection)
addAll in interface Collection<E>addAll in interface List<E>collection - -
collection to add
UnsupportedOperationExceptionList.addAll(Collection)
public boolean addAll(int index,
Collection<? extends E> collection)
addAll in interface List<E>index - -
index of element to addcollection - -
collection to add
UnsupportedOperationExceptionList.addAll(int, Collection)public boolean contains(Object element)
contains in interface Collection<E>contains in interface List<E>NullPointerException - if specified element is nullList.contains(java.lang.Object)public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>List.iterator()public Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>List.toArray()public <T> T[] toArray(T[] objects)
toArray in interface Collection<E>toArray in interface List<E>List.toArray(Object[])public boolean containsAll(Collection c)
containsAll in interface Collection<E>containsAll in interface List<E>List#containsAllpublic ListIterator<E> listIterator()
listIterator in interface List<E>listIterator()public ListIterator<E> listIterator(int index)
listIterator in interface List<E>index - of first element to be returned from the list iterator (by a call to the next method).listIterator(int)public E get(int index)
get in interface List<E>index - -
index of element to lookup
IndexOutOfBoundsException - if (index < 0 || index >= size())List.get(int)
public E set(int index,
E element)
set in interface List<E>IndexOutOfBoundsException - if (index < 0 || index >= size())
UnsupportedOperationExceptionList.set(int, E)public int indexOf(Object element)
indexOf in interface List<E>NullPointerException - if specified element is nullList.indexOf(java.lang.Object)public int lastIndexOf(Object element)
lastIndexOf in interface List<E>NullPointerException - if specified element is nullList.lastIndexOf(java.lang.Object)public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>List.isEmpty()public int size()
size in interface Collection<E>size in interface List<E>List.size()public E remove(int index)
remove in interface List<E>index - of the element to removed.
UnsupportedOperationExceptionremove(int)public boolean remove(Object element)
remove in interface Collection<E>remove in interface List<E>element - to be removed from this list, if present.
UnsupportedOperationExceptionremove(Object)public void clear()
clear in interface Collection<E>clear in interface List<E>UnsupportedOperationExceptionList.clear()public boolean retainAll(Collection<?> collection)
retainAll in interface Collection<E>retainAll in interface List<E>UnsupportedOperationExceptionList.retainAll(java.util.Collection>)public boolean removeAll(Collection<?> collection)
removeAll in interface Collection<E>removeAll in interface List<E>UnsupportedOperationExceptionList.removeAll(java.util.Collection>)
public List<E> subList(int fromIndex,
int toIndex)
subList in interface List<E>IndexOutOfBoundsException - if index values fail the condition (fromIndex < 0 || toIndex > size || fromIndex > toIndex)List.subList(int, int)
|
Last updated Tuesday, October 9, 2007 08:58 PDT | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||