1 22 package org.jboss.xb.binding; 23 24 import org.xml.sax.SAXException ; 25 26 import javax.xml.parsers.ParserConfigurationException ; 27 import java.io.Reader ; 28 import java.io.IOException ; 29 import java.io.Writer ; 30 31 37 public interface Marshaller 38 { 39 43 String PROP_OUTPUT_XML_VERSION = "org.jboss.xml.binding.marshalling.version"; 44 45 49 String PROP_MARSHALLER = "org.jboss.xml.binding.Marshaller"; 50 51 55 String PROP_OUTPUT_INDENTATION = "org.jboss.xml.binding.marshalling.indent"; 56 57 class FACTORY 58 { 59 public static Marshaller getInstance() 60 { 61 String impl = System.getProperty(PROP_MARSHALLER); 62 if(impl == null) 63 { 64 throw new IllegalStateException ("Required system property is not set: " + PROP_MARSHALLER); 65 } 66 67 Class implCls; 68 try 69 { 70 implCls = Thread.currentThread().getContextClassLoader().loadClass(impl); 71 } 72 catch(ClassNotFoundException e) 73 { 74 throw new IllegalStateException ("Failed to load marshaller implementation class: " + impl); 75 } 76 77 try 78 { 79 return (Marshaller)implCls.newInstance(); 80 } 81 catch(Exception e) 82 { 83 throw new IllegalStateException ("Failed to instantiate a marshaller: " + implCls); 84 } 85 } 86 } 87 88 String VERSION = "1.0"; 89 String ENCODING = "UTF-8"; 90 91 void setVersion(String version); 92 void setEncoding(String encoding); 93 94 void mapPublicIdToSystemId(String publicId, String systemId); 95 96 void mapClassToGlobalElement(Class cls, String localName, String nsUri, String schemaUrl, ObjectModelProvider provider); 97 98 void mapClassToGlobalType(Class cls, String localName, String nsUri, String schemaUrl, ObjectModelProvider provider); 99 100 void addRootElement(String namespaceUri, String prefix, String name); 101 102 void marshal(String schemaUri, ObjectModelProvider provider, Object root, Writer writer) throws IOException , 103 ParserConfigurationException , 104 SAXException ; 105 106 void marshal(Reader schema, ObjectModelProvider provider, Object document, Writer writer) 107 throws IOException , SAXException , ParserConfigurationException ; 108 109 void setProperty(String name, String value); 110 111 String getProperty(String name); 112 } 113 | Popular Tags |