@Override public Object decode(Object input) throws Exception { return decode((String) input); }
public void encode(OutputStream os) throws Exception { ppio.encode(object, os); }
public void encode(OutputStream os) throws Exception { ppio.encode(object, os); }
/** * Decodes a String into the internal object (used for CDATA inputs) * * @param input */ public abstract Object decode(String input) throws Exception; }
public void encode(ContentHandler output) throws Exception { ((LexicalHandler) output).startCDATA(); PipedInputStream pins = new PipedInputStream(); PipedOutputStream pos = new PipedOutputStream(pins); ppio.encode(object, pos); Reader r = new InputStreamReader(pins); char[] buffer = new char[1024]; int read; while ((read = r.read(buffer)) > 0) { output.characters(buffer, 0, read); } pos.close(); r.close(); ((LexicalHandler) output).endCDATA(); }
@Override public Object decode(Object input) throws Exception { Class<? extends Object> type = input.getClass(); if (type.isAssignableFrom(String.class)) { return decode((String) input); } if (type.isAssignableFrom(Text.class)) { return decode(((Text) input).getValue()); } return super.decode(input); }
public void encode(ContentHandler output) throws Exception { ((LexicalHandler) output).startCDATA(); try (OutputStream os = new WriterOutputStream(new ContentHandlerWriter(output))) { ppio.encode(object, os); } ((LexicalHandler) output).endCDATA(); }