下面列出了javax.xml.bind.Unmarshaller#Listener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget());
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.getPrev().getTarget());
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.target);
}
if(listener!=null)
listener.afterUnmarshal(child, state.target);
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget());
}
if(listener!=null)
listener.afterUnmarshal(child, state.getTarget());
}
}
public <T> T fromXML( final InputStream in, final Unmarshaller.Listener listener ) {
try {
final JAXBContext jc = createJAXBContext( additionalClazzes );
final Unmarshaller unmarshaller = jc.createUnmarshaller();
unmarshaller.setEventHandler( new DefaultValidationEventHandler() );
unmarshaller.setListener( listener );
@SuppressWarnings( "unchecked" )
final T result = (T) unmarshaller.unmarshal( in );
return result;
} catch ( final JAXBException e ) {
throw new RuntimeException( e );
}
}
public Unmarshaller.Listener getUnmarshallListener() {
return new Unmarshaller.Listener() {
@Override
public void afterUnmarshal( final Object target, final Object parent ) {
if ( target instanceof Screenshot ) {
if ( !loadScreenshot( (Screenshot) target ) ) {
parentsWithIncorrectScreenshots.put( parent, (Screenshot) target );
}
} else if ( parentsWithIncorrectScreenshots.containsKey( target ) ) {
ReflectionUtilities.setChildInParentToNull( target, parentsWithIncorrectScreenshots.get( target ) );
}
}
};
}
JsonProviderPrototypeServiceFactory(
Dictionary<String, ?> properties,
Optional<TypeConverter> typeConverter,
Optional<Marshaller.Listener> marshallerListener,
Optional<Unmarshaller.Listener> unmarshallerListener,
Optional<SchemaHandler> schemaHandler
) {
_properties = properties;
_typeConverter = typeConverter;
_marshallerListener = marshallerListener;
_unmarshallerListener = unmarshallerListener;
_schemaHandler = schemaHandler;
}
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget());
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.getPrev().getTarget());
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget());
}
if(listener!=null)
listener.afterUnmarshal(child, state.getTarget());
}
}
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget());
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.getPrev().getTarget());
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget());
}
if(listener!=null)
listener.afterUnmarshal(child, state.getTarget());
}
}
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget());
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.getPrev().getTarget());
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget());
}
if(listener!=null)
listener.afterUnmarshal(child, state.getTarget());
}
}
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.getPrev().getTarget());
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.getPrev().getTarget());
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.getTarget());
}
if(listener!=null)
listener.afterUnmarshal(child, state.getTarget());
}
}
/**
* Fires the beforeUnmarshal event if necessary.
*
* @param state
* state of the newly create child object.
*/
protected final void fireBeforeUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasBeforeUnmarshalMethod()) {
beanInfo.invokeBeforeUnmarshalMethod(context.parent, child, state.prev.target);
}
if(listener!=null) {
listener.beforeUnmarshal(child, state.prev.target);
}
}
}
/**
* Fires the afterUnmarshal event if necessary.
*
* @param state
* state of the parent object
*/
protected final void fireAfterUnmarshal(JaxBeanInfo beanInfo, Object child, UnmarshallingContext.State state) throws SAXException {
// fire the event callback
if(beanInfo.lookForLifecycleMethods()) {
UnmarshallingContext context = state.getContext();
Unmarshaller.Listener listener = context.parent.getListener();
if(beanInfo.hasAfterUnmarshalMethod()) {
beanInfo.invokeAfterUnmarshalMethod(context.parent, child, state.target);
}
if(listener!=null)
listener.afterUnmarshal(child, state.target);
}
}
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
this.unmarshallerListener = unmarshallerListener;
}
/**
* Set the {@code Unmarshaller.Listener} to be registered with the JAXB {@code Unmarshaller}.
*/
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
this.unmarshallerListener = unmarshallerListener;
}
/**
* Set the {@code Unmarshaller.Listener} to be registered with the JAXB {@code Unmarshaller}.
*/
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
this.unmarshallerListener = unmarshallerListener;
}
/**
* Sets the Unmarshaller.Listener that will be registered on the Unmarshallers
* @param unmarshallerListener
*/
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
this.unmarshallerListener = unmarshallerListener;
}