You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2012/05/03 12:48:50 UTC

[jira] [Created] (CODEC-141) Generics warnings for StringEncoderComparator

Sebb created CODEC-141:
--------------------------

             Summary: Generics warnings for StringEncoderComparator
                 Key: CODEC-141
                 URL: https://issues.apache.org/jira/browse/CODEC-141
             Project: Commons Codec
          Issue Type: Bug
            Reporter: Sebb
         Attachments: CODEC-141.patch

The StringEncoderComparator class currently extends the raw type Comparator.

I think it should extend Comparator<Object>, as it implements compare(Object, Object).

Although it is documented as being a String comparator, some StringEncoder implementations also support other types such as byte[].

Secondly, its compare() method currently casts the stringEncoder.encode() results to Comparable.
This might as well be String, as that is what a StringEncoder is supposed to do.
If a class cast exception occurs, then this is a bug in the provided StringEncoder (and casting to Comparable would likely also fail).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CODEC-141) Generics warnings for StringEncoderComparator

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated CODEC-141:
-----------------------

    Attachment: CODEC-141.patch
    
> Generics warnings for StringEncoderComparator
> ---------------------------------------------
>
>                 Key: CODEC-141
>                 URL: https://issues.apache.org/jira/browse/CODEC-141
>             Project: Commons Codec
>          Issue Type: Bug
>            Reporter: Sebb
>         Attachments: CODEC-141.patch
>
>
> The StringEncoderComparator class currently extends the raw type Comparator.
> I think it should extend Comparator<Object>, as it implements compare(Object, Object).
> Although it is documented as being a String comparator, some StringEncoder implementations also support other types such as byte[].
> Secondly, its compare() method currently casts the stringEncoder.encode() results to Comparable.
> This might as well be String, as that is what a StringEncoder is supposed to do.
> If a class cast exception occurs, then this is a bug in the provided StringEncoder (and casting to Comparable would likely also fail).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CODEC-141) Generics warnings for StringEncoderComparator

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438119#comment-13438119 ] 

Thomas Neidhart commented on CODEC-141:
---------------------------------------

I think the Comparator shall even extend Comparator<String>. The javadoc clearly states that it is used to compare strings that are encoded using the given StringEncoder. 

The reason why there are some StringEncoder implementations that also have an encode(byte[]) method is because these implementations (e.g. QuotedPrintableCode) also implement the BinaryEncoder interface.

If we want to support the general case of providing Object's as input, we should probable better create an EncoderComparator?
                
> Generics warnings for StringEncoderComparator
> ---------------------------------------------
>
>                 Key: CODEC-141
>                 URL: https://issues.apache.org/jira/browse/CODEC-141
>             Project: Commons Codec
>          Issue Type: Bug
>            Reporter: Sebb
>         Attachments: CODEC-141.patch
>
>
> The StringEncoderComparator class currently extends the raw type Comparator.
> I think it should extend Comparator<Object>, as it implements compare(Object, Object).
> Although it is documented as being a String comparator, some StringEncoder implementations also support other types such as byte[].
> Secondly, its compare() method currently casts the stringEncoder.encode() results to Comparable.
> This might as well be String, as that is what a StringEncoder is supposed to do.
> If a class cast exception occurs, then this is a bug in the provided StringEncoder (and casting to Comparable would likely also fail).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira