/** * Encode an object. * @param obj The object. * @throws IOException */ public Object encode(Object val, ClassLoader classloader, IEncodingContext context) { byte[] ret = BinarySerializer.objectToByteArray(val, null, getEncoderChain(context), null, 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, IEncodingContext context) { Object[] infos = info==null? null: info.get(getClass()); List<ITraverseProcessor> preprocessors = (List<ITraverseProcessor>)(infos!=null? infos[1]: null); byte[] ret = BinarySerializer.objectToByteArray(val, preprocessors, JadexBinaryCodec.getEncoderChain(context), null, classloader); 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 Object encode(Object val, ClassLoader classloader, IEncodingContext context) { byte[] ret = BinarySerializer.objectToByteArray(val, null, getEncoderChain(context), null, 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()); List<ITraverseProcessor> preprocessors = (List<ITraverseProcessor>)(infos!=null? infos[1]: null); byte[] ret = BinarySerializer.objectToByteArray(val, preprocessors, JadexBinaryCodec.getEncoderChain(context), null, classloader); if(DEBUG) { try { System.out.println("encode content: "+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()); List<ITraverseProcessor> preprocessors = (List<ITraverseProcessor>)(infos!=null? infos[1]: null); // byte[] ret = BinarySerializer.objectToByteArray(val, preprocessors, JadexBinaryCodec.getEncoderChain(context), null, classloader); ByteArrayOutputStream baos = new ByteArrayOutputStream(); SBinarySerializer2.writeObjectToStream(baos, val, preprocessors, JadexBinaryCodec.getEncoderChain(context), null, classloader); byte[] ret = baos.toByteArray(); if(DEBUG) { try { System.out.println("encode content: "+new String(ret, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } return ret; }