下面列出了javax.xml.bind.Unmarshaller#getUnmarshallerHandler ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
public static <T> T getPersistence(final Class<T> clazz, final InputStream persistenceDescriptor) throws Exception {
final JAXBContext jc = clazz.getClassLoader() == JaxbPersistenceFactory.class.getClassLoader() ?
JaxbJavaee.getContext(clazz) : JAXBContextFactory.newInstance(clazz);
final Unmarshaller u = jc.createUnmarshaller();
final UnmarshallerHandler uh = u.getUnmarshallerHandler();
// create a new XML parser
final SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
final SAXParser parser = factory.newSAXParser();
final XMLReader xmlReader = parser.getXMLReader();
// Create a filter to intercept events
final PersistenceFilter xmlFilter = new PersistenceFilter(xmlReader);
// Be sure the filter has the JAXB content handler set (or it wont work)
xmlFilter.setContentHandler(uh);
final SAXSource source = new SAXSource(xmlFilter, new InputSource(persistenceDescriptor));
return (T) u.unmarshal(source);
}
/**
* Applies the additional binding customizations.
*/
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
if(topLevel!=null) {
this.errorReceiver = errorReceiver;
Unmarshaller u = BindInfo.getCustomizationUnmarshaller();
this.unmarshaller = u.getUnmarshallerHandler();
ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
v.setErrorHandler(errorReceiver);
loader = new ForkContentHandler(v,unmarshaller);
topLevel.applyAll(schema.getSchemas());
this.loader = null;
this.unmarshaller = null;
this.errorReceiver = null;
}
}
protected org.kuali.rice.core.impl.config.property.Config unmarshal(Unmarshaller unmarshaller, InputStream in)
throws SAXException, ParserConfigurationException, IOException,
IllegalStateException, JAXBException {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
XMLFilter filter = new ConfigNamespaceURIFilter();
filter.setParent(spf.newSAXParser().getXMLReader());
UnmarshallerHandler handler = unmarshaller.getUnmarshallerHandler();
filter.setContentHandler(handler);
filter.parse(new InputSource(in));
return (org.kuali.rice.core.impl.config.property.Config) handler.getResult();
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}
/**
* Creates a new instance that uses the specified
* Unmarshaller to unmarshal an object.
*
* <p>
* This JAXBResult object will use the specified Unmarshaller
* instance. It is the caller's responsibility not to use the
* same Unmarshaller for other purposes while it is being
* used by this object.
*
* <p>
* The primary purpose of this method is to allow the client
* to configure Unmarshaller. Unless you know what you are doing,
* it's easier and safer to pass a JAXBContext.
*
* @param _unmarshaller the unmarshaller. This parameter must not be null.
* @throws JAXBException if an error is encountered while creating the
* JAXBResult or the Unmarshaller parameter is null.
*/
public JAXBResult( Unmarshaller _unmarshaller ) throws JAXBException {
if( _unmarshaller == null )
throw new JAXBException(
Messages.format( Messages.RESULT_NULL_UNMARSHALLER ) );
this.unmarshallerHandler = _unmarshaller.getUnmarshallerHandler();
super.setHandler(unmarshallerHandler);
}