Java Code Examples for javax.xml.bind.Unmarshaller#Listener

The following examples show how to use javax.xml.bind.Unmarshaller#Listener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Loader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 2
Source File: Loader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 3
Source File: Loader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 4
Source File: Loader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 5
Source File: Loader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 6
Source File: Loader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 7
Source File: Loader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 8
Source File: Loader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 9
Source File: Loader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 10
Source File: Loader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 11
Source File: Loader.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 12
Source File: JsonProviderPrototypeServiceFactory.java    From aries-jax-rs-whiteboard with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: ScreenshotFolderPersistence.java    From recheck with GNU Affero General Public License v3.0 5 votes vote down vote up
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 ) );
			}
		}
	};
}
 
Example 14
Source File: XmlTransformer.java    From recheck with GNU Affero General Public License v3.0 5 votes vote down vote up
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 );
	}
}
 
Example 15
Source File: Loader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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());
    }
}
 
Example 16
Source File: Loader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 17
Source File: Jaxb2Marshaller.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Set the {@code Unmarshaller.Listener} to be registered with the JAXB {@code Unmarshaller}.
 */
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
	this.unmarshallerListener = unmarshallerListener;
}
 
Example 18
Source File: AbstractJAXBProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
    this.unmarshallerListener = unmarshallerListener;
}
 
Example 19
Source File: Jaxb2Marshaller.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Set the {@code Unmarshaller.Listener} to be registered with the JAXB {@code Unmarshaller}.
 */
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
	this.unmarshallerListener = unmarshallerListener;
}
 
Example 20
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the Unmarshaller.Listener that will be registered on the Unmarshallers
 * @param unmarshallerListener
 */
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
    this.unmarshallerListener = unmarshallerListener;
}