< prev index next >

jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 


  26 package javax.xml.bind;
  27 
  28 import javax.xml.bind.annotation.adapters.XmlAdapter;
  29 import javax.xml.bind.attachment.AttachmentUnmarshaller;
  30 import javax.xml.validation.Schema;
  31 import java.io.Reader;
  32 
  33 /**
  34  * The {@code Unmarshaller} class governs the process of deserializing XML
  35  * data into newly created Java content trees, optionally validating the XML
  36  * data as it is unmarshalled.  It provides an overloading of unmarshal methods
  37  * for many different input kinds.
  38  *
  39  * <p>
  40  * Unmarshalling from a File:
  41  * <blockquote>
  42  *    <pre>
  43  *       JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
  44  *       Unmarshaller u = jc.createUnmarshaller();
  45  *       Object o = u.unmarshal( new File( "nosferatu.xml" ) );


 958      * Initially this property is set to {@code null}.
 959      *
 960      * @param schema Schema object to validate unmarshal operations against or null to disable validation
 961      * @throws UnsupportedOperationException could be thrown if this method is
 962      *         invoked on an Unmarshaller created from a JAXBContext referencing
 963      *         JAXB 1.0 mapped classes
 964      * @since 1.6, JAXB 2.0
 965      */
 966     public void setSchema( javax.xml.validation.Schema schema );
 967 
 968     /**
 969      * Get the JAXP 1.3 {@link javax.xml.validation.Schema Schema} object
 970      * being used to perform unmarshal-time validation.  If there is no
 971      * Schema set on the unmarshaller, then this method will return null
 972      * indicating that unmarshal-time validation will not be performed.
 973      * <p>
 974      * This method provides replacement functionality for the deprecated
 975      * {@link #isValidating()} API as well as access to the Schema object.
 976      * To determine if the Unmarshaller has validation enabled, simply
 977      * test the return type for null:
 978      * <p>
 979      * <pre>{@code
 980      *   boolean isValidating = u.getSchema()!=null;
 981      * }</pre>
 982      *
 983      * @return the Schema object being used to perform unmarshal-time
 984      *      validation or null if not present
 985      * @throws UnsupportedOperationException could be thrown if this method is
 986      *         invoked on an Unmarshaller created from a JAXBContext referencing
 987      *         JAXB 1.0 mapped classes
 988      * @since 1.6, JAXB 2.0
 989      */
 990     public javax.xml.validation.Schema getSchema();
 991 
 992     /**
 993      * Associates a configured instance of {@link XmlAdapter} with this unmarshaller.
 994      *
 995      * <p>
 996      * This is a convenience method that invokes {@code setAdapter(adapter.getClass(),adapter);}.
 997      *
 998      * @see #setAdapter(Class,XmlAdapter)


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 
  27 
  28 package javax.xml.bind;
  29 
  30 import javax.xml.bind.annotation.adapters.XmlAdapter;
  31 import javax.xml.bind.attachment.AttachmentUnmarshaller;
  32 import javax.xml.validation.Schema;
  33 import java.io.Reader;
  34 
  35 /**
  36  * The {@code Unmarshaller} class governs the process of deserializing XML
  37  * data into newly created Java content trees, optionally validating the XML
  38  * data as it is unmarshalled.  It provides an overloading of unmarshal methods
  39  * for many different input kinds.
  40  *
  41  * <p>
  42  * Unmarshalling from a File:
  43  * <blockquote>
  44  *    <pre>
  45  *       JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
  46  *       Unmarshaller u = jc.createUnmarshaller();
  47  *       Object o = u.unmarshal( new File( "nosferatu.xml" ) );


 960      * Initially this property is set to {@code null}.
 961      *
 962      * @param schema Schema object to validate unmarshal operations against or null to disable validation
 963      * @throws UnsupportedOperationException could be thrown if this method is
 964      *         invoked on an Unmarshaller created from a JAXBContext referencing
 965      *         JAXB 1.0 mapped classes
 966      * @since 1.6, JAXB 2.0
 967      */
 968     public void setSchema( javax.xml.validation.Schema schema );
 969 
 970     /**
 971      * Get the JAXP 1.3 {@link javax.xml.validation.Schema Schema} object
 972      * being used to perform unmarshal-time validation.  If there is no
 973      * Schema set on the unmarshaller, then this method will return null
 974      * indicating that unmarshal-time validation will not be performed.
 975      * <p>
 976      * This method provides replacement functionality for the deprecated
 977      * {@link #isValidating()} API as well as access to the Schema object.
 978      * To determine if the Unmarshaller has validation enabled, simply
 979      * test the return type for null:

 980      * <pre>{@code
 981      *   boolean isValidating = u.getSchema()!=null;
 982      * }</pre>
 983      *
 984      * @return the Schema object being used to perform unmarshal-time
 985      *      validation or null if not present
 986      * @throws UnsupportedOperationException could be thrown if this method is
 987      *         invoked on an Unmarshaller created from a JAXBContext referencing
 988      *         JAXB 1.0 mapped classes
 989      * @since 1.6, JAXB 2.0
 990      */
 991     public javax.xml.validation.Schema getSchema();
 992 
 993     /**
 994      * Associates a configured instance of {@link XmlAdapter} with this unmarshaller.
 995      *
 996      * <p>
 997      * This is a convenience method that invokes {@code setAdapter(adapter.getClass(),adapter);}.
 998      *
 999      * @see #setAdapter(Class,XmlAdapter)


< prev index next >