1 8 package com.sun.japex.testsuite.impl.runtime; 9 10 import javax.xml.bind.DatatypeConverter; 11 import javax.xml.bind.JAXBContext; 12 import javax.xml.bind.JAXBException; 13 import javax.xml.bind.Marshaller; 14 import javax.xml.bind.PropertyException; 15 import javax.xml.bind.Unmarshaller; 16 import javax.xml.bind.Validator; 17 18 import com.sun.xml.bind.Messages; 19 import com.sun.xml.bind.DatatypeConverterImpl; 20 21 28 public class DefaultJAXBContextImpl extends JAXBContext { 29 30 36 private GrammarInfo gi = null; 37 38 44 public DefaultJAXBContextImpl( String contextPath, ClassLoader classLoader ) 45 throws JAXBException { 46 47 this( GrammarInfoFacade.createGrammarInfoFacade( contextPath, classLoader ) ); 48 49 DatatypeConverter.setDatatypeConverter(DatatypeConverterImpl.theInstance); 51 } 52 53 58 public DefaultJAXBContextImpl( GrammarInfo gi ) { 59 this.gi = gi; 60 } 61 62 public GrammarInfo getGrammarInfo() { 63 return gi; 64 } 65 66 67 68 71 private com.sun.msv.grammar.Grammar grammar = null; 72 73 76 public com.sun.msv.grammar.Grammar getGrammar() throws JAXBException { 77 if( grammar==null ) 78 grammar = gi.getGrammar(); 84 return grammar; 85 } 86 87 88 96 public Marshaller createMarshaller() throws JAXBException { 97 return new MarshallerImpl( this ); 98 } 99 100 108 public Unmarshaller createUnmarshaller() throws JAXBException { 109 return new UnmarshallerImpl( this, gi ); 110 } 111 112 120 public Validator createValidator() throws JAXBException { 121 return new ValidatorImpl( this ); 122 } 123 124 125 126 133 public Object newInstance( Class javaContentInterface ) 134 throws JAXBException { 135 136 if( javaContentInterface == null ) { 137 throw new JAXBException( Messages.format( Messages.CI_NOT_NULL ) ); 138 } 139 140 try { 141 Class c = gi.getDefaultImplementation( javaContentInterface ); 142 if(c==null) 143 throw new JAXBException( 144 Messages.format( Messages.MISSING_INTERFACE, javaContentInterface )); 145 146 return c.newInstance(); 147 } catch( Exception e ) { 148 throw new JAXBException( e ); 149 } 150 } 151 152 156 public void setProperty( String name, Object value ) 157 throws PropertyException { 158 159 throw new PropertyException(name, value); 160 } 161 162 166 public Object getProperty( String name ) 167 throws PropertyException { 168 169 throw new PropertyException(name); 170 } 171 172 173 } 174 | Popular Tags |