Changeset 16834 for gli/trunk


Ignore:
Timestamp:
2008-08-15T16:07:28+12:00 (16 years ago)
Author:
ak19
Message:

Removed the longer calcDisplayString() and now the call to this methodname only refers to the shorter version, since the longer version which would try to convert the filename into several encodings produced strange results on Linux

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/collection/CollectionTreeNode.java

    r16770 r16834  
    6464    }
    6565
    66     /** Similar to calcDisplayString, but this version only checks whether the filename
    67      * String is UTF8. If so, it converts it into UTF8 and returns it. If the filename
    68      * is not UTF8, it is returned unchanged.
    69      */
    70     protected String quickCalcDisplayString() {
    71     String filename = super.toString();
    72     try{
    73         String utf8filename = new String(filename.getBytes(), "UTF8");
    74         if(utf8filename.indexOf('\ufffd') == -1) {
    75         return utf8filename;
    76         } else { // contains the character indicating that it's invalid utf8
    77         // return the original string
    78         return filename;
    79         }
    80     } catch(java.io.UnsupportedEncodingException e) {
    81         return filename;
    82     }
    83     }
    8466
    8567    /** This method returns a string representation of the filenodes in the Collection
     
    10789    protected String calcDisplayString() {
    10890    String filename = super.toString();
    109 
    11091    try{
    111         String[] charsets = {"UTF-8", "ISO-8859-1", "US-ASCII", "UTF-16BE", "UTF-16LE", "UTF-16"};
    112         for(int i = 0; i < charsets.length; i++) {
    113         String charset = charsets[i];
    114         String convertedfilename = new String(filename.getBytes(), charset);
    115         if(convertedfilename.indexOf('\ufffd') != -1) {
    116             // encountered the character that indicates when the conversion is invalid
    117             convertedfilename = null;
    118             continue; // try to use the next charset to encode the filename as
    119         }
    120         else { // valid conversion
    121             return convertedfilename;
    122         }
     92        String utf8filename = new String(filename.getBytes(), "UTF8");
     93        if(utf8filename.indexOf('\ufffd') == -1) {
     94        return utf8filename;
     95        } else { // contains the character indicating that it's invalid utf8
     96        // return the original string
     97        return filename;
    12398        }
    12499    } catch(java.io.UnsupportedEncodingException e) {
    125100        return filename;
    126101    }
    127 
    128     return filename; // attempted conversions all failed
    129102    }
    130103
Note: See TracChangeset for help on using the changeset viewer.