Package com.dd.plist

Class NSArray

    • Constructor Summary

      Constructors 
      Constructor Description
      NSArray​(int length)
      Creates a new NSArray instance of the specified size.
      NSArray​(NSObject... a)
      Creates a new NSArray instance containing the specified elements.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void assignIDs​(BinaryPropertyListWriter out)
      Assigns IDs to all the objects in this NSObject subtree.
      NSArray clone()
      Creates and returns a deep copy of this instance.
      int compareTo​(NSObject o)  
      boolean containsObject​(java.lang.Object obj)
      Checks whether an object is present in the array or whether it is equal to any of the objects in the array.
      int count()
      Returns the size of the array.
      boolean equals​(java.lang.Object obj)  
      NSObject[] getArray()
      Returns the array of NSObjects represented by this NSArray.
      int hashCode()  
      int indexOfIdenticalObject​(java.lang.Object obj)
      Searches for a specific object in the array.
      int indexOfObject​(java.lang.Object obj)
      Searches for an object in the array.
      NSObject lastObject()
      Returns the last object contained in this array.
      NSObject 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.
      void remove​(int i)
      Removes the i-th element from the array.
      void setValue​(int key, java.lang.Object value)
      Stores an object at the specified index.
      protected void toASCII​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object.
      private void toASCII​(java.lang.StringBuilder ascii, int level, boolean gnustep)  
      protected void toASCIIGnuStep​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object in the GnuStep format.
      java.lang.String toASCIIPropertyList()
      Generates a valid ASCII property list which has this NSArray as its root object.
      (package private) void toBinary​(BinaryPropertyListWriter out)
      Generates the binary representation of the object.
      java.lang.String toGnuStepASCIIPropertyList()
      Generates a valid ASCII property list in GnuStep format which has this NSArray as its root object.
      java.lang.Object toJavaObject()
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      (package private) void toXML​(java.lang.StringBuilder xml, int level)
      Generates the XML representation of the object (without XML headers or enclosing plist-tags).
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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

        public NSArray​(NSObject... a)
        Creates a new NSArray instance containing the specified elements.
        Parameters:
        a - The elements to be contained by the NSArray instance.
    • Method Detail

      • objectAtIndex

        public NSObject objectAtIndex​(int i)
        Returns the object stored at the given index. Equivalent to getArray()[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

        public void setValue​(int key,
                             java.lang.Object value)
        Stores an object at the specified index. If there was another object stored at that index it will be replaced. Equivalent to getArray()[key] = value.
        Parameters:
        key - The index where to store the object.
        value - The object.
      • getArray

        public NSObject[] 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

        public boolean containsObject​(java.lang.Object obj)
        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. false otherwise.
        See Also:
        Object.equals(java.lang.Object)
      • indexOfObject

        public int indexOfObject​(java.lang.Object obj)
        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:
        Object.equals(java.lang.Object), indexOfIdenticalObject(Object)
      • indexOfIdenticalObject

        public int indexOfIdenticalObject​(java.lang.Object obj)
        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:
        indexOfObject(Object)
      • lastObject

        public NSObject lastObject()
        Returns the last object contained in this array. Equivalent to getArray()[getArray().length-1].
        Returns:
        The value of the highest index in the array.
      • objectsAtIndexes

        public NSObject[] objectsAtIndexes​(int... indexes)
        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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • clone

        public NSArray clone()
        Description copied from class: NSObject
        Creates and returns a deep copy of this instance.
        Specified by:
        clone in class NSObject
        Returns:
        A clone of this instance.
      • toJavaObject

        public java.lang.Object toJavaObject()
        Description copied from class: NSObject
        Converts this NSObject into an equivalent object of the Java Runtime Environment.
        • NSArray objects are converted to arrays.
        • NSDictionary objects are converted to objects extending the Map class.
        • NSSet objects are converted to objects extending the Set class.
        • NSNumber objects are converted to primitive number values (int, long, double or boolean).
        • NSString objects are converted to String objects.
        • NSData objects are converted to byte arrays.
        • NSDate objects are converted to Date objects.
        • UID objects are converted to byte arrays.
        Specified by:
        toJavaObject in class NSObject
        Returns:
        A native java object representing this NSObject's value.
      • compareTo

        public int compareTo​(NSObject o)
      • toXML

        void toXML​(java.lang.StringBuilder xml,
                   int level)
        Description copied from class: NSObject
        Generates the XML representation of the object (without XML headers or enclosing plist-tags).
        Specified by:
        toXML in class NSObject
        Parameters:
        xml - The StringBuilder onto which the XML representation is appended.
        level - The indentation level of the object.
      • assignIDs

        void assignIDs​(BinaryPropertyListWriter out)
        Description copied from class: NSObject
        Assigns IDs to all the objects in this NSObject subtree.
        Overrides:
        assignIDs in class NSObject
        Parameters:
        out - The writer object that handles the binary serialization.
      • toBinary

        void toBinary​(BinaryPropertyListWriter out)
               throws java.io.IOException
        Description copied from class: NSObject
        Generates the binary representation of the object.
        Specified by:
        toBinary in class NSObject
        Parameters:
        out - The output stream to serialize the object to.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
      • toASCIIPropertyList

        public java.lang.String 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

        public java.lang.String 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

        protected void toASCII​(java.lang.StringBuilder ascii,
                               int level)
        Description copied from class: NSObject
        Generates the ASCII representation of this object. The generated ASCII representation does not end with a newline. Complies with the Old-Style ASCII Property Lists definition.
        Specified by:
        toASCII in class NSObject
        Parameters:
        ascii - The StringBuilder onto which the ASCII representation is appended.
        level - The indentation level of the object.
      • toASCIIGnuStep

        protected void toASCIIGnuStep​(java.lang.StringBuilder ascii,
                                      int level)
        Description copied from class: NSObject
        Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.
        Specified by:
        toASCIIGnuStep in class NSObject
        Parameters:
        ascii - The StringBuilder onto which the ASCII representation is appended.
        level - The indentation level of the object.
      • toASCII

        private void toASCII​(java.lang.StringBuilder ascii,
                             int level,
                             boolean gnustep)