Top Description Fields Constructors Methods
com.dd.plist

public abstract Class NSObject

extends Object
implements Cloneable, Comparable<NSObject>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, java.lang.Cloneable
Known Direct Subclasses
com.dd.plist.NSSet, com.dd.plist.NSString, com.dd.plist.UID, com.dd.plist.NSArray, com.dd.plist.NSData, com.dd.plist.NSDate, com.dd.plist.NSDictionary, com.dd.plist.NSNull, com.dd.plist.NSNumber
Imports
java.io.IOException, java.lang.reflect.*, java.util.*

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

Field Summary

Modifier and TypeField and Description
pack-priv static final int
ASCII_LINE_LENGTH

The maximum length of the text lines to be used when generating ASCII property lists.

private static final String
INDENT

The indentation character used for generating the XML output.

private LocationInformation
pack-priv static final String
NEWLINE

The newline character used for generating the XML output.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv void
assignIDs(BinaryPropertyListWriter
The writer object that handles the binary serialization.
out
)

Assigns IDs to all the objects in this NSObject subtree.

public abstract NSObject

Returns:

A clone of this instance.
clone
()

Overrides java.lang.Object.clone.

Creates and returns a deep copy of this instance.

private Object
deserializeArray(NSObject payload, Class<?> clazz)

private Object
deserializeCollection(NSObject payload, Class<?> clazz, Type[] types)

private static Object
deserializeData(NSData payload, Class<?> elementClass)

private static Date
deserializeDate(NSDate date, Class<?> clazz)

private Object
deserializeMap(Class<?> clazz, Type[] types, Map<String, NSObject> map)

private static Object
deserializeNumber(final NSNumber number, Class<?> clazz)

private Object
deserializeObject(NSDictionary payload, Class<?> clazz, Type[] types)

private static Object
deserializeSimple(NSObject payload, Class<?> clazz)

private static NSObject
fromArray(Object object, Class<?> objClass)

private static NSArray
fromCollection(Collection<?> collection)

private static NSData
fromData(Object object)

public static NSObject

Returns:

A NSObject instance.
fromJavaObject
(Object
The object to serialize.
object
)

Serializes the specified object into an NSObject.

private static NSDictionary
fromMap(Map<?, ?> map)

private static NSDictionary
fromPojo(Object object, Class<?> objClass)

private static NSSet
fromSet(Set<?> set)

private static NSObject
fromSimple(Object object, Class<?> objClass)

private static Class<?>
private static Object
getInstance(Class<?> clazz)

public LocationInformation

Returns:

The location information, or null if it is not available.
getLocationInformation
()

Gets information about the location of this NSObject within the parsed property list, if available.

protected void
indent(StringBuilder
The StringBuilder onto which the XML representation is appended.
xml
,
int
The level of indentation.
level
)

Helper method that adds correct indentation to the xml output.

private static boolean
isSimple(Class<?> clazz)

private static String
pack-priv void
setLocationInformation(LocationInformation
The location information.
locationInformation
)

Sets the location information.

pack-priv abstract void
toASCII(StringBuilder
The StringBuilder onto which the ASCII representation is appended.
ascii
,
int
The indentation level of the object.
level
)

Generates the ASCII representation of this object.

pack-priv abstract void
toASCIIGnuStep(StringBuilder
The StringBuilder onto which the ASCII representation is appended.
ascii
,
int
The indentation level of the object.
level
)

Generates the ASCII representation of this object in the GnuStep format.

pack-priv abstract void
toBinary(BinaryPropertyListWriter
The output stream to serialize the object to.
out
)

Generates the binary representation of the object.

public abstract Object

Returns:

A native java object representing this NSObject's value.
toJavaObject
()

Converts this NSObject into an equivalent object of the Java Runtime Environment.

public <
The target object type.
T
>
T

Returns:

A new instance of the specified class, deserialized from this NSObject.
toJavaObject
(Class<T>
The target class.
clazz
)

Converts this NSObject into an object of the specified class.

private Object
toJavaObject(NSObject payload, Class<?> clazz, Type[] types)

pack-priv abstract void
toXML(StringBuilder
The StringBuilder onto which the XML representation is appended.
xml
,
int
The indentation level of the object.
level
)

Generates the XML representation of the object (without XML headers or enclosing plist-tags).

public String

Returns:

The XML representation of the property list including XML header and doctype information.
toXMLPropertyList
()

Generates a valid XML property list including headers using this object as root.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASCII_LINE_LENGTHback to summary
pack-priv static final int ASCII_LINE_LENGTH

The 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.

INDENTback to summary
private static final String INDENT

The indentation character used for generating the XML output. This is the tabulator character.

locationInformationback to summary
private LocationInformation locationInformation
NEWLINEback to summary
pack-priv static final String 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.

Constructor Detail

NSObjectback to summary
public NSObject()

Method Detail

assignIDsback to summary
pack-priv void assignIDs(BinaryPropertyListWriter out)

Assigns IDs to all the objects in this NSObject subtree.

Parameters
out:BinaryPropertyListWriter

The writer object that handles the binary serialization.

cloneback to summary
public abstract NSObject clone()

Overrides java.lang.Object.clone.

Creates and returns a deep copy of this instance.

Returns:NSObject

A clone of this instance.

Annotations
@Override
deserializeArrayback to summary
private Object deserializeArray(NSObject payload, Class<?> clazz)
deserializeCollectionback to summary
private Object deserializeCollection(NSObject payload, Class<?> clazz, Type[] types)
deserializeDataback to summary
private static Object deserializeData(NSData payload, Class<?> elementClass)
deserializeDateback to summary
private static Date deserializeDate(NSDate date, Class<?> clazz)
deserializeMapback to summary
private Object deserializeMap(Class<?> clazz, Type[] types, Map<String, NSObject> map)
deserializeNumberback to summary
private static Object deserializeNumber(final NSNumber number, Class<?> clazz)
deserializeObjectback to summary
private Object deserializeObject(NSDictionary payload, Class<?> clazz, Type[] types)
deserializeSimpleback to summary
private static Object deserializeSimple(NSObject payload, Class<?> clazz)
fromArrayback to summary
private static NSObject fromArray(Object object, Class<?> objClass)
fromCollectionback to summary
private static NSArray fromCollection(Collection<?> collection)
fromDataback to summary
private static NSData fromData(Object object)
fromJavaObjectback to summary
public static NSObject fromJavaObject(Object object)

Serializes the specified object into an NSObject. Objects which do not have a direct type correspondence to an NSObject type will be serialized as a NSDictionary. The dictionary will contain the values of all publicly accessible fields and properties.

Parameters
object:Object

The object to serialize.

Returns:NSObject

A NSObject instance.

Exceptions
IllegalArgumentException:
If the specified object throws an exception while getting its properties.
fromMapback to summary
private static NSDictionary fromMap(Map<?, ?> map)
fromPojoback to summary
private static NSDictionary fromPojo(Object object, Class<?> objClass)
fromSetback to summary
private static NSSet fromSet(Set<?> set)
fromSimpleback to summary
private static NSObject fromSimple(Object object, Class<?> objClass)
Annotations
@SuppressWarnings:ConstantConditions
getClassForNameback to summary
private static Class<?> getClassForName(String className)
getInstanceback to summary
private static Object getInstance(Class<?> clazz)
getLocationInformationback to summary
public LocationInformation getLocationInformation()

Gets information about the location of this NSObject within the parsed property list, if available.

Returns:LocationInformation

The location information, or null if it is not available.

indentback to summary
protected void indent(StringBuilder xml, int level)

Helper method that adds correct indentation to the xml output. Calling this method will add level number of tab characters to the xml string.

Parameters
xml:StringBuilder

The StringBuilder onto which the XML representation is appended.

level:int

The level of indentation.

isSimpleback to summary
private static boolean isSimple(Class<?> clazz)
makeFirstCharLowercaseback to summary
private static String makeFirstCharLowercase(String input)
setLocationInformationback to summary
pack-priv void setLocationInformation(LocationInformation locationInformation)

Sets the location information.

Parameters
locationInformation:LocationInformation

The location information.

toASCIIback to summary
pack-priv abstract void toASCII(StringBuilder ascii, int level)

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:StringBuilder

The StringBuilder onto which the ASCII representation is appended.

level:int

The indentation level of the object.

toASCIIGnuStepback to summary
pack-priv abstract void toASCIIGnuStep(StringBuilder ascii, int level)

Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.

Parameters
ascii:StringBuilder

The StringBuilder onto which the ASCII representation is appended.

level:int

The indentation level of the object.

toBinaryback to summary
pack-priv abstract void toBinary(BinaryPropertyListWriter out) throws IOException

Generates the binary representation of the object.

Parameters
out:BinaryPropertyListWriter

The output stream to serialize the object to.

Exceptions
IOException:
If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
toJavaObjectback to summary
public abstract Object toJavaObject()

Converts this NSObject into an equivalent object of the Java Runtime Environment.

Returns:Object

A native java object representing this NSObject's value.

toJavaObjectback to summary
public <T> T toJavaObject(Class<T> clazz)

Converts this NSObject into an object of the specified class.

Parameters
<T>
The target object type.
clazz:Class<T>

The target class.

Returns:T

A new instance of the specified class, deserialized from this NSObject.

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalArgumentException:
If the specified class cannot be deserialized from this NSObject.
toJavaObjectback to summary
private Object toJavaObject(NSObject payload, Class<?> clazz, Type[] types)
toXMLback to summary
pack-priv abstract void toXML(StringBuilder xml, int level)

Generates the XML representation of the object (without XML headers or enclosing plist-tags).

Parameters
xml:StringBuilder

The StringBuilder onto which the XML representation is appended.

level:int

The indentation level of the object.

toXMLPropertyListback to summary
public String toXMLPropertyList()

Generates a valid XML property list including headers using this object as root.

Returns:String

The XML representation of the property list including XML header and doctype information.