Package com.dd.plist

Class NSSet

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<NSObject>

    public class NSSet
    extends NSObject
    The NSSet class is an unordered collection of NSObject instances. This implementation uses a LinkedHashSet or TreeSetas the underlying data structure.
    See Also:
    LinkedHashSet
    • Constructor Summary

      Constructors 
      Constructor Description
      NSSet()
      Creates a new NSSet instance.
      NSSet​(boolean ordered)
      Creates a new NSSet instance.
      NSSet​(boolean ordered, NSObject... objects)
      Create a new NSSet instance with the specified content.
      NSSet​(NSObject... objects)
      Creates a new NSSet instance with the specified content.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addObject​(NSObject obj)
      Adds an object to the set.
      NSObject[] allObjects()
      Returns all objects contained in the set.
      NSObject anyObject()
      Returns one of the objects in the set, or null if the set contains no objects.
      (package private) void assignIDs​(BinaryPropertyListWriter out)
      Assigns IDs to all the objects in this NSObject subtree.
      NSSet clone()
      Creates and returns a deep copy of this instance.
      int compareTo​(NSObject o)  
      boolean containsObject​(NSObject obj)
      Finds out whether the given object is contained in the set.
      int count()
      Gets the number of elements in the set.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      boolean intersectsSet​(NSSet otherSet)
      Finds out whether at least one object is present in both sets.
      boolean isSubsetOfSet​(NSSet otherSet)
      Finds out if this set is a subset of the given set.
      NSObject member​(NSObject obj)
      Determines whether the set contains an object equal to the given object and returns that object if it is present.
      java.util.Iterator<NSObject> objectIterator()
      Returns an iterator object that lets you iterate over all elements of the set.
      void removeObject​(NSObject obj)
      Removes an object from the set.
      protected void toASCII​(java.lang.StringBuilder ascii, int level)
      Returns the ASCII representation of this set.
      protected void toASCIIGnuStep​(java.lang.StringBuilder ascii, int level)
      Returns the ASCII representation of this set according to the GnuStep format.
      (package private) void toBinary​(BinaryPropertyListWriter out)
      Generates the binary representation of the 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)
      Returns the XML representation for this set.
      • Methods inherited from class java.lang.Object

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

      • set

        private final java.util.Set<NSObject> set
      • ordered

        private boolean ordered
    • Constructor Detail

      • NSSet

        public NSSet()
        Creates a new NSSet instance. The created set is unordered.
        See Also:
        LinkedHashSet
      • NSSet

        public NSSet​(boolean ordered)
        Creates a new NSSet instance.
        Parameters:
        ordered - Indicates whether the created set should be ordered or unordered.
        See Also:
        LinkedHashSet, TreeSet
      • NSSet

        public NSSet​(NSObject... objects)
        Creates a new NSSet instance with the specified content. The created set is unordered.
        Parameters:
        objects - The objects to populate the set.
        See Also:
        LinkedHashSet
      • NSSet

        public NSSet​(boolean ordered,
                     NSObject... objects)
        Create a new NSSet instance with the specified content.
        Parameters:
        ordered - Indicates whether the created set should be ordered or unordered.
        objects - The objects to populate the set.
        See Also:
        LinkedHashSet, TreeSet
    • Method Detail

      • addObject

        public void addObject​(NSObject obj)
        Adds an object to the set.
        Parameters:
        obj - The object to add.
      • removeObject

        public void removeObject​(NSObject obj)
        Removes an object from the set.
        Parameters:
        obj - The object to remove.
      • allObjects

        public NSObject[] allObjects()
        Returns all objects contained in the set.
        Returns:
        An array of all objects in the set.
      • anyObject

        public NSObject anyObject()
        Returns one of the objects in the set, or null if the set contains no objects.
        Returns:
        The first object in the set, or null if the set is empty.
      • containsObject

        public boolean containsObject​(NSObject obj)
        Finds out whether the given object is contained in the set.
        Parameters:
        obj - The object to look for.
        Returns:
        true, when the object was found, false otherwise.
      • member

        public NSObject member​(NSObject obj)
        Determines whether the set contains an object equal to the given object and returns that object if it is present.
        Parameters:
        obj - The object to look for.
        Returns:
        The object if it is present, null otherwise.
      • intersectsSet

        public boolean intersectsSet​(NSSet otherSet)
        Finds out whether at least one object is present in both sets.
        Parameters:
        otherSet - The other set.
        Returns:
        false if the intersection of both sets is empty, true otherwise.
      • isSubsetOfSet

        public boolean isSubsetOfSet​(NSSet otherSet)
        Finds out if this set is a subset of the given set.
        Parameters:
        otherSet - The other set.
        Returns:
        true if all elements in this set are also present in the other set, false otherwise.
      • objectIterator

        public java.util.Iterator<NSObject> objectIterator()
        Returns an iterator object that lets you iterate over all elements of the set. This is the equivalent to objectEnumerator in the Cocoa implementation of NSSet.
        Returns:
        The iterator for the set.
      • hashCode

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

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

        public int compareTo​(NSObject o)
      • count

        public int count()
        Gets the number of elements in the set.
        Returns:
        The number of elements in the set.
        See Also:
        Set.size()
      • clone

        public NSSet 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.
      • toXML

        void toXML​(java.lang.StringBuilder xml,
                   int level)
        Returns the XML representation for this set. There is no official XML representation specified for sets. In this implementation it is represented by an array.
        Specified by:
        toXML in class NSObject
        Parameters:
        xml - The XML StringBuilder
        level - The indentation level
      • 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.
      • toASCII

        protected void toASCII​(java.lang.StringBuilder ascii,
                               int level)
        Returns the ASCII representation of this set. There is no official ASCII representation for sets. In this implementation sets are represented as arrays.
        Specified by:
        toASCII in class NSObject
        Parameters:
        ascii - The ASCII file string builder
        level - The indentation level
      • toASCIIGnuStep

        protected void toASCIIGnuStep​(java.lang.StringBuilder ascii,
                                      int level)
        Returns the ASCII representation of this set according to the GnuStep format. There is no official ASCII representation for sets. In this implementation sets are represented as arrays.
        Specified by:
        toASCIIGnuStep in class NSObject
        Parameters:
        ascii - The ASCII file string builder
        level - The indentation level