This is an automated email from the ASF dual-hosted git repository. veithen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
The following commit(s) were added to refs/heads/master by this push: new 8a1729c92 Enforce consistent Java formatting 8a1729c92 is described below commit 8a1729c926746ed703f02afa682047742882127e Author: Andreas Veithen <andreas.veit...@gmail.com> AuthorDate: Sun Nov 20 16:13:17 2022 +0000 Enforce consistent Java formatting --- axiom-activation/pom.xml | 11 +++ .../axiom/ext/activation/SizeAwareDataSource.java | 45 ++++++------ .../axiom/mime/activation/PartDataHandler.java | 26 +++---- .../axiom/mime/activation/PartDataHandlerBlob.java | 4 +- .../activation/PartDataHandlerBlobFactory.java | 19 ++--- .../axiom/mime/activation/PartDataSource.java | 4 +- .../org/apache/axiom/mime/activation/Util.java | 5 +- .../WrappedTextNodeOMDataSourceFromDataSource.java | 15 ++-- .../axiom/util/activation/BlobDataSource.java | 6 +- .../axiom/util/activation/DataHandlerBlob.java | 2 +- .../activation/DataHandlerContentTypeProvider.java | 3 +- .../axiom/util/activation/DataHandlerUtils.java | 25 ++++--- .../axiom/util/activation/DataHandlerWrapper.java | 9 ++- .../axiom/util/activation/DataSourceUtils.java | 34 +++++---- .../axiom/util/activation/EmptyDataSource.java | 29 ++++---- .../DataHandlerContentTypeProviderTest.java | 15 ++-- axiom-jaxb/pom.xml | 11 +++ .../axiom/om/ds/jaxb/AttachmentMarshallerImpl.java | 22 ++++-- .../apache/axiom/om/ds/jaxb/JAXBOMDataSource.java | 38 +++++----- .../om/util/jaxb/AttachmentUnmarshallerImpl.java | 4 +- .../org/apache/axiom/om/util/jaxb/JAXBUtils.java | 82 +++++++++++----------- .../om/util/jaxb/UnmarshallerConfigurator.java | 12 ++-- 22 files changed, 217 insertions(+), 204 deletions(-) diff --git a/axiom-activation/pom.xml b/axiom-activation/pom.xml index 7a95ab50e..ecb1abc2e 100644 --- a/axiom-activation/pom.xml +++ b/axiom-activation/pom.xml @@ -68,6 +68,17 @@ </instructions> </configuration> </plugin> + <plugin> + <groupId>com.spotify.fmt</groupId> + <artifactId>fmt-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project> diff --git a/axiom-activation/src/main/java/org/apache/axiom/ext/activation/SizeAwareDataSource.java b/axiom-activation/src/main/java/org/apache/axiom/ext/activation/SizeAwareDataSource.java index c0d0aa272..663cb8058 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/ext/activation/SizeAwareDataSource.java +++ b/axiom-activation/src/main/java/org/apache/axiom/ext/activation/SizeAwareDataSource.java @@ -22,36 +22,35 @@ package org.apache.axiom.ext.activation; import javax.activation.DataSource; /** - * Optional extension interface that can be implemented by data sources that support a - * getSize method. - * Code working with data sources can use this this information to optimize certain operations. - * Note however that instead of checking of this interface directly, this kind of code - * should use {@link org.apache.axiom.util.activation.DataSourceUtils#getSize(DataSource)} - * because this method is able to determine the size of other types of data sources as well. - * <p> - * Code using this interface should be aware that some implementations may be unable to guarantee + * Optional extension interface that can be implemented by data sources that support a getSize + * method. Code working with data sources can use this this information to optimize certain + * operations. Note however that instead of checking of this interface directly, this kind of code + * should use {@link org.apache.axiom.util.activation.DataSourceUtils#getSize(DataSource)} because + * this method is able to determine the size of other types of data sources as well. + * + * <p>Code using this interface should be aware that some implementations may be unable to guarantee * 100% accuracy when determining the size of the data source. Situations where this can occur * include: + * * <ul> - * <li>The data source uses a network protocol that allows to get the size of the data - * but that doesn't guarantee accurateness.</li> - * <li>Reading the data involves a decoding operation and the length of the resulting stream - * can't be determined precisely without performing the decoding operation. In this - * case the implementation of this interface may return a value based on an estimation.</li> + * <li>The data source uses a network protocol that allows to get the size of the data but that + * doesn't guarantee accurateness. + * <li>Reading the data involves a decoding operation and the length of the resulting stream can't + * be determined precisely without performing the decoding operation. In this case the + * implementation of this interface may return a value based on an estimation. * </ul> - * When reading the actual data, the code should always read until the end of the stream is - * reached (as indicated by the return value of the <code>read</code> methods of the - * {@link java.io.InputStream} class). It must be prepared to reach the end of the stream after - * a number of bytes that is lower or higher than the value returned by {@link #getSize()}. + * + * When reading the actual data, the code should always read until the end of the stream is reached + * (as indicated by the return value of the <code>read</code> methods of the {@link + * java.io.InputStream} class). It must be prepared to reach the end of the stream after a number of + * bytes that is lower or higher than the value returned by {@link #getSize()}. */ public interface SizeAwareDataSource extends DataSource { /** - * Get the size of the data source. - * Implementations must return the number of bytes that can be read from - * the input stream returned by {@link #getInputStream()} before reaching - * the end of the stream. If the implementation is unable to determine the - * size, it must return -1. - * + * Get the size of the data source. Implementations must return the number of bytes that can be + * read from the input stream returned by {@link #getInputStream()} before reaching the end of + * the stream. If the implementation is unable to determine the size, it must return -1. + * * @return the size of the data source or -1 if the size is not known */ long getSize(); diff --git a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandler.java b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandler.java index 82a08ecb0..c159ba03d 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandler.java +++ b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandler.java @@ -28,9 +28,7 @@ import org.apache.axiom.blob.Blob; import org.apache.axiom.mime.Part; import org.apache.axiom.mime.PartBlob; -/** - * {@link DataHandler} implementation for MIME parts read from a stream. - */ +/** {@link DataHandler} implementation for MIME parts read from a stream. */ public class PartDataHandler extends DataHandler { private final Part part; private final PartDataHandlerBlob blob; @@ -50,7 +48,7 @@ public class PartDataHandler extends DataHandler { /** * Get the MIME part linked to this data handler. - * + * * @return the MIME part */ public final Part getPart() { @@ -59,7 +57,7 @@ public class PartDataHandler extends DataHandler { /** * Get the {@link PartBlob} that wraps this instance. - * + * * @return the blob wrapper */ public final PartBlob getBlob() { @@ -83,13 +81,11 @@ public class PartDataHandler extends DataHandler { /** * Create the {@link DataSource} to be returned by {@link #getDataSource()}. This method may be * overridden by subclasses to support custom {@link DataSource} implementations. - * - * @param content - * the content of the part - * @param contentType - * the content type expected to be returned by {@link DataSource#getContentType()}; - * defaults to {@code application/octet-stream} if the part doesn't specify a content - * type + * + * @param content the content of the part + * @param contentType the content type expected to be returned by {@link + * DataSource#getContentType()}; defaults to {@code application/octet-stream} if the part + * doesn't specify a content type * @return the {@link DataSource} instance, or {@code null} to use the default implementation */ protected DataSource createDataSource(Blob content, String contentType) { @@ -98,9 +94,9 @@ public class PartDataHandler extends DataHandler { @Override public final void writeTo(OutputStream os) throws IOException { - // The PartContent may have an implementation of writeTo that is more efficient than the default - // DataHandler#writeTo method (which requests an input stream and then copies it to the output - // stream). + // The PartContent may have an implementation of writeTo that is more efficient than the + // default DataHandler#writeTo method (which requests an input stream and then copies it to + // the output stream). part.getBlob().writeTo(os); } } diff --git a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlob.java b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlob.java index 6643ab968..008857174 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlob.java +++ b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlob.java @@ -26,9 +26,7 @@ import org.apache.axiom.ext.io.StreamCopyException; import org.apache.axiom.mime.Part; import org.apache.axiom.mime.PartBlob; -/** - * {@link PartBlob} implementation that wraps a {@link PartDataHandler}. - */ +/** {@link PartBlob} implementation that wraps a {@link PartDataHandler}. */ public final class PartDataHandlerBlob implements PartBlob { private final PartDataHandler dataHandler; diff --git a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlobFactory.java b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlobFactory.java index ebe6ceee5..5e64f8df1 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlobFactory.java +++ b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataHandlerBlobFactory.java @@ -23,20 +23,21 @@ import org.apache.axiom.mime.Part; import org.apache.axiom.mime.PartBlob; /** - * {@link PartBlobFactory} implementation that creates {@link PartBlob} instances that wrap - * {@link PartDataHandler} instances. + * {@link PartBlobFactory} implementation that creates {@link PartBlob} instances that wrap {@link + * PartDataHandler} instances. */ public abstract class PartDataHandlerBlobFactory implements PartBlobFactory { /** * {@link PartDataHandlerBlobFactory} instance that creates plain {@link PartDataHandler} * instances. */ - public static final PartDataHandlerBlobFactory DEFAULT = new PartDataHandlerBlobFactory() { - @Override - protected PartDataHandler createDataHandler(Part part) { - return new PartDataHandler(part); - } - }; + public static final PartDataHandlerBlobFactory DEFAULT = + new PartDataHandlerBlobFactory() { + @Override + protected PartDataHandler createDataHandler(Part part) { + return new PartDataHandler(part); + } + }; protected PartDataHandlerBlobFactory() {} @@ -47,7 +48,7 @@ public abstract class PartDataHandlerBlobFactory implements PartBlobFactory { /** * Create a {@link PartDataHandler} for the given {@link Part}. - * + * * @param part the MIME part * @return the data handler */ diff --git a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataSource.java b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataSource.java index acbc0f7ea..4aa3d8c95 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataSource.java +++ b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/PartDataSource.java @@ -25,9 +25,7 @@ import java.io.OutputStream; import org.apache.axiom.ext.activation.SizeAwareDataSource; import org.apache.axiom.mime.Part; -/** - * Default {@link DataSource} implementation for MIME parts. - */ +/** Default {@link DataSource} implementation for MIME parts. */ final class PartDataSource implements SizeAwareDataSource { private final Part part; diff --git a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/Util.java b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/Util.java index 61f007e2c..8c917203e 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/mime/activation/Util.java +++ b/axiom-activation/src/main/java/org/apache/axiom/mime/activation/Util.java @@ -29,9 +29,8 @@ final class Util { /** * Get the content type that should be reported by {@link DataSource} instances created for a * given part. - * - * @param Part - * the part + * + * @param Part the part * @return the content type */ static String getDataSourceContentType(Part part) { diff --git a/axiom-activation/src/main/java/org/apache/axiom/om/ds/activation/WrappedTextNodeOMDataSourceFromDataSource.java b/axiom-activation/src/main/java/org/apache/axiom/om/ds/activation/WrappedTextNodeOMDataSourceFromDataSource.java index 7aff8c349..a9ce5c80e 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/om/ds/activation/WrappedTextNodeOMDataSourceFromDataSource.java +++ b/axiom-activation/src/main/java/org/apache/axiom/om/ds/activation/WrappedTextNodeOMDataSourceFromDataSource.java @@ -40,23 +40,23 @@ public class WrappedTextNodeOMDataSourceFromDataSource extends WrappedTextNodeOM private final DataSource binaryData; private final Charset charset; - public WrappedTextNodeOMDataSourceFromDataSource(QName wrapperElementName, DataSource binaryData, - Charset charset) { + public WrappedTextNodeOMDataSourceFromDataSource( + QName wrapperElementName, DataSource binaryData, Charset charset) { super(wrapperElementName); this.binaryData = binaryData; this.charset = charset; } - + @Override public XMLStreamReader getReader() throws XMLStreamException { InputStream is; try { is = binaryData.getInputStream(); - } - catch (IOException ex) { + } catch (IOException ex) { throw new XMLStreamException(ex); } - return new WrappedTextNodeStreamReader(wrapperElementName, new InputStreamReader(is, charset)); + return new WrappedTextNodeStreamReader( + wrapperElementName, new InputStreamReader(is, charset)); } @Override @@ -71,6 +71,7 @@ public class WrappedTextNodeOMDataSourceFromDataSource extends WrappedTextNodeOM @Override public OMDataSourceExt copy() { - return new WrappedTextNodeOMDataSourceFromDataSource(wrapperElementName, binaryData, charset); + return new WrappedTextNodeOMDataSourceFromDataSource( + wrapperElementName, binaryData, charset); } } diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/BlobDataSource.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/BlobDataSource.java index 52f176a1e..eb31bfb68 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/BlobDataSource.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/BlobDataSource.java @@ -26,14 +26,12 @@ import java.io.OutputStream; import org.apache.axiom.blob.Blob; import org.apache.axiom.ext.activation.SizeAwareDataSource; -/** - * Data source backed by a {@link Blob}. - */ +/** Data source backed by a {@link Blob}. */ // TODO(AXIOM-506): this should not be public public class BlobDataSource implements SizeAwareDataSource { private final Blob blob; private final String contentType; - + public BlobDataSource(Blob blob, String contentType) { this.blob = blob; this.contentType = contentType; diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerBlob.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerBlob.java index 60edc401f..311613651 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerBlob.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerBlob.java @@ -29,7 +29,7 @@ import org.apache.axiom.ext.io.StreamCopyException; final class DataHandlerBlob implements Blob { private final DataHandler dataHandler; - + DataHandlerBlob(DataHandler dataHandler) { this.dataHandler = dataHandler; } diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerContentTypeProvider.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerContentTypeProvider.java index b5e4da206..03baf5501 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerContentTypeProvider.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerContentTypeProvider.java @@ -35,7 +35,8 @@ import org.apache.commons.logging.LogFactory; public final class DataHandlerContentTypeProvider implements ContentTypeProvider { private static final Log log = LogFactory.getLog(DataHandlerContentTypeProvider.class); - public static final DataHandlerContentTypeProvider INSTANCE = new DataHandlerContentTypeProvider(); + public static final DataHandlerContentTypeProvider INSTANCE = + new DataHandlerContentTypeProvider(); private DataHandlerContentTypeProvider() {} diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerUtils.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerUtils.java index 9f8162100..082fb5f75 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerUtils.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerUtils.java @@ -24,24 +24,23 @@ import org.apache.axiom.blob.Blob; import org.apache.axiom.mime.activation.PartDataHandler; import org.apache.axiom.mime.activation.PartDataHandlerBlob; -/** - * Contains utility methods to work with {@link DataHandler} objects. - */ +/** Contains utility methods to work with {@link DataHandler} objects. */ public final class DataHandlerUtils { private DataHandlerUtils() {} /** * Get the {@link DataHandler} wrapped by the given {@link Blob}. - * + * * @param blob the {@link Blob} to unwrap - * @return the wrapped {@link DataHandler}, or {@code null} if the blob doesn't wrap a {@link DataHandler} + * @return the wrapped {@link DataHandler}, or {@code null} if the blob doesn't wrap a {@link + * DataHandler} */ public static DataHandler getDataHandler(Blob blob) { if (blob instanceof DataHandlerBlob) { - return ((DataHandlerBlob)blob).getDataHandler(); + return ((DataHandlerBlob) blob).getDataHandler(); } if (blob instanceof PartDataHandlerBlob) { - return ((PartDataHandlerBlob)blob).getDataHandler(); + return ((PartDataHandlerBlob) blob).getDataHandler(); } return null; } @@ -49,7 +48,7 @@ public final class DataHandlerUtils { /** * Get a {@link DataHandler} for the given {@link Blob}. If the blob was obtained from {@link * #toBlob(DataHandler)}, the original {@link DataHandler} is returned. - * + * * @param blob the {@link Blob} to convert * @return a {@link DataHandler} representing the {@link Blob} */ @@ -59,18 +58,18 @@ public final class DataHandlerUtils { } /** - * Get a {@link Blob} for the given {@link DataHandler}. If the {@link DataHandler} was obtained from {@link - * #toDataHandler(Blob)}, the original {@link Blob} is returned. - * + * Get a {@link Blob} for the given {@link DataHandler}. If the {@link DataHandler} was obtained + * from {@link #toDataHandler(Blob)}, the original {@link Blob} is returned. + * * @param dh the {@link DataHandler} to convert * @return a {@link Blob} representing the {@link DataHandler} */ public static Blob toBlob(DataHandler dh) { if (dh instanceof BlobDataHandler) { - return ((BlobDataHandler)dh).getBlob(); + return ((BlobDataHandler) dh).getBlob(); } if (dh instanceof PartDataHandler) { - return ((PartDataHandler)dh).getBlob(); + return ((PartDataHandler) dh).getBlob(); } return new DataHandlerBlob(dh); } diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerWrapper.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerWrapper.java index bf8556ebc..abcef5b3e 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerWrapper.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataHandlerWrapper.java @@ -29,9 +29,7 @@ import javax.activation.CommandMap; import javax.activation.DataHandler; import javax.activation.DataSource; -/** - * Base class for {@link DataHandler} wrappers. - */ +/** Base class for {@link DataHandler} wrappers. */ public class DataHandlerWrapper extends DataHandler { private final DataHandler parent; @@ -43,7 +41,7 @@ public class DataHandlerWrapper extends DataHandler { super(EmptyDataSource.INSTANCE); this.parent = parent; } - + @Override public CommandInfo[] getAllCommands() { return parent.getAllCommands(); @@ -95,7 +93,8 @@ public class DataHandlerWrapper extends DataHandler { } @Override - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { return parent.getTransferData(flavor); } diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataSourceUtils.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataSourceUtils.java index 34a235a1e..74b8265b6 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataSourceUtils.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/DataSourceUtils.java @@ -27,12 +27,10 @@ import javax.activation.FileDataSource; import org.apache.axiom.ext.activation.SizeAwareDataSource; -/** - * Contains utility methods to work with {@link DataSource} objects. - */ +/** Contains utility methods to work with {@link DataSource} objects. */ public class DataSourceUtils { private static final Class<?> byteArrayDataSourceClass; - + static { Class<?> clazz; try { @@ -42,31 +40,31 @@ public class DataSourceUtils { } byteArrayDataSourceClass = clazz; } - + /** - * Determine the size of the data represented by a {@link DataSource} object. - * The method will try to determine the size without reading the data source. - * It will do so by looking for the {@link SizeAwareDataSource} interface. In addition, it - * supports some other well known data source implementations for which it is possible to - * get the size of the data without reading it. - * <p> - * As noted in the documentation of the {@link SizeAwareDataSource}, the returned value - * may be an estimation that is not 100% accurate, and code using this method must be prepared - * to receive more or less data from the data source. - * + * Determine the size of the data represented by a {@link DataSource} object. The method will + * try to determine the size without reading the data source. It will do so by looking for the + * {@link SizeAwareDataSource} interface. In addition, it supports some other well known data + * source implementations for which it is possible to get the size of the data without reading + * it. + * + * <p>As noted in the documentation of the {@link SizeAwareDataSource}, the returned value may + * be an estimation that is not 100% accurate, and code using this method must be prepared to + * receive more or less data from the data source. + * * @param ds the data source * @return (an estimation of) the size of the data or <code>-1</code> if the size is unknown */ public static long getSize(DataSource ds) { if (ds instanceof SizeAwareDataSource) { - return ((SizeAwareDataSource)ds).getSize(); + return ((SizeAwareDataSource) ds).getSize(); } else if (byteArrayDataSourceClass != null && byteArrayDataSourceClass.isInstance(ds)) { // Special optimization for JavaMail's ByteArrayDataSource (Axiom's ByteArrayDataSource // already implements SizeAwareDataSource and doesn't need further optimization): // we know that ByteArrayInputStream#available() directly returns the size of the // data source. try { - return ((ByteArrayInputStream)ds.getInputStream()).available(); + return ((ByteArrayInputStream) ds.getInputStream()).available(); } catch (IOException ex) { // We will never get here... return -1; @@ -74,7 +72,7 @@ public class DataSourceUtils { } else if (ds instanceof FileDataSource) { // Special optimization for FileDataSources: no need to open and read the file // to know its size! - return ((FileDataSource)ds).getFile().length(); + return ((FileDataSource) ds).getFile().length(); } else { return -1; } diff --git a/axiom-activation/src/main/java/org/apache/axiom/util/activation/EmptyDataSource.java b/axiom-activation/src/main/java/org/apache/axiom/util/activation/EmptyDataSource.java index 414519b5c..20f933630 100644 --- a/axiom-activation/src/main/java/org/apache/axiom/util/activation/EmptyDataSource.java +++ b/axiom-activation/src/main/java/org/apache/axiom/util/activation/EmptyDataSource.java @@ -25,27 +25,24 @@ import java.io.OutputStream; import org.apache.axiom.ext.activation.SizeAwareDataSource; -/** - * A data source with empty (zero length) content. - */ +/** A data source with empty (zero length) content. */ public class EmptyDataSource implements SizeAwareDataSource { - /** - * Empty data source instance with content type {@code application/octet-stream}. - */ + /** Empty data source instance with content type {@code application/octet-stream}. */ public static final EmptyDataSource INSTANCE = new EmptyDataSource("application/octet-stream"); - - private static final InputStream emptyInputStream = new InputStream() { - @Override - public int read() throws IOException { - return -1; - } - }; - + + private static final InputStream emptyInputStream = + new InputStream() { + @Override + public int read() throws IOException { + return -1; + } + }; + private final String contentType; - + /** * Construct an empty data source with the given content type. - * + * * @param contentType the content type */ public EmptyDataSource(String contentType) { diff --git a/axiom-activation/src/test/java/org/apache/axiom/util/activation/DataHandlerContentTypeProviderTest.java b/axiom-activation/src/test/java/org/apache/axiom/util/activation/DataHandlerContentTypeProviderTest.java index d25b5416c..426f5abd6 100644 --- a/axiom-activation/src/test/java/org/apache/axiom/util/activation/DataHandlerContentTypeProviderTest.java +++ b/axiom-activation/src/test/java/org/apache/axiom/util/activation/DataHandlerContentTypeProviderTest.java @@ -30,23 +30,26 @@ import org.junit.Test; public class DataHandlerContentTypeProviderTest { @Test public void testNotDataHandler() { - assertThat(DataHandlerContentTypeProvider.INSTANCE - .getContentType(Blobs.createBlob(new byte[10]))).isNull(); + assertThat( + DataHandlerContentTypeProvider.INSTANCE.getContentType( + Blobs.createBlob(new byte[10]))) + .isNull(); } @Test public void testDataHandlerWithoutContentType() { DataHandler dh = new DataHandler(new BlobDataSource(Blobs.createBlob(new byte[10]), null)); assertThat( - DataHandlerContentTypeProvider.INSTANCE.getContentType(DataHandlerUtils.toBlob(dh))) - .isNull(); + DataHandlerContentTypeProvider.INSTANCE.getContentType( + DataHandlerUtils.toBlob(dh))) + .isNull(); } @Test public void testDataHandlerWithContentType() { DataHandler dh = new DataHandler("test", "text/plain"); - ContentType contentType = DataHandlerContentTypeProvider.INSTANCE - .getContentType(DataHandlerUtils.toBlob(dh)); + ContentType contentType = + DataHandlerContentTypeProvider.INSTANCE.getContentType(DataHandlerUtils.toBlob(dh)); assertThat(contentType).isNotNull(); assertThat(contentType.getMediaType()).isEqualTo(MediaType.TEXT_PLAIN); } diff --git a/axiom-jaxb/pom.xml b/axiom-jaxb/pom.xml index a4e853ed2..43370d453 100644 --- a/axiom-jaxb/pom.xml +++ b/axiom-jaxb/pom.xml @@ -57,6 +57,17 @@ <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> </plugin> + <plugin> + <groupId>com.spotify.fmt</groupId> + <artifactId>fmt-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project> diff --git a/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/AttachmentMarshallerImpl.java b/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/AttachmentMarshallerImpl.java index 98a8521a7..c5ad24836 100644 --- a/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/AttachmentMarshallerImpl.java +++ b/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/AttachmentMarshallerImpl.java @@ -28,7 +28,7 @@ import org.apache.axiom.util.activation.DataHandlerUtils; final class AttachmentMarshallerImpl extends AttachmentMarshaller { private final MTOMXMLStreamWriter out; - + public AttachmentMarshallerImpl(MTOMXMLStreamWriter out) { this.out = out; } @@ -39,14 +39,19 @@ final class AttachmentMarshallerImpl extends AttachmentMarshaller { } @Override - public String addMtomAttachment(DataHandler data, String elementNamespace, - String elementLocalName) { + public String addMtomAttachment( + DataHandler data, String elementNamespace, String elementLocalName) { return "cid:" + out.prepareBlob(DataHandlerUtils.toBlob(data)); } @Override - public String addMtomAttachment(byte[] data, int offset, int length, String mimeType, - String elementNamespace, String elementLocalName) { + public String addMtomAttachment( + byte[] data, + int offset, + int length, + String mimeType, + String elementNamespace, + String elementLocalName) { // TODO: instead of copying the array, we could use a specialized DataHandler/DataSource if (offset != 0 || length != data.length) { int len = length - offset; @@ -54,8 +59,11 @@ final class AttachmentMarshallerImpl extends AttachmentMarshaller { System.arraycopy(data, offset, newData, 0, len); data = newData; } - return addMtomAttachment(new DataHandler(new BlobDataSource(Blobs.createBlob(data), "application/octet-stream")), - elementNamespace, elementLocalName); + return addMtomAttachment( + new DataHandler( + new BlobDataSource(Blobs.createBlob(data), "application/octet-stream")), + elementNamespace, + elementLocalName); } @Override diff --git a/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/JAXBOMDataSource.java b/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/JAXBOMDataSource.java index f6f9b237b..556b3bf5f 100644 --- a/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/JAXBOMDataSource.java +++ b/axiom-jaxb/src/main/java/org/apache/axiom/om/ds/jaxb/JAXBOMDataSource.java @@ -41,30 +41,28 @@ import org.apache.axiom.om.impl.MTOMXMLStreamWriter; * and for {@link JAXBElement} instances. It implements {@link QNameAwareOMDataSource} so that it * can be used with {@link OMFactory#createOMElement(OMDataSource)}, i.e. it is not necessary to * supply the QName during construction of the {@link OMSourcedElement}. It also has full support - * for XOP/MTOM. It is implemented as a push-style {@link OMDataSource} so that an - * {@link OMSourcedElement} backed by an instance of this class can be expanded in an efficient way - * (including the case where the JAXB object contains base64 binary data represented as - * {@link DataHandler} instances or byte arrays). - * <p> - * The JAXB object encapsulated by an instance of this class can be retrieved using - * {@link OMDataSourceExt#getObject()}. Note that modifying the JAXB object after passing it to the + * for XOP/MTOM. It is implemented as a push-style {@link OMDataSource} so that an {@link + * OMSourcedElement} backed by an instance of this class can be expanded in an efficient way + * (including the case where the JAXB object contains base64 binary data represented as {@link + * DataHandler} instances or byte arrays). + * + * <p>The JAXB object encapsulated by an instance of this class can be retrieved using {@link + * OMDataSourceExt#getObject()}. Note that modifying the JAXB object after passing it to the * constructor may result in unexpected behavior and should be avoided. - * <p> - * Instances of this class are non destructive, in the sense defined by - * {@link OMDataSourceExt#isDestructiveWrite()}. + * + * <p>Instances of this class are non destructive, in the sense defined by {@link + * OMDataSourceExt#isDestructiveWrite()}. */ public class JAXBOMDataSource extends AbstractPushOMDataSource implements QNameAwareOMDataSource { private final JAXBContext context; private final Object object; private QName cachedQName; - + /** * Constructor. - * - * @param context - * the JAXB context to which the object is known - * @param object - * the JAXB object; this may be a plain Java bean or a {@link JAXBElement} + * + * @param context the JAXB context to which the object is known + * @param object the JAXB object; this may be a plain Java bean or a {@link JAXBElement} */ public JAXBOMDataSource(JAXBContext context, Object object) { this.context = context; @@ -82,7 +80,7 @@ public class JAXBOMDataSource extends AbstractPushOMDataSource implements QNameA Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); if (writer instanceof MTOMXMLStreamWriter) { - MTOMXMLStreamWriter mtomWriter = (MTOMXMLStreamWriter)writer; + MTOMXMLStreamWriter mtomWriter = (MTOMXMLStreamWriter) writer; if (mtomWriter.isOptimized()) { marshaller.setAttachmentMarshaller(new AttachmentMarshallerImpl(mtomWriter)); } @@ -93,7 +91,7 @@ public class JAXBOMDataSource extends AbstractPushOMDataSource implements QNameA Throwable cause = ex.getCause(); while (cause != null) { if (cause instanceof XMLStreamException) { - throw (XMLStreamException)cause; + throw (XMLStreamException) cause; } cause = cause.getCause(); } @@ -104,7 +102,7 @@ public class JAXBOMDataSource extends AbstractPushOMDataSource implements QNameA private QName getQName() { if (cachedQName == null) { if (object instanceof JAXBElement) { - cachedQName = ((JAXBElement<?>)object).getName(); + cachedQName = ((JAXBElement<?>) object).getName(); } else { cachedQName = context.createJAXBIntrospector().getElementName(object); if (cachedQName == null) { @@ -116,7 +114,7 @@ public class JAXBOMDataSource extends AbstractPushOMDataSource implements QNameA } return cachedQName; } - + @Override public String getLocalName() { return getQName().getLocalPart(); diff --git a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/AttachmentUnmarshallerImpl.java b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/AttachmentUnmarshallerImpl.java index f401c98d9..e535dffa7 100644 --- a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/AttachmentUnmarshallerImpl.java +++ b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/AttachmentUnmarshallerImpl.java @@ -30,13 +30,13 @@ import org.apache.axiom.util.activation.DataHandlerUtils; final class AttachmentUnmarshallerImpl extends AttachmentUnmarshaller { private final OMAttachmentAccessor attachmentAccessor; - + AttachmentUnmarshallerImpl(OMAttachmentAccessor attachmentAccessor) { this.attachmentAccessor = attachmentAccessor; } /** * Extract the content ID from a URL following the cid scheme defined by RFC2392. - * + * * @param url the URL * @return the corresponding content ID * @throws IllegalArgumentException if the URL doesn't use the cid scheme diff --git a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java index 3bcdb6c34..2fa5d2837 100644 --- a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java +++ b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/JAXBUtils.java @@ -28,70 +28,72 @@ import org.apache.axiom.om.OMContainer; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.XOPEncoded; -/** - * Contains utility methods that integrate JAXB with Axiom. - */ +/** Contains utility methods that integrate JAXB with Axiom. */ public final class JAXBUtils { private JAXBUtils() {} - + /** - * @deprecated Use - * {@link #unmarshal(OMContainer, JAXBContext, UnmarshallerConfigurator, boolean)} - * instead. + * @deprecated Use {@link #unmarshal(OMContainer, JAXBContext, UnmarshallerConfigurator, + * boolean)} instead. */ - public static Object unmarshal(JAXBContext context, OMElement element, boolean cache) throws JAXBException { + public static Object unmarshal(JAXBContext context, OMElement element, boolean cache) + throws JAXBException { return unmarshal(element, context, null, cache); } - + /** * Unmarshall the information item using JAXB. - * - * @param container - * the document or element to unmarshall - * @param context - * the JAXB context - * @param configurator - * custom unmarshaller settings to apply; may be {@code null} - * @param preserve - * specifies whether the content of the information item should be preserved + * + * @param container the document or element to unmarshall + * @param context the JAXB context + * @param configurator custom unmarshaller settings to apply; may be {@code null} + * @param preserve specifies whether the content of the information item should be preserved * @return the unmarshalled object - * @throws JAXBException - * if an error occurred while unmarshalling + * @throws JAXBException if an error occurred while unmarshalling */ - public static Object unmarshal(OMContainer container, JAXBContext context, UnmarshallerConfigurator configurator, boolean preserve) throws JAXBException { + public static Object unmarshal( + OMContainer container, + JAXBContext context, + UnmarshallerConfigurator configurator, + boolean preserve) + throws JAXBException { Unmarshaller unmarshaller = context.createUnmarshaller(); if (configurator != null) { configurator.configure(unmarshaller); } - XOPEncoded<XMLStreamReader> xopEncodedStream = container.getXOPEncodedStreamReader(preserve); - unmarshaller.setAttachmentUnmarshaller(new AttachmentUnmarshallerImpl(xopEncodedStream.getAttachmentAccessor())); + XOPEncoded<XMLStreamReader> xopEncodedStream = + container.getXOPEncodedStreamReader(preserve); + unmarshaller.setAttachmentUnmarshaller( + new AttachmentUnmarshallerImpl(xopEncodedStream.getAttachmentAccessor())); return unmarshaller.unmarshal(xopEncodedStream.getRootPart()); } - + /** * Unmarshall the information item using JAXB. - * - * @param container - * the document or element to unmarshall - * @param context - * the JAXB context - * @param configurator - * custom unmarshaller settings to apply; may be {@code null} - * @param declaredType - * a JAXB mapped class to hold the XML data. - * @param preserve - * specifies whether the content of the information item should be preserved + * + * @param container the document or element to unmarshall + * @param context the JAXB context + * @param configurator custom unmarshaller settings to apply; may be {@code null} + * @param declaredType a JAXB mapped class to hold the XML data. + * @param preserve specifies whether the content of the information item should be preserved * @return the unmarshalled object - * @throws JAXBException - * if an error occurred while unmarshalling + * @throws JAXBException if an error occurred while unmarshalling */ - public static <T> JAXBElement<T> unmarshal(OMContainer container, JAXBContext context, UnmarshallerConfigurator configurator, Class<T> declaredType, boolean preserve) throws JAXBException { + public static <T> JAXBElement<T> unmarshal( + OMContainer container, + JAXBContext context, + UnmarshallerConfigurator configurator, + Class<T> declaredType, + boolean preserve) + throws JAXBException { Unmarshaller unmarshaller = context.createUnmarshaller(); if (configurator != null) { configurator.configure(unmarshaller); } - XOPEncoded<XMLStreamReader> xopEncodedStream = container.getXOPEncodedStreamReader(preserve); - unmarshaller.setAttachmentUnmarshaller(new AttachmentUnmarshallerImpl(xopEncodedStream.getAttachmentAccessor())); + XOPEncoded<XMLStreamReader> xopEncodedStream = + container.getXOPEncodedStreamReader(preserve); + unmarshaller.setAttachmentUnmarshaller( + new AttachmentUnmarshallerImpl(xopEncodedStream.getAttachmentAccessor())); return unmarshaller.unmarshal(xopEncodedStream.getRootPart(), declaredType); } } diff --git a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/UnmarshallerConfigurator.java b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/UnmarshallerConfigurator.java index 4f05474dd..20c20bdc4 100644 --- a/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/UnmarshallerConfigurator.java +++ b/axiom-jaxb/src/main/java/org/apache/axiom/om/util/jaxb/UnmarshallerConfigurator.java @@ -21,17 +21,13 @@ package org.apache.axiom.om.util.jaxb; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; -/** - * Interface used to apply custom settings to an {@link Unmarshaller}. - */ +/** Interface used to apply custom settings to an {@link Unmarshaller}. */ public interface UnmarshallerConfigurator { /** * Apply settings to the given unmarshaller. - * - * @param unmarshaller - * the unmarshaller to configure - * @throws JAXBException - * if the unmarshaller throws an exception + * + * @param unmarshaller the unmarshaller to configure + * @throws JAXBException if the unmarshaller throws an exception */ void configure(Unmarshaller unmarshaller) throws JAXBException; }