Refined javadoc and exception messages

This commit is contained in:
Juergen Hoeller 2018-02-13 15:25:42 +01:00
parent d3cee45f30
commit 0c78c9c6f7
4 changed files with 26 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,14 +24,14 @@ import org.springframework.util.Assert;
/**
* The purpose of this class is to enable capturing and passing a generic
* {@link Type}. In order to capture the generic type and retain it at runtime,
* you need to create a subclass as follows:
* you need to create a subclass (ideally as anonymous inline class) as follows:
*
* <pre class="code">
* ParameterizedTypeReference&lt;List&lt;String&gt;&gt; typeRef = new ParameterizedTypeReference&lt;List&lt;String&gt;&gt;() {};
* </pre>
*
* <p>The resulting {@code typeReference} instance can then be used to obtain a
* {@link Type} instance that carries parameterized type information.
* <p>The resulting {@code typeRef} instance can then be used to obtain a {@link Type}
* instance that carries the captured parameterized type information at runtime.
* For more information on "super type tokens" see the link to Neal Gafter's blog post.
*
* @author Arjen Poutsma

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,8 +22,8 @@ import javax.xml.transform.Transformer;
import org.springframework.util.Assert;
/**
* Contains common behavior relating to {@link javax.xml.transform.Transformer Transformers}, and the
* {@code javax.xml.transform} package in general.
* Contains common behavior relating to {@link javax.xml.transform.Transformer Transformers}
* and the {@code javax.xml.transform} package in general.
*
* @author Rick Evans
* @author Juergen Hoeller
@ -32,16 +32,16 @@ import org.springframework.util.Assert;
public abstract class TransformerUtils {
/**
* The indent amount of characters if {@link #enableIndenting(javax.xml.transform.Transformer) indenting is enabled}.
* The indent amount of characters if {@link #enableIndenting indenting is enabled}.
* <p>Defaults to "2".
*/
public static final int DEFAULT_INDENT_AMOUNT = 2;
/**
* Enable indenting for the supplied {@link javax.xml.transform.Transformer}. <p>If the underlying XSLT engine is
* Xalan, then the special output key {@code indent-amount} will be also be set to a value of {@link
* #DEFAULT_INDENT_AMOUNT} characters.
*
* Enable indenting for the supplied {@link javax.xml.transform.Transformer}.
* <p>If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount}
* will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters.
* @param transformer the target transformer
* @see javax.xml.transform.Transformer#setOutputProperty(String, String)
* @see javax.xml.transform.OutputKeys#INDENT
@ -51,18 +51,19 @@ public abstract class TransformerUtils {
}
/**
* Enable indenting for the supplied {@link javax.xml.transform.Transformer}. <p>If the underlying XSLT engine is
* Xalan, then the special output key {@code indent-amount} will be also be set to a value of {@link
* #DEFAULT_INDENT_AMOUNT} characters.
*
* @param transformer the target transformer
* @param indentAmount the size of the indent (2 characters, 3 characters, etc.)
* Enable indenting for the supplied {@link javax.xml.transform.Transformer}.
* <p>If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount}
* will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters.
* @param transformer the target transformer
* @param indentAmount the size of the indent (2 characters, 3 characters, etc)
* @see javax.xml.transform.Transformer#setOutputProperty(String, String)
* @see javax.xml.transform.OutputKeys#INDENT
*/
public static void enableIndenting(Transformer transformer, int indentAmount) {
Assert.notNull(transformer, "Transformer must not be null");
Assert.isTrue(indentAmount > -1, () -> "The indent amount cannot be less than zero : got " + indentAmount);
if (indentAmount < 0) {
throw new IllegalArgumentException("Invalid indent amount (must not be less than zero): " + indentAmount);
}
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
try {
// Xalan-specific, but this is the most common XSLT engine in any case
@ -74,7 +75,6 @@ public abstract class TransformerUtils {
/**
* Disable indenting for the supplied {@link javax.xml.transform.Transformer}.
*
* @param transformer the target transformer
* @see javax.xml.transform.OutputKeys#INDENT
*/

View File

@ -580,8 +580,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
Assert.notNull(resource, "Resource is null");
Assert.isTrue(resource.exists(), () -> "Resource " + resource + " does not exist");
Assert.isTrue(resource != null && resource.exists(), () -> "Resource does not exist: " + resource);
InputSource inputSource = SaxResourceUtils.createInputSource(resource);
schemaSources[i] = new SAXSource(xmlReader, inputSource);
}
@ -595,8 +594,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
@Override
public boolean supports(Class<?> clazz) {
return ((this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) ||
supportsInternal(clazz, this.checkForXmlRootElement));
return (this.supportJaxbElementClass && JAXBElement.class.isAssignableFrom(clazz)) ||
supportsInternal(clazz, this.checkForXmlRootElement);
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -120,7 +120,7 @@ class HtmlCharacterEntityReferences {
}
/**
* Return the reference mapped to the given character or {@code null}.
* Return the reference mapped to the given character, or {@code null} if none found.
*/
@Nullable
public String convertToReference(char character) {
@ -128,7 +128,7 @@ class HtmlCharacterEntityReferences {
}
/**
* Return the reference mapped to the given character or {@code null}.
* Return the reference mapped to the given character, or {@code null} if none found.
* @since 4.1.2
*/
@Nullable