Package com.dd.plist
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.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final intThe maximum length of the text lines to be used when generating ASCII property lists.private static final StringThe indentation character used for generating the XML output.(package private) static final StringThe newline character used for generating the XML output. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidAssigns IDs to all the objects in this NSObject subtree.abstract NSObjectclone()Creates and returns a deep copy of this instance.private ObjectdeserializeArray(NSObject payload, Class<?> clazz) private ObjectdeserializeCollection(NSObject payload, Class<?> clazz, Type[] types) private static ObjectdeserializeData(NSData payload, Class<?> elementClass) private static DatedeserializeDate(NSDate date, Class<?> clazz) private Objectprivate static ObjectdeserializeNumber(NSNumber number, Class<?> clazz) private ObjectdeserializeObject(NSDictionary payload, Class<?> clazz, Type[] types) private static ObjectdeserializeSimple(NSObject payload, Class<?> clazz) private static NSObjectprivate static NSArrayfromCollection(Collection<?> collection) private static NSDatastatic NSObjectfromJavaObject(Object object) Serializes the specified object into an NSObject.private static NSDictionaryprivate static NSDictionaryprivate static NSSetprivate static NSObjectfromSimple(Object object, Class<?> objClass) private static Class<?> getClassForName(String className) private static ObjectgetInstance(Class<?> clazz) protected voidindent(StringBuilder xml, int level) Helper method that adds correct indentation to the xml output.private static booleanprivate static StringmakeFirstCharLowercase(String input) (package private) abstract voidtoASCII(StringBuilder ascii, int level) Generates the ASCII representation of this object.(package private) abstract voidtoASCIIGnuStep(StringBuilder ascii, int level) Generates the ASCII representation of this object in the GnuStep format.(package private) abstract voidGenerates the binary representation of the object.abstract ObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.private ObjecttoJavaObject(NSObject payload, Class<?> clazz, Type[] types) <T> TtoJavaObject(Class<T> clazz) Converts this NSObject into an object of the specified class.(package private) abstract voidtoXML(StringBuilder xml, int level) Generates the XML representation of the object (without XML headers or enclosing plist-tags).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
-
Field Details
-
NEWLINE
The newline character used for generating the XML output. This constant will be different depending on the operating system on which you use this library. -
ASCII_LINE_LENGTH
static final int ASCII_LINE_LENGTHThe maximum length of the text lines to be used when generating ASCII property lists. But this number is only a guideline it is not guaranteed that it will not be overstepped.- See Also:
-
INDENT
The indentation character used for generating the XML output. This is the tabulator character.- See Also:
-
-
Constructor Details
-
NSObject
public NSObject()
-
-
Method Details
-
clone
Creates and returns a deep copy of this instance. -
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.
-
toXML
Generates the XML representation of the object (without XML headers or enclosing plist-tags).- Parameters:
xml- TheStringBuilderonto which the XML representation is appended.level- The indentation level of the object.
-
assignIDs
Assigns IDs to all the objects in this NSObject subtree.- Parameters:
out- The writer object that handles the binary serialization.
-
toBinary
Generates the binary representation of the object.- 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
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.- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
toASCIIGnuStep
Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
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.
-
isSimple
-
getInstance
-
getClassForName
-
makeFirstCharLowercase
-
toJavaObject
-
deserializeObject
-
deserializeMap
-
deserializeCollection
-
deserializeArray
-
deserializeData
-
deserializeSimple
-
deserializeDate
-
deserializeNumber
-
fromSimple
-
fromPojo
-
fromMap
-
fromArray
-
fromData
-
fromCollection
-
fromSet
-