1 55 package org.apache.axis.encoding.ser.castor; 56 57 import org.apache.axis.encoding.SerializationContext; 58 import org.xml.sax.Attributes ; 59 import org.xml.sax.SAXException ; 60 import org.xml.sax.helpers.DefaultHandler ; 61 62 import javax.xml.namespace.QName ; 63 import java.io.IOException ; 64 65 70 public class AxisContentHandler extends DefaultHandler { 71 74 private SerializationContext context; 75 76 81 public AxisContentHandler(SerializationContext context) { 82 super(); 83 setContext(context); 84 } 85 86 91 public SerializationContext getContext() { 92 return context; 93 } 94 95 100 public void setContext(SerializationContext context) { 101 this.context = context; 102 } 103 104 107 public void startElement(String uri, String localName, String qName, 108 Attributes attributes) throws SAXException { 109 try { 110 context.startElement(new QName (uri, localName), attributes); 111 } catch (IOException ioe) { 112 throw new SAXException (ioe); 113 } 114 } 115 116 119 public void endElement(String uri, String localName, String qName) 120 throws SAXException { 121 try { 122 context.endElement(); 123 } catch (IOException ioe) { 124 throw new SAXException (ioe); 125 } 126 } 127 128 131 public void characters(char[] ch, int start, int length) 132 throws org.xml.sax.SAXException { 133 try { 134 context.writeChars(ch, start, length); 135 } catch (IOException ioe) { 136 throw new SAXException (ioe); 137 } 138 } 139 } 140 141 | Popular Tags |