Skip to content

Commit

Permalink
checkstyle-10.19.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ao-apps committed Oct 30, 2024
1 parent f74c36a commit d688687
Show file tree
Hide file tree
Showing 33 changed files with 907 additions and 1,145 deletions.
12 changes: 11 additions & 1 deletion checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
ao-encoding - High performance streaming character encoding.
Copyright (C) 2022, 2023 AO Industries, Inc.
Copyright (C) 2022, 2023, 2024 AO Industries, Inc.
[email protected]
7262 Bull Pen Cir
Mobile, AL 36695
Expand Down Expand Up @@ -30,6 +30,16 @@ along with ao-encoding. If not, see <https://www.gnu.org/licenses/>.
<!-- TODO: Complete Javadocs -->
<suppress checks="(MissingJavadocMethod|MissingJavadocType|SummaryJavadoc)" />

<!-- Cannot find how to allow <p> inside @param and @return -->
<suppress
checks="JavadocParagraph"
files="[/\\]com[/\\]aoapps[/\\]encoding[/\\]Encode\.java$"
/>
<suppress
checks="JavadocParagraph"
files="[/\\]com[/\\]aoapps[/\\]encoding[/\\]Encoding\.java$"
/>

<!-- TODO: Remove in 8.0.0 release -->
<suppress
checks="AbbreviationAsWordInName"
Expand Down
34 changes: 15 additions & 19 deletions src/main/java/com/aoapps/encoding/ChainWriter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ao-encoding - High performance streaming character encoding.
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 AO Industries, Inc.
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2024 AO Industries, Inc.
* [email protected]
* 7262 Bull Pen Cir
* Mobile, AL 36695
Expand Down Expand Up @@ -138,10 +138,9 @@ public ChainWriter(PrintWriter out) {

/**
* Create a new PrintWriter, if needed, without automatic line flushing.
* <p>
* When {@code out} is already a {@link PrintWriter}, it is used directly,
* regardless of {@code autoFlush} settings.
* </p>
*
* <p>When {@code out} is already a {@link PrintWriter}, it is used directly,
* regardless of {@code autoFlush} settings.</p>
*
* @param out A character-output stream
*/
Expand All @@ -167,10 +166,9 @@ public ChainWriter(Writer out) {

/**
* Create a new PrintWriter, if needed.
* <p>
* When {@code out} is already a {@link PrintWriter}, it is used directly,
* regardless of {@code autoFlush} settings.
* </p>
*
* <p>When {@code out} is already a {@link PrintWriter}, it is used directly,
* regardless of {@code autoFlush} settings.</p>
*
* @param out A character-output stream
* @param autoFlush A boolean; if true, the println() methods will flush
Expand Down Expand Up @@ -209,11 +207,10 @@ public PrintWriter getPrintWriter() {

/**
* Flushes the stream.
* <p>
* Unlike <code>{@link PrintWriter#flush()}</code>, exceptions are thrown immediately, as requiring the caller
* to remember to invoke <code>{@link PrintWriter#checkError()}</code> too easily leads to swallowed
* exceptions and hard-to-diagnose runtime problems.
* </p>
*
* <p>Unlike <code>{@link PrintWriter#flush()}</code>, exceptions are thrown immediately, as requiring the caller
* to remember to invoke <code>{@link PrintWriter#checkError()}</code> too easily leads to swallowed
* exceptions and hard-to-diagnose runtime problems.</p>
*/
public ChainWriter flush() throws IOException {
if (out.checkError()) {
Expand All @@ -224,11 +221,10 @@ public ChainWriter flush() throws IOException {

/**
* Closes the stream.
* <p>
* Unlike <code>{@link PrintWriter#close()}</code>, exceptions are thrown immediately, as requiring the caller
* to remember to invoke <code>{@link PrintWriter#checkError()}</code> too easily leads to swallowed
* exceptions and hard-to-diagnose runtime problems.
* </p>
*
* <p>Unlike <code>{@link PrintWriter#close()}</code>, exceptions are thrown immediately, as requiring the caller
* to remember to invoke <code>{@link PrintWriter#checkError()}</code> too easily leads to swallowed
* exceptions and hard-to-diagnose runtime problems.</p>
*/
@Override
public void close() throws IOException {
Expand Down
110 changes: 47 additions & 63 deletions src/main/java/com/aoapps/encoding/Encode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ao-encoding - High performance streaming character encoding.
* Copyright (C) 2022 AO Industries, Inc.
* Copyright (C) 2022, 2024 AO Industries, Inc.
* [email protected]
* 7262 Bull Pen Cir
* Mobile, AL 36695
Expand Down Expand Up @@ -38,10 +38,9 @@ public interface Encode {
// <editor-fold desc="Encode - definition" defaultstate="collapsed">
/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* @return {@code this} writer
*/
Expand All @@ -54,10 +53,9 @@ default Encode encode(MediaType contentType, char ch) throws IOException {

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* @return {@code this} writer
*/
Expand All @@ -72,10 +70,9 @@ default Encode encode(MediaType contentType, char[] cbuf) throws IOException {

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* @return {@code this} writer
*/
Expand All @@ -90,59 +87,51 @@ default Encode encode(MediaType contentType, char[] cbuf, int offset, int len) t

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.</p>
*
* @return {@code this} writer
*/
Encode encode(MediaType contentType, CharSequence csq) throws IOException;

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.</p>
*
* @return {@code this} writer
*/
Encode encode(MediaType contentType, CharSequence csq, int start, int end) throws IOException;

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.</p>
*
* @return {@code this} writer
*/
Encode encode(MediaType contentType, Object content) throws IOException;

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>If the string is translated, comments will be added giving the
* translation lookup id to aid in translation of server-translated values.</p>
*
* @param <Ex> An arbitrary exception type that may be thrown
*
Expand All @@ -154,13 +143,11 @@ default <Ex extends Throwable> Encode encode(MediaType contentType, IOSupplierE<

/**
* Encodes the given nested type with proper encoding.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* Does not perform any translation markups.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>Does not perform any translation markups.</p>
*
* @param <Ex> An arbitrary exception type that may be thrown
*
Expand All @@ -178,21 +165,18 @@ default <Ex extends Throwable> Encode encode(MediaType contentType, MediaWritabl
/**
* Encodes the given nested type with proper encoding.
* This is well suited for use in a try-with-resources block.
* <p>
* Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.
* </p>
* <p>
* Does not perform any translation markups.
* </p>
*
* <p>Adds {@linkplain MediaEncoder#writePrefixTo(java.lang.Appendable) prefixes}
* and {@linkplain MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean) suffixes} by media type, such as {@code "…"}.</p>
*
* <p>Does not perform any translation markups.</p>
*
* @return A new writer that may be used for the given content type.
* This writer must be closed for completed calls to {@link MediaEncoder#writeSuffixTo(java.lang.Appendable, boolean)}.
* <p>
* The returned writer will be of the specific subclass of {@link MediaWriter} matching {@code contentType}
*
* <p>The returned writer will be of the specific subclass of {@link MediaWriter} matching {@code contentType}
* (see {@link MediaType#getMediaWriterClass()}. This means {@link MediaWriter#getValidMediaInputType()} will
* be {@code contentType}.
* </p>
* be {@code contentType}.</p>
*/
MediaWriter encode(MediaType contentType) throws IOException;
// </editor-fold>
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/com/aoapps/encoding/EncodingContext.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ao-encoding - High performance streaming character encoding.
* Copyright (C) 2016, 2019, 2020, 2021, 2022 AO Industries, Inc.
* Copyright (C) 2016, 2019, 2020, 2021, 2022, 2024 AO Industries, Inc.
* [email protected]
* 7262 Bull Pen Cir
* Mobile, AL 36695
Expand Down Expand Up @@ -80,39 +80,35 @@ public Serialization getSerialization() {
* Encodes a URL for the current encoding context.
* The resulting URL must be valid <a href="https://datatracker.ietf.org/doc/html/rfc3986">RFC 3986 URI</a> or
* <a href="https://datatracker.ietf.org/doc/html/rfc3987">RFC 3987 IRI</a>.
* <p>
* Defaults to performing no encoding.
* </p>
*
* <p>Defaults to performing no encoding.</p>
*/
default String encodeURL(String url) {
return url;
}

/**
* The current doctype.
* <p>
* Defaults to {@link Doctype#DEFAULT}.
* </p>
*
* <p>Defaults to {@link Doctype#DEFAULT}.</p>
*/
default Doctype getDoctype() {
return Doctype.DEFAULT;
}

/**
* The current serialization.
* <p>
* Defaults to {@link Serialization#DEFAULT}.
* </p>
*
* <p>Defaults to {@link Serialization#DEFAULT}.</p>
*/
default Serialization getSerialization() {
return Serialization.DEFAULT;
}

/**
* The output character encoding.
* <p>
* Defaults to {@link StandardCharsets#UTF_8}.
* </p>
*
* <p>Defaults to {@link StandardCharsets#UTF_8}.</p>
*/
default Charset getCharacterEncoding() {
return StandardCharsets.UTF_8;
Expand Down
Loading

0 comments on commit d688687

Please sign in to comment.