Commits

Jon S  committed 258fd28

small tweaks to API

  • Participants
  • Parent commits 3334137

Comments (0)

Files changed (4)

 	- (Much) Simpler API
 	- No external dependencies
 	- No builtin support for native object serialization, annotations, or RPC.
+	- It's very minimalistic - at the time of this writing, the entire redistributable
+	  library is only ~11kb ... with full library sources for reference.
 	
 Usage: 
 import net.asdfa.msgpack;
 Object unpacked = MsgPack.unpack(data);
 System.out.println("Unpacked data: " + unpacked);
 
+
 See Test.java for more examples.
 You can also pack/unpack to/from Data(Output/Input)Streams.
+You can also specify unpacking options:
+    Object unpacked = MsgPack.unpack(data, UNPACK_RAW_AS_STRING);
+  to unpack things as something other than a raw byte[].
 
 Types:
 This implementation uses the builtin Java types:
 
 	<target name="package" depends="compile">
 		<mkdir dir="dist" />
-		<jar destfile="dist/msgpack-java-lite">
+		<jar destfile="dist/msgpack-java-lite.jar">
 			<fileset dir="build">
-				<exclude name="new/asdfa/msgpack/Test.*" />
+				<exclude name="net/asdfa/msgpack/Test.*" />
 			</fileset>
-			<fileset dir="src"></fileset>
+			<fileset dir="src">
+				<exclude name="net/asdfa/msgpack/Test.*" />
+			</fileset>
 		</jar>
 	</target>
 

File src/net/asdfa/msgpack/MsgPack.java

 		return out.toByteArray();
 	}
 
-	public static final int UNPACK_OPTION_RAW_AS_STRING = 0x1;
-	public static final int UNPACK_OPTION_RAW_AS_BYTE_BUFFER = 0x2;
+	public static final int UNPACK_RAW_AS_STRING = 0x1;
+	public static final int UNPACK_RAW_AS_BYTE_BUFFER = 0x2;
 
 	/**
 	 * This is the same as calling unpack(data, 0)
 		byte[] data = new byte[size];
 		in.read(data);
 
-		if ((options & UNPACK_OPTION_RAW_AS_BYTE_BUFFER) != 0) {
+		if ((options & UNPACK_RAW_AS_BYTE_BUFFER) != 0) {
 			return ByteBuffer.wrap(data);
-		} else if ((options & UNPACK_OPTION_RAW_AS_STRING) != 0) {
+		} else if ((options & UNPACK_RAW_AS_STRING) != 0) {
 			return new String(data, "UTF-8");
 		} else {
 			return data;

File src/net/asdfa/msgpack/Test.java

 
 			{
 				byte[] packed = MsgPack.pack(dataRaw);
-				Object unpacked = MsgPack.unpack(packed, MsgPack.UNPACK_OPTION_RAW_AS_BYTE_BUFFER);
+				Object unpacked = MsgPack.unpack(packed, MsgPack.UNPACK_RAW_AS_BYTE_BUFFER);
 
 				//System.out.println(dataRaw + " => " + toHex(packed) + " => " + unpacked);
 
 		);
 
 		byte[] packed = MsgPack.pack(obj);
-		Object unpacked = MsgPack.unpack(packed, MsgPack.UNPACK_OPTION_RAW_AS_STRING);
+		Object unpacked = MsgPack.unpack(packed, MsgPack.UNPACK_RAW_AS_STRING);
 
 		//System.out.println(obj + " => " + toHex(packed) + " => " + unpacked);