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

public abstract class NSObject extends Object implements Cloneable, Comparable<NSObject>
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 Details

    • NSObject

      public NSObject()
  • Method Details

    • getLocationInformation

      public LocationInformation getLocationInformation()
      Gets information about the location of this NSObject within the parsed property list, if available.
      Returns:
      The location information, or null if it is not available.
    • clone

      public abstract NSObject clone()
      Creates and returns a deep copy of this instance.
      Overrides:
      clone in class Object
      Returns:
      A clone of this instance.
    • toJavaObject

      public abstract Object toJavaObject()
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      • NSArray objects are converted to arrays.
      • NSDictionary objects are converted to objects extending the Map class.
      • NSSet objects are converted to objects extending the Set class.
      • NSNumber objects are converted to primitive number values (int, long, double or boolean).
      • NSString objects are converted to String objects.
      • NSData objects are converted to byte arrays.
      • NSDate objects are converted to Date objects.
      • UID objects are converted to byte arrays.
      Returns:
      A native java object representing this NSObject's value.
    • toXMLPropertyList

      public String 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

      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 - The StringBuilder onto which the XML representation is appended.
      level - The level of indentation.
    • toJavaObject

      public <T> T toJavaObject(Class<T> clazz)
      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

      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 - The object to serialize.
      Returns:
      A NSObject instance.
      Throws:
      IllegalArgumentException - If the specified object throws an exception while getting its properties.