1 7 package org.jboss.xml.binding; 8 9 import org.xml.sax.SAXException ; 10 11 import javax.xml.parsers.ParserConfigurationException ; 12 import java.io.Reader ; 13 import java.io.IOException ; 14 import java.io.Writer ; 15 16 22 public interface Marshaller 23 { 24 28 String PROP_OUTPUT_XML_VERSION = "org.jboss.xml.binding.marshalling.version"; 29 30 34 String PROP_MARSHALLER = "org.jboss.xml.binding.Marshaller"; 35 36 40 String PROP_OUTPUT_INDENTATION = "org.jboss.xml.binding.marshalling.indent"; 41 42 class FACTORY 43 { 44 public static Marshaller getInstance() 45 { 46 String impl = System.getProperty(PROP_MARSHALLER); 47 if(impl == null) 48 { 49 throw new IllegalStateException ("Required system property is not set: " + PROP_MARSHALLER); 50 } 51 52 Class implCls; 53 try 54 { 55 implCls = Thread.currentThread().getContextClassLoader().loadClass(impl); 56 } 57 catch(ClassNotFoundException e) 58 { 59 throw new IllegalStateException ("Failed to load marshaller implementation class: " + impl); 60 } 61 62 try 63 { 64 return (Marshaller)implCls.newInstance(); 65 } 66 catch(Exception e) 67 { 68 throw new IllegalStateException ("Failed to instantiate a marshaller: " + implCls); 69 } 70 } 71 } 72 73 String VERSION = "1.0"; 74 String ENCODING = "UTF-8"; 75 76 void setVersion(String version); 77 void setEncoding(String encoding); 78 79 void mapPublicIdToSystemId(String publicId, String systemId); 80 81 void mapClassToNamespace(Class cls, String root, String namespaceUri, Reader schemaReader, ObjectModelProvider provider); 82 83 void mapClassToNamespace(Class cls, String root, String namespaceUri, String schemaUrl, ObjectModelProvider provider); 84 85 void addRootElement(String namespaceUri, String prefix, String name); 86 87 void marshal(String schemaUri, ObjectModelProvider provider, Object root, Writer writer) throws IOException , 88 ParserConfigurationException , 89 SAXException ; 90 91 void marshal(Reader schema, ObjectModelProvider provider, Object document, Writer writer) 92 throws IOException , SAXException , ParserConfigurationException ; 93 94 void setProperty(String name, String value); 95 96 String getProperty(String name); 97 } 98 | Popular Tags |