/** * Decode an object. * @return The decoded object. * @throws IOException */ // public Object decode(byte[] bytes, ClassLoader classloader) public Object decode(Object bytes, ClassLoader classloader) { Object ret = bytes instanceof byte[] ? JavaReader.objectFromByteArray((byte[])bytes, classloader) : JavaReader.objectFromInputStream((InputStream)bytes, classloader); if(DEBUG) System.out.println("decode message: "+(new String((byte[])bytes))); return ret; } }
/** * Fill in message values from string. */ public Map decodeMessage(String msg) { Map map = (Map)JavaReader.objectFromXML(msg, null); // Todo: classloader!? return map; }
/** * Join sets of typeinfos. * @param typeinfos The user specific type infos. * @return The joined type infos. */ public static Set<TypeInfo> joinTypeInfos(Set<TypeInfo> typeinfos) { Set<TypeInfo> ret = getTypeInfos(); if(typeinfos!=null) ret.addAll(typeinfos); return ret; }
/** * Convert an xml to an object. * @param val The string value. * @return The decoded object. */ public static <T> T objectFromXML(String val, ClassLoader classloader, TypeInfoPathManager manager, IObjectReaderHandler handler) { return (T)AReader.objectFromXML(getInstance(), val, classloader, manager==null? getPathManager(): manager, handler==null? getObjectHandler(): handler); }
/** * Convert a byte array (of an xml) to an object. * @param val The byte array. * @param classloader The class loader. * @return The decoded object. */ public static Object objectFromByteArray(byte[] val, ClassLoader classloader, IErrorReporter rep) { return objectFromByteArray(val, classloader, null, null, rep); }
/** * Convert a byte array (of an xml) to an object. * @param val The input stream. * @param classloader The class loader. * @return The decoded object. */ public static Object objectFromInputStream(InputStream val, ClassLoader classloader, IErrorReporter rep) { return objectFromInputStream(val, classloader, null, null, rep); }
/** * Decode data with the codec. * @param val The string value. * @return The encoded object. */ public Object decode(byte[] val, ClassLoader classloader, Map<Class<?>, Object[]> info) { Object[] infos = info==null? null: info.get(getClass()); Tuple2<TypeInfoPathManager, IObjectReaderHandler> tup = (Tuple2<TypeInfoPathManager, IObjectReaderHandler>)(infos!=null? infos[0]: null); Object ret = JavaReader.objectFromByteArray(val, classloader, tup==null? null: tup.getFirstEntity(), tup==null? null: tup.getSecondEntity()); if(DEBUG) System.out.println("decode content: "+ret); return ret; } }
/** * Read the object from the */ public Object readFrom(Class<Object> type, Type generictype, Annotation[] annotations, MediaType mediatype, MultivaluedMap<String, String> httpheaders, InputStream entitystream) throws IOException, WebApplicationException { try { return JavaReader.objectFromInputStream(entitystream, Thread.currentThread().getContextClassLoader(), null); } catch(Exception e) { return null; } } }
/** * Decode an object. * @return The decoded object. * @throws IOException */ // public Object decode(byte[] bytes, ClassLoader classloader) public Object decode(Object bytes, ClassLoader classloader, IErrorReporter rep) { Object ret = bytes instanceof byte[] ? JavaReader.objectFromByteArray((byte[])bytes, classloader, rep) : JavaReader.objectFromInputStream((InputStream)bytes, classloader, rep); if(DEBUG) System.out.println("decode message: "+(new String((byte[])bytes, Charset.forName("UTF-8")))); return ret; } }
/** * Convert an xml to an object. * @param val The string value. * @return The decoded object. */ public static <T> T objectFromXML(String val, ClassLoader classloader) { return JavaReader.<T>objectFromXML(val, classloader, null, null); }
/** * Decode data with the codec. * @param val The string value. * @return The encoded object. */ public Object decode(byte[] val, ClassLoader classloader, Map<Class<?>, Object[]> info, IErrorReporter rep) { Object[] infos = info==null? null: info.get(getClass()); Tuple2<TypeInfoPathManager, IObjectReaderHandler> tup = (Tuple2<TypeInfoPathManager, IObjectReaderHandler>)(infos!=null? infos[0]: null); Object ret = JavaReader.objectFromByteArray(val, classloader, tup==null? null: tup.getFirstEntity(), tup==null? null: tup.getSecondEntity(), rep); if(DEBUG) System.out.println("decode content: "+ret); return ret; } }
/** * Read the object from the */ public Object readFrom(Class<Object> type, Type generictype, Annotation[] annotations, MediaType mediatype, MultivaluedMap<String, String> httpheaders, InputStream entitystream) throws IOException, WebApplicationException { try { return JavaReader.objectFromInputStream(entitystream, Thread.currentThread().getContextClassLoader(), null); } catch(Exception e) { return null; } } }
/** * Get the default Java reader. * @return The Java reader. */ public static TypeInfoPathManager getPathManager() { if(pathmanager==null) { synchronized(JavaReader.class) { if(pathmanager==null) { pathmanager = new TypeInfoPathManager(getTypeInfos()); } } } return pathmanager; }
/** * Decode an object. * @return The decoded object. * @throws IOException */ // public Object decode(byte[] bytes, ClassLoader classloader) public Object decode(Object bytes, ClassLoader classloader, IErrorReporter rep) { Object ret = bytes instanceof byte[] ? JavaReader.objectFromByteArray((byte[])bytes, classloader, rep) : JavaReader.objectFromInputStream((InputStream)bytes, classloader, rep); if(DEBUG) { try { System.out.println("decode message: "+(new String((byte[])bytes, "UTF-8"))); } catch(UnsupportedEncodingException e) { throw new RuntimeException(e); } } return ret; } }
/** * Fill in message values from string. */ public Map decodeMessage(String msg) { Map map = (Map)JavaReader.objectFromXML(msg, null); // Todo: classloader!? return map; }
/** * Decode data with the codec. * @param val The string value. * @return The encoded object. */ public Object decode(byte[] val, ClassLoader classloader, Map<Class<?>, Object[]> info, IErrorReporter rep) { Object[] infos = info==null? null: info.get(getClass()); Tuple2<TypeInfoPathManager, IObjectReaderHandler> tup = (Tuple2<TypeInfoPathManager, IObjectReaderHandler>)(infos!=null? infos[0]: null); Object ret = JavaReader.objectFromByteArray(val, classloader, tup==null? null: tup.getFirstEntity(), tup==null? null: tup.getSecondEntity(), rep); if(DEBUG) System.out.println("decode content: "+ret); return ret; } }
/** * Get the default Java reader. * @return The Java reader. */ public static IObjectReaderHandler getObjectHandler() { if(handler==null) { synchronized(JavaReader.class) { if(handler==null) { handler = new BeanObjectReaderHandler(getTypeInfos()); } } } return handler; } }
Creature[] hscreatures = (Creature[]) JavaReader.objectFromXML(fileData.toString(), this.getClass().getClassLoader());
info = (AwarenessInfo)JavaReader.objectFromByteArray((byte[])msg.getMessage().get(SFipa.CONTENT), getClass().getClassLoader(), IErrorReporter.IGNORE);
Set<TypeInfo> typeinfosread = JavaReader.getTypeInfos();