public Object readObject(Object classorobject, InputStream is) { return readObject(classorobject, is, null); }
public String toString(Object towrite) { return toString(towrite, true); }
public String toString(Object towrite, boolean compactmode) { DeSAXalizer desaxalizer = getDeSAXalizer(); String resourcename = mappingcontext.classnamemanager.getClassName(towrite.getClass()); if (resourcename == null) { throw new UniversalRuntimeException("Object of unknown type " + towrite.getClass() + " supplied to writeXML"); } try { return desaxalizer.toString(towrite, resourcename, compactmode); } catch (Throwable t) { throw UniversalRuntimeException.accumulate(t, "Error writing object of class " + towrite.getClass()); } }
public Object fromString(String toread) { int roottagi = toread.indexOf('<'); if (roottagi == -1) { throw new UniversalRuntimeException("Couldn't find root tag in string "+ toread); } int roottagt = roottagi + 1; int endtag = toread.indexOf('>', roottagi); if (endtag == -1) { throw new UniversalRuntimeException("Unterminated root tag in string " + toread); } for (; roottagt < endtag; ++ roottagt) { char c = toread.charAt(roottagt); // QQQQQ technically not correct, XML whitespace does not agree with Java. if (Character.isWhitespace(c)) break; } String roottag = toread.substring(roottagi + 1, roottagt); Class objclass = findClass(roottag); StringReader sr = new StringReader(toread); SAXalizerHelper saxalizer = (SAXalizerHelper) saxalizergetter.get(); try { return saxalizer.produceSubtree(objclass.newInstance(), sr); } catch (Throwable t) { throw UniversalRuntimeException.accumulate(t, "Error reading object of class " + objclass); } }
public void writeObject(Object towrite, OutputStream os) { DeSAXalizer desaxalizer = getDeSAXalizer(); String resourcename = mappingcontext.classnamemanager.getClassName(towrite.getClass()); if (resourcename == null) { throw new UniversalRuntimeException("Object of unknown type " + towrite.getClass() + " supplied to writeXML"); } try { desaxalizer.serializeSubtree(towrite, resourcename, os); } catch (Throwable t) { throw UniversalRuntimeException.accumulate(t, "Error writing object of class " + towrite.getClass()); } }
public Object readObject(Object classorobject, ReadInputStream ris) { Reader r = new RISReader(ris); return readObject(classorobject, null, r); }
public void loadMapping(InputStream is) { SAXalizerMapperEntry entry = (SAXalizerMapperEntry)readObject(SAXalizerMapperEntry.class, is); mappingcontext.mapper.addEntry(entry); }