Fix compiler warnings (#193)
* Fix compiler warnings
-explicit constructors
-raw types
-diamond operator
-redundant casts
-add override
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/Binder.java b/jaxb-api/src/main/java/jakarta/xml/bind/Binder.java
index 6543729..a340235 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/Binder.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/Binder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -15,23 +15,23 @@
import javax.xml.validation.Schema;
/**
- * Enable synchronization between XML infoset nodes and Jakarta XML Binding objects
+ * Enable synchronization between XML infoset nodes and Jakarta XML Binding objects
* representing same XML document.
*
* <p>
* An instance of this class maintains the association between XML nodes of
- * an infoset preserving view and a Jakarta XML Binding representation of an XML document.
+ * an infoset preserving view and a Jakarta XML Binding representation of an XML document.
* Navigation between the two views is provided by the methods
* {@link #getXMLNode(Object)} and {@link #getJAXBNode(Object)}.
- *
+ *
* <p>
- * Modifications can be made to either the infoset preserving view or the
- * Jakarta XML Binding representation of the document while the other view remains
- * unmodified. The binder is able to synchronize the changes made in the
+ * Modifications can be made to either the infoset preserving view or the
+ * Jakarta XML Binding representation of the document while the other view remains
+ * unmodified. The binder is able to synchronize the changes made in the
* modified view back into the other view using the appropriate
- * Binder update methods, {@link #updateXML(Object, Object)} or
+ * Binder update methods, {@link #updateXML(Object, Object)} or
* {@link #updateJAXB(Object)}.
- *
+ *
* <p>
* A typical usage scenario is the following:
* <ul>
@@ -40,36 +40,42 @@
* (Note to conserve resources, it is possible to only unmarshal a
* subtree of the XML infoset view to the Jakarta XML Binding view.)</li>
* <li>application access/updates Jakarta XML Binding view of XML document.</li>
- * <li>{@link #updateXML(Object)} synchronizes modifications to Jakarta XML Binding view
- * back into the XML infoset view. Update operation preserves as
+ * <li>{@link #updateXML(Object)} synchronizes modifications to Jakarta XML Binding view
+ * back into the XML infoset view. Update operation preserves as
* much of original XML infoset as possible (i.e. comments, PI, ...)</li>
* </ul>
- *
+ *
* <p>
- * A Binder instance is created using the factory method
+ * A Binder instance is created using the factory method
* {@link JAXBContext#createBinder()} or {@link JAXBContext#createBinder(Class)}.
*
* <p>
* The template parameter, <code>XmlNode</code>, is the
* root interface/class for the XML infoset preserving representation.
* A Binder implementation is required to minimally support
- * an <code>XmlNode</code> value of <code>org.w3c.dom.Node.class</code>.
- * A Binder implementation can support alternative XML infoset
+ * an <code>XmlNode</code> value of <code>org.w3c.dom.Node.class</code>.
+ * A Binder implementation can support alternative XML infoset
* preserving representations.
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
* Joseph Fialli
- *
+ *
* @since 1.6, JAXB 2.0
*/
public abstract class Binder<XmlNode> {
+
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected Binder() {}
+
/**
* Unmarshal XML infoset view to a Jakarta XML Binding object tree.
*
* <p>
* This method is similar to {@link Unmarshaller#unmarshal(Node)}
- * with the addition of maintaining the association between XML nodes
+ * with the addition of maintaining the association between XML nodes
* and the produced Jakarta XML Binding objects, enabling future update operations,
* {@link #updateXML(Object, Object)} or {@link #updateJAXB(Object)}.
*
@@ -81,11 +87,11 @@
* This method throws {@link UnmarshalException} when the Binder's
* {@link JAXBContext} does not have a mapping for the XML element name
* or the type, specifiable via {@code @xsi:type}, of {@code xmlNode}
- * to a Jakarta XML Binding mapped class. The method {@link #unmarshal(Object, Class)}
+ * to a Jakarta XML Binding mapped class. The method {@link #unmarshal(Object, Class)}
* enables an application to specify the Jakarta XML Binding mapped class that
* the {@code xmlNode} should be mapped to.
*
- * @param xmlNode
+ * @param xmlNode
* the document/element to unmarshal XML data from.
*
* @return
@@ -109,10 +115,10 @@
*
* <p>
* Implements <a href="Unmarshaller.html#unmarshalByDeclaredType">Unmarshal by Declared Type</a>
- *
+ *
* <p>
* This method is similar to {@link Unmarshaller#unmarshal(Node, Class)}
- * with the addition of maintaining the association between XML nodes
+ * with the addition of maintaining the association between XML nodes
* and the produced Jakarta XML Binding objects, enabling future update operations,
* {@link #updateXML(Object, Object)} or {@link #updateJAXB(Object)}.
*
@@ -120,13 +126,13 @@
* When {@link #getSchema()} is non-null, <code>xmlNode</code>
* and its descendants is validated during this operation.
*
- * @param xmlNode
+ * @param xmlNode
* the document/element to unmarshal XML data from.
* @param declaredType
* appropriate Jakarta XML Binding mapped class to hold {@code node}'s XML data.
*
* @return
- * <a href="JAXBElement.html">JAXBElement</a> representation
+ * <a href="JAXBElement.html">JAXBElement</a> representation
* of {@code node}
*
* @throws JAXBException
@@ -140,8 +146,8 @@
* If any of the input parameters are null
* @since 1.6, JAXB 2.0
*/
- public abstract <T> JAXBElement<T>
- unmarshal( XmlNode xmlNode, Class<T> declaredType )
+ public abstract <T> JAXBElement<T>
+ unmarshal( XmlNode xmlNode, Class<T> declaredType )
throws JAXBException;
/**
@@ -149,9 +155,9 @@
*
* <p>
* This method is similar to {@link Marshaller#marshal(Object, Node)}
- * with the addition of maintaining the association between Jakarta XML Binding objects
+ * with the addition of maintaining the association between Jakarta XML Binding objects
* and the produced XML nodes,
- * enabling future update operations such as
+ * enabling future update operations such as
* {@link #updateXML(Object, Object)} or {@link #updateJAXB(Object)}.
*
* <p>
@@ -159,7 +165,7 @@
* xml content is validated during this operation.
*
* @param jaxbObject
- * The content tree to be marshalled.
+ * The content tree to be marshalled.
* @param xmlNode
* The parameter must be a Node that accepts children.
*
@@ -170,7 +176,7 @@
* returns false from its {@code handleEvent} method or the
* {@code Binder} is unable to marshal {@code jaxbObject} (or any
* object reachable from {@code jaxbObject}).
- *
+ *
* @throws IllegalArgumentException
* If any of the method parameters are null
*/
@@ -190,7 +196,7 @@
* have associated Jakarta XML Binding objects, and not all Jakarta XML Binding objects have
* associated XML elements.
*
- * @param jaxbObject An instance that is reachable from a prior
+ * @param jaxbObject An instance that is reachable from a prior
* call to a bind or update method that returned
* a Jakarta XML Binding object tree.
*
@@ -300,7 +306,7 @@
* but it maybe
* a different object, for example when the name of the XML
* element has changed.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs updating corresponding Jakarta XML Binding mapped content.
* @throws IllegalArgumentException
@@ -332,8 +338,8 @@
* <p>
* The {@code ValidationEventHandler} will be called by the Jakarta XML Binding Provider
* if any validation errors are encountered during calls to any of the
- * Binder unmarshal, marshal and update methods.
- *
+ * Binder unmarshal, marshal and update methods.
+ *
* <p>
* Calling this method with a null parameter will cause the Binder
* to revert back to the default default event handler.
@@ -356,13 +362,13 @@
public abstract ValidationEventHandler getEventHandler() throws JAXBException;
/**
- *
+ *
* Set the particular property in the underlying implementation of
* {@code Binder}. This method can only be used to set one of
- * the standard Jakarta XML Binding defined unmarshal/marshal properties
+ * the standard Jakarta XML Binding defined unmarshal/marshal properties
* or a provider specific property for binder, unmarshal or marshal.
* Attempting to set an undefined property will result in
- * a PropertyException being thrown. See
+ * a PropertyException being thrown. See
* <a href="Unmarshaller.html#supportedProps">Supported Unmarshal Properties</a>
* and
* <a href="Marshaller.html#supportedProps">Supported Marshal Properties</a>.
@@ -384,10 +390,10 @@
* Get the particular property in the underlying implementation of
* {@code Binder}. This method can only
* be used to get one of
- * the standard Jakarta XML Binding defined unmarshal/marshal properties
- * or a provider specific property for binder, unmarshal or marshal.
+ * the standard Jakarta XML Binding defined unmarshal/marshal properties
+ * or a provider specific property for binder, unmarshal or marshal.
* Attempting to get an undefined property will result in
- * a PropertyException being thrown. See
+ * a PropertyException being thrown. See
* <a href="Unmarshaller.html#supportedProps">Supported Unmarshal Properties</a>
* and
* <a href="Marshaller.html#supportedProps">Supported Marshal Properties</a>.
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java b/jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
index 6c01465..65667d8 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
@@ -18,6 +18,7 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Map;
@@ -121,7 +122,7 @@
* The Class object of the type that is being cast to
* @return JAXBException to be thrown.
*/
- private static JAXBException handleClassCastException(Class originalType, Class targetType) {
+ private static JAXBException handleClassCastException(Class<?> originalType, Class<?> targetType) {
final URL targetTypeURL = which(targetType);
return new JAXBException(Messages.format(Messages.ILLEGAL_CAST,
@@ -135,13 +136,13 @@
* Create an instance of a class using the specified ClassLoader
*/
static JAXBContext newInstance(String contextPath,
- Class[] contextPathClasses,
+ Class<?>[] contextPathClasses,
String className,
ClassLoader classLoader,
- Map properties) throws JAXBException {
+ Map<String, ?> properties) throws JAXBException {
try {
- Class spFactory = ServiceLoaderUtil.safeLoadClass(className, DEFAULT_FACTORY_CLASS, classLoader);
+ Class<?> spFactory = ServiceLoaderUtil.safeLoadClass(className, DEFAULT_FACTORY_CLASS, classLoader);
return newInstance(contextPath, contextPathClasses, spFactory, classLoader, properties);
} catch (ClassNotFoundException x) {
throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), x);
@@ -161,10 +162,10 @@
}
static JAXBContext newInstance(String contextPath,
- Class[] contextPathClasses,
- Class spFactory,
+ Class<?>[] contextPathClasses,
+ Class<?> spFactory,
ClassLoader classLoader,
- Map properties) throws JAXBException {
+ Map<String, ?> properties) throws JAXBException {
try {
@@ -225,7 +226,7 @@
return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
- return implClass.newInstance();
+ return implClass.getConstructor().newInstance();
}
});
}
@@ -239,16 +240,16 @@
/**
* Create an instance of a class using the thread context ClassLoader
*/
- private static JAXBContext newInstance(Class[] classes, Map properties, String className) throws JAXBException {
+ private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className) throws JAXBException {
return newInstance(classes, properties, className, getContextClassLoader());
}
/**
* Create an instance of a class using passed in ClassLoader
*/
- private static JAXBContext newInstance(Class[] classes, Map properties, String className, ClassLoader loader) throws JAXBException {
+ private static JAXBContext newInstance(Class<?>[] classes, Map<String, ?> properties, String className, ClassLoader loader) throws JAXBException {
- Class spi;
+ Class<?> spi;
try {
spi = ServiceLoaderUtil.safeLoadClass(className, DEFAULT_FACTORY_CLASS, loader);
} catch (ClassNotFoundException e) {
@@ -263,9 +264,9 @@
return newInstance(classes, properties, spi);
}
- static JAXBContext newInstance(Class[] classes,
- Map properties,
- Class spFactory) throws JAXBException {
+ static JAXBContext newInstance(Class<?>[] classes,
+ Map<String, ?> properties,
+ Class<?> spFactory) throws JAXBException {
try {
ModuleUtil.delegateAddOpensToImplModule(classes, spFactory);
@@ -292,7 +293,7 @@
static JAXBContext find(String factoryId,
String contextPath,
ClassLoader classLoader,
- Map properties) throws JAXBException {
+ Map<String, ?> properties) throws JAXBException {
if (contextPath == null || contextPath.isEmpty()) {
// no context is specified
@@ -300,7 +301,7 @@
}
//ModuleUtil is mr-jar class, scans context path for jaxb classes on jdk9 and higher
- Class[] contextPathClasses = ModuleUtil.getClassesFromContextPath(contextPath, classLoader);
+ Class<?>[] contextPathClasses = ModuleUtil.getClassesFromContextPath(contextPath, classLoader);
//first try with classloader#getResource
String factoryClassName = jaxbProperties(contextPath, classLoader, factoryId);
@@ -329,7 +330,7 @@
factoryName = firstByServiceLoaderDeprecated(JAXBContext.class, classLoader);
if (factoryName != null) return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties);
- Class ctxFactory = (Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader(
+ Class<?> ctxFactory = (Class<?>) ServiceLoaderUtil.lookupUsingOSGiServiceLoader(
"jakarta.xml.bind.JAXBContext", logger);
if (ctxFactory != null) {
@@ -345,7 +346,7 @@
// search for jaxb.properties in the class loader of each class first
logger.fine("Searching jaxb.properties");
- for (final Class c : classes) {
+ for (final Class<?> c : classes) {
// this classloader is used only to load jaxb.properties, so doing this should be safe.
// this is possible for primitives, arrays, and classes that are
// loaded by poorly implemented ClassLoaders
@@ -395,7 +396,7 @@
if (className != null) return newInstance(classes, properties, className, loader);
logger.fine("Trying to create the platform default provider");
- Class ctxFactoryClass =
+ Class<?> ctxFactoryClass =
(Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader("jakarta.xml.bind.JAXBContext", logger);
if (ctxFactoryClass != null) {
@@ -516,7 +517,7 @@
* @return
* the URL for the class or null if it wasn't found
*/
- static URL which(Class clazz, ClassLoader loader) {
+ static URL which(Class<?> clazz, ClassLoader loader) {
String classnameAsResource = clazz.getName().replace('.', '/') + ".class";
@@ -539,7 +540,7 @@
* @return
* the URL for the class or null if it wasn't found
*/
- static URL which(Class clazz) {
+ static URL which(Class<?> clazz) {
return which(clazz, getClassClassLoader(clazz));
}
@@ -548,10 +549,10 @@
if (System.getSecurityManager() == null) {
return Thread.currentThread().getContextClassLoader();
} else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
@Override
- public java.lang.Object run() {
+ public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
});
@@ -559,14 +560,14 @@
}
@SuppressWarnings("unchecked")
- private static ClassLoader getClassClassLoader(final Class c) {
+ private static ClassLoader getClassClassLoader(final Class<?> c) {
if (System.getSecurityManager() == null) {
return c.getClassLoader();
} else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
@Override
- public java.lang.Object run() {
+ public ClassLoader run() {
return c.getClassLoader();
}
});
@@ -577,10 +578,10 @@
if (System.getSecurityManager() == null) {
return ClassLoader.getSystemClassLoader();
} else {
- return (ClassLoader) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
@Override
- public java.lang.Object run() {
+ public ClassLoader run() {
return ClassLoader.getSystemClassLoader();
}
});
@@ -589,7 +590,7 @@
// ServiceLoaderUtil.firstByServiceLoaderDeprecated should be used instead.
@Deprecated
- static String firstByServiceLoaderDeprecated(Class spiClass,
+ static String firstByServiceLoaderDeprecated(Class<?> spiClass,
ClassLoader classLoader) throws JAXBException {
final String jaxbContextFQCN = spiClass.getName();
@@ -645,8 +646,8 @@
return null;
}
- private static String jaxbProperties(Class[] classesFromContextPath, String factoryId) throws JAXBException {
- for (Class c : classesFromContextPath) {
+ private static String jaxbProperties(Class<?>[] classesFromContextPath, String factoryId) throws JAXBException {
+ for (Class<?> c : classesFromContextPath) {
URL jaxbPropertiesUrl = getResourceUrl(c, "jaxb.properties");
if (jaxbPropertiesUrl != null) {
return classNameFromPackageProperties(jaxbPropertiesUrl, factoryId, JAXB_CONTEXT_FACTORY_DEPRECATED);
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java b/jaxb-api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java
index ef7bd09..7329565 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -46,10 +46,12 @@
protected DatatypeConverterImpl() {
}
+ @Override
public String parseString(String lexicalXSDString) {
return lexicalXSDString;
}
+ @Override
public BigInteger parseInteger(String lexicalXSDInteger) {
return _parseInteger(lexicalXSDInteger);
}
@@ -58,6 +60,7 @@
return new BigInteger(removeOptionalPlus(WhiteSpaceProcessor.trim(s)).toString());
}
+ @Override
public String printInteger(BigInteger val) {
return _printInteger(val);
}
@@ -66,6 +69,7 @@
return val.toString();
}
+ @Override
public int parseInt(String s) {
return _parseInt(s);
}
@@ -104,6 +108,7 @@
return r * sign;
}
+ @Override
public long parseLong(String lexicalXSLong) {
return _parseLong(lexicalXSLong);
}
@@ -112,6 +117,7 @@
return Long.parseLong(removeOptionalPlus(WhiteSpaceProcessor.trim(s)).toString());
}
+ @Override
public short parseShort(String lexicalXSDShort) {
return _parseShort(lexicalXSDShort);
}
@@ -120,6 +126,7 @@
return (short) _parseInt(s);
}
+ @Override
public String printShort(short val) {
return _printShort(val);
}
@@ -128,6 +135,7 @@
return String.valueOf(val);
}
+ @Override
public BigDecimal parseDecimal(String content) {
return _parseDecimal(content);
}
@@ -154,6 +162,7 @@
// 1 (not 1.0) is returned from "1.000"
}
+ @Override
public float parseFloat(String lexicalXSDFloat) {
return _parseFloat(lexicalXSDFloat);
}
@@ -195,6 +204,7 @@
return Float.parseFloat(s);
}
+ @Override
public String printFloat(float v) {
return _printFloat(v);
}
@@ -212,6 +222,7 @@
return String.valueOf(v);
}
+ @Override
public double parseDouble(String lexicalXSDDouble) {
return _parseDouble(lexicalXSDDouble);
}
@@ -240,9 +251,10 @@
return Double.parseDouble(val);
}
+ @Override
public boolean parseBoolean(String lexicalXSDBoolean) {
Boolean b = _parseBoolean(lexicalXSDBoolean);
- return (b == null) ? false : b.booleanValue();
+ return (b == null) ? false : b;
}
public static Boolean _parseBoolean(CharSequence literal) {
@@ -317,6 +329,7 @@
// throw new IllegalArgumentException("String \"" + literal + "\" is not valid boolean value.");
}
+ @Override
public String printBoolean(boolean val) {
return val ? "true" : "false";
}
@@ -325,6 +338,7 @@
return val ? "true" : "false";
}
+ @Override
public byte parseByte(String lexicalXSDByte) {
return _parseByte(lexicalXSDByte);
}
@@ -333,6 +347,7 @@
return (byte) _parseInt(literal);
}
+ @Override
public String printByte(byte val) {
return _printByte(val);
}
@@ -341,6 +356,7 @@
return String.valueOf(val);
}
+ @Override
public QName parseQName(String lexicalXSDQName, NamespaceContext nsc) {
return _parseQName(lexicalXSDQName, nsc);
}
@@ -398,6 +414,7 @@
return new QName(uri, localPart, prefix);
}
+ @Override
public Calendar parseDateTime(String lexicalXSDDateTime) {
return _parseDateTime(lexicalXSDDateTime);
}
@@ -407,6 +424,7 @@
return datatypeFactory.newXMLGregorianCalendar(val).toGregorianCalendar();
}
+ @Override
public String printDateTime(Calendar val) {
return _printDateTime(val);
}
@@ -415,10 +433,12 @@
return CalendarFormatter.doFormat("%Y-%M-%DT%h:%m:%s%z", val);
}
+ @Override
public byte[] parseBase64Binary(String lexicalXSDBase64Binary) {
return _parseBase64Binary(lexicalXSDBase64Binary);
}
+ @Override
public byte[] parseHexBinary(String s) {
final int len = s.length();
@@ -456,6 +476,7 @@
}
private static final char[] hexCode = "0123456789ABCDEF".toCharArray();
+ @Override
public String printHexBinary(byte[] data) {
StringBuilder r = new StringBuilder(data.length * 2);
for (byte b : data) {
@@ -465,30 +486,37 @@
return r.toString();
}
+ @Override
public long parseUnsignedInt(String lexicalXSDUnsignedInt) {
return _parseLong(lexicalXSDUnsignedInt);
}
+ @Override
public String printUnsignedInt(long val) {
return _printLong(val);
}
+ @Override
public int parseUnsignedShort(String lexicalXSDUnsignedShort) {
return _parseInt(lexicalXSDUnsignedShort);
}
+ @Override
public Calendar parseTime(String lexicalXSDTime) {
return datatypeFactory.newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar();
}
+ @Override
public String printTime(Calendar val) {
return CalendarFormatter.doFormat("%h:%m:%s%z", val);
}
+ @Override
public Calendar parseDate(String lexicalXSDDate) {
return datatypeFactory.newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar();
}
+ @Override
public String printDate(Calendar val) {
return _printDate(val);
}
@@ -497,16 +525,19 @@
return CalendarFormatter.doFormat((new StringBuilder("%Y-%M-%D").append("%z")).toString(),val);
}
+ @Override
public String parseAnySimpleType(String lexicalXSDAnySimpleType) {
return lexicalXSDAnySimpleType;
// return (String)SimpleURType.theInstance._createValue( lexicalXSDAnySimpleType, null );
}
+ @Override
public String printString(String val) {
// return StringType.theInstance.convertToLexicalValue( val, null );
return val;
}
+ @Override
public String printInt(int val) {
return _printInt(val);
}
@@ -515,6 +546,7 @@
return String.valueOf(val);
}
+ @Override
public String printLong(long val) {
return _printLong(val);
}
@@ -523,6 +555,7 @@
return String.valueOf(val);
}
+ @Override
public String printDecimal(BigDecimal val) {
return _printDecimal(val);
}
@@ -531,6 +564,7 @@
return val.toPlainString();
}
+ @Override
public String printDouble(double v) {
return _printDouble(v);
}
@@ -548,6 +582,7 @@
return String.valueOf(v);
}
+ @Override
public String printQName(QName val, NamespaceContext nsc) {
return _printQName(val, nsc);
}
@@ -567,14 +602,17 @@
return qname;
}
+ @Override
public String printBase64Binary(byte[] val) {
return _printBase64Binary(val);
}
+ @Override
public String printUnsignedShort(int val) {
return String.valueOf(val);
}
+ @Override
public String printAnySimpleType(String val) {
return val;
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/GetPropertyAction.java b/jaxb-api/src/main/java/jakarta/xml/bind/GetPropertyAction.java
index 40bd122..607eda3 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/GetPropertyAction.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/GetPropertyAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -23,6 +23,7 @@
this.propertyName = propertyName;
}
+ @Override
public String run() {
return System.getProperty(propertyName);
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/JAXB.java b/jaxb-api/src/main/java/jakarta/xml/bind/JAXB.java
index 54ff0e9..b3606fc 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/JAXB.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/JAXB.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -80,7 +80,7 @@
*/
public final class JAXB {
/**
- * No instanciation is allowed.
+ * No instantiation is allowed.
*/
private JAXB() {}
@@ -88,10 +88,10 @@
* To improve the performance, we'll cache the last {@link JAXBContext} used.
*/
private static final class Cache {
- final Class type;
+ final Class<?> type;
final JAXBContext context;
- public Cache(Class type) throws JAXBException {
+ public Cache(Class<?> type) throws JAXBException {
this.type = type;
this.context = JAXBContext.newInstance(type);
}
@@ -121,7 +121,7 @@
// overwrite the cache
Cache d = new Cache(type);
- cache = new WeakReference<Cache>(d);
+ cache = new WeakReference<>(d);
return d.context;
}
@@ -151,9 +151,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -169,9 +167,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -188,9 +184,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -206,9 +200,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -225,9 +217,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -242,9 +232,7 @@
try {
JAXBElement<T> item = getContext(type).createUnmarshaller().unmarshal(toSource(xml), type);
return item.getValue();
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
@@ -535,6 +523,7 @@
* @throws DataBindingException
* If the operation fails, such as due to I/O error, unbindable classes.
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
private static void _marshal( Object jaxbObject, Object xml ) {
try {
JAXBContext context;
@@ -554,14 +543,12 @@
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
m.marshal(jaxbObject, toResult(xml));
- } catch (JAXBException e) {
- throw new DataBindingException(e);
- } catch (IOException e) {
+ } catch (JAXBException | IOException e) {
throw new DataBindingException(e);
}
}
- private static String inferName(Class clazz) {
+ private static String inferName(Class<?> clazz) {
// XXX - behaviour of this method must be same as of Introspector.decapitalize
// which is not used to avoid dependency on java.desktop
String simpleName = clazz.getSimpleName();
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBContext.java b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBContext.java
index f53a4fe..5967785 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBContext.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBContext.java
@@ -787,6 +787,7 @@
} else {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<ClassLoader>() {
+ @Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBElement.java b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBElement.java
index a760132..811bb80 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBElement.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -16,32 +16,32 @@
/**
* <p>Jakarta XML Binding representation of an Xml Element.</p>
*
- * <p>This class represents information about an Xml Element from both the element
+ * <p>This class represents information about an Xml Element from both the element
* declaration within a schema and the element instance value within an xml document
* with the following properties
* <ul>
* <li>element's xml tag <b>{@code name}</b></li>
- * <li><b>{@code value}</b> represents the element instance's atttribute(s) and content model</li>
+ * <li><b>{@code value}</b> represents the element instance's attribute(s) and content model</li>
* <li>element declaration's <b>{@code declaredType}</b> ({@code xs:element @type} attribute)</li>
* <li><b>{@code scope}</b> of element declaration</li>
* <li>boolean <b>{@code nil}</b> property. (element instance's <b>{@code xsi:nil}</b> attribute)</li>
* </ul>
- *
+ *
* <p>The {@code declaredType} and {@code scope} property are the
* Jakarta XML Binding class binding for the xml type definition.
* </p>
- *
+ *
* <p><b>{@code Scope}</b> is either {@link GlobalScope} or the Java class representing the
* complex type definition containing the schema element declaration.
* </p>
- *
+ *
* <p>There is a property constraint that if <b>{@code value}</b> is {@code null},
* then {@code nil} must be {@code true}. The converse is not true to enable
* representing a nil element with attribute(s). If {@code nil} is true, it is possible
* that {@code value} is non-null so it can hold the value of the attributes
* associated with a nil element.
* </p>
- *
+ *
* @author Kohsuke Kawaguchi, Joe Fialli
* @since 1.6, JAXB 2.0
*/
@@ -57,13 +57,13 @@
/** Scope of xml element declaration representing this xml element instance.
* Can be one of the following values:
* - {@link GlobalScope} for global xml element declaration.
- * - local element declaration has a scope set to the Java class
+ * - local element declaration has a scope set to the Java class
* representation of complex type defintion containing
- * xml element declaration.
+ * xml element declaration.
*/
- final protected Class scope;
+ final protected Class<?> scope;
- /** xml element value.
+ /** xml element value.
Represents content model and attributes of an xml element instance. */
protected T value;
@@ -73,11 +73,13 @@
/**
* Designates global scope for an xml element.
*/
- public static final class GlobalScope {}
+ public static final class GlobalScope {
+ private GlobalScope() {}
+ }
/**
* <p>Construct an xml element instance.</p>
- *
+ *
* @param name Java binding of xml element tag name
* @param declaredType Java binding of xml element declaration's type
* @param scope
@@ -88,9 +90,9 @@
* @see #getScope()
* @see #isTypeSubstituted()
*/
- public JAXBElement(QName name,
- Class<T> declaredType,
- Class scope,
+ public JAXBElement(QName name,
+ Class<T> declaredType,
+ Class<?> scope,
T value) {
if(declaredType==null || name==null)
throw new IllegalArgumentException();
@@ -138,7 +140,7 @@
/**
* <p>Return the content model and attribute values for this element.</p>
- *
+ *
* <p>See {@link #isNil()} for a description of a property constraint when
* this value is {@code null}</p>
*/
@@ -152,10 +154,10 @@
* @see #isGlobalScope()
* @return {@code GlobalScope.class} if this element is of global scope.
*/
- public Class getScope() {
+ public Class<?> getScope() {
return scope;
}
-
+
/**
* <p>Returns {@code true} iff this element instance content model
* is nil.</p>
@@ -171,15 +173,15 @@
/**
* <p>Set whether this element has nil content.</p>
- *
+ *
* @see #isNil()
*/
public void setNil(boolean value) {
this.nil = value;
}
-
- /* Convenience methods
- * (Not necessary but they do unambiguously conceptualize
+
+ /* Convenience methods
+ * (Not necessary but they do unambiguously conceptualize
* the rationale behind this class' fields.)
*/
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBException.java b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBException.java
index e53709d..fa312ef 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBException.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -22,14 +22,14 @@
* @since 1.6, JAXB 1.0
*/
public class JAXBException extends Exception {
-
- /**
+
+ /**
* Vendor specific error code
*
*/
private String errorCode;
- /**
+ /**
* Exception reference
*
*/
@@ -37,8 +37,8 @@
static final long serialVersionUID = -5621384651494307979L;
- /**
- * Construct a JAXBException with the specified detail message. The
+ /**
+ * Construct a JAXBException with the specified detail message. The
* errorCode and linkedException will default to null.
*
* @param message a description of the exception
@@ -47,8 +47,8 @@
this( message, null, null );
}
- /**
- * Construct a JAXBException with the specified detail message and vendor
+ /**
+ * Construct a JAXBException with the specified detail message and vendor
* specific errorCode. The linkedException will default to null.
*
* @param message a description of the exception
@@ -58,7 +58,7 @@
this( message, errorCode, null );
}
- /**
+ /**
* Construct a JAXBException with a linkedException. The detail message and
* vendor specific errorCode will default to null.
*
@@ -67,9 +67,9 @@
public JAXBException(Throwable exception) {
this( null, null, exception );
}
-
- /**
- * Construct a JAXBException with the specified detail message and
+
+ /**
+ * Construct a JAXBException with the specified detail message and
* linkedException. The errorCode will default to null.
*
* @param message a description of the exception
@@ -78,9 +78,9 @@
public JAXBException(String message, Throwable exception) {
this( message, null, exception );
}
-
- /**
- * Construct a JAXBException with the specified detail message, vendor
+
+ /**
+ * Construct a JAXBException with the specified detail message, vendor
* specific errorCode, and linkedException.
*
* @param message a description of the exception
@@ -92,8 +92,8 @@
this.errorCode = errorCode;
this.linkedException = exception;
}
-
- /**
+
+ /**
* Get the vendor specific error code
*
* @return a string specifying the vendor specific error code
@@ -103,7 +103,7 @@
}
/**
- * Get the linked exception
+ * Get the linked exception
*
* @return the linked Exception, null if none exists
*/
@@ -114,20 +114,21 @@
/**
* Add a linked Exception.
*
- * @param exception the linked Exception (A null value is permitted and
+ * @param exception the linked Exception (A null value is permitted and
* indicates that the linked exception does not exist or
* is unknown).
*/
public void setLinkedException( Throwable exception ) {
this.linkedException = exception;
}
-
+
/**
* Returns a short description of this JAXBException.
*
*/
+ @Override
public String toString() {
- return linkedException == null ?
+ return linkedException == null ?
super.toString() :
super.toString() + "\n - with linked exception:\n[" +
linkedException.toString()+ "]";
@@ -139,6 +140,7 @@
*
* @param s PrintStream to use for output
*/
+ @Override
public void printStackTrace( java.io.PrintStream s ) {
super.printStackTrace(s);
}
@@ -148,6 +150,7 @@
* of the linkedException if it is non-null) to {@code System.err}.
*
*/
+ @Override
public void printStackTrace() {
super.printStackTrace();
}
@@ -158,6 +161,7 @@
*
* @param s PrintWriter to use for output
*/
+ @Override
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java
index 2a3062e..71ff142 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -16,14 +16,14 @@
* Provide access to Jakarta XML Binding xml binding data for a Jakarta XML Binding object.
*
* <p>
- * Intially, the intent of this class is to just conceptualize how
- * a Jakarta XML Binding application developer can access xml binding information,
+ * Initially, the intent of this class is to just conceptualize how
+ * a Jakarta XML Binding application developer can access xml binding information,
* independent if binding model is java to schema or schema to java.
* Since accessing the XML element name related to a Jakarta XML Binding element is
* a highly requested feature, demonstrate access to this
* binding information.
*
- * The factory method to get a <code>JAXBIntrospector</code> instance is
+ * The factory method to get a <code>JAXBIntrospector</code> instance is
* {@link JAXBContext#createJAXBIntrospector()}.
*
* @see JAXBContext#createJAXBIntrospector()
@@ -31,12 +31,17 @@
*/
public abstract class JAXBIntrospector {
- /**
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected JAXBIntrospector() {}
+
+ /**
* <p>Return true if <code>object</code> represents a Jakarta XML Binding element.</p>
* <p>Parameter <code>object</code> is a Jakarta XML Binding element for following cases:
* <ol>
* <li>It is an instance of <code>jakarta.xml.bind.JAXBElement</code>.</li>
- * <li>The class of <code>object</code> is annotated with
+ * <li>The class of <code>object</code> is annotated with
* <code>@XmlRootElement</code>.
* </li>
* </ol>
@@ -49,7 +54,7 @@
* <p>Get xml element qname for <code>jaxbElement</code>.</p>
*
* @param jaxbElement is an object that {@link #isElement(Object)} returned true.
- *
+ *
* @return xml element qname associated with jaxbElement;
* null if <code>jaxbElement</code> is not a JAXBElement.
*/
@@ -58,7 +63,7 @@
/**
* <p>Get the element value of a Jakarta XML Binding element.</p>
*
- * <p>Convenience method to abstract whether working with either
+ * <p>Convenience method to abstract whether working with either
* a jakarta.xml.bind.JAXBElement instance or an instance of
* {@code @XmlRootElement} annotated Java class.</p>
*
@@ -70,7 +75,7 @@
if (jaxbElement instanceof JAXBElement) {
return ((JAXBElement)jaxbElement).getValue();
} else {
- // assume that class of this instance is
+ // assume that class of this instance is
// annotated with @XmlRootElement.
return jaxbElement;
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/Marshaller.java b/jaxb-api/src/main/java/jakarta/xml/bind/Marshaller.java
index f4decfa..d3d1e17 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/Marshaller.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/Marshaller.java
@@ -32,7 +32,7 @@
* Marshaller m = jc.createMarshaller();
* </pre>
* </blockquote>
- *
+ *
* <p>
* Marshalling to a File:
* <blockquote>
@@ -47,7 +47,7 @@
* <blockquote>
* <pre>
* // assume MyContentHandler instanceof ContentHandler
- * m.marshal( element, new MyContentHandler() );
+ * m.marshal( element, new MyContentHandler() );
* </pre>
* </blockquote>
*
@@ -96,7 +96,7 @@
* <blockquote>
* <pre>
* DOMResult result = new DOMResult();
- *
+ *
* m.marshal( element, result );
* </pre>
* </blockquote>
@@ -106,7 +106,7 @@
* <blockquote>
* <pre>
* StreamResult result = new StreamResult( System.out );
- *
+ *
* m.marshal( element, result );
* </pre>
* </blockquote>
@@ -115,9 +115,9 @@
* Marshalling to a javax.xml.stream.XMLStreamWriter:
* <blockquote>
* <pre>
- * XMLStreamWriter xmlStreamWriter =
+ * XMLStreamWriter xmlStreamWriter =
* XMLOutputFactory.newInstance().createXMLStreamWriter( ... );
- *
+ *
* m.marshal( element, xmlStreamWriter );
* </pre>
* </blockquote>
@@ -126,9 +126,9 @@
* Marshalling to a javax.xml.stream.XMLEventWriter:
* <blockquote>
* <pre>
- * XMLEventWriter xmlEventWriter =
+ * XMLEventWriter xmlEventWriter =
* XMLOutputFactory.newInstance().createXMLEventWriter( ... );
- *
+ *
* m.marshal( element, xmlEventWriter );
* </pre>
* </blockquote>
@@ -139,15 +139,15 @@
* <blockquote>
* The first parameter of the overloaded
* {@code Marshaller.marshal(java.lang.Object, ...)} methods must be a
- * Jakarta XML Binding element as computed by
+ * Jakarta XML Binding element as computed by
* {@link JAXBIntrospector#isElement(java.lang.Object)};
* otherwise, a {@code Marshaller.marshal} method must throw a
- * {@link MarshalException}. There exist two mechanisms
+ * {@link MarshalException}. There exist two mechanisms
* to enable marshalling an instance that is not a Jakarta XML Binding element.
- * One method is to wrap the instance as a value of a {@link JAXBElement},
+ * One method is to wrap the instance as a value of a {@link JAXBElement},
* and pass the wrapper element as the first parameter to
* a {@code Marshaller.marshal} method. For java to schema binding, it
- * is also possible to simply annotate the instance's class with
+ * is also possible to simply annotate the instance's class with
* @{@link XmlRootElement}.
* </blockquote>
*
@@ -156,30 +156,30 @@
* <blockquote>
* By default, the Marshaller will use UTF-8 encoding when generating XML data
* to a {@code java.io.OutputStream}, or a {@code java.io.Writer}. Use the
- * {@link #setProperty(String,Object) setProperty} API to change the output
+ * {@link #setProperty(String,Object) setProperty} API to change the output
* encoding used during these marshal operations. Client applications are
* expected to supply a valid character encoding name as defined in the
* <a href="http://www.w3.org/TR/2000/REC-xml-20001006#charencoding">W3C XML 1.0
* Recommendation</a> and supported by your Java Platform.
* </blockquote>
- *
+ *
* <p>
* <b>Validation and Well-Formedness</b><br>
* <blockquote>
* <p>
* Client applications are not required to validate the Java content tree prior
- * to calling any of the marshal API's. Furthermore, there is no requirement
+ * to calling any of the marshal API's. Furthermore, there is no requirement
* that the Java content tree be valid with respect to its original schema in
- * order to marshal it back into XML data. Different Jakarta XML Binding Providers will
+ * order to marshal it back into XML data. Different Jakarta XML Binding Providers will
* support marshalling invalid Java content trees at varying levels, however
- * all Jakarta XML Binding Providers must be able to marshal a valid content tree back to
+ * all Jakarta XML Binding Providers must be able to marshal a valid content tree back to
* XML data. A Jakarta XML Binding Provider must throw a {@code MarshalException} when it
* is unable to complete the marshal operation due to invalid content. Some
* Jakarta XML Binding Providers will fully allow marshalling invalid content, others will fail
* on the first validation error.
* <p>
* Even when schema validation is not explictly enabled for the marshal operation,
- * it is possible that certain types of validation events will be detected
+ * it is possible that certain types of validation events will be detected
* during the operation. Validation events will be reported to the registered
* event handler. If the client application has not registered an event handler
* prior to invoking one of the marshal API's, then events will be delivered to
@@ -187,7 +187,7 @@
* encountering the first error or fatal error. Note that for Jakarta XML Binding and
* later versions, {@link jakarta.xml.bind.helpers.DefaultValidationEventHandler} is
* no longer used.
- *
+ *
* </blockquote>
*
* <p>
@@ -205,31 +205,31 @@
* <dt>{@code jaxb.formatted.output} - value must be a java.lang.Boolean</dt>
* <dd>This property controls whether or not the Marshaller will format
* the resulting XML data with line breaks and indentation. A
- * true value for this property indicates human readable indented
+ * true value for this property indicates human readable indented
* xml data, while a false value indicates unformatted xml data.
- * The Marshaller will default to false (unformatted) if this
+ * The Marshaller will default to false (unformatted) if this
* property is not specified.</dd>
* <dt>{@code jaxb.schemaLocation} - value must be a java.lang.String</dt>
* <dd>This property allows the client application to specify an
- * xsi:schemaLocation attribute in the generated XML data. The format of
- * the schemaLocation attribute value is discussed in an easy to
- * understand, non-normative form in
- * <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">Section 5.6
- * of the W3C XML Schema Part 0: Primer</a> and specified in
+ * xsi:schemaLocation attribute in the generated XML data. The format of
+ * the schemaLocation attribute value is discussed in an easy to
+ * understand, non-normative form in
+ * <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">Section 5.6
+ * of the W3C XML Schema Part 0: Primer</a> and specified in
* <a href="http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
* Section 2.6 of the W3C XML Schema Part 1: Structures</a>.</dd>
* <dt>{@code jaxb.noNamespaceSchemaLocation} - value must be a java.lang.String</dt>
* <dd>This property allows the client application to specify an
- * xsi:noNamespaceSchemaLocation attribute in the generated XML
- * data. The format of the schemaLocation attribute value is discussed in
- * an easy to understand, non-normative form in
- * <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">Section 5.6
- * of the W3C XML Schema Part 0: Primer</a> and specified in
+ * xsi:noNamespaceSchemaLocation attribute in the generated XML
+ * data. The format of the schemaLocation attribute value is discussed in
+ * an easy to understand, non-normative form in
+ * <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">Section 5.6
+ * of the W3C XML Schema Part 0: Primer</a> and specified in
* <a href="http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
* Section 2.6 of the W3C XML Schema Part 1: Structures</a>.</dd>
* <dt>{@code jaxb.fragment} - value must be a java.lang.Boolean</dt>
* <dd>This property determines whether or not document level events will be
- * generated by the Marshaller. If the property is not specified, the
+ * generated by the Marshaller. If the property is not specified, the
* default is {@code false}. This property has different implications depending
* on which marshal api you are using - when this property is set to true:<br>
* <ul>
@@ -254,7 +254,7 @@
* </dd>
* </dl>
* </blockquote>
- *
+ *
* <p>
* <a id="marshalEventCallback"></a>
* <b>Marshal Event Callbacks</b><br>
@@ -267,22 +267,22 @@
* of marshal events in one callback method rather than by type event callbacks.
*
* <p>
- * Class defined event callback methods allow any Jakarta XML Binding mapped class to specify
+ * Class defined event callback methods allow any Jakarta XML Binding mapped class to specify
* its own specific callback methods by defining methods with the following method signatures:
* <blockquote>
* <pre>
* // Invoked by Marshaller after it has created an instance of this object.
* boolean beforeMarshal(Marshaller);
- *
+ *
* // Invoked by Marshaller after it has marshalled all properties of this object.
* void afterMarshal(Marshaller);
* </pre>
* </blockquote>
* The class defined event callback methods should be used when the callback method requires
- * access to non-public methods and/or fields of the class.
+ * access to non-public methods and/or fields of the class.
* <p>
- * The external listener callback mechanism enables the registration of a {@link Listener}
- * instance with a {@link Marshaller#setListener(Listener)}. The external listener receives all callback events,
+ * The external listener callback mechanism enables the registration of a {@link Listener}
+ * instance with a {@link Marshaller#setListener(Listener)}. The external listener receives all callback events,
* allowing for more centralized processing than per class defined callback methods.
* <p>
* The 'class defined' and external listener event callback methods are independent of each other,
@@ -291,7 +291,7 @@
* <p>
* An event callback method throwing an exception terminates the current marshal process.
* </blockquote>
- *
+ *
* @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext
* @see Unmarshaller
@@ -307,8 +307,8 @@
"jaxb.encoding";
/**
- * The name of the property used to specify whether or not the marshalled
- * XML data is formatted with linefeeds and indentation.
+ * The name of the property used to specify whether or not the marshalled
+ * XML data is formatted with linefeeds and indentation.
*/
public static final String JAXB_FORMATTED_OUTPUT =
"jaxb.formatted.output";
@@ -338,19 +338,19 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into the specified
* {@code javax.xml.transform.Result}.
- *
+ *
* <p>
* All Jakarta XML Binding Providers must at least support
* {@link javax.xml.transform.dom.DOMResult},
* {@link javax.xml.transform.sax.SAXResult}, and
- * {@link javax.xml.transform.stream.StreamResult}. It can
+ * {@link javax.xml.transform.stream.StreamResult}. It can
* support other derived classes of {@code Result} as well.
- *
+ *
* @param jaxbElement
- * The root of content tree to be marshalled.
+ * The root of content tree to be marshalled.
* @param result
* XML will be sent to this Result
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -367,12 +367,12 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into an output stream.
- *
+ *
* @param jaxbElement
- * The root of content tree to be marshalled.
+ * The root of content tree to be marshalled.
* @param os
* XML will be added to this stream.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -412,12 +412,12 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into a Writer.
- *
+ *
* @param jaxbElement
- * The root of content tree to be marshalled.
+ * The root of content tree to be marshalled.
* @param writer
* XML will be sent to this writer.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -434,12 +434,12 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into SAX2 events.
- *
+ *
* @param jaxbElement
- * The root of content tree to be marshalled.
+ * The root of content tree to be marshalled.
* @param handler
* XML will be sent to this handler as SAX2 events.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -456,16 +456,16 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into a DOM tree.
- *
+ *
* @param jaxbElement
- * The content tree to be marshalled.
+ * The content tree to be marshalled.
* @param node
* DOM nodes will be added as children of this node.
* This parameter must be a Node that accepts children
* ({@link org.w3c.dom.Document},
* {@link org.w3c.dom.DocumentFragment}, or
* {@link org.w3c.dom.Element})
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -483,12 +483,12 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into a
* {@link javax.xml.stream.XMLStreamWriter}.
- *
+ *
* @param jaxbElement
- * The content tree to be marshalled.
+ * The content tree to be marshalled.
* @param writer
* XML will be sent to this writer.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -507,12 +507,12 @@
/**
* Marshal the content tree rooted at {@code jaxbElement} into a
* {@link javax.xml.stream.XMLEventWriter}.
- *
+ *
* @param jaxbElement
- * The content tree rooted at jaxbElement to be marshalled.
+ * The content tree rooted at jaxbElement to be marshalled.
* @param writer
* XML will be sent to this writer.
- *
+ *
* @throws JAXBException
* If any unexpected problem occurs during the marshalling.
* @throws MarshalException
@@ -530,20 +530,20 @@
/**
* Get a DOM tree view of the content tree(Optional).
- *
- * If the returned DOM tree is updated, these changes are also
- * visible in the content tree.
+ *
+ * If the returned DOM tree is updated, these changes are also
+ * visible in the content tree.
* Use {@link #marshal(Object, org.w3c.dom.Node)} to force
* a deep copy of the content tree to a DOM representation.
- *
+ *
* @param contentTree - Jakarta XML Binding Java representation of XML content
- *
+ *
* @return the DOM tree view of the contentTree
- *
+ *
* @throws UnsupportedOperationException
* If the Jakarta XML Binding provider implementation does not support a
* DOM view of the content tree
- *
+ *
* @throws IllegalArgumentException
* If any of the method parameters are null
*
@@ -555,7 +555,7 @@
throws JAXBException;
/**
- * Set the particular property in the underlying implementation of
+ * Set the particular property in the underlying implementation of
* {@code Marshaller}. This method can only be used to set one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to set an undefined property will result in
@@ -563,7 +563,7 @@
* Supported Properties</a>.
*
* @param name the name of the property to be set. This value can either
- * be specified using one of the constant fields or a user
+ * be specified using one of the constant fields or a user
* supplied string.
* @param value the value of the property to be set
*
@@ -576,7 +576,7 @@
throws PropertyException;
/**
- * Get the particular property in the underlying implementation of
+ * Get the particular property in the underlying implementation of
* {@code Marshaller}. This method can only be used to get one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to get an undefined property will result in
@@ -599,14 +599,14 @@
* <p>
* The validation event handler will be called by the Jakarta XML Binding Provider if any
* validation errors are encountered during calls to any of the marshal
- * API's. If the client application does not register a validation event
- * handler before invoking one of the marshal methods, then validation
- * events will be handled by the default event handler which will terminate
+ * API's. If the client application does not register a validation event
+ * handler before invoking one of the marshal methods, then validation
+ * events will be handled by the default event handler which will terminate
* the marshal operation after the first error or fatal error is encountered.
* <p>
* Calling this method with a null parameter will cause the Marshaller
* to revert back to the default default event handler.
- *
+ *
* @param handler the validation event handler
* @throws JAXBException if an error was encountered while setting the
* event handler
@@ -620,7 +620,7 @@
*
* @return the current ValidationEventHandler or the default event handler
* if it hasn't been set
- * @throws JAXBException if an error was encountered while getting the
+ * @throws JAXBException if an error was encountered while getting the
* current event handler
*/
public ValidationEventHandler getEventHandler()
@@ -641,7 +641,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public void setAdapter( XmlAdapter adapter );
+ public <A extends XmlAdapter<?, ?>> void setAdapter( A adapter );
/**
* Associates a configured instance of {@link XmlAdapter} with this marshaller.
@@ -670,7 +670,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public <A extends XmlAdapter> void setAdapter( Class<A> type, A adapter );
+ public <A extends XmlAdapter<?, ?>> void setAdapter( Class<A> type, A adapter );
/**
* Gets the adapter associated with the specified type.
@@ -683,7 +683,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public <A extends XmlAdapter> A getAdapter( Class<A> type );
+ public <A extends XmlAdapter<?, ?>> A getAdapter( Class<A> type );
/**
@@ -753,6 +753,13 @@
* @since 1.6, JAXB 2.0
*/
public static abstract class Listener {
+
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected Listener() {
+ }
+
/**
* <p>
* Callback method invoked before marshalling from {@code source} to XML.
@@ -785,7 +792,7 @@
/**
* <p>
* Register marshal event callback {@link Listener} with this {@link Marshaller}.
- *
+ *
* <p>
* There is only one Listener per Marshaller. Setting a Listener replaces the previous set Listener.
* One can unregister current Listener by setting listener to {@code null}.
@@ -797,14 +804,10 @@
/**
* <p>Return {@link Listener} registered with this {@link Marshaller}.
- *
+ *
* @return registered {@link Listener} or {@code null}
* if no Listener is registered with this Marshaller.
* @since 1.6, JAXB 2.0
*/
public Listener getListener();
}
-
-
-
-
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java b/jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
index e43bd5e..b81253a 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
@@ -24,14 +24,14 @@
* Resolves classes from context path.
* Only one class per package is needed to access its {@link java.lang.Module}
*/
- static Class[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
+ static Class<?>[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
return null;
}
/**
* Find first class in package by {@code jaxb.index} file.
*/
- static Class findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
+ static Class<?> findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
return null;
}
@@ -42,7 +42,7 @@
* @param classes used to resolve module for {@linkplain java.lang.Module#addOpens(String, java.lang.Module)}
* @param factorySPI used to resolve {@link java.lang.Module} of the implementation.
*/
- static void delegateAddOpensToImplModule(Class[] classes, Class<?> factorySPI) {
+ static void delegateAddOpensToImplModule(Class<?>[] classes, Class<?> factorySPI) {
//stub
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/SchemaOutputResolver.java b/jaxb-api/src/main/java/jakarta/xml/bind/SchemaOutputResolver.java
index adff627..726547b 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/SchemaOutputResolver.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/SchemaOutputResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -30,6 +30,12 @@
* @since 1.6
*/
public abstract class SchemaOutputResolver {
+
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected SchemaOutputResolver() {}
+
/**
* Decides where the schema file (of the given namespace URI)
* will be written, and return it as a {@link Result} object.
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/ServiceLoaderUtil.java b/jaxb-api/src/main/java/jakarta/xml/bind/ServiceLoaderUtil.java
index b3dc516..5ab87b7 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/ServiceLoaderUtil.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/ServiceLoaderUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -37,8 +37,8 @@
ServiceLoader<P> serviceLoader = ServiceLoader.load(spiClass);
for (P impl : serviceLoader) {
- logger.fine("ServiceProvider loading Facility used; returning object [" +
- impl.getClass().getName() + "]");
+ logger.log(Level.FINE, "ServiceProvider loading Facility used; returning object [{0}]",
+ impl.getClass().getName());
return impl;
}
@@ -52,14 +52,14 @@
try {
// Use reflection to avoid having any dependency on ServiceLoader class
- Class serviceClass = Class.forName(factoryId);
- Class target = Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
+ Class<?> serviceClass = Class.forName(factoryId);
+ Class<?> target = Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
Method m = target.getMethod(OSGI_SERVICE_LOADER_METHOD_NAME, Class.class);
- Iterator iter = ((Iterable) m.invoke(null, serviceClass)).iterator();
+ Iterator<?> iter = ((Iterable) m.invoke(null, serviceClass)).iterator();
if (iter.hasNext()) {
Object next = iter.next();
- logger.fine("Found implementation using OSGi facility; returning object [" +
- next.getClass().getName() + "].");
+ logger.log(Level.FINE, "Found implementation using OSGi facility; returning object [{0}].",
+ next.getClass().getName());
return next;
} else {
return null;
@@ -85,7 +85,7 @@
}
}
- static Class nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ static Class<?> nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
if (classLoader == null) {
return Class.forName(className);
} else {
@@ -100,7 +100,7 @@
String defaultImplClassName,
final ExceptionHandler<T> handler) throws T {
try {
- return safeLoadClass(className, defaultImplClassName, contextClassLoader(handler)).newInstance();
+ return safeLoadClass(className, defaultImplClassName, contextClassLoader(handler)).getConstructor().newInstance();
} catch (ClassNotFoundException x) {
throw handler.createException(x, "Provider " + className + " not found");
} catch (Exception x) {
@@ -108,7 +108,7 @@
}
}
- static Class safeLoadClass(String className,
+ static Class<?> safeLoadClass(String className,
String defaultImplClassName,
ClassLoader classLoader) throws ClassNotFoundException {
@@ -125,7 +125,7 @@
return nullSafeLoadClass(className, classLoader);
}
- static ClassLoader contextClassLoader(ExceptionHandler exceptionHandler) throws Exception {
+ static <T extends Exception> ClassLoader contextClassLoader(ExceptionHandler<T> exceptionHandler) throws T {
try {
return Thread.currentThread().getContextClassLoader();
} catch (Exception x) {
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/TypeConstraintException.java b/jaxb-api/src/main/java/jakarta/xml/bind/TypeConstraintException.java
index b30b533..e3fa8cd 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/TypeConstraintException.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/TypeConstraintException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -11,7 +11,7 @@
package jakarta.xml.bind;
/**
- * This exception indicates that a violation of a dynamically checked type
+ * This exception indicates that a violation of a dynamically checked type
* constraint was detected.
*
* <p>
@@ -19,26 +19,26 @@
* derived Java content classes. However, since fail-fast validation is
* an optional feature for Jakarta XML Binding Providers to support, not all setter methods
* will throw this exception when a type constraint is violated.
- *
+ *
* <p>
* If this exception is throw while invoking a fail-fast setter, the value of
* the property is guaranteed to remain unchanged, as if the setter were never
* called.
*
- * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
+ * @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see ValidationEvent
* @since 1.6, JAXB 1.0
*/
public class TypeConstraintException extends java.lang.RuntimeException {
-
- /**
+
+ /**
* Vendor specific error code
*
*/
private String errorCode;
- /**
+ /**
* Exception reference
*
*/
@@ -46,8 +46,8 @@
static final long serialVersionUID = -3059799699420143848L;
- /**
- * Construct a TypeConstraintException with the specified detail message. The
+ /**
+ * Construct a TypeConstraintException with the specified detail message. The
* errorCode and linkedException will default to null.
*
* @param message a description of the exception
@@ -56,8 +56,8 @@
this( message, null, null );
}
- /**
- * Construct a TypeConstraintException with the specified detail message and vendor
+ /**
+ * Construct a TypeConstraintException with the specified detail message and vendor
* specific errorCode. The linkedException will default to null.
*
* @param message a description of the exception
@@ -67,7 +67,7 @@
this( message, errorCode, null );
}
- /**
+ /**
* Construct a TypeConstraintException with a linkedException. The detail message and
* vendor specific errorCode will default to null.
*
@@ -76,9 +76,9 @@
public TypeConstraintException(Throwable exception) {
this( null, null, exception );
}
-
- /**
- * Construct a TypeConstraintException with the specified detail message and
+
+ /**
+ * Construct a TypeConstraintException with the specified detail message and
* linkedException. The errorCode will default to null.
*
* @param message a description of the exception
@@ -87,8 +87,8 @@
public TypeConstraintException(String message, Throwable exception) {
this( message, null, exception );
}
-
- /**
+
+ /**
* Construct a TypeConstraintException with the specified detail message,
* vendor specific errorCode, and linkedException.
*
@@ -101,8 +101,8 @@
this.errorCode = errorCode;
this.linkedException = exception;
}
-
- /**
+
+ /**
* Get the vendor specific error code
*
* @return a string specifying the vendor specific error code
@@ -112,7 +112,7 @@
}
/**
- * Get the linked exception
+ * Get the linked exception
*
* @return the linked Exception, null if none exists
*/
@@ -123,31 +123,33 @@
/**
* Add a linked Exception.
*
- * @param exception the linked Exception (A null value is permitted and
+ * @param exception the linked Exception (A null value is permitted and
* indicates that the linked exception does not exist or
* is unknown).
*/
public void setLinkedException( Throwable exception ) {
this.linkedException = exception;
}
-
+
/**
* Returns a short description of this TypeConstraintException.
*
*/
+ @Override
public String toString() {
- return linkedException == null ?
+ return linkedException == null ?
super.toString() :
super.toString() + "\n - with linked exception:\n[" +
linkedException.toString()+ "]";
}
-
+
/**
* Prints this TypeConstraintException and its stack trace (including the stack trace
* of the linkedException if it is non-null) to the PrintStream.
*
* @param s PrintStream to use for output
*/
+ @Override
public void printStackTrace( java.io.PrintStream s ) {
if( linkedException != null ) {
linkedException.printStackTrace(s);
@@ -156,12 +158,13 @@
super.printStackTrace(s);
}
-
+
/**
* Prints this TypeConstraintException and its stack trace (including the stack trace
* of the linkedException if it is non-null) to {@code System.err}.
*
*/
+ @Override
public void printStackTrace() {
printStackTrace(System.err);
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/Unmarshaller.java b/jaxb-api/src/main/java/jakarta/xml/bind/Unmarshaller.java
index b50a1fc..d94832b 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/Unmarshaller.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/Unmarshaller.java
@@ -17,10 +17,10 @@
/**
* The {@code Unmarshaller} class governs the process of deserializing XML
- * data into newly created Java content trees, optionally validating the XML
+ * data into newly created Java content trees, optionally validating the XML
* data as it is unmarshalled. It provides an overloading of unmarshal methods
* for many different input kinds.
- *
+ *
* <p>
* Unmarshalling from a File:
* <blockquote>
@@ -31,7 +31,7 @@
* </pre>
* </blockquote>
*
- *
+ *
* <p>
* Unmarshalling from an InputStream:
* <blockquote>
@@ -55,7 +55,7 @@
* </blockquote>
*
* <p>
- * Unmarshalling from a StringBuffer using a
+ * Unmarshalling from a StringBuffer using a
* {@code javax.xml.transform.stream.StreamSource}:
* <blockquote>
* <pre>{@code
@@ -72,7 +72,7 @@
* <pre>
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
- *
+ *
* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
* dbf.setNamespaceAware(true);
* DocumentBuilder db = dbf.newDocumentBuilder();
@@ -81,7 +81,7 @@
* Object o = u.unmarshal( doc );
* </pre>
* </blockquote>
- *
+ *
* <p>
* Unmarshalling from a {@code javax.xml.transform.sax.SAXSource} using a
* client specified validating SAX2.0 parser:
@@ -102,7 +102,7 @@
* spf.setNamespaceAware(true);
* spf.setValidating(true);
* SAXParser saxParser = spf.newSAXParser();
- *
+ *
* try {
* saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
* saxParser.setProperty(JAXP_SCHEMA_LOCATION, "http://....");
@@ -111,7 +111,7 @@
* }
*
* XMLReader xmlReader = saxParser.getXMLReader();
- * SAXSource source =
+ * SAXSource source =
* new SAXSource( xmlReader, new InputSource( "http://..." ) );
*
* // Setup Jakarta XML Binding to unmarshal
@@ -119,8 +119,8 @@
* Unmarshaller u = jc.createUnmarshaller();
* ValidationEventCollector vec = new ValidationEventCollector();
* u.setEventHandler( vec );
- *
- * // turn off the Jakarta XML Binding provider's default validation mechanism to
+ *
+ * // turn off the Jakarta XML Binding provider's default validation mechanism to
* // avoid duplicate validation
* u.setValidating( false )
*
@@ -140,10 +140,10 @@
* <pre>
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
- *
- * javax.xml.stream.XMLStreamReader xmlStreamReader =
+ *
+ * javax.xml.stream.XMLStreamReader xmlStreamReader =
* javax.xml.stream.XMLInputFactory().newInstance().createXMLStreamReader( ... );
- *
+ *
* Object o = u.unmarshal( xmlStreamReader );
* </pre>
* </blockquote>
@@ -154,10 +154,10 @@
* <pre>
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
- *
- * javax.xml.stream.XMLEventReader xmlEventReader =
+ *
+ * javax.xml.stream.XMLEventReader xmlEventReader =
* javax.xml.stream.XMLInputFactory().newInstance().createXMLEventReader( ... );
- *
+ *
* Object o = u.unmarshal( xmlEventReader );
* </pre>
* </blockquote>
@@ -166,20 +166,20 @@
* <a id="unmarshalEx"></a>
* <b>Unmarshalling XML Data</b><br>
* <blockquote>
- * Unmarshalling can deserialize XML data that represents either an entire XML document
+ * Unmarshalling can deserialize XML data that represents either an entire XML document
* or a subtree of an XML document. Typically, it is sufficient to use the
- * unmarshalling methods described by
+ * unmarshalling methods described by
* <a href="#unmarshalGlobal">Unmarshal root element that is declared globally</a>.
* These unmarshal methods utilize {@link JAXBContext}'s mapping of global XML element
- * declarations and type definitions to Jakarta XML Binding mapped classes to initiate the
- * unmarshalling of the root element of XML data. When the {@link JAXBContext}'s
- * mappings are not sufficient to unmarshal the root element of XML data,
- * the application can assist the unmarshalling process by using the
+ * declarations and type definitions to Jakarta XML Binding mapped classes to initiate the
+ * unmarshalling of the root element of XML data. When the {@link JAXBContext}'s
+ * mappings are not sufficient to unmarshal the root element of XML data,
+ * the application can assist the unmarshalling process by using the
* <a href="#unmarshalByDeclaredType">unmarshal by declaredType methods</a>.
* These methods are useful for unmarshalling XML data where
* the root element corresponds to a local element declaration in the schema.
* </blockquote>
- *
+ *
* <blockquote>
* An unmarshal method never returns null. If the unmarshal process is unable to unmarshal
* the root of XML content to a Jakarta XML Binding mapped object, a fatal error is reported that
@@ -191,9 +191,9 @@
* <b>Unmarshal a root element that is globally declared</b><br>
* <blockquote>
* The unmarshal methods that do not have an {@code declaredType} parameter use
- * {@link JAXBContext} to unmarshal the root element of an XML data. The {@link JAXBContext}
+ * {@link JAXBContext} to unmarshal the root element of an XML data. The {@link JAXBContext}
* instance is the one that was used to create this {@code Unmarshaller}. The {@link JAXBContext}
- * instance maintains a mapping of globally declared XML element and type definition names to
+ * instance maintains a mapping of globally declared XML element and type definition names to
* Jakarta XML Binding mapped classes. The unmarshal method checks if {@link JAXBContext} has a mapping
* from the root element's XML name and/or {@code @xsi:type} to a Jakarta XML Binding mapped class. If it does, it umarshalls the
* XML data using the appropriate Jakarta XML Binding mapped class. Note that when the root element name is unknown and the root
@@ -201,11 +201,11 @@
* using that Jakarta XML Binding mapped class as the value of a {@link JAXBElement}.
* When the {@link JAXBContext} object does not have a mapping for the root element's name
* nor its {@code @xsi:type}, if it exists,
- * then the unmarshal operation will abort immediately by throwing a {@link UnmarshalException
- * UnmarshalException}. This exception scenario can be worked around by using the unmarshal by
+ * then the unmarshal operation will abort immediately by throwing a {@link UnmarshalException
+ * UnmarshalException}. This exception scenario can be worked around by using the unmarshal by
* declaredType methods described in the next subsection.
* </blockquote>
- *
+ *
* <p>
* <a id="unmarshalByDeclaredType"></a>
* <b>Unmarshal by Declared Type</b><br>
@@ -215,16 +215,16 @@
* there is no mapping in {@link JAXBContext} of the root element's XML name.
* The unmarshaller unmarshals the root element using the application provided
* mapping specified as the {@code declaredType} parameter.
- * Note that even when the root element's element name is mapped by {@link JAXBContext},
+ * Note that even when the root element's element name is mapped by {@link JAXBContext},
* the {@code declaredType} parameter overrides that mapping for
- * deserializing the root element when using these unmarshal methods.
+ * deserializing the root element when using these unmarshal methods.
* Additionally, when the root element of XML data has an {@code xsi:type} attribute and
- * that attribute's value references a type definition that is mapped
- * to a Jakarta XML Binding mapped class by {@link JAXBContext}, that the root
+ * that attribute's value references a type definition that is mapped
+ * to a Jakarta XML Binding mapped class by {@link JAXBContext}, that the root
* element's {@code xsi:type} attribute takes
* precedence over the unmarshal methods {@code declaredType} parameter.
* These methods always return a {@code JAXBElement<declaredType>}
- * instance. The table below shows how the properties of the returned JAXBElement
+ * instance. The table below shows how the properties of the returned JAXBElement
* instance are set.
*
* <a id="unmarshalDeclaredTypeReturn"></a>
@@ -258,12 +258,12 @@
* </blockquote>
*
* <p>
- * The following is an example of
+ * The following is an example of
* <a href="#unmarshalByDeclaredType">unmarshal by declaredType method</a>.
* <p>
* Unmarshal by declaredType from a {@code org.w3c.dom.Node}:
* <blockquote>
- * <pre>{@code
+ * <pre>{@code
* Schema fragment for example
* <xs:schema>
* <xs:complexType name="FooType">...<\xs:complexType>
@@ -281,19 +281,19 @@
*
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
- *
+ *
* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
* dbf.setNamespaceAware(true);
* DocumentBuilder db = dbf.newDocumentBuilder();
* Document doc = db.parse(new File( "nosferatu.xml"));
- * Element fooSubtree = ...; // traverse DOM till reach xml element foo, constrained by a
+ * Element fooSubtree = ...; // traverse DOM till reach xml element foo, constrained by a
* // local element declaration in schema.
- *
+ *
* // FooType is the Jakarta XML Binding mapping of the type of local element declaration foo.
* JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class);
* }</pre>
* </blockquote>
- *
+ *
* <p>
* <b>Support for SAX2.0 Compliant Parsers</b><br>
* <blockquote>
@@ -303,7 +303,7 @@
* is not required to be SAX2.0 compliant, all providers are required to allow
* a client application to specify their own SAX2.0 parser. Some providers may
* require the client application to specify the SAX2.0 parser at schema compile
- * time. See {@link #unmarshal(javax.xml.transform.Source) unmarshal(Source)}
+ * time. See {@link #unmarshal(javax.xml.transform.Source) unmarshal(Source)}
* for more detail.
* </blockquote>
*
@@ -313,22 +313,22 @@
* <p>
* A client application can enable or disable JAXP validation
* mechanism via the {@code setSchema(javax.xml.validation.Schema)} API.
- * Sophisticated clients can specify their own validating SAX 2.0 compliant
- * parser and bypass the JAXP validation mechanism using the
+ * Sophisticated clients can specify their own validating SAX 2.0 compliant
+ * parser and bypass the JAXP validation mechanism using the
* {@link #unmarshal(javax.xml.transform.Source) unmarshal(Source)} API.
- *
+ *
* <p>
- * Since unmarshalling invalid XML content is defined in Jakarta XML Binding,
+ * Since unmarshalling invalid XML content is defined in Jakarta XML Binding,
* the Unmarshaller default validation event handler was made more lenient
* than in JAXB 1.0. When schema-derived code generated
- * by JAXB 1.0 binding compiler is registered with {@link JAXBContext},
- * the default unmarshal validation handler is
+ * by JAXB 1.0 binding compiler is registered with {@link JAXBContext},
+ * the default unmarshal validation handler is
* {@link jakarta.xml.bind.helpers.DefaultValidationEventHandler} and it
- * terminates the marshal operation after encountering either a fatal error or an error.
+ * terminates the marshal operation after encountering either a fatal error or an error.
* For a Jakarta XML Binding client application, there is no explicitly defined default
- * validation handler and the default event handling only
+ * validation handler and the default event handling only
* terminates the unmarshal operation after encountering a fatal error.
- *
+ *
* </blockquote>
*
* <p>
@@ -336,11 +336,11 @@
* <b>Supported Properties</b><br>
* <blockquote>
* <p>
- * There currently are not any properties required to be supported by all
- * Jakarta XML Binding Providers on Unmarshaller. However, some providers may support
+ * There currently are not any properties required to be supported by all
+ * Jakarta XML Binding Providers on Unmarshaller. However, some providers may support
* their own set of provider specific properties.
* </blockquote>
- *
+ *
* <p>
* <a id="unmarshalEventCallback"></a>
* <b>Unmarshal Event Callbacks</b><br>
@@ -352,53 +352,53 @@
* unmarshalling. 'External listeners' allow for centralized processing
* of unmarshal events in one callback method rather than by type event callbacks.
* <p>
- * 'Class defined' event callback methods allow any Jakarta XML Binding mapped class to specify
+ * 'Class defined' event callback methods allow any Jakarta XML Binding mapped class to specify
* its own specific callback methods by defining methods with the following method signature:
* <blockquote>
* <pre>
- * // This method is called immediately after the object is created and before the unmarshalling of this
+ * // This method is called immediately after the object is created and before the unmarshalling of this
* // object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
* void beforeUnmarshal(Unmarshaller, Object parent);
- *
- * //This method is called after all the properties (except IDREF) are unmarshalled for this object,
+ *
+ * //This method is called after all the properties (except IDREF) are unmarshalled for this object,
* //but before this object is set to the parent object.
* void afterUnmarshal(Unmarshaller, Object parent);
* </pre>
* </blockquote>
* The class defined callback methods should be used when the callback method requires
- * access to non-public methods and/or fields of the class.
+ * access to non-public methods and/or fields of the class.
* <p>
- * The external listener callback mechanism enables the registration of a {@link Listener}
- * instance with an {@link Unmarshaller#setListener(Listener)}. The external listener receives all callback events,
- * allowing for more centralized processing than per class defined callback methods. The external listener
+ * The external listener callback mechanism enables the registration of a {@link Listener}
+ * instance with an {@link Unmarshaller#setListener(Listener)}. The external listener receives all callback events,
+ * allowing for more centralized processing than per class defined callback methods. The external listener
* receives events when unmarshalling process is marshalling to a Jakarta XML Binding element or to Jakarta XML Binding mapped class.
* <p>
* The 'class defined' and external listener event callback methods are independent of each other,
* both can be called for one event. The invocation ordering when both listener callback methods exist is
- * defined in {@link Listener#beforeUnmarshal(Object, Object)} and {@link Listener#afterUnmarshal(Object, Object)}.
+ * defined in {@link Listener#beforeUnmarshal(Object, Object)} and {@link Listener#afterUnmarshal(Object, Object)}.
* <p>
* An event callback method throwing an exception terminates the current unmarshal process.
- *
+ *
* </blockquote>
- *
+ *
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see JAXBContext
* @see Marshaller
* @since 1.6, JAXB 1.0
*/
public interface Unmarshaller {
-
+
/**
* Unmarshal XML data from the specified file and return the resulting
* content tree.
*
* <p>
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
- *
- * @param f the file to unmarshal XML data from
- * @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @param f the file to unmarshal XML data from
+ * @return the newly created root object of the java content tree
+ *
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -409,19 +409,19 @@
* If the file parameter is null
*/
public Object unmarshal( java.io.File f ) throws JAXBException;
-
+
/**
- * Unmarshal XML data from the specified InputStream and return the
+ * Unmarshal XML data from the specified InputStream and return the
* resulting content tree. Validation event location information may
* be incomplete when using this form of the unmarshal API.
*
* <p>
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
- *
- * @param is the InputStream to unmarshal XML data from
- * @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @param is the InputStream to unmarshal XML data from
+ * @return the newly created root object of the java content tree
+ *
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -441,7 +441,7 @@
*
* <p>
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
- *
+ *
* @param reader the Reader to unmarshal XML data from
* @return the newly created root object of the java content tree
*
@@ -466,9 +466,9 @@
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
*
* @param url the url to unmarshal XML data from
- * @return the newly created root object of the java content tree
+ * @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -479,7 +479,7 @@
* If the URL parameter is null
*/
public Object unmarshal( java.net.URL url ) throws JAXBException;
-
+
/**
* Unmarshal XML data from the specified SAX InputSource and return the
* resulting content tree.
@@ -488,9 +488,9 @@
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
*
* @param source the input source to unmarshal XML data from
- * @return the newly created root object of the java content tree
+ * @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -501,7 +501,7 @@
* If the InputSource parameter is null
*/
public Object unmarshal( org.xml.sax.InputSource source ) throws JAXBException;
-
+
/**
* Unmarshal global XML data from the specified DOM tree and return the resulting
* content tree.
@@ -512,9 +512,9 @@
* @param node
* the document/element to unmarshal XML data from.
* The caller must support at least Document and Element.
- * @return the newly created root object of the java content tree
+ * @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -539,10 +539,10 @@
* The caller must support at least Document and Element.
* @param declaredType
* appropriate Jakarta XML Binding mapped class to hold {@code node}'s XML data.
- *
+ *
* @return <a href="#unmarshalDeclaredTypeReturn">JAXBElement</a> representation of {@code node}
- *
- * @throws JAXBException
+ *
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -554,10 +554,10 @@
* @since 1.6, JAXB 2.0
*/
public <T> JAXBElement<T> unmarshal( org.w3c.dom.Node node, Class<T> declaredType ) throws JAXBException;
-
+
/**
- * Unmarshal XML data from the specified XML Source and return the
- * resulting content tree.
+ * Unmarshal XML data from the specified XML Source and return the
+ * resulting content tree.
*
* <p>
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
@@ -578,29 +578,29 @@
* then the Jakarta XML Binding provider's default parser mechanism will be used.
* <p>
* This parser replacement mechanism can also be used to replace the Jakarta XML Binding
- * provider's unmarshal-time validation engine. The client application
+ * provider's unmarshal-time validation engine. The client application
* must properly configure their SAX 2.0 compliant parser to perform
* validation (as shown in the example above). Any {@code SAXParserExceptions}
* encountered by the parser during the unmarshal operation will be
- * processed by the Jakarta XML Binding provider and converted into Jakarta XML Binding
+ * processed by the Jakarta XML Binding provider and converted into Jakarta XML Binding
* {@code ValidationEvent} objects which will be reported back to the
* client via the {@code ValidationEventHandler} registered with the
* {@code Unmarshaller}. <i>Note:</i> specifying a substitute validating
- * SAX 2.0 parser for unmarshalling does not necessarily replace the
- * validation engine used by the Jakarta XML Binding provider for performing on-demand
+ * SAX 2.0 parser for unmarshalling does not necessarily replace the
+ * validation engine used by the Jakarta XML Binding provider for performing on-demand
* validation.
* <p>
* The only way for a client application to specify an alternate parser
- * mechanism to be used during unmarshal is via the
+ * mechanism to be used during unmarshal is via the
* {@code unmarshal(SAXSource)} API. All other forms of the unmarshal
- * method (File, URL, Node, etc) will use the Jakarta XML Binding provider's default
+ * method (File, URL, Node, etc) will use the Jakarta XML Binding provider's default
* parser and validator mechanisms.
*
* @param source the XML Source to unmarshal XML data from (providers are
* only required to support SAXSource, DOMSource, and StreamSource)
* @return the newly created root object of the java content tree
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -617,7 +617,7 @@
/**
* Unmarshal XML data from the specified XML Source by {@code declaredType} and return the
- * resulting content tree.
+ * resulting content tree.
*
* <p>
* Implements <a href="#unmarshalByDeclaredType">Unmarshal by Declared Type</a>
@@ -627,11 +627,11 @@
*
* @param source the XML Source to unmarshal XML data from (providers are
* only required to support SAXSource, DOMSource, and StreamSource)
- * @param declaredType
+ * @param declaredType
* appropriate Jakarta XML Binding mapped class to hold {@code source}'s xml root element
* @return Java content rooted by <a href="#unmarshalDeclaredTypeReturn">JAXBElement</a>
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -644,27 +644,27 @@
*/
public <T> JAXBElement<T> unmarshal( javax.xml.transform.Source source, Class<T> declaredType )
throws JAXBException;
-
+
/**
* Unmarshal XML data from the specified pull parser and return the
* resulting content tree.
*
* <p>
* Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>.
- *
+ *
* <p>
* This method assumes that the parser is on a START_DOCUMENT or
- * START_ELEMENT event. Unmarshalling will be done from this
- * start event to the corresponding end event. If this method
+ * START_ELEMENT event. Unmarshalling will be done from this
+ * start event to the corresponding end event. If this method
* returns successfully, the {@code reader} will be pointing at
* the token right after the end event.
- *
+ *
* @param reader
* The parser to be read.
* @return
* the newly created root object of the java content tree.
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -681,28 +681,28 @@
*/
public Object unmarshal( javax.xml.stream.XMLStreamReader reader )
throws JAXBException;
-
+
/**
* Unmarshal root element to Jakarta XML Binding mapped {@code declaredType}
* and return the resulting content tree.
- *
+ *
* <p>
* This method implements <a href="#unmarshalByDeclaredType">unmarshal by declaredType</a>.
* <p>
* This method assumes that the parser is on a START_DOCUMENT or
- * START_ELEMENT event. Unmarshalling will be done from this
- * start event to the corresponding end event. If this method
- * returns successfully, the {@code reader} will be pointing at
+ * START_ELEMENT event. Unmarshalling will be done from this
+ * start event to the corresponding end event. If this method
+ * returns successfully, the {@code reader} will be pointing at
* the token right after the end event.
*
* @param reader
- * The parser to be read.
+ * The parser to be read.
* @param declaredType
* appropriate Jakarta XML Binding mapped class to hold {@code reader}'s START_ELEMENT XML data.
- *
+ *
* @return content tree rooted by <a href="#unmarshalDeclaredTypeReturn">JAXBElement</a> representation
- *
- * @throws JAXBException
+ *
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -724,17 +724,17 @@
*
* <p>
* This method assumes that the parser is on a START_DOCUMENT or
- * START_ELEMENT event. Unmarshalling will be done from this
- * start event to the corresponding end event. If this method
- * returns successfully, the {@code reader} will be pointing at
- * the token right after the end event.
- *
+ * START_ELEMENT event. Unmarshalling will be done from this
+ * start event to the corresponding end event. If this method
+ * returns successfully, the {@code reader} will be pointing at
+ * the token right after the end event.
+ *
* @param reader
* The parser to be read.
* @return
* the newly created root object of the java content tree.
*
- * @throws JAXBException
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -751,29 +751,29 @@
*/
public Object unmarshal( javax.xml.stream.XMLEventReader reader )
throws JAXBException;
-
+
/**
* Unmarshal root element to Jakarta XML Binding mapped {@code declaredType}
* and return the resulting content tree.
- *
+ *
* <p>
* This method implements <a href="#unmarshalByDeclaredType">unmarshal by declaredType</a>.
*
* <p>
* This method assumes that the parser is on a START_DOCUMENT or
- * START_ELEMENT event. Unmarshalling will be done from this
- * start event to the corresponding end event. If this method
- * returns successfully, the {@code reader} will be pointing at
+ * START_ELEMENT event. Unmarshalling will be done from this
+ * start event to the corresponding end event. If this method
+ * returns successfully, the {@code reader} will be pointing at
* the token right after the end event.
*
* @param reader
- * The parser to be read.
+ * The parser to be read.
* @param declaredType
* appropriate Jakarta XML Binding mapped class to hold {@code reader}'s START_ELEMENT XML data.
- *
+ *
* @return content tree rooted by <a href="#unmarshalDeclaredTypeReturn">JAXBElement</a> representation
- *
- * @throws JAXBException
+ *
+ * @throws JAXBException
* If any unexpected errors occur while unmarshalling
* @throws UnmarshalException
* If the {@link ValidationEventHandler ValidationEventHandler}
@@ -789,10 +789,10 @@
/**
* Get an unmarshaller handler object that can be used as a component in
* an XML pipeline.
- *
+ *
* <p>
- * The Jakarta XML Binding Provider can return the same handler object for multiple
- * invocations of this method. In other words, this method does not
+ * The Jakarta XML Binding Provider can return the same handler object for multiple
+ * invocations of this method. In other words, this method does not
* necessarily create a new instance of {@code UnmarshallerHandler}. If the
* application needs to use more than one {@code UnmarshallerHandler}, it
* should create more than one {@code Unmarshaller}.
@@ -801,16 +801,16 @@
* @see UnmarshallerHandler
*/
public UnmarshallerHandler getUnmarshallerHandler();
-
+
/**
* Allow an application to register a {@code ValidationEventHandler}.
* <p>
* The {@code ValidationEventHandler} will be called by the Jakarta XML Binding Provider
- * if any validation errors are encountered during calls to any of the
- * unmarshal methods. If the client application does not register a
+ * if any validation errors are encountered during calls to any of the
+ * unmarshal methods. If the client application does not register a
* {@code ValidationEventHandler} before invoking the unmarshal methods,
* then {@code ValidationEvents} will be handled by the default event
- * handler which will terminate the unmarshal operation after the first
+ * handler which will terminate the unmarshal operation after the first
* error or fatal error is encountered.
* <p>
* Calling this method with a null parameter will cause the Unmarshaller
@@ -829,14 +829,14 @@
*
* @return the current ValidationEventHandler or the default event handler
* if it hasn't been set
- * @throws JAXBException if an error was encountered while getting the
+ * @throws JAXBException if an error was encountered while getting the
* current event handler
*/
public ValidationEventHandler getEventHandler()
throws JAXBException;
/**
- * Set the particular property in the underlying implementation of
+ * Set the particular property in the underlying implementation of
* {@code Unmarshaller}. This method can only be used to set one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to set an undefined property will result in
@@ -844,7 +844,7 @@
* Supported Properties</a>.
*
* @param name the name of the property to be set. This value can either
- * be specified using one of the constant fields or a user
+ * be specified using one of the constant fields or a user
* supplied string.
* @param value the value of the property to be set
*
@@ -853,11 +853,11 @@
* @throws IllegalArgumentException
* If the name parameter is null
*/
- public void setProperty( String name, Object value )
+ public void setProperty( String name, Object value )
throws PropertyException;
-
+
/**
- * Get the particular property in the underlying implementation of
+ * Get the particular property in the underlying implementation of
* {@code Unmarshaller}. This method can only be used to get one of
* the standard Jakarta XML Binding defined properties above or a provider specific
* property. Attempting to get an undefined property will result in
@@ -889,14 +889,14 @@
* JAXB 1.0 mapped classes
* @since 1.6, JAXB 2.0
*/
- public void setSchema( javax.xml.validation.Schema schema );
+ public void setSchema( Schema schema );
/**
* Get the JAXP {@link javax.xml.validation.Schema Schema} object
* being used to perform unmarshal-time validation. If there is no
* Schema set on the unmarshaller, then this method will return null
* indicating that unmarshal-time validation will not be performed.
- *
+ *
* @return the Schema object being used to perform unmarshal-time
* validation or null if not present
* @throws UnsupportedOperationException could be thrown if this method is
@@ -904,7 +904,7 @@
* JAXB 1.0 mapped classes
* @since 1.6, JAXB 2.0
*/
- public javax.xml.validation.Schema getSchema();
+ public Schema getSchema();
/**
* Associates a configured instance of {@link XmlAdapter} with this unmarshaller.
@@ -919,7 +919,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public void setAdapter( XmlAdapter adapter );
+ public <A extends XmlAdapter<?, ?>> void setAdapter( A adapter );
/**
* Associates a configured instance of {@link XmlAdapter} with this unmarshaller.
@@ -948,7 +948,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public <A extends XmlAdapter> void setAdapter( Class<A> type, A adapter );
+ public <A extends XmlAdapter<?, ?>> void setAdapter( Class<A> type, A adapter );
/**
* Gets the adapter associated with the specified type.
@@ -961,7 +961,7 @@
* if invoked agains a JAXB 1.0 implementation.
* @since 1.6, JAXB 2.0
*/
- public <A extends XmlAdapter> A getAdapter( Class<A> type );
+ public <A extends XmlAdapter<?, ?>> A getAdapter( Class<A> type );
/**
* <p>Associate a context that resolves cid's, content-id URIs, to
@@ -999,6 +999,13 @@
* @since 1.6, JAXB 2.0
*/
public static abstract class Listener {
+
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected Listener() {
+ }
+
/**
* <p>
* Callback method invoked before unmarshalling into {@code target}.
@@ -1038,11 +1045,11 @@
/**
* <p>
* Register unmarshal event callback {@link Listener} with this {@link Unmarshaller}.
- *
+ *
* <p>
* There is only one Listener per Unmarshaller. Setting a Listener replaces the previous set Listener.
* One can unregister current Listener by setting listener to {@code null}.
- *
+ *
* @param listener provides unmarshal event callbacks for this {@link Unmarshaller}
* @since 1.6, JAXB 2.0
*/
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/W3CDomHandler.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/W3CDomHandler.java
index 5c3385d..fe3e0ff 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/W3CDomHandler.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/W3CDomHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -63,6 +63,7 @@
this.builder = builder;
}
+ @Override
public DOMResult createUnmarshaller(ValidationEventHandler errorHandler) {
if(builder==null)
return new DOMResult();
@@ -70,6 +71,7 @@
return new DOMResult(builder.newDocument());
}
+ @Override
public Element getElement(DOMResult r) {
// JAXP spec is ambiguous about what really happens in this case,
// so work defensively
@@ -88,6 +90,7 @@
throw new IllegalStateException(n.toString());
}
+ @Override
public Source marshal(Element element, ValidationEventHandler errorHandler) {
return new DOMSource(element);
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlAnyElement.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlAnyElement.java
index 1ba25a5..8be8ce6 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlAnyElement.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlAnyElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -272,5 +272,5 @@
* Specifies the {@link DomHandler} which is responsible for actually
* converting XML from/to a DOM-like data structure.
*/
- Class<? extends DomHandler> value() default W3CDomHandler.class;
+ Class<? extends DomHandler<?, ?>> value() default W3CDomHandler.class;
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElement.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElement.java
index 9d6cf75..9ba982f 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElement.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -14,9 +14,10 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Maps a JavaBean property to a XML element derived from property name.
@@ -181,12 +182,14 @@
/**
* The Java class being referenced.
*/
- Class type() default DEFAULT.class;
+ Class<?> type() default DEFAULT.class;
/**
* Used in {@link XmlElement#type()} to
* signal that the type be inferred from the signature
* of the property.
*/
- static final class DEFAULT {}
+ static final class DEFAULT {
+ private DEFAULT() {}
+ }
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementDecl.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementDecl.java
index 7dfcb29..b3b4da0 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementDecl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementDecl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -27,18 +27,18 @@
* declaration. Typically, the element factory method is generated
* (and annotated) from a schema into the ObjectFactory class in a
* Java package that represents the binding of the element
- * declaration's target namespace. Thus, while the annotation syntax
+ * declaration's target namespace. Thus, while the annotation syntax
* allows @XmlElementDecl to be used on any method, semantically
- * its use is restricted to annotation of element factory method.
+ * its use is restricted to annotation of element factory method.
*
* The usage is subject to the following constraints:
- *
+ *
* <ul>
* <li> The class containing the element factory method annotated
* with @XmlElementDecl must be marked with {@link
- * XmlRegistry}. </li>
+ * XmlRegistry}. </li>
* <li> The element factory method must take one parameter
- * assignable to {@link Object}.</li>
+ * assignable to {@link Object}.</li>
* </ul>
*
* <p><b>Example 1: </b>Annotation on a factory method
@@ -51,7 +51,7 @@
* }
* </pre>
* <pre> {@code
- *
+ *
* <!-- XML input -->
* <foo>string</foo>
*
@@ -71,11 +71,11 @@
* <p>
* The following example illustrates the use of scope annotation
* parameter in binding of element declaration in schema derived
- * code.
+ * code.
* <p>
* The following example may be replaced in a future revision of
* this javadoc.
- *
+ *
* <pre>{@code
* <!-- Example: XML schema definition -->
* <xs:schema>
@@ -87,7 +87,7 @@
* </xs:complexType>
* <xs:element name="foo" type="xs:int"/>
* </xs:schema>
- * }</pre>
+ * }</pre>
* <pre>
* // Example: expected default binding
* class Pea {
@@ -97,23 +97,23 @@
* })
* List<JAXBElement<String>> fooOrBar;
* }
- *
+ *
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(scope=Pea.class,name="foo")
* JAXBElement<String> createPeaFoo(String s);
- *
+ *
* @XmlElementDecl(scope=Pea.class,name="bar")
* JAXBElement<String> createPeaBar(String s);
- *
+ *
* @XmlElementDecl(name="foo")
* JAXBElement<Integer> createFoo(Integer i);
* }
- *
+ *
* </pre>
* Without scope createFoo and createPeaFoo would become ambiguous
* since both of them map to a XML schema element with the same local
- * name "foo".
+ * name "foo".
*
* @see XmlRegistry
* @since 1.6, JAXB 2.0
@@ -128,7 +128,7 @@
* If this is not {@link XmlElementDecl.GLOBAL}, then this element
* declaration mapping is only active within the specified class.
*/
- Class scope() default GLOBAL.class;
+ Class<?> scope() default GLOBAL.class;
/**
* namespace name of the XML element.
@@ -156,14 +156,14 @@
* <p>
* This specifies the namespace name of the XML element whose local
* name is specified by {@code substitutionHeadName()}.
- * <p>
+ * <p>
* If {@code susbtitutionHeadName()} is "", then this
* value can only be "##default". But the value is ignored since
* since this element is not part of susbtitution group when the
* value of {@code susbstitutionHeadName()} is "".
* <p>
* If {@code susbtitutionHeadName()} is not "" and the value is
- * "##default", then the namespace name is the namespace name to
+ * "##default", then the namespace name is the namespace name to
* which the package of the containing class, marked with {@link
* XmlRegistry }, is mapped.
* <p>
@@ -193,10 +193,12 @@
* to recognize the 'no default value' state.
*/
String defaultValue() default "\u0000";
-
+
/**
* Used in {@link XmlElementDecl#scope()} to
* signal that the declaration is in the global scope.
*/
- public final class GLOBAL {}
+ public final class GLOBAL {
+ private GLOBAL() {}
+ }
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementRef.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementRef.java
index 3eefb42..db284bd 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementRef.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlElementRef.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -213,7 +213,7 @@
* If the value is DEFAULT.class, the type is inferred from the
* the type of the JavaBean property.
*/
- Class type() default DEFAULT.class;
+ Class<?> type() default DEFAULT.class;
/**
* This parameter and {@link #name()} are used to determine the
@@ -250,7 +250,9 @@
* signal that the type be inferred from the signature
* of the property.
*/
- static final class DEFAULT {}
+ static final class DEFAULT {
+ private DEFAULT() {}
+ }
/**
* Customize the element declaration to be required.
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaType.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaType.java
index 6bbd4db..1fb1b34 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaType.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -24,15 +24,15 @@
* <p> <b>Usage</b> </p>
* <p>
* {@code @XmlSchemaType} annotation can be used with the following program
- * elements:
- * <ul>
+ * elements:
+ * <ul>
* <li> a JavaBean property </li>
* <li> field </li>
* <li> package</li>
* </ul>
*
* <p> {@code @XmlSchemaType} annotation defined for Java type
- * applies to all references to the Java type from a property/field.
+ * applies to all references to the Java type from a property/field.
* A {@code @XmlSchemaType} annotation specified on the
* property/field overrides the {@code @XmlSchemaType} annotation
* specified at the package level.
@@ -42,7 +42,7 @@
* <p>
* <b>Example 1: </b> Customize mapping of XMLGregorianCalendar on the
* field.
- *
+ *
* <pre>
* //Example: Code fragment
* public class USPrice {
@@ -51,7 +51,7 @@
* public XMLGregorianCalendar date;
* }
* {@code
- *
+ *
* <!-- Example: Local XML Schema element -->
* <xs:complexType name="USPrice"/>
* <xs:sequence>
@@ -68,11 +68,11 @@
* name="date", type=javax.xml.datatype.XMLGregorianCalendar.class)
* }
* </pre>
- *
+ *
* @since 1.6, JAXB 2.0
*/
-@Retention(RUNTIME) @Target({FIELD,METHOD,PACKAGE})
+@Retention(RUNTIME) @Target({FIELD,METHOD,PACKAGE})
public @interface XmlSchemaType {
String name();
String namespace() default "http://www.w3.org/2001/XMLSchema";
@@ -81,7 +81,7 @@
* the type() must be specified.
*/
- Class type() default DEFAULT.class;
+ Class<?> type() default DEFAULT.class;
/**
* Used in {@link XmlSchemaType#type()} to
@@ -89,7 +89,9 @@
* of the property.
*/
- static final class DEFAULT {}
+ static final class DEFAULT {
+ private DEFAULT() {};
+ }
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSeeAlso.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSeeAlso.java
index 8d8e468..43994d0 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSeeAlso.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlSeeAlso.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -60,5 +60,5 @@
@Target({ElementType.TYPE})
@Retention(RUNTIME)
public @interface XmlSeeAlso {
- Class[] value();
+ Class<?>[] value();
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlType.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlType.java
index 20e9f9b..5d154aa 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlType.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/XmlType.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -424,14 +424,16 @@
* {@code factoryMethod} must not be "" and must be the name of
* a static factory method specified in {@code factoryClass}.
*/
- Class factoryClass() default DEFAULT.class;
+ Class<?> factoryClass() default DEFAULT.class;
/**
* Used in {@link XmlType#factoryClass()} to
* signal that either factory mehod is not used or
* that it's in the class with this {@link XmlType} itself.
*/
- static final class DEFAULT {}
+ static final class DEFAULT {
+ private DEFAULT() {}
+ }
/**
* Name of a no-arg factory method in the class specified in
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/CollapsedStringAdapter.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/CollapsedStringAdapter.java
index 198a21f..97b2347 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/CollapsedStringAdapter.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/CollapsedStringAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -10,8 +10,6 @@
package jakarta.xml.bind.annotation.adapters;
-
-
/**
* Built-in {@link XmlAdapter} to handle {@code xs:token} and its derived types.
*
@@ -23,11 +21,15 @@
* @since 1.6, JAXB 2.0
*/
public class CollapsedStringAdapter extends XmlAdapter<String,String> {
+
+ public CollapsedStringAdapter() {}
+
/**
* Removes leading and trailing whitespaces of the string
* given as the parameter, then truncate any
* sequence of tab, CR, LF, and SP by a single whitespace character ' '.
*/
+ @Override
public String unmarshal(String text) {
if(text==null) return null; // be defensive
@@ -87,6 +89,7 @@
*
* Just return the same string given as the parameter.
*/
+ @Override
public String marshal(String s) {
return s;
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/HexBinaryAdapter.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/HexBinaryAdapter.java
index f0fb84f..5a74f80 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/HexBinaryAdapter.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/HexBinaryAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -22,11 +22,16 @@
* @since 1.6, JAXB 2.0
*/
public final class HexBinaryAdapter extends XmlAdapter<String,byte[]> {
+
+ public HexBinaryAdapter() {}
+
+ @Override
public byte[] unmarshal(String s) {
if(s==null) return null;
return DatatypeConverter.parseHexBinary(s);
}
+ @Override
public String marshal(byte[] bytes) {
if(bytes==null) return null;
return DatatypeConverter.printHexBinary(bytes);
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/NormalizedStringAdapter.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/NormalizedStringAdapter.java
index dcdedcc..613862f 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/NormalizedStringAdapter.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/NormalizedStringAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -10,8 +10,6 @@
package jakarta.xml.bind.annotation.adapters;
-
-
/**
* {@link XmlAdapter} to handle {@code xs:normalizedString}.
*
@@ -23,10 +21,14 @@
* @since 1.6, JAXB 2.0
*/
public final class NormalizedStringAdapter extends XmlAdapter<String,String> {
+
+ public NormalizedStringAdapter() {}
+
/**
* Replace any tab, CR, and LF by a whitespace character ' ',
* as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a>
*/
+ @Override
public String unmarshal(String text) {
if(text==null) return null; // be defensive
@@ -57,6 +59,7 @@
*
* Just return the same string given as the parameter.
*/
+ @Override
public String marshal(String s) {
return s;
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java
index 22d92c4..15f94af 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -36,8 +36,8 @@
* <p> <b> Usage: </b> </p>
*
* <p> The {@code @XmlJavaTypeAdapter} annotation can be used with the
- * following program elements:
- * <ul>
+ * following program elements:
+ * <ul>
* <li> a JavaBean property </li>
* <li> field </li>
* <li> parameter </li>
@@ -56,7 +56,7 @@
* <p> A {@code @XmlJavaTypeAdapter} annotation on a field, property
* or parameter overrides the {@code @XmlJavaTypeAdapter} annotation
* associated with the class being referenced by the field, property
- * or parameter.
+ * or parameter.
* <p> A {@code @XmlJavaTypeAdapter} annotation on a class overrides
* the {@code @XmlJavaTypeAdapter} annotation specified at the
* package level for that class.
@@ -66,8 +66,8 @@
* {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be
* used at the package level with the following annotations:
* {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType},
- * {@link XmlSchemaTypes}.
- *
+ * {@link XmlSchemaTypes}.
+ *
* <p><b> Example: </b> See example in {@link XmlAdapter}
*
* @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul>
@@ -75,20 +75,20 @@
* @see XmlAdapter
*/
-@Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
+@Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
public @interface XmlJavaTypeAdapter {
/**
* Points to the class that converts a value type to a bound type or vice versa.
* See {@link XmlAdapter} for more details.
*/
- Class<? extends XmlAdapter> value();
+ Class<? extends XmlAdapter<?, ?>> value();
/**
* If this annotation is used at the package level, then value of
* the type() must be specified.
*/
- Class type() default DEFAULT.class;
+ Class<?> type() default DEFAULT.class;
/**
* Used in {@link XmlJavaTypeAdapter#type()} to
@@ -96,6 +96,8 @@
* of the field, property, parameter or the class.
*/
- static final class DEFAULT {}
-
+ static final class DEFAULT {
+ private DEFAULT() {}
+ }
+
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentMarshaller.java b/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentMarshaller.java
index 4fd991f..fae7f70 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentMarshaller.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentMarshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -45,6 +45,11 @@
public abstract class AttachmentMarshaller {
/**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected AttachmentMarshaller() {}
+
+ /**
* <p>Consider MIME content {@code data} for optimized binary storage as an attachment.
*
* <p>
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentUnmarshaller.java b/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentUnmarshaller.java
index 884ef84..f31622e 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentUnmarshaller.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/attachment/AttachmentUnmarshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -17,8 +17,8 @@
*
* <p>This API enables an efficient cooperative processing of optimized
* binary data formats between a Jakarta XML Binding implementation and MIME-based package
- * processor (MTOM/XOP and WS-I AP 1.0). Jakarta XML Binding unmarshals the body of a package, delegating the
- * understanding of the packaging format being used to a MIME-based
+ * processor (MTOM/XOP and WS-I AP 1.0). Jakarta XML Binding unmarshals the body of a package, delegating the
+ * understanding of the packaging format being used to a MIME-based
* package processor that implements this abstract class.</p>
*
* <p>This abstract class identifies if a package requires XOP processing, {@link #isXOPPackage()}
@@ -27,24 +27,24 @@
* <h2>Identifying the content-id, cid, to pass to {@code getAttachment*(String cid)}</h2>
* <ul>
* <li>
- * For XOP processing, the infoset representation of the cid is described
- * in step 2a in
+ * For XOP processing, the infoset representation of the cid is described
+ * in step 2a in
* <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#interpreting_xop_packages">Section 3.2 Interpreting XOP Packages</a>
* </li>
* <li>
- * For WS-I AP 1.0, the cid is identified as an element or attribute of
+ * For WS-I AP 1.0, the cid is identified as an element or attribute of
* type {@code ref:swaRef} specified in
* <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope">
* Section 4.4 Referencing Attachments from the SOAP Envelope</a>
* </li>
* </ul>
- *
+ *
* @author Marc Hadley
* @author Kohsuke Kawaguchi
* @author Joseph Fialli
- *
+ *
* @since 1.6, JAXB 2.0
- *
+ *
* @see jakarta.xml.bind.Unmarshaller#setAttachmentUnmarshaller(AttachmentUnmarshaller)
*
* @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
@@ -52,11 +52,17 @@
* @see <a href="http://www.w3.org/TR/xml-media-types/">Describing Media Content of Binary Data in XML</a>
*/
public abstract class AttachmentUnmarshaller {
- /**
+
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected AttachmentUnmarshaller() {}
+
+ /**
* <p>Lookup MIME content by content-id, {@code cid}, and return as a {@link DataHandler}.</p>
- *
+ *
* <p>The returned {@code DataHandler} instance must be configured
- * to meet the following required mapping constaint.
+ * to meet the following required mapping constaint.
* <table class="striped">
* <caption>Required Mappings between MIME and Java Types</caption>
* <thead>
@@ -85,11 +91,11 @@
* </tbody>
* </table>
* Note that it is allowable to support additional mappings.
- *
- * @param cid It is expected to be a valid lexical form of the XML Schema
+ *
+ * @param cid It is expected to be a valid lexical form of the XML Schema
* {@code xs:anyURI} datatype. If {@link #isXOPPackage()}{@code ==true},
* it must be a valid URI per the {@code cid:} URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
- *
+ *
* @return
* a {@link DataHandler} that represents the MIME attachment.
*
@@ -100,12 +106,12 @@
/**
* <p>Retrieve the attachment identified by content-id, {@code cid}, as a {@code byte[]}.
*
- * @param cid It is expected to be a valid lexical form of the XML Schema
+ * @param cid It is expected to be a valid lexical form of the XML Schema
* {@code xs:anyURI} datatype. If {@link #isXOPPackage()}{@code ==true},
* it must be a valid URI per the {@code cid:} URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
*
* @return byte[] representation of attachment identified by cid.
- *
+ *
* @throws IllegalArgumentException if the attachment for the given cid is not found.
*/
public abstract byte[] getAttachmentAsByteArray(String cid);
@@ -119,7 +125,7 @@
*
* @return true when MIME context is a XOP Document.
*/
- public boolean isXOPPackage() { return false; }
+ public boolean isXOPPackage() { return false; }
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractMarshallerImpl.java b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractMarshallerImpl.java
index 4b1b15f..599ee4e 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractMarshallerImpl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractMarshallerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -34,11 +34,11 @@
/**
* Partial default {@code Marshaller} implementation.
- *
+ *
* <p>
* This class provides a partial default implementation for the
* {@link jakarta.xml.bind.Marshaller} interface.
- *
+ *
* <p>
* The only methods that a Jakarta XML Binding Provider has to implement are
* {@link Marshaller#marshal(Object, javax.xml.transform.Result) marshal(Object, javax.xml.transform.Result)},
@@ -52,34 +52,41 @@
public abstract class AbstractMarshallerImpl implements Marshaller
{
/** handler that will be used to process errors and warnings during marshal */
- private ValidationEventHandler eventHandler =
+ private ValidationEventHandler eventHandler =
new DefaultValidationEventHandler();
-
+
//J2SE1.4 feature
//private Charset encoding = null;
-
+
/** store the value of the encoding property. */
private String encoding = "UTF-8";
-
+
/** store the value of the schemaLocation property. */
private String schemaLocation = null;
/** store the value of the noNamespaceSchemaLocation property. */
private String noNSSchemaLocation = null;
-
+
/** store the value of the formattedOutput property. */
private boolean formattedOutput = false;
/** store the value of the fragment property. */
private boolean fragment = false;
+ /**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected AbstractMarshallerImpl() {}
+
+ @Override
public final void marshal( Object obj, java.io.OutputStream os )
throws JAXBException {
-
+
checkNotNull( obj, "obj", os, "os" );
marshal( obj, new StreamResult(os) );
}
+ @Override
public void marshal(Object jaxbElement, File output) throws JAXBException {
checkNotNull(jaxbElement, "jaxbElement", output, "output" );
try {
@@ -94,117 +101,121 @@
}
}
- public final void marshal( Object obj, java.io.Writer w )
+ @Override
+ public final void marshal( Object obj, java.io.Writer w )
throws JAXBException {
-
+
checkNotNull( obj, "obj", w, "writer" );
marshal( obj, new StreamResult(w) );
}
-
- public final void marshal( Object obj, org.xml.sax.ContentHandler handler )
+
+ @Override
+ public final void marshal( Object obj, org.xml.sax.ContentHandler handler )
throws JAXBException {
-
+
checkNotNull( obj, "obj", handler, "handler" );
marshal( obj, new SAXResult(handler) );
}
-
- public final void marshal( Object obj, org.w3c.dom.Node node )
+
+ @Override
+ public final void marshal( Object obj, org.w3c.dom.Node node )
throws JAXBException {
-
+
checkNotNull( obj, "obj", node, "node" );
marshal( obj, new DOMResult(node) );
}
-
+
/**
* By default, the getNode method is unsupported and throw
* an {@link java.lang.UnsupportedOperationException}.
- *
+ *
* Implementations that choose to support this method must
* override this method.
*/
+ @Override
public org.w3c.dom.Node getNode( Object obj ) throws JAXBException {
-
+
checkNotNull( obj, "obj", Boolean.TRUE, "foo" );
-
+
throw new UnsupportedOperationException();
}
-
+
/**
* Convenience method for getting the current output encoding.
- *
+ *
* @return the current encoding or "UTF-8" if it hasn't been set.
*/
protected String getEncoding() {
return encoding;
}
-
+
/**
* Convenience method for setting the output encoding.
- *
- * @param encoding a valid encoding as specified in the Marshaller class
+ *
+ * @param encoding a valid encoding as specified in the Marshaller class
* documentation
*/
protected void setEncoding( String encoding ) {
this.encoding = encoding;
}
-
+
/**
* Convenience method for getting the current schemaLocation.
- *
+ *
* @return the current schemaLocation or null if it hasn't been set
*/
protected String getSchemaLocation() {
return schemaLocation;
}
-
+
/**
* Convenience method for setting the schemaLocation.
- *
+ *
* @param location the schemaLocation value
*/
protected void setSchemaLocation( String location ) {
schemaLocation = location;
}
-
+
/**
* Convenience method for getting the current noNamespaceSchemaLocation.
- *
+ *
* @return the current noNamespaceSchemaLocation or null if it hasn't
* been set
*/
protected String getNoNSSchemaLocation() {
return noNSSchemaLocation;
}
-
+
/**
* Convenience method for setting the noNamespaceSchemaLocation.
- *
+ *
* @param location the noNamespaceSchemaLocation value
*/
protected void setNoNSSchemaLocation( String location ) {
noNSSchemaLocation = location;
}
-
+
/**
* Convenience method for getting the formatted output flag.
- *
+ *
* @return the current value of the formatted output flag or false if
* it hasn't been set.
*/
protected boolean isFormattedOutput() {
return formattedOutput;
}
-
+
/**
* Convenience method for setting the formatted output flag.
- *
+ *
* @param v value of the formatted output flag.
*/
protected void setFormattedOutput( boolean v ) {
formattedOutput = v;
}
-
-
+
+
/**
* Convenience method for getting the fragment flag.
*
@@ -232,46 +243,46 @@
"UTF-16LE", "UnicodeLittleUnmarked",
"US-ASCII", "ASCII",
"TIS-620", "TIS620",
-
+
// taken from the project-X parser
"ISO-10646-UCS-2", "Unicode",
-
+
"EBCDIC-CP-US", "cp037",
"EBCDIC-CP-CA", "cp037",
"EBCDIC-CP-NL", "cp037",
"EBCDIC-CP-WT", "cp037",
-
+
"EBCDIC-CP-DK", "cp277",
"EBCDIC-CP-NO", "cp277",
"EBCDIC-CP-FI", "cp278",
"EBCDIC-CP-SE", "cp278",
-
+
"EBCDIC-CP-IT", "cp280",
"EBCDIC-CP-ES", "cp284",
"EBCDIC-CP-GB", "cp285",
"EBCDIC-CP-FR", "cp297",
-
+
"EBCDIC-CP-AR1", "cp420",
"EBCDIC-CP-HE", "cp424",
"EBCDIC-CP-BE", "cp500",
"EBCDIC-CP-CH", "cp500",
-
+
"EBCDIC-CP-ROECE", "cp870",
"EBCDIC-CP-YU", "cp870",
"EBCDIC-CP-IS", "cp871",
"EBCDIC-CP-AR2", "cp918",
-
+
// IANA also defines two that JDK 1.2 doesn't handle:
// EBCDIC-CP-GR --> CP423
// EBCDIC-CP-TR --> CP905
};
-
+
/**
* Gets the corresponding Java encoding name from an IANA name.
- *
+ *
* This method is a helper method for the derived class to convert
* encoding names.
- *
+ *
* @exception UnsupportedEncodingException
* If this implementation couldn't find the Java encoding name.
*/
@@ -287,7 +298,7 @@
return aliases[i+1];
}
}
-
+
throw new UnsupportedEncodingException(encoding);
}
/* J2SE1.4 feature
@@ -298,21 +309,22 @@
}
*/
}
-
+
/**
* Default implementation of the setProperty method handles
- * the four defined properties in Marshaller. If a provider
- * needs to handle additional properties, it should override
+ * the four defined properties in Marshaller. If a provider
+ * needs to handle additional properties, it should override
* this method in a derived class.
*/
+ @Override
public void setProperty( String name, Object value )
throws PropertyException {
-
+
if( name == null ) {
- throw new IllegalArgumentException(
+ throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "name" ) );
}
-
+
// recognize and handle four pre-defined properties.
if( JAXB_ENCODING.equals(name) ) {
checkString( name, value );
@@ -320,7 +332,7 @@
return;
}
if( JAXB_FORMATTED_OUTPUT.equals(name) ) {
- checkBoolean( name, value );
+ checkBoolean( name, value );
setFormattedOutput((Boolean) value );
return;
}
@@ -345,18 +357,19 @@
/**
* Default implementation of the getProperty method handles
- * the four defined properties in Marshaller. If a provider
- * needs to support additional provider specific properties,
+ * the four defined properties in Marshaller. If a provider
+ * needs to support additional provider specific properties,
* it should override this method in a derived class.
*/
+ @Override
public Object getProperty( String name )
throws PropertyException {
-
+
if( name == null ) {
- throw new IllegalArgumentException(
+ throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "name" ) );
}
-
+
// recognize and handle four pre-defined properties.
if( JAXB_ENCODING.equals(name) )
return getEncoding();
@@ -374,6 +387,7 @@
/**
* @see jakarta.xml.bind.Marshaller#getEventHandler()
*/
+ @Override
public ValidationEventHandler getEventHandler() throws JAXBException {
return eventHandler;
}
@@ -381,9 +395,10 @@
/**
* @see jakarta.xml.bind.Marshaller#setEventHandler(ValidationEventHandler)
*/
+ @Override
public void setEventHandler(ValidationEventHandler handler)
throws JAXBException {
-
+
if( handler == null ) {
eventHandler = new DefaultValidationEventHandler();
} else {
@@ -402,7 +417,7 @@
throw new PropertyException(
Messages.format( Messages.MUST_BE_BOOLEAN, name ) );
}
-
+
/*
* assert that the given object is a String
*/
@@ -411,69 +426,82 @@
throw new PropertyException(
Messages.format( Messages.MUST_BE_STRING, name ) );
}
-
+
/*
* assert that the parameters are not null
*/
private void checkNotNull( Object o1, String o1Name,
Object o2, String o2Name ) {
-
+
if( o1 == null ) {
- throw new IllegalArgumentException(
+ throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, o1Name ) );
}
if( o2 == null ) {
- throw new IllegalArgumentException(
+ throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, o2Name ) );
}
}
+ @Override
public void marshal(Object obj, XMLEventWriter writer)
throws JAXBException {
-
+
throw new UnsupportedOperationException();
}
+ @Override
public void marshal(Object obj, XMLStreamWriter writer)
throws JAXBException {
-
+
throw new UnsupportedOperationException();
}
+ @Override
public void setSchema(Schema schema) {
throw new UnsupportedOperationException();
}
+ @Override
public Schema getSchema() {
throw new UnsupportedOperationException();
}
- public void setAdapter(XmlAdapter adapter) {
- if(adapter==null)
+ @Override
+ @SuppressWarnings("unchecked")
+ public <A extends XmlAdapter<?, ?>> void setAdapter(A adapter) {
+ if (adapter==null) {
throw new IllegalArgumentException();
- setAdapter((Class)adapter.getClass(),adapter);
+ }
+ setAdapter((Class<A>)adapter.getClass(),adapter);
}
- public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter) {
+ @Override
+ public <A extends XmlAdapter<?, ?>> void setAdapter(Class<A> type, A adapter) {
throw new UnsupportedOperationException();
}
- public <A extends XmlAdapter> A getAdapter(Class<A> type) {
+ @Override
+ public <A extends XmlAdapter<?, ?>> A getAdapter(Class<A> type) {
throw new UnsupportedOperationException();
}
+ @Override
public void setAttachmentMarshaller(AttachmentMarshaller am) {
throw new UnsupportedOperationException();
}
+ @Override
public AttachmentMarshaller getAttachmentMarshaller() {
throw new UnsupportedOperationException();
}
+ @Override
public void setListener(Listener listener) {
throw new UnsupportedOperationException();
}
+ @Override
public Listener getListener() {
throw new UnsupportedOperationException();
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractUnmarshallerImpl.java b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractUnmarshallerImpl.java
index 2065ab5..5cc1d2f 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractUnmarshallerImpl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/AbstractUnmarshallerImpl.java
@@ -23,6 +23,11 @@
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import jakarta.xml.bind.attachment.AttachmentUnmarshaller;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.Reader;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.XMLEventReader;
@@ -32,21 +37,20 @@
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
-import java.io.*;
import java.net.URL;
/**
* Partial default {@code Unmarshaller} implementation.
- *
+ *
* <p>
* This class provides a partial default implementation for the
* {@link jakarta.xml.bind.Unmarshaller}interface.
- *
+ *
* <p>
* A Jakarta XML Binding Provider has to implement five methods (getUnmarshallerHandler,
* unmarshal(Node), unmarshal(XMLReader,InputSource),
* unmarshal(XMLStreamReader), and unmarshal(XMLEventReader).
- *
+ *
* @author <ul>
* <li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li>
* </ul>
@@ -54,9 +58,9 @@
* @since 1.6, JAXB 1.0
*/
public abstract class AbstractUnmarshallerImpl implements Unmarshaller
-{
+{
/** handler that will be used to process errors and warnings during unmarshal */
- private ValidationEventHandler eventHandler =
+ private ValidationEventHandler eventHandler =
new DefaultValidationEventHandler();
/**
@@ -65,11 +69,16 @@
private XMLReader reader = null;
/**
+ * Do-nothing constructor for the derived classes.
+ */
+ protected AbstractUnmarshallerImpl() {}
+
+ /**
* Obtains a configured XMLReader.
- *
+ *
* This method is used when the client-specified
* {@link SAXSource} object doesn't have XMLReader.
- *
+ *
* {@link Unmarshaller} is not re-entrant, so we will
* only use one instance of XMLReader.
*/
@@ -79,55 +88,55 @@
SAXParserFactory parserFactory;
parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
- // there is no point in asking a validation because
+ // there is no point in asking a validation because
// there is no guarantee that the document will come with
// a proper schemaLocation.
parserFactory.setValidating(false);
reader = parserFactory.newSAXParser().getXMLReader();
- } catch( ParserConfigurationException e ) {
- throw new JAXBException(e);
- } catch( SAXException e ) {
+ } catch( ParserConfigurationException | SAXException e ) {
throw new JAXBException(e);
}
}
return reader;
}
-
+
+ @Override
public Object unmarshal( Source source ) throws JAXBException {
if( source == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "source" ) );
}
-
+
if(source instanceof SAXSource)
return unmarshal( (SAXSource)source );
if(source instanceof StreamSource)
return unmarshal( streamSourceToInputSource((StreamSource)source));
if(source instanceof DOMSource)
return unmarshal( ((DOMSource)source).getNode() );
-
+
// we don't handle other types of Source
throw new IllegalArgumentException();
}
// use the client specified XMLReader contained in the SAXSource.
private Object unmarshal( SAXSource source ) throws JAXBException {
-
+
XMLReader r = source.getXMLReader();
if( r == null )
r = getXMLReader();
-
+
return unmarshal( r, source.getInputSource() );
}
/**
* Unmarshals an object by using the specified XMLReader and the InputSource.
- *
+ *
* The callee should call the setErrorHandler method of the XMLReader
* so that errors are passed to the client-specified ValidationEventHandler.
*/
protected abstract Object unmarshal( XMLReader reader, InputSource source ) throws JAXBException;
-
+
+ @Override
public final Object unmarshal( InputSource source ) throws JAXBException {
if( source == null ) {
throw new IllegalArgumentException(
@@ -136,12 +145,13 @@
return unmarshal( getXMLReader(), source );
}
-
+
private Object unmarshal( String url ) throws JAXBException {
return unmarshal( new InputSource(url) );
}
-
+
+ @Override
public final Object unmarshal( URL url ) throws JAXBException {
if( url == null ) {
throw new IllegalArgumentException(
@@ -150,7 +160,8 @@
return unmarshal( url.toExternalForm() );
}
-
+
+ @Override
public final Object unmarshal( File f ) throws JAXBException {
if( f == null ) {
throw new IllegalArgumentException(
@@ -163,10 +174,11 @@
throw new IllegalArgumentException(e.getMessage());
}
}
-
- public final Object unmarshal( java.io.InputStream is )
+
+ @Override
+ public final Object unmarshal( java.io.InputStream is )
throws JAXBException {
-
+
if( is == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "is" ) );
@@ -176,6 +188,7 @@
return unmarshal( isrc );
}
+ @Override
public final Object unmarshal( Reader reader ) throws JAXBException {
if( reader == null ) {
throw new IllegalArgumentException(
@@ -192,11 +205,11 @@
is.setSystemId( ss.getSystemId() );
is.setByteStream( ss.getInputStream() );
is.setCharacterStream( ss.getReader() );
-
+
return is;
}
-
-
+
+
/**
* Allow an application to register a validation event handler.
* <p>
@@ -211,17 +224,18 @@
* @throws JAXBException if an error was encountered while setting the
* event handler
*/
- public void setEventHandler(ValidationEventHandler handler)
+ @Override
+ public void setEventHandler(ValidationEventHandler handler)
throws JAXBException {
-
+
if( handler == null ) {
eventHandler = new DefaultValidationEventHandler();
} else {
eventHandler = handler;
}
}
-
-
+
+
/**
* Return the current event handler or the default event handler if one
* hasn't been set.
@@ -231,16 +245,17 @@
* @throws JAXBException if an error was encountered while getting the
* current event handler
*/
+ @Override
public ValidationEventHandler getEventHandler() throws JAXBException {
return eventHandler;
}
-
-
+
+
/**
* Creates an UnmarshalException from a SAXException.
- *
+ *
* This is an utility method provided for the derived classes.
- *
+ *
* <p>
* When a provider-implemented ContentHandler wants to throw a
* JAXBException, it needs to wrap the exception by a SAXException.
@@ -248,11 +263,11 @@
* by JAXBException, such an exception will be a JAXBException
* wrapped by a SAXException wrapped by another JAXBException.
* This is silly.
- *
+ *
* <p>
* This method checks the nested exception of SAXException
* and reduce those excessive wrapping.
- *
+ *
* @return the resulting UnmarshalException
*/
protected UnmarshalException createUnmarshalException( SAXException e ) {
@@ -260,27 +275,28 @@
Exception nested = e.getException();
if(nested instanceof UnmarshalException)
return (UnmarshalException)nested;
-
+
if(nested instanceof RuntimeException)
// typically this is an unexpected exception,
// just throw it rather than wrap it, so that the full stack
// trace can be displayed.
throw (RuntimeException)nested;
-
-
+
+
// otherwise simply wrap it
if(nested!=null)
return new UnmarshalException(nested);
else
return new UnmarshalException(e);
}
-
+
/**
- * Default implementation of the setProperty method always
+ * Default implementation of the setProperty method always
* throws PropertyException since there are no required
- * properties. If a provider needs to handle additional
+ * properties. If a provider needs to handle additional
* properties, it should override this method in a derived class.
*/
+ @Override
public void setProperty( String name, Object value )
throws PropertyException {
@@ -291,16 +307,17 @@
throw new PropertyException(name, value);
}
-
+
/**
- * Default implementation of the getProperty method always
+ * Default implementation of the getProperty method always
* throws PropertyException since there are no required
- * properties. If a provider needs to handle additional
+ * properties. If a provider needs to handle additional
* properties, it should override this method in a derived class.
*/
+ @Override
public Object getProperty( String name )
throws PropertyException {
-
+
if( name == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "name" ) );
@@ -308,67 +325,84 @@
throw new PropertyException(name);
}
-
+
+ @Override
public Object unmarshal(XMLEventReader reader) throws JAXBException {
-
+
throw new UnsupportedOperationException();
}
+ @Override
public Object unmarshal(XMLStreamReader reader) throws JAXBException {
-
+
throw new UnsupportedOperationException();
}
+ @Override
public <T> JAXBElement<T> unmarshal(Node node, Class<T> expectedType) throws JAXBException {
throw new UnsupportedOperationException();
}
+ @Override
public <T> JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws JAXBException {
throw new UnsupportedOperationException();
}
+ @Override
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws JAXBException {
throw new UnsupportedOperationException();
}
+ @Override
public <T> JAXBElement<T> unmarshal(XMLEventReader reader, Class<T> expectedType) throws JAXBException {
throw new UnsupportedOperationException();
}
+ @Override
public void setSchema(Schema schema) {
throw new UnsupportedOperationException();
}
+ @Override
public Schema getSchema() {
throw new UnsupportedOperationException();
}
- public void setAdapter(XmlAdapter adapter) {
- if(adapter==null)
+ @Override
+ @SuppressWarnings("unchecked")
+ public <A extends XmlAdapter<?, ?>> void setAdapter(A adapter) {
+ if(adapter==null) {
throw new IllegalArgumentException();
- setAdapter((Class)adapter.getClass(),adapter);
+ }
+ setAdapter((Class<A>) adapter.getClass(),adapter);
}
- public <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter) {
+ @Override
+ public <A extends XmlAdapter<?, ?>> void setAdapter(Class<A> type, A adapter) {
throw new UnsupportedOperationException();
}
- public <A extends XmlAdapter> A getAdapter(Class<A> type) {
+ @Override
+ public <A extends XmlAdapter<?, ?>> A getAdapter(Class<A> type) {
throw new UnsupportedOperationException();
}
+ @Override
public void setAttachmentUnmarshaller(AttachmentUnmarshaller au) {
throw new UnsupportedOperationException();
}
+ @Override
public AttachmentUnmarshaller getAttachmentUnmarshaller() {
throw new UnsupportedOperationException();
}
+ @Override
public void setListener(Listener listener) {
throw new UnsupportedOperationException();
}
+ @Override
public Listener getListener() {
throw new UnsupportedOperationException();
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/DefaultValidationEventHandler.java b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/DefaultValidationEventHandler.java
index 54875cc..8a42489 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/DefaultValidationEventHandler.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/DefaultValidationEventHandler.java
@@ -19,17 +19,17 @@
/**
* <p>
- * JAXB 1.0 only default validation event handler. This is the default
+ * JAXB 1.0 only default validation event handler. This is the default
* handler for all objects created from a JAXBContext that is managing
- * schema-derived code generated by a JAXB 1.0 binding compiler.
+ * schema-derived code generated by a JAXB 1.0 binding compiler.
*
* <p>
* This handler causes the unmarshal and validate operations to fail on the first
* error or fatal error.
- *
+ *
* <p>
- * This handler is not the default handler for Jakarta XML Binding mapped classes following
- * Jakarta XML Binding or later versions. Default validation event handling has changed
+ * This handler is not the default handler for Jakarta XML Binding mapped classes following
+ * Jakarta XML Binding or later versions. Default validation event handling has changed
* and is specified in {@link jakarta.xml.bind.Unmarshaller} and
* {@link jakarta.xml.bind.Marshaller}.
*
@@ -39,14 +39,17 @@
* @since 1.6, JAXB 1.0
*/
public class DefaultValidationEventHandler implements ValidationEventHandler {
-
+
+ public DefaultValidationEventHandler() {}
+
+ @Override
public boolean handleEvent( ValidationEvent event ) {
-
+
if( event == null ) {
throw new IllegalArgumentException();
}
- // calculate the severity prefix and return value
+ // calculate the severity prefix and return value
String severity = null;
boolean retVal = false;
switch ( event.getSeverity() ) {
@@ -67,49 +70,49 @@
Messages.format( Messages.UNRECOGNIZED_SEVERITY,
event.getSeverity() );
}
-
+
// calculate the location message
String location = getLocation( event );
-
- System.out.println(
+
+ System.out.println(
Messages.format( Messages.SEVERITY_MESSAGE,
severity,
event.getMessage(),
location ) );
-
+
// fail on the first error or fatal error
return retVal;
}
/**
* Calculate a location message for the event
- *
+ *
*/
private String getLocation(ValidationEvent event) {
- StringBuffer msg = new StringBuffer();
-
+ StringBuilder msg = new StringBuilder();
+
ValidationEventLocator locator = event.getLocator();
-
+
if( locator != null ) {
-
+
URL url = locator.getURL();
Object obj = locator.getObject();
Node node = locator.getNode();
int line = locator.getLineNumber();
-
+
if( url!=null || line!=-1 ) {
- msg.append( "line " + line );
+ msg.append("line ").append(line);
if( url!=null )
- msg.append( " of " + url );
+ msg.append(" of ").append(url);
} else if( obj != null ) {
- msg.append( " obj: " + obj.toString() );
+ msg.append(" obj: ").append(obj.toString());
} else if( node != null ) {
- msg.append( " node: " + node.toString() );
+ msg.append(" node: ").append(node.toString());
}
} else {
msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) );
- }
-
+ }
+
return msg.toString();
}
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventImpl.java b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventImpl.java
index 8b752fd..5eac79d 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventImpl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventImpl.java
@@ -17,13 +17,13 @@
/**
* Default implementation of the ValidationEvent interface.
- *
+ *
* <p>
* Jakarta XML Binding providers are allowed to use whatever class that implements
* the ValidationEvent interface. This class is just provided for a
* convenience.
*
- * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li></ul>
+ * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li></ul>
* @see jakarta.xml.bind.ValidationEventHandler
* @see jakarta.xml.bind.ValidationEvent
* @see jakarta.xml.bind.ValidationEventLocator
@@ -31,28 +31,28 @@
*/
public class ValidationEventImpl implements ValidationEvent
{
-
+
/**
* Create a new ValidationEventImpl.
- *
+ *
* @param _severity The severity value for this event. Must be one of
- * ValidationEvent.WARNING, ValidationEvent.ERROR, or
+ * ValidationEvent.WARNING, ValidationEvent.ERROR, or
* ValidationEvent.FATAL_ERROR
* @param _message The text message for this event - may be null.
* @param _locator The locator object for this event - may be null.
* @throws IllegalArgumentException if an illegal severity field is supplied
*/
- public ValidationEventImpl( int _severity, String _message,
+ public ValidationEventImpl( int _severity, String _message,
ValidationEventLocator _locator ) {
-
+
this(_severity,_message,_locator,null);
}
/**
* Create a new ValidationEventImpl.
- *
+ *
* @param _severity The severity value for this event. Must be one of
- * ValidationEvent.WARNING, ValidationEvent.ERROR, or
+ * ValidationEvent.WARNING, ValidationEvent.ERROR, or
* ValidationEvent.FATAL_ERROR
* @param _message The text message for this event - may be null.
* @param _locator The locator object for this event - may be null.
@@ -60,87 +60,92 @@
* additional information about the event - may be null.
* @throws IllegalArgumentException if an illegal severity field is supplied
*/
- public ValidationEventImpl( int _severity, String _message,
- ValidationEventLocator _locator,
+ public ValidationEventImpl( int _severity, String _message,
+ ValidationEventLocator _locator,
Throwable _linkedException ) {
-
+
setSeverity( _severity );
this.message = _message;
this.locator = _locator;
this.linkedException = _linkedException;
}
-
+
private int severity;
private String message;
private Throwable linkedException;
private ValidationEventLocator locator;
-
+
+ @Override
public int getSeverity() {
return severity;
}
-
-
+
+
/**
- * Set the severity field of this event.
- *
- * @param _severity Must be one of ValidationEvent.WARNING,
+ * Set the severity field of this event.
+ *
+ * @param _severity Must be one of ValidationEvent.WARNING,
* ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
* @throws IllegalArgumentException if an illegal severity field is supplied
*/
public void setSeverity( int _severity ) {
-
- if( _severity != ValidationEvent.WARNING &&
- _severity != ValidationEvent.ERROR &&
+
+ if( _severity != ValidationEvent.WARNING &&
+ _severity != ValidationEvent.ERROR &&
_severity != ValidationEvent.FATAL_ERROR ) {
- throw new IllegalArgumentException(
+ throw new IllegalArgumentException(
Messages.format( Messages.ILLEGAL_SEVERITY ) );
}
this.severity = _severity;
}
-
+
+ @Override
public String getMessage() {
return message;
}
/**
* Set the message field of this event.
- *
+ *
* @param _message String message - may be null.
*/
public void setMessage( String _message ) {
this.message = _message;
}
-
+
+ @Override
public Throwable getLinkedException() {
return linkedException;
}
/**
* Set the linked exception field of this event.
- *
+ *
* @param _linkedException Optional linked exception - may be null.
*/
public void setLinkedException( Throwable _linkedException ) {
this.linkedException = _linkedException;
}
-
+
+ @Override
public ValidationEventLocator getLocator() {
return locator;
}
/**
* Set the locator object for this event.
- *
+ *
* @param _locator The locator - may be null.
*/
public void setLocator( ValidationEventLocator _locator ) {
this.locator = _locator;
}
-
+
/**
* Returns a string representation of this object in a format
* helpful to debugging.
- *
+ *
* @see Object#equals(Object)
*/
+ @Override
public String toString() {
String s;
switch(getSeverity()) {
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventLocatorImpl.java b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventLocatorImpl.java
index f575c8a..1b282d0 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventLocatorImpl.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/helpers/ValidationEventLocatorImpl.java
@@ -21,13 +21,13 @@
/**
* Default implementation of the ValidationEventLocator interface.
- *
+ *
* <p>
* Jakarta XML Binding providers are allowed to use whatever class that implements
* the ValidationEventLocator interface. This class is just provided for a
* convenience.
*
- * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li></ul>
+ * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li></ul>
* @see jakarta.xml.bind.ValidationEventHandler
* @see jakarta.xml.bind.ValidationEvent
* @see jakarta.xml.bind.ValidationEventLocator
@@ -41,14 +41,14 @@
public ValidationEventLocatorImpl() {
}
- /**
- * Constructs an object from an org.xml.sax.Locator.
- *
- * The object's ColumnNumber, LineNumber, and URL become available from the
+ /**
+ * Constructs an object from an org.xml.sax.Locator.
+ *
+ * The object's ColumnNumber, LineNumber, and URL become available from the
* values returned by the locator's getColumnNumber(), getLineNumber(), and
- * getSystemId() methods respectively. Node, Object, and Offset are not
- * available.
- *
+ * getSystemId() methods respectively. Node, Object, and Offset are not
+ * available.
+ *
* @param loc the SAX Locator object that will be used to populate this
* event locator.
* @throws IllegalArgumentException if the Locator is null
@@ -64,14 +64,14 @@
this.lineNumber = loc.getLineNumber();
}
- /**
- * Constructs an object from the location information of a SAXParseException.
- *
- * The object's ColumnNumber, LineNumber, and URL become available from the
+ /**
+ * Constructs an object from the location information of a SAXParseException.
+ *
+ * The object's ColumnNumber, LineNumber, and URL become available from the
* values returned by the locator's getColumnNumber(), getLineNumber(), and
- * getSystemId() methods respectively. Node, Object, and Offset are not
- * available.
- *
+ * getSystemId() methods respectively. Node, Object, and Offset are not
+ * available.
+ *
* @param e the SAXParseException object that will be used to populate this
* event locator.
* @throws IllegalArgumentException if the SAXParseException is null
@@ -87,12 +87,12 @@
this.lineNumber = e.getLineNumber();
}
- /**
- * Constructs an object that points to a DOM Node.
- *
- * The object's Node becomes available. ColumnNumber, LineNumber, Object,
+ /**
+ * Constructs an object that points to a DOM Node.
+ *
+ * The object's Node becomes available. ColumnNumber, LineNumber, Object,
* Offset, and URL are not available.
- *
+ *
* @param _node the DOM Node object that will be used to populate this
* event locator.
* @throws IllegalArgumentException if the Node is null
@@ -106,12 +106,12 @@
this.node = _node;
}
- /**
- * Constructs an object that points to a Jakarta XML Binding content object.
- *
- * The object's Object becomes available. ColumnNumber, LineNumber, Node,
+ /**
+ * Constructs an object that points to a Jakarta XML Binding content object.
+ *
+ * The object's Object becomes available. ColumnNumber, LineNumber, Node,
* Offset, and URL are not available.
- *
+ *
* @param _object the Object that will be used to populate this
* event locator.
* @throws IllegalArgumentException if the Object is null
@@ -124,7 +124,7 @@
this.object = _object;
}
-
+
/** Converts a system ID to an URL object. */
private static URL toURL( String systemId ) {
try {
@@ -134,117 +134,124 @@
return null; // for now
}
}
-
+
private URL url = null;
private int offset = -1;
private int lineNumber = -1;
private int columnNumber = -1;
private Object object = null;
private Node node = null;
-
-
+
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getURL()
*/
+ @Override
public URL getURL() {
return url;
- }
-
+ }
+
/**
* Set the URL field on this event locator. Null values are allowed.
- *
+ *
* @param _url the url
*/
public void setURL( URL _url ) {
this.url = _url;
- }
-
+ }
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getOffset()
*/
+ @Override
public int getOffset() {
return offset;
}
-
+
/**
- * Set the offset field on this event locator.
- *
+ * Set the offset field on this event locator.
+ *
* @param _offset the offset
*/
public void setOffset( int _offset ) {
this.offset = _offset;
}
-
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getLineNumber()
*/
+ @Override
public int getLineNumber() {
return lineNumber;
}
-
+
/**
* Set the lineNumber field on this event locator.
- *
+ *
* @param _lineNumber the line number
*/
public void setLineNumber( int _lineNumber ) {
this.lineNumber = _lineNumber;
}
-
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getColumnNumber()
*/
+ @Override
public int getColumnNumber() {
return columnNumber;
}
-
+
/**
* Set the columnNumber field on this event locator.
- *
+ *
* @param _columnNumber the column number
*/
public void setColumnNumber( int _columnNumber ) {
this.columnNumber = _columnNumber;
}
-
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getObject()
*/
+ @Override
public Object getObject() {
return object;
}
-
+
/**
* Set the Object field on this event locator. Null values are allowed.
- *
+ *
* @param _object the java content object
*/
public void setObject( Object _object ) {
this.object = _object;
}
-
+
/**
* @see jakarta.xml.bind.ValidationEventLocator#getNode()
*/
+ @Override
public Node getNode() {
return node;
}
-
+
/**
* Set the Node field on this event locator. Null values are allowed.
- *
+ *
* @param _node the Node
*/
public void setNode( Node _node ) {
this.node = _node;
}
-
+
/**
* Returns a string representation of this object in a format
* helpful to debugging.
- *
+ *
* @see Object#equals(Object)
*/
+ @Override
public String toString() {
return MessageFormat.format("[node={0},object={1},url={2},line={3},col={4},offset={5}]",
getNode(),
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/util/JAXBSource.java b/jaxb-api/src/main/java/jakarta/xml/bind/util/JAXBSource.java
index 79287d5..31f7648 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/util/JAXBSource.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/util/JAXBSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -31,31 +31,31 @@
/**
* JAXP {@link javax.xml.transform.Source} implementation
* that marshals a Jakarta XML Binding-generated object.
- *
+ *
* <p>
* This utility class is useful to combine Jakarta XML Binding with
* other Java/XML technologies.
- *
+ *
* <p>
* The following example shows how to use Jakarta XML Binding to marshal a document
* for transformation by XSLT.
- *
+ *
* <blockquote>
* <pre>
* MyObject o = // get JAXB content tree
- *
+ *
* // jaxbContext is a JAXBContext object from which 'o' is created.
* JAXBSource source = new JAXBSource( jaxbContext, o );
- *
+ *
* // set up XSLT transformation
* TransformerFactory tf = TransformerFactory.newInstance();
* Transformer t = tf.newTransformer(new StreamSource("test.xsl"));
- *
+ *
* // run transformation
* t.transform(source,new StreamResult(System.out));
* </pre>
* </blockquote>
- *
+ *
* <p>
* The fact that JAXBSource derives from SAXSource is an implementation
* detail. Thus in general applications are strongly discouraged from
@@ -64,7 +64,7 @@
* The XMLReader object obtained by the getXMLReader method shall
* be used only for parsing the InputSource object returned by
* the getInputSource method.
- *
+ *
* <p>
* Similarly the InputSource object obtained by the getInputSource
* method shall be used only for being parsed by the XMLReader object
@@ -78,7 +78,7 @@
/**
* Creates a new {@link javax.xml.transform.Source} for the given content object.
- *
+ *
* @param context
* JAXBContext that was used to create
* <code>contentObject</code>. This context is used
@@ -90,22 +90,22 @@
* @throws JAXBException if an error is encountered while creating the
* JAXBSource or if either of the parameters are null.
*/
- public JAXBSource( JAXBContext context, Object contentObject )
+ public JAXBSource( JAXBContext context, Object contentObject )
throws JAXBException {
-
- this(
- ( context == null ) ?
- assertionFailed( Messages.format( Messages.SOURCE_NULL_CONTEXT ) ) :
+
+ this(
+ ( context == null ) ?
+ assertionFailed( Messages.format( Messages.SOURCE_NULL_CONTEXT ) ) :
context.createMarshaller(),
-
- ( contentObject == null ) ?
- assertionFailed( Messages.format( Messages.SOURCE_NULL_CONTENT ) ) :
+
+ ( contentObject == null ) ?
+ assertionFailed( Messages.format( Messages.SOURCE_NULL_CONTENT ) ) :
contentObject);
}
-
+
/**
* Creates a new {@link javax.xml.transform.Source} for the given content object.
- *
+ *
* @param marshaller
* A marshaller instance that will be used to marshal
* <code>contentObject</code> into XML. This must be
@@ -118,32 +118,33 @@
* @throws JAXBException if an error is encountered while creating the
* JAXBSource or if either of the parameters are null.
*/
- public JAXBSource( Marshaller marshaller, Object contentObject )
+ public JAXBSource( Marshaller marshaller, Object contentObject )
throws JAXBException {
-
+
if( marshaller == null )
- throw new JAXBException(
+ throw new JAXBException(
Messages.format( Messages.SOURCE_NULL_MARSHALLER ) );
-
+
if( contentObject == null )
- throw new JAXBException(
+ throw new JAXBException(
Messages.format( Messages.SOURCE_NULL_CONTENT ) );
-
+
this.marshaller = marshaller;
this.contentObject = contentObject;
-
+
super.setXMLReader(pseudoParser);
// pass a dummy InputSource. We don't care
super.setInputSource(new InputSource());
}
-
+
private final Marshaller marshaller;
private final Object contentObject;
-
+
// this object will pretend as an XMLReader.
// no matter what parameter is specified to the parse method,
// it just parse the contentObject.
private final XMLReader pseudoParser = new XMLReader() {
+ @Override
public boolean getFeature(String name) throws SAXNotRecognizedException {
if(name.equals("http://xml.org/sax/features/namespaces"))
return true;
@@ -152,6 +153,7 @@
throw new SAXNotRecognizedException(name);
}
+ @Override
public void setFeature(String name, boolean value) throws SAXNotRecognizedException {
if(name.equals("http://xml.org/sax/features/namespaces") && value)
return;
@@ -160,6 +162,7 @@
throw new SAXNotRecognizedException(name);
}
+ @Override
public Object getProperty(String name) throws SAXNotRecognizedException {
if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
return lexicalHandler;
@@ -167,6 +170,7 @@
throw new SAXNotRecognizedException(name);
}
+ @Override
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
if( "http://xml.org/sax/properties/lexical-handler".equals(name) ) {
this.lexicalHandler = (LexicalHandler)value;
@@ -179,17 +183,21 @@
// we will store this value but never use it by ourselves.
private EntityResolver entityResolver;
+ @Override
public void setEntityResolver(EntityResolver resolver) {
this.entityResolver = resolver;
}
+ @Override
public EntityResolver getEntityResolver() {
return entityResolver;
}
private DTDHandler dtdHandler;
+ @Override
public void setDTDHandler(DTDHandler handler) {
this.dtdHandler = handler;
}
+ @Override
public DTDHandler getDTDHandler() {
return dtdHandler;
}
@@ -199,25 +207,31 @@
// two components.
private XMLFilter repeater = new XMLFilterImpl();
+ @Override
public void setContentHandler(ContentHandler handler) {
repeater.setContentHandler(handler);
}
+ @Override
public ContentHandler getContentHandler() {
return repeater.getContentHandler();
}
private ErrorHandler errorHandler;
+ @Override
public void setErrorHandler(ErrorHandler handler) {
this.errorHandler = handler;
}
+ @Override
public ErrorHandler getErrorHandler() {
return errorHandler;
}
+ @Override
public void parse(InputSource input) throws SAXException {
parse();
}
+ @Override
public void parse(String systemId) throws SAXException {
parse();
}
@@ -250,9 +264,9 @@
* Hook to throw exception from the middle of a contructor chained call
* to this
*/
- private static Marshaller assertionFailed( String message )
+ private static Marshaller assertionFailed( String message )
throws JAXBException {
-
+
throw new JAXBException( message );
}
}
diff --git a/jaxb-api/src/main/java/jakarta/xml/bind/util/ValidationEventCollector.java b/jaxb-api/src/main/java/jakarta/xml/bind/util/ValidationEventCollector.java
index 4208e5f..7251d86 100644
--- a/jaxb-api/src/main/java/jakarta/xml/bind/util/ValidationEventCollector.java
+++ b/jaxb-api/src/main/java/jakarta/xml/bind/util/ValidationEventCollector.java
@@ -18,14 +18,14 @@
/**
* {@link jakarta.xml.bind.ValidationEventHandler ValidationEventHandler}
* implementation that collects all events.
- *
+ *
* <p>
* To use this class, create a new instance and pass it to the setEventHandler
- * method of the Validator, Unmarshaller, Marshaller class. After the call to
- * validate or unmarshal completes, call the getEvents method to retrieve all
+ * method of the Unmarshaller, Marshaller class. After the call to
+ * validate or unmarshal completes, call the getEvents method to retrieve all
* the reported errors and warnings.
*
- * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
+ * @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see jakarta.xml.bind.ValidationEventHandler
* @see jakarta.xml.bind.ValidationEvent
* @see jakarta.xml.bind.ValidationEventLocator
@@ -33,12 +33,14 @@
*/
public class ValidationEventCollector implements ValidationEventHandler
{
- private final List<ValidationEvent> events = new ArrayList<ValidationEvent>();
-
+ private final List<ValidationEvent> events = new ArrayList<>();
+
+ public ValidationEventCollector() {}
+
/**
- * Return an array of ValidationEvent objects containing a copy of each of
+ * Return an array of ValidationEvent objects containing a copy of each of
* the collected errors and warnings.
- *
+ *
* @return
* a copy of all the collected errors and warnings or an empty array
* if there weren't any
@@ -46,26 +48,27 @@
public ValidationEvent[] getEvents() {
return events.toArray(new ValidationEvent[events.size()]);
}
-
+
/**
* Clear all collected errors and warnings.
*/
public void reset() {
events.clear();
}
-
+
/**
- * Returns true if this event collector contains at least one
+ * Returns true if this event collector contains at least one
* ValidationEvent.
*
- * @return true if this event collector contains at least one
+ * @return true if this event collector contains at least one
* ValidationEvent, false otherwise
*/
public boolean hasEvents() {
return !events.isEmpty();
}
-
- public boolean handleEvent( ValidationEvent event ) {
+
+ @Override
+ public boolean handleEvent( ValidationEvent event ) {
events.add(event);
boolean retVal = true;
@@ -80,12 +83,12 @@
retVal = false; // halt validation
break;
default:
- _assert( false,
+ _assert( false,
Messages.format( Messages.UNRECOGNIZED_SEVERITY,
event.getSeverity() ) );
break;
}
-
+
return retVal;
}
diff --git a/jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java b/jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
index 87f0cf8..e316871 100644
--- a/jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
+++ b/jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
@@ -32,13 +32,13 @@
* Resolves classes from context path.
* Only one class per package is needed to access its {@link java.lang.Module}
*/
- static Class[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
- List<Class> classes = new ArrayList<>();
+ static Class<?>[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws JAXBException {
+ List<Class<?>> classes = new ArrayList<>();
if (contextPath == null || contextPath.isEmpty()){
- return classes.toArray(new Class[]{});
+ return classes.toArray(new Class<?>[]{});
}
-
- String [] tokens = contextPath.split(":");
+
+ String [] tokens = contextPath.split(":");
for (String pkg : tokens){
// look for ObjectFactory and load it
@@ -50,10 +50,10 @@
} catch (ClassNotFoundException e) {
// not necessarily an error
}
-
+
// look for jaxb.index and load the list of classes
try {
- final Class firstByJaxbIndex = findFirstByJaxbIndex(pkg, classLoader);
+ final Class<?> firstByJaxbIndex = findFirstByJaxbIndex(pkg, classLoader);
if (firstByJaxbIndex != null) {
classes.add(firstByJaxbIndex);
}
@@ -65,13 +65,13 @@
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Resolved classes from context path: {0}", classes);
}
- return classes.toArray(new Class[]{});
+ return classes.toArray(new Class<?>[]{});
}
/**
* Find first class in package by {@code jaxb.index} file.
*/
- static Class findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
+ static Class<?> findFirstByJaxbIndex(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
final String resource = pkg.replace('.', '/') + "/jaxb.index";
final InputStream resourceAsStream = classLoader.getResourceAsStream(resource);
@@ -112,13 +112,13 @@
*
* @throws JAXBException if ony of a classes package is not open to {@code jakarta.xml.bind} module.
*/
- public static void delegateAddOpensToImplModule(Class[] classes, Class<?> factorySPI) throws JAXBException {
+ public static void delegateAddOpensToImplModule(Class<?>[] classes, Class<?> factorySPI) throws JAXBException {
final Module implModule = factorySPI.getModule();
Module jaxbModule = JAXBContext.class.getModule();
- for (Class cls : classes) {
- Class jaxbClass = cls.isArray() ?
+ for (Class<?> cls : classes) {
+ Class<?> jaxbClass = cls.isArray() ?
cls.getComponentType() : cls;
final Module classModule = jaxbClass.getModule();