Added support for parsing byte arrays.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@843 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-09-24 00:09:37 +00:00
parent 0aac64cdd5
commit 90383047cd
@@ -1,5 +1,5 @@
//
// $Id: ValueMarshaller.java,v 1.5 2002/03/08 06:13:21 mdb Exp $
// $Id: ValueMarshaller.java,v 1.6 2002/09/24 00:09:37 mdb Exp $
package com.samskivert.util;
@@ -41,6 +41,7 @@ public class ValueMarshaller
protected static HashMap _parsers;
protected static final byte[] BYTE_ARRAY_PROTOTYPE = new byte[0];
protected static final int[] INT_ARRAY_PROTOTYPE = new int[0];
protected static final float[] FLOAT_ARRAY_PROTOTYPE = new float[0];
protected static final String[] STRING_ARRAY_PROTOTYPE = new String[0];
@@ -83,6 +84,19 @@ public class ValueMarshaller
}
});
// and byte arrays
_parsers.put(BYTE_ARRAY_PROTOTYPE.getClass(), new Parser() {
public Object parse (String source) throws Exception {
int[] values = StringUtil.parseIntArray(source);
int vcount = values.length;
byte[] bytes = new byte[vcount];
for (int ii = 0; ii < vcount; ii++) {
bytes[ii] = (byte)values[ii];
}
return bytes;
}
});
// and int arrays
_parsers.put(INT_ARRAY_PROTOTYPE.getClass(), new Parser() {
public Object parse (String source) throws Exception {