1 5 package javax.xml.bind.util; 6 7 import javax.xml.bind.JAXBContext; 8 import javax.xml.bind.JAXBException; 9 import javax.xml.bind.Unmarshaller; 10 import javax.xml.bind.UnmarshallerHandler; 11 import javax.xml.transform.sax.SAXResult ; 12 13 54 public class JAXBResult extends SAXResult { 55 56 65 public JAXBResult( JAXBContext context ) throws JAXBException { 66 this( ( context == null ) ? assertionFailed() : context.createUnmarshaller() ); 67 } 68 69 88 public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException { 89 if( _unmarshaller == null ) 90 throw new JAXBException( 91 Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) ); 92 93 this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler(); 94 95 super.setHandler(unmarshallerHandler); 96 } 97 98 102 private final UnmarshallerHandler unmarshallerHandler; 103 104 118 public Object getResult() throws JAXBException { 119 return unmarshallerHandler.getResult(); 120 } 121 122 126 private static Unmarshaller assertionFailed() throws JAXBException { 127 throw new JAXBException( Messages.format( Messages.RESULT_NULL_CONTEXT ) ); 128 } 129 } 130 | Popular Tags |