Package com.dd.plist

Class NSData

    • Constructor Summary

      Constructors 
      Constructor Description
      NSData​(byte[] bytes)
      Creates a new NSData instance with the specified content.
      NSData​(java.io.File file)
      Creates a new NSData instance with the specified file as content.
      NSData​(java.lang.String base64)
      Creates a new NSData instance with the specified Base64 encoded content.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] bytes()
      Returns the bytes contained in this instance.
      NSData clone()
      Creates and returns a deep copy of this instance.
      int compareTo​(NSObject o)  
      boolean equals​(java.lang.Object obj)  
      java.lang.String getBase64EncodedData()
      Gets the Base64 encoded data contained in this instance.
      void getBytes​(java.nio.ByteBuffer buf, int length)
      Copies data from this instance into the specified buffer.
      void getBytes​(java.nio.ByteBuffer buf, int rangeStart, int rangeStop)
      Copies data from this instance into the specified buffer.
      int hashCode()  
      int length()
      Returns the number of bytes stored in this instance.
      protected void toASCII​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object.
      protected void toASCIIGnuStep​(java.lang.StringBuilder ascii, int level)
      Generates the ASCII representation of this object in the GnuStep format.
      (package private) void toBinary​(BinaryPropertyListWriter out)
      Generates the binary representation of the object.
      java.lang.Object toJavaObject()
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      (package private) void toXML​(java.lang.StringBuilder xml, int level)
      Generates the XML representation of the object (without XML headers or enclosing plist-tags).
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bytes

        private final byte[] bytes
    • Constructor Detail

      • NSData

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

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

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

      • 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​(java.nio.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​(java.nio.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 java.lang.String getBase64EncodedData()
        Gets the Base64 encoded data contained in this instance.
        Returns:
        The data as a Base64 encoded String.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.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 java.lang.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​(java.lang.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 java.io.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:
        java.io.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​(java.lang.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​(java.lang.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.