|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.foundation.NSArray
public class NSArray
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
,
NSArray.count()
,
NSArray.objectAtIndex(int)
,
indexOfObject
,
NSArray.arrayByAddingObjectsFromArray(com.webobjects.foundation.NSArray)
,
NSArray.componentsJoinedByString(java.lang.String)
,
NSArray.objectEnumerator()
,
Serialized FormNested 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 |
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 |
Constructor Summary | |
---|---|
|
NSArray()
Creates an empty, immutable array. |
|
NSArray(Collection collection)
Creates a NSArray from objects that implement the java.util.Collection interface. |
|
NSArray(Collection collection,
boolean checkForNull)
Creates a NSArray from objects that implement the java.util.Collection interface. |
|
NSArray(Object object)
Creates an array containing the single element object . |
|
NSArray(Object[] objects)
Creates an array containing the elements from objects . |
|
NSArray(Object[] objects,
NSRange range)
Creates an array containing the objects from objects in the range specified by range . |
|
NSArray(List list,
NSRange range,
boolean ignoreNull)
Creates an array containing the objects from list in the range specified by range . |
|
NSArray(NSArray otherArray)
One should use immutableClone instead. |
protected |
NSArray(Object[] objects,
int rangeLocation,
int rangeLength,
boolean checkForNull,
boolean ignoreNull)
|
Method Summary | |
---|---|
boolean |
add(Object element)
add is not a supported operation in NSArray |
void |
add(int index,
Object element)
add is not a supported operation in NSArray |
boolean |
addAll(Collection collection)
addAll is not a supported operation in NSArray |
boolean |
addAll(int index,
Collection collection)
addAll is not a supported operation in NSArray |
NSArray |
arrayByAddingObject(Object object)
Returns a new NSArray which contains the values from this array, and appends the object argument. |
NSArray |
arrayByAddingObjectsFromArray(NSArray otherArray)
Returns a new NSArray which contains the values from this array, and appends values from the otherArray argument. |
ArrayList |
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 |
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 NSArray |
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 . |
Object |
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 |
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 |
iterator()
|
int |
lastIndexOf(Object element)
|
Object |
lastObject()
|
ListIterator |
listIterator()
|
ListIterator |
listIterator(int index)
|
void |
makeObjectsPerformSelector(NSSelector selector,
Object[] parameters)
Invokes the method specified by selector on each object in this array. |
NSMutableArray |
mutableClone()
NSArray's implementation creates a new NSMutableArray with this array's elements, not copies. |
Object |
objectAtIndex(int index)
Returns the Object reference stored at index within this NSArray. |
Enumeration |
objectEnumerator()
This method creates a java.util.Enumeration which can used to iterate through the array's elements. |
Object[] |
objects()
|
Object[] |
objects(NSRange range)
Copies a subset of this array into a Java array. |
protected Object[] |
objectsNoCopy()
This method should only be used by subclasses. |
static NSArray.Operator |
operatorForKey(String operatorName)
|
static NSArray |
operatorNames()
Returns the names of the operations that can be performed on array elements. |
Object |
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 |
reverseObjectEnumerator()
This method creates a java.util.Enumeration which can used to iterate through the array's elements in reverse. |
Object |
set(int index,
Object element)
|
static void |
setOperatorForKey(String operatorName,
NSArray.Operator arrayOperator)
Registers an operator with a String. |
int |
size()
|
NSArray |
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 |
subarrayWithRange(NSRange range)
This method creates a new array from a subset of this array. |
List |
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()
|
Object[] |
toArray(Object[] objects)
|
String |
toString()
|
Object |
valueForKey(String key)
Conformance to the NSKeyValueCoding interface. |
Object |
valueForKeyPath(String keyPath)
Conformance to the NSKeyValueCodingAdditions interface. |
Vector |
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()
NSArray.EmptyArray
public NSArray(Object 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, boolean ignoreNull)
public NSArray(Object[] 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 NSArraypublic NSArray(Object[] 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 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 duplicatedNSArray.immutableClone()
public NSArray(Collection 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
.List
public NSArray(Collection 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 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 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 null
public static NSArray.Operator operatorForKey(String operatorName)
operatorName
- the human-readable name for the operator instance
operatorName
if one exists, null otherwiseNSArray
public 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 Object[] objectsNoCopy()
public int count()
public Object 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
NSArray._count
public NSArray arrayByAddingObject(Object 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#addObject
public NSArray arrayByAddingObjectsFromArray(NSArray otherArray)
otherArray
argument.
otherArray
- the array to be appended
otherArray
appended.NSMutableArray#addObjectsFromArray
public Object[] objects()
public Object[] objects(NSRange range)
range
- the range specifying a subset to copy
public Vector vector()
public ArrayList 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 false
public 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.NSArray.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 objects
NSArray.objects(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
anObject
NSArray.NotFound
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
object
NSArray.NotFound
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 boundsNSArray.NotFound
public NSArray 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 Object 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 false
NSArray.equals(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
equals
in interface List
equals
in class Object
object
- 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 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.
NSArray.reverseObjectEnumerator()
public Enumeration 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.
NSArray.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.ComparisonException
NSArray.sortedArrayUsingComparator(com.webobjects.foundation.NSComparator)
public NSArray 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.compare(java.lang.Object, java.lang.Object)
public 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 in between each element. It may be any String object, including null
or an empty String
separator
between the elements of this arrayNSArray.componentsSeparatedByString(java.lang.String, java.lang.String)
public static NSArray 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 separator
NSArray.componentsJoinedByString(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 NSKeyValueCoding
key
- the input key
valueForKeyPath
on each element of this arrayNSKeyValueCoding.valueForKey(java.lang.String)
,
NSArray.operatorNames()
,
NSArray.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 NSKeyValueCoding
value
- each element's new value for the keypathkey
- the keypath for the property to set on each elementNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
public 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 NSKeyValueCodingAdditions
keyPath
- the keypath to the elements in the input array
valueForKeyPath
on each element of this arrayNSArray.valueForKey(java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSArray.operatorNames()
public void takeValueForKeyPath(Object value, String keyPath)
NSKeyValueCodingAdditions
keyPath
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 NSKeyValueCodingAdditions
value
- the property identified by keyPath
is set to thiskeyPath
- identifies the property of an objectNSKeyValueCoding.takeValueForKey(java.lang.Object, java.lang.String)
,
NSKeyValueCodingAdditions.valueForKeyPath(java.lang.String)
,
NSKeyValueCodingAdditions.DefaultImplementation
public Class classForCoder()
classForCoder
in interface NSCoding
NSCoding.Support.classForCoder(java.lang.Object)
,
NSCoding
,
NSMutableArray
public static Object decodeObject(NSCoder coder)
coder
. This is the inverse function of encodeWithCoder
coder
- the coder from which to retrieve the array's data
NSCoding
public void encodeWithCoder(NSCoder coder)
NSCoding
coder
. Object type information along with an object's data is stored.
encodeWithCoder
in interface NSCoding
coder
- 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 parameters
as 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 null
parameters
- the arguments to that methodNSSelector.invoke( Object target, Object[] arguments)
public int hashCode()
hashCode
in interface Collection
hashCode
in interface List
hashCode
in class Object
Object.hashCode()
public Object clone()
clone
in class Object
this
NSMutableArray
,
NSArray.immutableClone()
,
NSArray.mutableClone()
,
Object.clone()
public NSArray immutableClone()
this
. Subclasses such as NSMutableArray should override this method to create an immutable copy of this
array.
NSMutableArray
,
NSArray.mutableClone()
,
NSArray.clone()
public NSMutableArray mutableClone()
NSMutableArray
,
NSArray.immutableClone()
,
NSArray.clone()
public String toString()
toString
in class Object
public static final NSArray 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.)
NSArray.EmptyArray
public void add(int index, Object element)
add
in interface List
UnsupportedOperationException
List.add(int, Object)
public boolean add(Object element)
add
in interface Collection
add
in interface List
element
- -
object to add
UnsupportedOperationException
List.add(Object)
public boolean addAll(Collection collection)
addAll
in interface Collection
addAll
in interface List
collection
- -
collection to add
UnsupportedOperationException
List.addAll(Collection)
public boolean addAll(int index, Collection collection)
addAll
in interface List
index
- -
index of element to addcollection
- -
collection to add
UnsupportedOperationException
List.addAll(int, Collection)
public boolean contains(Object element)
contains
in interface Collection
contains
in interface List
NullPointerException
- if specified element is nullList.contains(java.lang.Object)
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
List.iterator()
public Object[] toArray()
toArray
in interface Collection
toArray
in interface List
List.toArray()
public Object[] toArray(Object[] objects)
toArray
in interface Collection
toArray
in interface List
List.toArray(Object[])
public boolean containsAll(Collection c)
containsAll
in interface Collection
containsAll
in interface List
List#containsAll
public ListIterator listIterator()
listIterator
in interface List
listIterator()
public ListIterator listIterator(int index)
listIterator
in interface List
index
- of first element to be returned from the list iterator (by a call to the next method).listIterator(int)
public Object get(int index)
get
in interface List
index
- -
index of element to lookup
IndexOutOfBoundsException
- if (index < 0 || index >= size())List.get(int)
public Object set(int index, Object element)
set
in interface List
IndexOutOfBoundsException
- if (index < 0 || index >= size())
UnsupportedOperationException
List.set(int, E)
public int indexOf(Object element)
indexOf
in interface List
NullPointerException
- if specified element is nullList.indexOf(java.lang.Object)
public int lastIndexOf(Object element)
lastIndexOf
in interface List
NullPointerException
- if specified element is nullList.lastIndexOf(java.lang.Object)
public boolean isEmpty()
isEmpty
in interface Collection
isEmpty
in interface List
List.isEmpty()
public int size()
size
in interface Collection
size
in interface List
List.size()
public Object remove(int index)
remove
in interface List
index
- of the element to removed.
UnsupportedOperationException
remove(int)
public boolean remove(Object element)
remove
in interface Collection
remove
in interface List
element
- to be removed from this list, if present.
UnsupportedOperationException
remove(Object)
public void clear()
clear
in interface Collection
clear
in interface List
UnsupportedOperationException
List.clear()
public boolean retainAll(Collection collection)
retainAll
in interface Collection
retainAll
in interface List
UnsupportedOperationException
List.retainAll(java.util.Collection)
public boolean removeAll(Collection collection)
removeAll
in interface Collection
removeAll
in interface List
UnsupportedOperationException
List.removeAll(java.util.Collection)
public List subList(int fromIndex, int toIndex)
subList
in interface List
IndexOutOfBoundsException
- if index values fail the condition (fromIndex < 0 || toIndex > size || fromIndex > toIndex)List.subList(int, int)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |