Package com.dd.plist
Class NSData
- java.lang.Object
-
- com.dd.plist.NSObject
-
- com.dd.plist.NSData
-
- All Implemented Interfaces:
java.lang.Cloneable,java.lang.Comparable<NSObject>
public class NSData extends NSObject
The NSData class is a wrapper for a byte buffer.- See Also:
- Foundation NSData documentation
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bytes-
Fields inherited from class com.dd.plist.NSObject
ASCII_LINE_LENGTH, NEWLINE
-
-
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.NSDataclone()Creates and returns a deep copy of this instance.intcompareTo(NSObject o)booleanequals(java.lang.Object obj)java.lang.StringgetBase64EncodedData()Gets the Base64 encoded data contained in this instance.voidgetBytes(java.nio.ByteBuffer buf, int length)Copies data from this instance into the specified buffer.voidgetBytes(java.nio.ByteBuffer buf, int rangeStart, int rangeStop)Copies data from this instance into the specified buffer.inthashCode()intlength()Returns the number of bytes stored in this instance.protected voidtoASCII(java.lang.StringBuilder ascii, int level)Generates the ASCII representation of this object.protected voidtoASCIIGnuStep(java.lang.StringBuilder ascii, int level)Generates the ASCII representation of this object in the GnuStep format.(package private) voidtoBinary(BinaryPropertyListWriter out)Generates the binary representation of the object.java.lang.ObjecttoJavaObject()Converts this NSObject into an equivalent object of the Java Runtime Environment.(package private) voidtoXML(java.lang.StringBuilder xml, int level)Generates the XML representation of the object (without XML headers or enclosing plist-tags).-
Methods inherited from class com.dd.plist.NSObject
assignIDs, fromJavaObject, indent, toJavaObject, toXMLPropertyList
-
-
-
-
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.IOExceptionCreates 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.IOExceptionCreates 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
clone
public NSData clone()
Description copied from class:NSObjectCreates and returns a deep copy of this instance.
-
toJavaObject
public java.lang.Object toJavaObject()
Description copied from class:NSObjectConverts 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.
- Specified by:
toJavaObjectin classNSObject- 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:NSObjectGenerates the XML representation of the object (without XML headers or enclosing plist-tags).
-
toBinary
void toBinary(BinaryPropertyListWriter out) throws java.io.IOException
Description copied from class:NSObjectGenerates the binary representation of the object.
-
toASCII
protected void toASCII(java.lang.StringBuilder ascii, int level)Description copied from class:NSObjectGenerates 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.
-
toASCIIGnuStep
protected void toASCIIGnuStep(java.lang.StringBuilder ascii, int level)Description copied from class:NSObjectGenerates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.- Specified by:
toASCIIGnuStepin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
-