RFR 8251989: Hex formatter and parser utility
peter.levart at gmail.com
Thu Aug 27 17:21:53 UTC 2020
About methods in Hex.Formatter that append to StringBuilder, like the
public StringBuilder format(StringBuilder sb, byte bytes)
...I was thinking that such method could have more utility if it was
public <A extends Appendable> A format(A appendable, byte bytes)
For example, you could also format directly to PrintStream, Writer,
CharBuffer or any custom implementation. The only grief is that
Appendable methods are specified to throw IOException, but
Hex.Formatter.format(Appendable ... methods could be specified to wrap
such exception with UncheckedIOException. For usage with StringBuilder
this would not change anything as it never throws IOException.
What do you think?
On 8/27/20 3:34 AM, Roger Riggs wrote:
> Please review updates to the formatting and parsing API based on the
> last round of comments.
> There are many changes, so it may be useful to read it as a fresh draft.
> - Rename classes: Encoder -> Formatter; Decoder -> Parser
> - Rename methods: encode -> format; decode -> parse, etc.
> - Rename factory methods to match
> - Added a factory method and re-arrange arguments to make it more
> to create uppercase formatters based on the existing uses.
> - The implementation has been updated based on the suggestions and
> API changes
> The webrev for applying the API to the security classes will be
> updated when the API settles down.
> The previous (encoder/decoder) javadoc has been renamed to:
More information about the core-libs-dev