Package com.dd.plist

Class NSData

All Implemented Interfaces:
Cloneable, Comparable<NSObject>

public class NSData extends NSObject
The NSData class is a wrapper for a byte buffer.
See Also:
  • Field Details

    • bytes

      private final byte[] bytes
  • Constructor Details

    • NSData

      public NSData(byte[] bytes)
      Creates a new NSData instance with the specified content.
      Parameters:
      bytes - The data content.
    • NSData

      public NSData(String base64) throws IOException
      Creates a new NSData instance with the specified Base64 encoded content.
      Parameters:
      base64 - The Base64 encoded data content.
      Throws:
      IOException - When the given string is not a proper Base64 formatted string.
    • NSData

      public NSData(File file) throws IOException
      Creates a new NSData instance with the specified file as content.
      Parameters:
      file - The file containing the data.
      Throws:
      FileNotFoundException - If the file could not be found.
      IOException - If the file could not be read.
  • Method Details

    • bytes

      public byte[] bytes()
      Returns the bytes contained in this instance.
      Returns:
      The data as bytes
    • length

      public int length()
      Returns the number of bytes stored in this instance.
      Returns:
      The number of bytes contained in this object.
    • getBytes

      public void getBytes(ByteBuffer buf, int length)
      Copies data from this instance into the specified buffer.
      Parameters:
      buf - The byte buffer which will contain the data.
      length - The number of bytes to copy.
    • getBytes

      public void getBytes(ByteBuffer buf, int rangeStart, int rangeStop)
      Copies data from this instance into the specified buffer.
      Parameters:
      buf - The byte buffer which will contain the data.
      rangeStart - The index from which to start copying.
      rangeStop - The index at which to stop copying.
    • getBase64EncodedData

      public String getBase64EncodedData()
      Gets the Base64 encoded data contained in this instance.
      Returns:
      The data as a Base64 encoded String.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public NSData clone()
      Description copied from class: NSObject
      Creates and returns a deep copy of this instance.
      Specified by:
      clone in class NSObject
      Returns:
      A clone of this instance.
    • toJavaObject

      public Object toJavaObject()
      Description copied from class: NSObject
      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.
      Specified by:
      toJavaObject in class NSObject
      Returns:
      A native java object representing this NSObject's value.
    • compareTo

      public int compareTo(NSObject o)
    • toXML

      void toXML(StringBuilder xml, int level)
      Description copied from class: NSObject
      Generates the XML representation of the object (without XML headers or enclosing plist-tags).
      Specified by:
      toXML in class NSObject
      Parameters:
      xml - The StringBuilder onto which the XML representation is appended.
      level - The indentation level of the object.
    • toBinary

      void toBinary(BinaryPropertyListWriter out) throws IOException
      Description copied from class: NSObject
      Generates the binary representation of the object.
      Specified by:
      toBinary in class NSObject
      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

      protected void toASCII(StringBuilder ascii, int level)
      Description copied from class: NSObject
      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.
      Specified by:
      toASCII in class NSObject
      Parameters:
      ascii - The StringBuilder onto which the ASCII representation is appended.
      level - The indentation level of the object.
    • toASCIIGnuStep

      protected void toASCIIGnuStep(StringBuilder ascii, int level)
      Description copied from class: NSObject
      Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.
      Specified by:
      toASCIIGnuStep in class NSObject
      Parameters:
      ascii - The StringBuilder onto which the ASCII representation is appended.
      level - The indentation level of the object.