-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
907 additions
and
1,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
*/ | ||
|
@@ -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 | ||
|
@@ -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()) { | ||
|
@@ -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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
*/ | ||
|
@@ -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 | ||
*/ | ||
|
@@ -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 | ||
*/ | ||
|
@@ -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 | ||
* | ||
|
@@ -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 | ||
* | ||
|
@@ -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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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; | ||
|
Oops, something went wrong.