commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-337) ByteOrderMark can be refactored as an enum
Date Mon, 01 Jun 2015 19:20:19 GMT

    [ https://issues.apache.org/jira/browse/IO-337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567831#comment-14567831
] 

Niall Pemberton commented on IO-337:
------------------------------------

There are more byte order marks than the five defined as static variables in the ByteOrderMark
class. This way we just define the common ones, but allow people to construct others. Switching
to an enum would prevent this. It would also prevent the (ab)use of this class to detect starting
bytes such as the BOMInputStream does with the XML_GUESS_BYTES boms that it constructs.


http://en.wikipedia.org/wiki/Byte_order_mark

> ByteOrderMark can be refactored as an enum
> ------------------------------------------
>
>                 Key: IO-337
>                 URL: https://issues.apache.org/jira/browse/IO-337
>             Project: Commons IO
>          Issue Type: New Feature
>            Reporter: Yaniv Kunda
>            Priority: Minor
>         Attachments: ByteOrderMark-enum.patch
>
>
> ByteOrderMark is used primarily for encapsulating the data regarding to Unicode BOMs.
Since those are fixed, it would make sense to make it an enum, instead of a public class.
> I have attached a patch that only covers ByteOrderMark itself, including an additional
getCharset() utility method, and toString() simplification.
> This patch does not cover:
> 1) Its incorrect use (per its perceived purpose) in XmlStreamReader.XML_GUESS_BYTES
> 2) The now-unnecessary tests



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message