diff --git a/src/main/java/com/dd/plist/ASCIIPropertyListParser.java b/src/main/java/com/dd/plist/ASCIIPropertyListParser.java index 046315d..33026db 100644 --- a/src/main/java/com/dd/plist/ASCIIPropertyListParser.java +++ b/src/main/java/com/dd/plist/ASCIIPropertyListParser.java @@ -568,7 +568,7 @@ private NSArray parseArray() throws ParseException { //parse end token this.read(ARRAY_END_TOKEN); - return new NSArray(objects.toArray(new NSObject[objects.size()])); + return new NSArray(objects.toArray(new NSObject[0])); } /** diff --git a/src/main/java/com/dd/plist/Base64.java b/src/main/java/com/dd/plist/Base64.java index 4cbf9a0..1185797 100644 --- a/src/main/java/com/dd/plist/Base64.java +++ b/src/main/java/com/dd/plist/Base64.java @@ -29,34 +29,34 @@ /** *
Encodes and decodes to and from Base64 notation.
*Homepage: http://iharder.net/base64.
- * + * *Example:
* *String encoded = Base64.encode( myByteArray );
*
* byte[] myByteArray = Base64.decode( encoded );
- *
+ *
* The options
parameter, which appears in a few places, is used to pass
* several pieces of information to the encoder. In the "higher level" methods such as
* encodeBytes( bytes, options ) the options parameter can be used to indicate such
* things as first gzipping the bytes before encoding them, not inserting linefeeds,
* and encoding using the URL-safe and Ordered dialects.
Note, according to RFC3548, * Section 2.1, implementations should not add line feeds unless explicitly told * to do so. I've got Base64 set to this behavior now, although earlier versions * broke lines by default.
- * + * *The constants defined in Base64 can be OR-ed together to combine options, so you * might make a call like this:
- * + * *String encoded = Base64.encodeBytes( mybytes, Base64.GZIP | Base64.DO_BREAK_LINES );
* to compress the data before encoding it and then making the output have newline characters.
*Also...
*String encoded = Base64.encodeBytes( crazyString.getBytes() );
- *
- *
- *
+ *
+ *
+ *
* * Change Log: *
@@ -133,7 +133,7 @@ * Special thanks to Jim Kellerman at http://www.powerset.com/ * for contributing the new Base64 dialects. * - * + * *As of v 2.3, if the object * cannot be serialized or there is another error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but * in retrospect that's a pretty poor way to handle it.
- * + * * The object is not GZip-compressed before being encoded. * * @param serializableObject The object to encode @@ -665,22 +665,22 @@ public static String encodeObject(java.io.Serializable serializableObject) /** * Serializes an object and returns the Base64-encoded * version of that serialized object. - * + * *As of v 2.3, if the object * cannot be serialized or there is another error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but * in retrospect that's a pretty poor way to handle it.
- * + * * The object is not GZip-compressed before being encoded. - * + * * Example options:* GZIP: gzip-compresses object before encoding it. * DO_BREAK_LINES: break lines at 76 characters *- * + * * Example:
encodeObject( myObj, Base64.GZIP )
or
- *
+ *
* Example: encodeObject( myObj, Base64.GZIP | Base64.DO_BREAK_LINES )
*
* @param serializableObject The object to encode
@@ -791,8 +791,8 @@ public static String encodeBytes(byte[] source) {
* Example: encodeBytes( myData, Base64.GZIP )
or
*
* Example: encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES )
- *
- *
+ *
+ *
*
As of v 2.3, if there is an error with the GZIP stream, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but @@ -815,7 +815,7 @@ public static String encodeBytes(byte[] source, int options) throws java.io.IOEx /** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. - * + * *
As of v 2.3, if there is an error,
* the method will throw an java.io.IOException. This is new to v2.3!
* In earlier versions, it just returned a null value, but
@@ -856,8 +856,8 @@ public static String encodeBytes(byte[] source, int off, int len) {
* Example: encodeBytes( myData, Base64.GZIP )
or
*
* Example: encodeBytes( myData, Base64.GZIP | Base64.DO_BREAK_LINES )
- *
- *
+ *
+ *
*
As of v 2.3, if there is an error with the GZIP stream, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned a null value, but @@ -1444,7 +1444,7 @@ public Class> resolveClass(java.io.ObjectStreamClass streamClass) /** * Convenience method for encoding data to a file. - * + * *
As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1484,7 +1484,7 @@ public static void encodeToFile(byte[] dataToEncode, String filename) /** * Convenience method for decoding data to a file. - * + * *
As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1520,7 +1520,7 @@ public static void decodeToFile(String dataToDecode, String filename) /** * Convenience method for reading a base64-encoded * file and decoding it. - * + * *
As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1581,7 +1581,7 @@ public static byte[] decodeFromFile(String filename) /** * Convenience method for reading a binary file * and base64-encoding it. - * + * *
As of v 2.3, if there is a error, * the method will throw an java.io.IOException. This is new to v2.3! * In earlier versions, it just returned false, but @@ -1704,15 +1704,15 @@ public static void decodeFileToFile(String infile, String outfile) */ public static class B64InputStream extends java.io.FilterInputStream { - private boolean encode; // Encoding or decoding + private final boolean encode; // Encoding or decoding private int position; // Current position in the buffer - private byte[] buffer; // Small buffer holding converted data - private int bufferLength; // Length of buffer (3 or 4) + private final byte[] buffer; // Small buffer holding converted data + private final int bufferLength; // Length of buffer (3 or 4) private int numSigBytes; // Number of meaningful bytes in the buffer private int lineLength; - private boolean breakLines; // Break lines at less than 80 characters - private int options; // Record options used to create the stream. - private byte[] decodabet; // Local copies to avoid extra method calls + private final boolean breakLines; // Break lines at less than 80 characters + private final int options; // Record options used to create the stream. + private final byte[] decodabet; // Local copies to avoid extra method calls /** @@ -1729,13 +1729,13 @@ public B64InputStream(java.io.InputStream in) { /** * Constructs a {@link com.dd.plist.Base64.B64InputStream} in * either ENCODE or DECODE mode. - * + * * Valid options:
* ENCODE or DECODE: Encode or Decode as data is read. * DO_BREAK_LINES: break lines at 76 characters * (only meaningful when encoding) *- * + * * Example:
new Base64.B64InputStream( in, Base64.DECODE )
*
* @param in the java.io.InputStream
from which to read data.
@@ -1940,13 +1940,13 @@ public B64OutputStream(java.io.OutputStream out) {
/**
* Constructs a {@link com.dd.plist.Base64.B64OutputStream} in
* either ENCODE or DECODE mode.
- *
+ *
* Valid options:* ENCODE or DECODE: Encode or Decode as data is read. * DO_BREAK_LINES: don't break lines at 76 characters * (only meaningful when encoding) *- * + * * Example:
new Base64.B64OutputStream( out, Base64.ENCODE )
*
* @param out the java.io.B64OutputStream
to which data will be written.
diff --git a/src/main/java/com/dd/plist/BinaryPropertyListParser.java b/src/main/java/com/dd/plist/BinaryPropertyListParser.java
index bba7ca4..b20e2b6 100644
--- a/src/main/java/com/dd/plist/BinaryPropertyListParser.java
+++ b/src/main/java/com/dd/plist/BinaryPropertyListParser.java
@@ -84,7 +84,7 @@ public final class BinaryPropertyListParser {
private int offsetSize;
private int numObjects;
private int offsetTableOffset;
- private HashMap