Package com.dd.plist
Class NSSet
- java.lang.Object
-
- com.dd.plist.NSObject
-
- com.dd.plist.NSSet
-
-
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 voidaddObject(NSObject obj)Adds an object to the set.NSObject[]allObjects()Returns all objects contained in the set.NSObjectanyObject()Returns one of the objects in the set, ornullif the set contains no objects.(package private) voidassignIDs(BinaryPropertyListWriter out)Assigns IDs to all the objects in this NSObject subtree.NSSetclone()Creates and returns a deep copy of this instance.intcompareTo(NSObject o)booleancontainsObject(NSObject obj)Finds out whether the given object is contained in the set.intcount()Gets the number of elements in the set.booleanequals(java.lang.Object obj)inthashCode()booleanintersectsSet(NSSet otherSet)Finds out whether at least one object is present in both sets.booleanisSubsetOfSet(NSSet otherSet)Finds out if this set is a subset of the given set.NSObjectmember(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.voidremoveObject(NSObject obj)Removes an object from the set.protected voidtoASCII(java.lang.StringBuilder ascii, int level)Returns the ASCII representation of this set.protected voidtoASCIIGnuStep(java.lang.StringBuilder ascii, int level)Returns the ASCII representation of this set according to the GnuStep format.(package private) voidtoBinary(BinaryPropertyListWriter out)Generates the binary representation of the object.java.lang.ObjecttoJavaObject()Converts this NSObject into an equivalent object of the Java Runtime Environment.(package private) voidtoXML(java.lang.StringBuilder xml, int level)Returns the XML representation for this set.-
Methods inherited from class com.dd.plist.NSObject
fromJavaObject, indent, toJavaObject, toXMLPropertyList
-
-
-
-
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, ornullif the set contains no objects.- Returns:
- The first object in the set, or
nullif 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,falseotherwise.
-
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,
nullotherwise.
-
intersectsSet
public boolean intersectsSet(NSSet otherSet)
Finds out whether at least one object is present in both sets.- Parameters:
otherSet- The other set.- Returns:
falseif the intersection of both sets is empty,trueotherwise.
-
isSubsetOfSet
public boolean isSubsetOfSet(NSSet otherSet)
Finds out if this set is a subset of the given set.- Parameters:
otherSet- The other set.- Returns:
trueif all elements in this set are also present in the other set,falseotherwise.
-
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 toobjectEnumeratorin the Cocoa implementation of NSSet.- Returns:
- The iterator for the set.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.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:NSObjectCreates and returns a deep copy of this instance.
-
toJavaObject
public java.lang.Object 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.
-
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.
-
assignIDs
void assignIDs(BinaryPropertyListWriter out)
Description copied from class:NSObjectAssigns IDs to all the objects in this NSObject subtree.
-
toBinary
void toBinary(BinaryPropertyListWriter out) throws java.io.IOException
Description copied from class:NSObjectGenerates the binary representation of the object.
-
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.
-
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:
toASCIIGnuStepin classNSObject- Parameters:
ascii- The ASCII file string builderlevel- The indentation level
-
-