Skip to content

Commit

Permalink
[MSHARED-860] deprecate constants that are now available in Java 7+ (#42
Browse files Browse the repository at this point in the history
)

* deprecate constants that are now available in Java 7+
* update URLs
* fix some api doc
  • Loading branch information
elharo authored May 29, 2020
1 parent d1042e0 commit 660fd80
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 66 deletions.
81 changes: 46 additions & 35 deletions src/main/java/org/apache/maven/shared/utils/ReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,57 +40,63 @@
*
* @author <a href="mailto:[email protected]">Hervé Boutemy</a>
* @see java.nio.charset.Charset
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported encodings</a>
*/
public class ReaderFactory
{
/**
* ISO Latin Alphabet #1, also known as ISO-LATIN-1.
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.ISO_8859_1}
*/
@Deprecated
public static final String ISO_8859_1 = "ISO-8859-1";

/**
* Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.US_ASCII}
*/
@Deprecated
public static final String US_ASCII = "US-ASCII";

/**
* Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either
* order accepted on input, big-endian used on output).
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16}
*/
@Deprecated
public static final String UTF_16 = "UTF-16";

/**
* Sixteen-bit Unicode Transformation Format, big-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16BE}
*/
@Deprecated
public static final String UTF_16BE = "UTF-16BE";

/**
* Sixteen-bit Unicode Transformation Format, little-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16LE}
*/
@Deprecated
public static final String UTF_16LE = "UTF-16LE";

/**
* Eight-bit Unicode Transformation Format.
* Every implementation of the Java platform is required to support this character encoding.
*
* @see java.nio.charset.Charset
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_8}
*/
@Deprecated
public static final String UTF_8 = "UTF-8";

/**
Expand All @@ -101,9 +107,9 @@ public class ReaderFactory
/**
* Create a new Reader with XML encoding detection rules.
*
* @param in not null input stream.
* @return an XML reader instance for the input stream.
* @throws IOException if any.
* @param in not null input stream
* @return an XML reader instance for the input stream
* @throws IOException if any
* @see XmlStreamReader
*/
public static Reader newXmlReader( @Nonnull InputStream in )
Expand All @@ -115,9 +121,9 @@ public static Reader newXmlReader( @Nonnull InputStream in )
/**
* Create a new Reader with XML encoding detection rules.
*
* @param file not null file.
* @return an XML reader instance for the input file.
* @throws IOException if any.
* @param file not null file
* @return an XML reader instance for the input file
* @throws IOException if any
* @see XmlStreamReader
*/
public static Reader newXmlReader( @Nonnull File file )
Expand All @@ -129,9 +135,9 @@ public static Reader newXmlReader( @Nonnull File file )
/**
* Create a new Reader with XML encoding detection rules.
*
* @param url not null url.
* @return an XML reader instance for the input url.
* @throws IOException if any.
* @param url not null url
* @return an XML reader instance for the input URL
* @throws IOException if any
* @see XmlStreamReader
*/
public static Reader newXmlReader( @Nonnull URL url )
Expand All @@ -141,13 +147,15 @@ public static Reader newXmlReader( @Nonnull URL url )
}

/**
* Create a new Reader with default plaform encoding.
* Create a new Reader with default platform encoding.
*
* @param file not null file.
* @return a reader instance for the input file using the default platform charset.
* @throws FileNotFoundException if any.
* @return a reader instance for the input file using the default platform character set
* @throws FileNotFoundException if any
* @see java.nio.charset.Charset#defaultCharset()
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
public static Reader newPlatformReader( @Nonnull File file )
throws FileNotFoundException
{
Expand All @@ -157,11 +165,12 @@ public static Reader newPlatformReader( @Nonnull File file )
/**
* Create a new Reader with specified encoding.
*
* @param in not null input stream.
* @param encoding not null supported encoding.
* @return a reader instance for the input stream using the given encoding.
* @throws UnsupportedEncodingException if any.
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @param in not null input stream
* @param encoding not null supported encoding
* @return a reader instance for the input stream using the given encoding
* @throws UnsupportedEncodingException if any
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported
* encodings</a>
*/
public static Reader newReader( @Nonnull InputStream in, @Nonnull String encoding )
throws UnsupportedEncodingException
Expand All @@ -172,12 +181,13 @@ public static Reader newReader( @Nonnull InputStream in, @Nonnull String encodin
/**
* Create a new Reader with specified encoding.
*
* @param file not null file.
* @param encoding not null supported encoding.
* @return a reader instance for the input file using the given encoding.
* @throws FileNotFoundException if any.
* @throws UnsupportedEncodingException if any.
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @param file not null file
* @param encoding not null supported encoding
* @return a reader instance for the input file using the given encoding
* @throws FileNotFoundException if any
* @throws UnsupportedEncodingException if any
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported
* encodings</a>
*/
public static Reader newReader( @Nonnull File file, @Nonnull String encoding )
throws FileNotFoundException, UnsupportedEncodingException
Expand All @@ -188,11 +198,12 @@ public static Reader newReader( @Nonnull File file, @Nonnull String encoding )
/**
* Create a new Reader with specified encoding.
*
* @param url not null url.
* @param encoding not null supported encoding.
* @return a reader instance for the input url using the given encoding.
* @throws IOException if any.
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @param url not null URL
* @param encoding not null supported encoding
* @return a reader instance for the input URL using the given encoding
* @throws IOException if any
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported
* encodings</a>
*/
public static Reader newReader( @Nonnull URL url, @Nonnull String encoding )
throws IOException
Expand Down
78 changes: 47 additions & 31 deletions src/main/java/org/apache/maven/shared/utils/WriterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,63 @@
*
* @author Hervé Boutemy
* @see java.nio.charset.Charset
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported encodings</a>
*/
public class WriterFactory
{
/**
* ISO Latin Alphabet #1, also known as ISO-LATIN-1.
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.ISO_8859_1}
*/
@Deprecated
public static final String ISO_8859_1 = "ISO-8859-1";

/**
* Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.US_ASCII}
*/
@Deprecated
public static final String US_ASCII = "US-ASCII";

/**
* Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either
* order accepted on input, big-endian used on output).
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16}
*/
@Deprecated
public static final String UTF_16 = "UTF-16";

/**
* Sixteen-bit Unicode Transformation Format, big-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16BE}
*/
@Deprecated
public static final String UTF_16BE = "UTF-16BE";

/**
* Sixteen-bit Unicode Transformation Format, little-endian byte order.
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_16LE}
*/
@Deprecated
public static final String UTF_16LE = "UTF-16LE";

/**
* Eight-bit Unicode Transformation Format.
* Every implementation of the Java platform is required to support this character encoding.
* @see java.nio.charset.Charset
*
* @deprecated use {@code java.nio.charset.StandardCharset.UTF_8}
*/
@Deprecated
public static final String UTF_8 = "UTF-8";

/**
Expand All @@ -94,9 +106,9 @@ public class WriterFactory
/**
* Create a new Writer with XML encoding detection rules.
*
* @param out not null output stream.
* @return an XML writer instance for the output stream.
* @throws IOException if any.
* @param out not null output stream
* @return an XML writer instance for the output stream
* @throws IOException if any
* @see XmlStreamWriter
*/
public static XmlStreamWriter newXmlWriter( @Nonnull OutputStream out )
Expand All @@ -108,9 +120,9 @@ public static XmlStreamWriter newXmlWriter( @Nonnull OutputStream out )
/**
* Create a new Writer with XML encoding detection rules.
*
* @param file not null file.
* @return an XML writer instance for the output file.
* @throws IOException if any.
* @param file not null file
* @return an XML writer instance for the output file
* @throws IOException if any
* @see XmlStreamWriter
*/
public static XmlStreamWriter newXmlWriter( @Nonnull File file )
Expand All @@ -122,10 +134,11 @@ public static XmlStreamWriter newXmlWriter( @Nonnull File file )
/**
* Create a new Writer with default platform encoding.
*
* @param out not null output stream.
* @return a writer instance for the output stream using the default platform charset.
* @see java.nio.charset.Charset#defaultCharset()
* @param out not null output stream
* @return a writer instance for the output stream using the default platform charset
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
public static Writer newPlatformWriter( @Nonnull OutputStream out )
{
return new OutputStreamWriter( out );
Expand All @@ -134,11 +147,12 @@ public static Writer newPlatformWriter( @Nonnull OutputStream out )
/**
* Create a new Writer with default platform encoding.
*
* @param file not null file.
* @return a writer instance for the output file using the default platform charset.
* @throws IOException if any.
* @see java.nio.charset.Charset#defaultCharset()
* @param file not null file
* @return a writer instance for the output file using the default platform charset
* @throws IOException if any
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
public static Writer newPlatformWriter( @Nonnull File file )
throws IOException
{
Expand All @@ -148,11 +162,12 @@ public static Writer newPlatformWriter( @Nonnull File file )
/**
* Create a new Writer with specified encoding.
*
* @param out not null output stream.
* @param encoding not null supported encoding.
* @return a writer instance for the output stream using the given encoding.
* @throws UnsupportedEncodingException if any.
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @param out not null output stream
* @param encoding not null supported encoding
* @return a writer instance for the output stream using the given encoding
* @throws UnsupportedEncodingException if any
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported
* encodings</a>
*/
public static Writer newWriter( @Nonnull OutputStream out, @Nonnull String encoding )
throws UnsupportedEncodingException
Expand All @@ -163,12 +178,13 @@ public static Writer newWriter( @Nonnull OutputStream out, @Nonnull String encod
/**
* Create a new Writer with specified encoding.
*
* @param file not null file.
* @param encoding not null supported encoding.
* @return a writer instance for the output file using the given encoding.
* @throws UnsupportedEncodingException if any.
* @throws FileNotFoundException if any.
* @see <a href="http://docs.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">Supported encodings</a>
* @param file not null file
* @param encoding not null supported encoding
* @return a writer instance for the output file using the given encoding
* @throws UnsupportedEncodingException if any
* @throws FileNotFoundException if any
* @see <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html">Supported
* encodings</a>
*/
public static Writer newWriter( @Nonnull File file, @Nonnull String encoding )
throws UnsupportedEncodingException, FileNotFoundException
Expand Down

0 comments on commit 660fd80

Please sign in to comment.