Class NSObject
java.lang.Object
com.dd.plist.NSObject
- All Implemented Interfaces:
Cloneable,Comparable<NSObject>
- Direct Known Subclasses:
NSArray,NSData,NSDate,NSDictionary,NSNull,NSNumber,NSSet,NSString,UID
Abstract interface for an object contained in a property list.
The names and functions of the various objects orient themselves towards Apple's Cocoa API.
- Author:
- Daniel Dreibrodt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract NSObjectclone()Creates and returns a deep copy of this instance.static NSObjectfromJavaObject(Object object) Serializes the specified object into an NSObject.Gets information about the location of this NSObject within the parsed property list, if available.protected voidindent(StringBuilder xml, int level) Helper method that adds correct indentation to the xml output.abstract ObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.<T> TtoJavaObject(Class<T> clazz) Converts this NSObject into an object of the specified class.Generates a valid XML property list including headers using this object as root.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
NSObject
public NSObject()
-
-
Method Details
-
getLocationInformation
Gets information about the location of this NSObject within the parsed property list, if available.- Returns:
- The location information, or
nullif it is not available.
-
clone
-
toJavaObject
Converts 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.
- Returns:
- A native java object representing this NSObject's value.
-
toXMLPropertyList
Generates a valid XML property list including headers using this object as root.- Returns:
- The XML representation of the property list including XML header and doctype information.
-
indent
Helper method that adds correct indentation to the xml output. Calling this method will addlevelnumber of tab characters to thexmlstring.- Parameters:
xml- TheStringBuilderonto which the XML representation is appended.level- The level of indentation.
-
toJavaObject
Converts this NSObject into an object of the specified class.- Type Parameters:
T- The target object type.- Parameters:
clazz- The target class.- Returns:
- A new instance of the specified class, deserialized from this NSObject.
- Throws:
IllegalArgumentException- If the specified class cannot be deserialized from this NSObject.
-
fromJavaObject
Serializes the specified object into an NSObject. Objects which do not have a direct type correspondence to an NSObject type will be serialized as aNSDictionary. The dictionary will contain the values of all publicly accessible fields and properties.- Parameters:
object- The object to serialize.- Returns:
- A NSObject instance.
- Throws:
IllegalArgumentException- If the specified object throws an exception while getting its properties.
-