Java Code Examples for javax.xml.bind.Unmarshaller#getUnmarshallerHandler()

The following examples show how to use javax.xml.bind.Unmarshaller#getUnmarshallerHandler() . 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: SCDBasedBindingSet.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 2
Source File: JAXBConfigImpl.java    From rice with Educational Community License v2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: SCDBasedBindingSet.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 4
Source File: JaxbPersistenceFactory.java    From tomee with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: SCDBasedBindingSet.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 6
Source File: SCDBasedBindingSet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 7
Source File: SCDBasedBindingSet.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 8
Source File: SCDBasedBindingSet.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 9
Source File: SCDBasedBindingSet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 10
Source File: JAXBResult.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: JAXBResult.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: JAXBResult.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: JAXBResult.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: JAXBResult.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: JAXBResult.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 16
Source File: JAXBResult.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: JAXBResult.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source File: JAXBResult.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 19
Source File: JAXBResult.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: JAXBResult.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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);
}