Class NSArray
java.lang.Object
com.dd.plist.NSObject
com.dd.plist.NSArray
- All Implemented Interfaces:
Cloneable,Comparable<NSObject>
The NSArray class is a wrapper for an array of NSObject instances.
- Author:
- Daniel Dreibrodt
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a deep copy of this instance.intbooleancontainsObject(Object obj) Checks whether an object is present in the array or whether it is equal to any of the objects in the array.intcount()Returns the size of the array.booleanNSObject[]getArray()Returns the array of NSObjects represented by this NSArray.inthashCode()intSearches for a specific object in the array.intindexOfObject(Object obj) Searches for an object in the array.Returns the last object contained in this array.objectAtIndex(int i) Returns the object stored at the given index.NSObject[]objectsAtIndexes(int... indexes) Returns a new array containing only the values stored at the given indices.voidremove(int i) Removes the i-th element from the array.voidStores an object at the specified index.protected voidtoASCII(StringBuilder ascii, int level) protected voidtoASCIIGnuStep(StringBuilder ascii, int level) Generates a valid ASCII property list which has this NSArray as its root object.Generates a valid ASCII property list in GnuStep format which has this NSArray as its root object.Converts this NSObject into an equivalent object of the Java Runtime Environment.Methods inherited from class com.dd.plist.NSObject
fromJavaObject, getLocationInformation, indent, toJavaObject, toXMLPropertyList
-
Constructor Details
-
NSArray
public NSArray(int length) Creates a new NSArray instance of the specified size.- Parameters:
length- The number of elements the NSArray instance will be able to hold.
-
NSArray
Creates a new NSArray instance containing the specified elements.- Parameters:
a- The elements to be contained by the NSArray instance.
-
-
Method Details
-
objectAtIndex
Returns the object stored at the given index. Equivalent togetArray()[i].- Parameters:
i- The index of the object.- Returns:
- The object at the given index.
-
remove
public void remove(int i) Removes the i-th element from the array. The array will be resized.- Parameters:
i- The index of the object
-
setValue
Stores an object at the specified index. If there was another object stored at that index it will be replaced. Equivalent togetArray()[key] = value.- Parameters:
key- The index where to store the object.value- The object.
-
getArray
Returns the array of NSObjects represented by this NSArray. Any changes to the values of this array will also affect the NSArray.- Returns:
- The actual array represented by this NSArray.
-
count
public int count()Returns the size of the array.- Returns:
- The number of elements that this array can store.
-
containsObject
Checks whether an object is present in the array or whether it is equal to any of the objects in the array.- Parameters:
obj- The object to look for.- Returns:
true, when the object could be found.falseotherwise.- See Also:
-
indexOfObject
Searches for an object in the array. If the specified object or an object equal to it is found, its index is returned. Otherwise, -1 is returned.- Parameters:
obj- The object to look for.- Returns:
- The index of the object, if it was found. -1 otherwise.
- See Also:
-
indexOfIdenticalObject
Searches for a specific object in the array. If the specified object is found (reference equality), its index is returned. Otherwise, -1 is returned.- Parameters:
obj- The object to look for.- Returns:
- The index of the object, if it was found. -1 otherwise.
- See Also:
-
lastObject
Returns the last object contained in this array. Equivalent togetArray()[getArray().length-1].- Returns:
- The value of the highest index in the array.
-
objectsAtIndexes
Returns a new array containing only the values stored at the given indices. The values are sorted by their index.- Parameters:
indexes- The indices of the objects.- Returns:
- The new array containing the objects stored at the given indices.
-
equals
-
hashCode
-
clone
-
toJavaObject
Description copied from class:NSObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.NSArrayobjects are converted to arrays.NSDictionaryobjects are converted to objects extending theMapclass.NSSetobjects are converted to objects extending theSetclass.NSNumberobjects are converted to primitive number values (int, long, double or boolean).NSStringobjects are converted toStringobjects.NSDataobjects are converted to byte arrays.NSDateobjects are converted toDateobjects.UIDobjects are converted to byte arrays.
- Specified by:
toJavaObjectin classNSObject- Returns:
- A native java object representing this NSObject's value.
-
compareTo
-
toASCIIPropertyList
Generates a valid ASCII property list which has this NSArray as its root object. The generated property list complies with the format as described in Property List Programming Guide - Old-Style ASCII Property Lists.- Returns:
- ASCII representation of this object.
-
toGnuStepASCIIPropertyList
Generates a valid ASCII property list in GnuStep format which has this NSArray as its root object. The generated property list complies with the format as described in GnuStep - NSPropertyListSerialization class documentation- Returns:
- GnuStep ASCII representation of this object.
-
toASCII
-
toASCIIGnuStep
-