示例#1
0
  @Override
  protected void marshalSaxHandlers(
      Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
      throws XmlMappingException {

    SaxWriter saxWriter = new SaxWriter();
    saxWriter.setContentHandler(contentHandler);
    marshal(graph, saxWriter);
  }
  @Override
  public void encode(Object object, ContentHandler handler) throws Exception {
    // prepare xml encoding
    XStream xstream = buildXStream();

    // bind with the content handler
    SaxWriter writer = new SaxWriter(nameCoder);
    writer.setContentHandler(handler);

    // write out xml
    xstream.marshal(object, writer);
  }