From 667d73a213fab5ea1b562e30373774205ab982cb Mon Sep 17 00:00:00 2001 From: Lukas Jungmann Date: Sun, 18 Feb 2024 02:19:22 +0100 Subject: [PATCH] typos, grammar, javadoc formatting, minor code cleanup Signed-off-by: Lukas Jungmann --- .../main/java/jakarta/xml/bind/Binder.java | 8 ++--- .../java/jakarta/xml/bind/ContextFinder.java | 24 +++++++------- .../jakarta/xml/bind/DatatypeConverter.java | 6 ++-- .../xml/bind/DatatypeConverterImpl.java | 24 +++++++------- .../xml/bind/DatatypeConverterInterface.java | 6 ++-- .../main/java/jakarta/xml/bind/Element.java | 4 +-- api/src/main/java/jakarta/xml/bind/JAXB.java | 10 +++--- .../java/jakarta/xml/bind/JAXBContext.java | 18 +++++------ .../jakarta/xml/bind/JAXBContextFactory.java | 4 +-- .../java/jakarta/xml/bind/JAXBElement.java | 6 ++-- .../jakarta/xml/bind/JAXBIntrospector.java | 6 ++-- .../java/jakarta/xml/bind/Marshaller.java | 21 ++++++------ .../java/jakarta/xml/bind/ModuleUtil.java | 7 ++-- .../xml/bind/SchemaOutputResolver.java | 12 +++---- .../jakarta/xml/bind/ServiceLoaderUtil.java | 4 +-- .../java/jakarta/xml/bind/Unmarshaller.java | 16 ++++------ .../jakarta/xml/bind/UnmarshallerHandler.java | 2 +- .../xml/bind/ValidationEventHandler.java | 4 +-- .../xml/bind/ValidationEventLocator.java | 4 +-- .../xml/bind/annotation/DomHandler.java | 12 +++---- .../xml/bind/annotation/W3CDomHandler.java | 4 +-- .../xml/bind/annotation/XmlAccessType.java | 10 +++--- .../xml/bind/annotation/XmlAnyAttribute.java | 4 +-- .../xml/bind/annotation/XmlAnyElement.java | 9 ++---- .../xml/bind/annotation/XmlAttachmentRef.java | 4 +-- .../xml/bind/annotation/XmlAttribute.java | 10 +++--- .../xml/bind/annotation/XmlElement.java | 8 ++--- .../xml/bind/annotation/XmlElementDecl.java | 32 +++++++++---------- .../xml/bind/annotation/XmlElementRef.java | 6 ++-- .../xml/bind/annotation/XmlElementRefs.java | 6 ++-- .../bind/annotation/XmlElementWrapper.java | 2 +- .../xml/bind/annotation/XmlElements.java | 4 +-- .../jakarta/xml/bind/annotation/XmlEnum.java | 4 +-- .../jakarta/xml/bind/annotation/XmlID.java | 4 +-- .../jakarta/xml/bind/annotation/XmlIDREF.java | 6 ++-- .../bind/annotation/XmlInlineBinaryData.java | 4 +-- .../jakarta/xml/bind/annotation/XmlMixed.java | 1 - .../jakarta/xml/bind/annotation/XmlNs.java | 4 +-- .../xml/bind/annotation/XmlNsForm.java | 4 +-- .../xml/bind/annotation/XmlRootElement.java | 2 +- .../xml/bind/annotation/XmlSchema.java | 8 ++--- .../xml/bind/annotation/XmlSchemaType.java | 2 +- .../xml/bind/annotation/XmlSeeAlso.java | 2 +- .../jakarta/xml/bind/annotation/XmlType.java | 18 +++++------ .../jakarta/xml/bind/annotation/XmlValue.java | 8 ++--- .../adapters/CollapsedStringAdapter.java | 4 +-- .../adapters/NormalizedStringAdapter.java | 5 ++- .../bind/annotation/adapters/XmlAdapter.java | 4 +-- .../annotation/adapters/package-info.java | 4 +-- .../xml/bind/annotation/package-info.java | 6 ++-- .../bind/attachment/AttachmentMarshaller.java | 6 ++-- .../attachment/AttachmentUnmarshaller.java | 6 ++-- .../bind/helpers/AbstractMarshallerImpl.java | 13 +++----- .../helpers/AbstractUnmarshallerImpl.java | 20 ++++++------ .../DefaultValidationEventHandler.java | 6 ++-- .../xml/bind/helpers/ValidationEventImpl.java | 5 ++- .../helpers/ValidationEventLocatorImpl.java | 12 +++---- .../jakarta/xml/bind/util/JAXBResult.java | 8 ++--- .../jakarta/xml/bind/util/JAXBSource.java | 8 ++--- .../bind/util/ValidationEventCollector.java | 6 ++-- .../jakarta/xml/bind/Messages.properties | 8 ++--- 61 files changed, 236 insertions(+), 249 deletions(-) diff --git a/api/src/main/java/jakarta/xml/bind/Binder.java b/api/src/main/java/jakarta/xml/bind/Binder.java index cb3f17f..89305d6 100644 --- a/api/src/main/java/jakarta/xml/bind/Binder.java +++ b/api/src/main/java/jakarta/xml/bind/Binder.java @@ -237,7 +237,7 @@ protected Binder() {} public abstract Object getJAXBNode( XmlNode xmlNode ); /** - * Takes an Jakarta XML Binding object and updates + * Takes a Jakarta XML Binding object and updates * its associated XML node and its descendants. * *

@@ -272,7 +272,7 @@ protected Binder() {} * would create a new tree that doesn't contain any of those.) * *

- * As a side-effect, this operation updates the association between + * As a side effect, this operation updates the association between * XML nodes and Jakarta XML Binding objects. * * @param jaxbObject root of potentially modified Jakarta XML Binding object tree @@ -301,7 +301,7 @@ protected Binder() {} * as possible. * *

- * As a side-effect, this operation updates the association between + * As a side effect, this operation updates the association between * XML nodes and Jakarta XML Binding objects. * * @param xmlNode the XML node @@ -350,7 +350,7 @@ protected Binder() {} * *

* Calling this method with a null parameter will cause the Binder - * to revert back to the default default event handler. + * to revert back to the default event handler. * * @param handler the validation event handler * @throws JAXBException if an error was encountered while setting the diff --git a/api/src/main/java/jakarta/xml/bind/ContextFinder.java b/api/src/main/java/jakarta/xml/bind/ContextFinder.java index 10c995e..6424a09 100644 --- a/api/src/main/java/jakarta/xml/bind/ContextFinder.java +++ b/api/src/main/java/jakarta/xml/bind/ContextFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024 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 @@ -28,7 +28,7 @@ /** * This class is package private and therefore is not exposed as part of the * Jakarta XML Binding API. - * + *

* This code is designed to implement the XML Binding spec pluggability feature * * @author

@@ -77,7 +77,7 @@ class ContextFinder { } private static ServiceLoaderUtil.ExceptionHandler EXCEPTION_HANDLER = - new ServiceLoaderUtil.ExceptionHandler() { + new ServiceLoaderUtil.ExceptionHandler<>() { @Override public JAXBException createException(Throwable throwable, String message) { return new JAXBException(message, throwable); @@ -86,7 +86,7 @@ public JAXBException createException(Throwable throwable, String message) { /** * If the {@link InvocationTargetException} wraps an exception that shouldn't be wrapped, - * throw the wrapped exception. Otherwise returns exception to be wrapped for further processing. + * throw the wrapped exception. Otherwise, returns exception to be wrapped for further processing. */ private static Throwable handleInvocationTargetException(InvocationTargetException x) throws JAXBException { Throwable t = x.getTargetException(); @@ -107,7 +107,7 @@ private static Throwable handleInvocationTargetException(InvocationTargetExcepti /** * Determine if two types (JAXBContext in this case) will generate a ClassCastException. - * + *

* For example, (targetType)originalType * * @param originalType @@ -217,7 +217,7 @@ static JAXBContext newInstance(String contextPath, private static Object instantiateProviderIfNecessary(final Class implClass) throws JAXBException { try { if (JAXBContextFactory.class.isAssignableFrom(implClass)) { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { + return AccessController.doPrivileged(new PrivilegedExceptionAction<>() { @Override public Object run() throws Exception { return implClass.getConstructor().newInstance(); @@ -330,7 +330,7 @@ static JAXBContext find(String factoryId, try { return newInstance(contextPath, contextPathClasses, ctxFactory, classLoader, properties); } catch (Throwable t) { - logger.log(Level.FINE, t, () -> "Error instantiating provivder " + ctxFactory); + logger.log(Level.FINE, t, () -> "Error instantiating provider " + ctxFactory); } } } @@ -432,9 +432,9 @@ static URL which(Class clazz, ClassLoader loader) { /** * Get the URL for the Class from it's ClassLoader. - * + *

* Convenience method for {@link #which(Class, ClassLoader)}. - * + *

* Equivalent to calling: which(clazz, clazz.getClassLoader()) * * @param clazz @@ -451,7 +451,7 @@ private static ClassLoader getContextClassLoader() { return Thread.currentThread().getContextClassLoader(); } else { return AccessController.doPrivileged( - new PrivilegedAction() { + new PrivilegedAction<>() { @Override public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); @@ -465,7 +465,7 @@ private static ClassLoader getClassClassLoader(final Class c) { return c.getClassLoader(); } else { return AccessController.doPrivileged( - new PrivilegedAction() { + new PrivilegedAction<>() { @Override public ClassLoader run() { return c.getClassLoader(); @@ -479,7 +479,7 @@ private static ClassLoader getSystemClassLoader() { return ClassLoader.getSystemClassLoader(); } else { return AccessController.doPrivileged( - new PrivilegedAction() { + new PrivilegedAction<>() { @Override public ClassLoader run() { return ClassLoader.getSystemClassLoader(); diff --git a/api/src/main/java/jakarta/xml/bind/DatatypeConverter.java b/api/src/main/java/jakarta/xml/bind/DatatypeConverter.java index f40c844..ab23e3a 100644 --- a/api/src/main/java/jakarta/xml/bind/DatatypeConverter.java +++ b/api/src/main/java/jakarta/xml/bind/DatatypeConverter.java @@ -17,7 +17,7 @@ * The javaType binding declaration can be used to customize the binding of * an XML schema datatype to a Java datatype. Customizations can involve * writing a parse and print method for parsing and printing lexical - * representations of a XML schema datatype respectively. However, writing + * representations of an XML schema datatype respectively. However, writing * parse and print methods requires knowledge of the lexical representations ( * XML Schema Part2: Datatypes * specification ) and hence may be difficult to write. @@ -61,7 +61,7 @@ *

* *

- * A print method for a XML schema datatype can output any lexical + * A print method for an XML schema datatype can output any lexical * representation that is valid with respect to the XML schema datatype. * If an error is encountered during conversion, then an IllegalArgumentException, * or a subclass of IllegalArgumentException must be thrown by the method. @@ -158,7 +158,7 @@ public static java.math.BigInteger parseInteger( String lexicalXSDInteger ) { * A string containing a lexical representation of * xsd:int. * @return - * A int value represented by the string argument. + * An int value represented by the string argument. * @throws NumberFormatException lexicalXSDInt is not a valid string representation of an int value. */ public static int parseInt( String lexicalXSDInt ) { diff --git a/api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java b/api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java index 965168c..052ddb0 100644 --- a/api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java +++ b/api/src/main/java/jakarta/xml/bind/DatatypeConverterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024 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 @@ -77,7 +77,7 @@ public int parseInt(String s) { /** * Faster but less robust {@code String->int} conversion. - * + *

* Note that: *

    *
  1. XML Schema allows '+', but {@link Integer#valueOf(String)} is not. @@ -175,7 +175,7 @@ public static float _parseFloat(CharSequence _val) { * jfloat.valueOf ignores leading and trailing whitespaces, whereas this is not allowed in xfloat. * jfloat.valueOf allows "float type suffix" (f, F) to be - appended after float literal (e.g., 1.52e-2f), whereare + appended after float literal (e.g., 1.52e-2f), whereas this is not the case of xfloat. gray zone @@ -195,7 +195,7 @@ appended after float literal (e.g., 1.52e-2f), whereare return Float.NEGATIVE_INFINITY; } - if (s.length() == 0 + if (s.isEmpty() || !isDigitOrPeriodOrSign(s.charAt(0)) || !isDigitOrPeriodOrSign(s.charAt(s.length() - 1))) { throw new NumberFormatException(); @@ -241,7 +241,7 @@ public static double _parseDouble(CharSequence _val) { return Double.NEGATIVE_INFINITY; } - if (val.length() == 0 + if (val.isEmpty() || !isDigitOrPeriodOrSign(val.charAt(0)) || !isDigitOrPeriodOrSign(val.charAt(val.length() - 1))) { throw new NumberFormatException(val); @@ -398,7 +398,7 @@ public static QName _parseQName(CharSequence text, NamespaceContext nsc) { uri = nsc.getNamespaceURI(prefix); // uri can never be null according to javadoc, // but some users reported that there are implementations that return null. - if (uri == null || uri.length() == 0) // crap. the NamespaceContext interface is broken. + if (uri == null || uri.isEmpty()) // crap. the NamespaceContext interface is broken. // error: unbound prefix { throw new IllegalArgumentException("prefix " + prefix + " is not bound to a namespace"); @@ -520,7 +520,7 @@ public String printDate(Calendar val) { public static String _printDate(Calendar val) { if (null == val) throw new IllegalArgumentException("val is null"); - return CalendarFormatter.doFormat((new StringBuilder("%Y-%M-%D").append("%z")).toString(),val); + return CalendarFormatter.doFormat("%Y-%M-%D%z",val); } @Override @@ -592,7 +592,7 @@ public static String _printQName(QName val, NamespaceContext nsc) { String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); - if (prefix == null || prefix.length() == 0) { // be defensive + if (prefix == null || prefix.isEmpty()) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; @@ -706,7 +706,7 @@ private static int guessLength(String text) { * base64Binary data is likely to be long, and decoding requires * each character to be accessed twice (once for counting length, another * for decoding.) - * + *

    * A benchmark showed that taking {@link String} is faster, presumably * because JIT can inline a lot of string access (with data of 1K chars, it was twice as fast) */ @@ -799,7 +799,7 @@ public static String _printBase64Binary(byte[] input, int offset, int len) { /** * Encodes a byte array into a char array by doing base64 encoding. - * + *

    * The caller must supply a big enough buffer. * * @return @@ -841,7 +841,7 @@ public static int _printBase64Binary(byte[] input, int offset, int len, char[] b /** * Encodes a byte array into another byte array by first doing base64 encoding * then encoding the result in ASCII. - * + *

    * The caller must supply a big enough buffer. * * @return @@ -1050,7 +1050,7 @@ private static void formatTimeZone(Calendar cal, StringBuilder buf) { offset *= -1; } - offset /= 60 * 1000; // offset is in milli-seconds + offset /= 60 * 1000; // offset is in milliseconds formatTwoDigits(offset / 60, buf); buf.append(':'); diff --git a/api/src/main/java/jakarta/xml/bind/DatatypeConverterInterface.java b/api/src/main/java/jakarta/xml/bind/DatatypeConverterInterface.java index 361fb0b..38885da 100644 --- a/api/src/main/java/jakarta/xml/bind/DatatypeConverterInterface.java +++ b/api/src/main/java/jakarta/xml/bind/DatatypeConverterInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024 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 @@ -35,7 +35,7 @@ * class. * *

    - * A parse method for a XML schema datatype must be capable of converting any + * A parse method for an XML schema datatype must be capable of converting any * lexical representation of the XML schema datatype ( specified by the * XML Schema Part2: Datatypes * specification into a value in the value space of the XML schema datatype. @@ -43,7 +43,7 @@ * or a subclass of IllegalArgumentException must be thrown by the method. * *

    - * A print method for a XML schema datatype can output any lexical + * A print method for an XML schema datatype can output any lexical * representation that is valid with respect to the XML schema datatype. * If an error is encountered during conversion, then an IllegalArgumentException, * or a subclass of IllegalArgumentException must be thrown by the method. diff --git a/api/src/main/java/jakarta/xml/bind/Element.java b/api/src/main/java/jakarta/xml/bind/Element.java index 110a9e3..a23ca10 100644 --- a/api/src/main/java/jakarta/xml/bind/Element.java +++ b/api/src/main/java/jakarta/xml/bind/Element.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024 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 @@ -12,7 +12,7 @@ /** * This is an element marker interface. - * + *

    * Under certain circumstances, it is necessary for the binding compiler to * generate derived java content classes that implement this interface. In * those cases, client applications must supply element instances rather than diff --git a/api/src/main/java/jakarta/xml/bind/JAXB.java b/api/src/main/java/jakarta/xml/bind/JAXB.java index 7610cba..0e99cf2 100644 --- a/api/src/main/java/jakarta/xml/bind/JAXB.java +++ b/api/src/main/java/jakarta/xml/bind/JAXB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024 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 @@ * in the {@link JAXBContext}, {@link Unmarshaller}, and {@link Marshaller}. * * They are designed - * to be the prefered methods for developers new to Jakarta XML Binding. They have - * the following characterstics: + * to be the preferred methods for developers new to Jakarta XML Binding. They have + * the following characteristics: * *

      *
    1. Generally speaking, the performance is not necessarily optimal. @@ -457,8 +457,8 @@ public static void marshal( Object jaxbObject, Result xml ) { *

      * This method is a convenience method that combines several basic operations * in the {@link JAXBContext} and {@link Marshaller}. This method is designed - * to be the prefered method for developers new to Jakarta XML Binding. This method - * has the following characterstics: + * to be the preferred method for developers new to Jakarta XML Binding. This method + * has the following characteristics: * *

        *
      1. Generally speaking, the performance is not necessarily optimal. diff --git a/api/src/main/java/jakarta/xml/bind/JAXBContext.java b/api/src/main/java/jakarta/xml/bind/JAXBContext.java index e25266c..de223f0 100644 --- a/api/src/main/java/jakarta/xml/bind/JAXBContext.java +++ b/api/src/main/java/jakarta/xml/bind/JAXBContext.java @@ -57,7 +57,7 @@ * any global XML element declared in the schema to be unmarshalled as * the root of an instance document. * Additionally, the unmarshal method allows for an unrecognized root element that - * has an xsi:type attribute's value that references a type definition declared in + * has an xsi:type attribute's value that references a type definition declared in * the schema to be unmarshalled as the root of an instance document. * The {@code JAXBContext} object * allows the merging of global elements and type definitions across a set of schemas (listed @@ -97,7 +97,7 @@ * } * *

        - * Once the client application has an instance of the the schema derived object, + * Once the client application has an instance of the schema derived object, * it can use the mutator methods to set content on it. * *

        @@ -121,11 +121,11 @@ * marshalling process can alternatively produce SAX2 event streams to a * registered {@code ContentHandler} or produce a DOM Node object. * Client applications have control over the output encoding as well as - * whether or not to marshal the XML data as a complete document or + * whether to marshal the XML data as a complete document or * as a fragment. * *

        - * Here is a simple example that unmarshals an XML document and then marshals + * Here is a simple example that unmarshalls an XML document and then marshals * it back out: * * {@snippet : @@ -299,7 +299,7 @@ public static JAXBContext newInstance( String contextPath ) * are reachable, as defined in {@link #newInstance(Class...)}, from the * listed classes are also registered with JAXBContext. *

        - * Constraints on class name occuring in a {@code jaxb.index} file are: + * Constraints on class name occurring in a {@code jaxb.index} file are: *