Package com.dd.plist
Class NSSet
java.lang.Object
com.dd.plist.NSObject
com.dd.plist.NSSet
- All Implemented Interfaces:
Cloneable,Comparable<NSObject>
The NSSet class is an unordered collection of NSObject instances.
This implementation uses a
LinkedHashSet or TreeSetas the underlying
data structure.- See Also:
-
Field Summary
FieldsFields inherited from class com.dd.plist.NSObject
ASCII_LINE_LENGTH, NEWLINE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an object to the set.NSObject[]Returns all objects contained in the set.Returns one of the objects in the set, ornullif the set contains no objects.(package private) voidAssigns IDs to all the objects in this NSObject subtree.clone()Creates and returns a deep copy of this instance.intbooleancontainsObject(NSObject obj) Finds out whether the given object is contained in the set.intcount()Gets the number of elements in the set.booleaninthashCode()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.Determines whether the set contains an object equal to the given object and returns that object if it is present.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(StringBuilder ascii, int level) Returns the ASCII representation of this set.protected voidtoASCIIGnuStep(StringBuilder ascii, int level) Returns the ASCII representation of this set according to the GnuStep format.(package private) voidGenerates the binary representation of the object.Converts this NSObject into an equivalent object of the Java Runtime Environment.(package private) voidtoXML(StringBuilder xml, int level) Returns the XML representation for this set.Methods inherited from class com.dd.plist.NSObject
fromJavaObject, indent, toJavaObject, toXMLPropertyList
-
Field Details
-
set
-
ordered
private boolean ordered
-
-
Constructor Details
-
NSSet
public NSSet()Creates a new NSSet instance. The created set is unordered.- See Also:
-
NSSet
public NSSet(boolean ordered) Creates a new NSSet instance.- Parameters:
ordered- Indicates whether the created set should be ordered or unordered.- See Also:
-
NSSet
Creates a new NSSet instance with the specified content. The created set is unordered.- Parameters:
objects- The objects to populate the set.- See Also:
-
NSSet
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:
-
-
Method Details
-
addObject
Adds an object to the set.- Parameters:
obj- The object to add.
-
removeObject
Removes an object from the set.- Parameters:
obj- The object to remove.
-
allObjects
Returns all objects contained in the set.- Returns:
- An array of all objects in the set.
-
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
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
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
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
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
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() -
equals
-
compareTo
-
count
public int count()Gets the number of elements in the set.- Returns:
- The number of elements in the set.
- See Also:
-
clone
Description copied from class:NSObjectCreates and returns a deep copy of this instance. -
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
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
Description copied from class:NSObjectAssigns IDs to all the objects in this NSObject subtree. -
toBinary
Description copied from class:NSObjectGenerates the binary representation of the object.- Specified by:
toBinaryin classNSObject- Parameters:
out- The output stream to serialize the object to.- Throws:
IOException- If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
-
toASCII
Returns the ASCII representation of this set. There is no official ASCII representation for sets. In this implementation sets are represented as arrays. -
toASCIIGnuStep
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
-