/** * Convert to a byte array. */ public static byte[] objectToByteArray(Object val, ClassLoader classloader) { return objectToByteArray(val, classloader, null); }
/** * Encode an object. * @param obj The object. * @throws IOException */ // public byte[] encode(Object val, ClassLoader classloader) public Object encode(Object val, ClassLoader classloader) { byte[] ret = JavaWriter.objectToByteArray(val, classloader); if(DEBUG) System.out.println("encode message: "+(new String(ret))); return ret; }
/** * Get the size of the result. */ public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return JavaWriter.objectToByteArray(t, Thread.currentThread().getContextClassLoader()).length; } }
/** * Get the size of the result. */ public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { return JavaWriter.objectToByteArray(t, Thread.currentThread().getContextClassLoader()).length; } }
/** * Encode an object. * @param obj The object. * @throws IOException */ // public byte[] encode(Object val, ClassLoader classloader) public Object encode(Object val, ClassLoader classloader, IEncodingContext context) { byte[] ret = JavaWriter.objectToByteArray(val, classloader); if(DEBUG) System.out.println("encode message: "+(new String(ret, Charset.forName("UTF-8")))); return ret; }
/** * Encode data with the codec. * @param val The value. * @return The encoded object. */ public byte[] encode(Object val, ClassLoader classloader, Map<Class<?>, Object[]> info) { Object[] infos = info==null? null: info.get(getClass()); IObjectWriterHandler handler = (IObjectWriterHandler)(infos!=null? infos[1]: null); byte[] ret = JavaWriter.objectToByteArray(val, classloader, handler); if(DEBUG) System.out.println("encode content: "+ret); return ret; }
/** * Encode data with the codec. * @param val The value. * @return The encoded object. */ public byte[] encode(Object val, ClassLoader classloader, Map<Class<?>, Object[]> info, IEncodingContext context) { Object[] infos = info==null? null: info.get(getClass()); IObjectWriterHandler handler = (IObjectWriterHandler)(infos!=null? infos[1]: null); byte[] ret = JavaWriter.objectToByteArray(val, classloader, handler); if(DEBUG) System.out.println("encode content: "+new String(ret, Charset.forName("UTF-8"))); return ret; }
/** * Encode an object. * @param obj The object. * @throws IOException */ // public byte[] encode(Object val, ClassLoader classloader) public Object encode(Object val, ClassLoader classloader, IEncodingContext context) { byte[] ret = JavaWriter.objectToByteArray(val, classloader); if(DEBUG) { try { System.out.println("encode message: "+(new String(ret, "UTF-8"))); } catch(UnsupportedEncodingException e) { throw new RuntimeException(e); } } return ret; }
/** * Encode data with the codec. * @param val The value. * @return The encoded object. */ public byte[] encode(Object val, ClassLoader classloader, Map<Class<?>, Object[]> info, IEncodingContext context) { Object[] infos = info==null? null: info.get(getClass()); IObjectWriterHandler handler = (IObjectWriterHandler)(infos!=null? infos[1]: null); byte[] ret = JavaWriter.objectToByteArray(val, classloader, handler); if(DEBUG) { try { System.out.println("encode content: "+new String(ret, "UTF-8")); } catch(UnsupportedEncodingException e) { throw new RuntimeException(e); } } return ret; }
byte[] cidbytes = JavaWriter.objectToByteArray(cid, AbstractRemoteCommand.class.getClassLoader()); for(int runs=0; runs<3; runs++)