View | Details | Raw Unified | Return to bug 17039
Collapse All | Expand All

(-)HeaderRecord.java (-18 / +59 lines)
Line 76 Link Here
76
    private String            field_2_header;
76
    private byte              field_2_unicode_flag;
77
--
77
    private String            field_3_header;
Lines 122-123 Link Here
122
            field_2_header     = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
123
            field_2_unicode_flag = data[ 2 + offset ];
123
                                            LittleEndian.ubyteToInt(field_1_header_len));
124
            if(isMultibyte())
124
--
125
            {
126
                field_3_header = StringUtil.getFromUnicodeHigh(
127
                        data,3 + offset,LittleEndian.ubyteToInt(field_1_header_len));
128
            }
129
            else
130
            {
131
                field_3_header     = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
132
                                            LittleEndian.ubyteToInt( field_1_header_len) );
133
            }
Line 128 Link Here
138
     * see the unicode flag
139
     *
140
     * @return boolean flag
141
     *  true:footer string has at least one multibyte character
142
     */
143
     public boolean isMultibyte() {
144
         return ((field_2_unicode_flag & 0xFF) == 1);
145
    }
146
147
    /**
148
     * check the parameter has multibyte character
149
     *
150
     * @param value  string to check
151
     * @return  boolean result
152
     *  true:string has at least one multibyte character
153
     */
154
    private static boolean hasMultibyte(String value){
155
        if( value == null )return false;
156
        for(int i = 0 ; i < value.length() ; i++ ){
157
            char c = value.charAt(i);
158
            if(c > 0xFF )return true;
159
        }
160
        return false;
161
    }
162
163
    /**
Line 148 Link Here
148
        field_2_header = header;
184
        field_3_header = header;
149
--
185
        field_2_unicode_flag = 
186
            (byte) (hasMultibyte(field_3_header) ? 1 : 0);
Line 172 Link Here
172
        return field_2_header;
210
        return field_3_header;
173
--
Line 196 Link Here
234
        short bytelen = (short)(isMultibyte() ?
235
            getHeaderLength()*2 : getHeaderLength() );
Line 198 Link Here
198
                              ( short ) ((len - 4) + getHeaderLength()));
238
                              ( short ) ((len - 4) + bytelen));
199
--
Line 203 Link Here
203
            StringUtil.putCompressedUnicode(getHeader(), data, 7 + offset); // [Shawn] Place the string in the correct offset
243
            data[ 6 + offset ] = field_2_unicode_flag;
204
--
244
            if(isMultibyte())
245
            {
246
                StringUtil.putUncompressedUnicode(getHeader(), data, 7 + offset);
247
            }
248
            else
249
            {
250
                StringUtil.putCompressedUnicode(getHeader(), data, 7 + offset); // [Shawn] Place the string in the correct offset
251
            }
Lines 216-217 Link Here
216
        retval += getHeaderLength();
264
       return (isMultibyte() ? 
217
        return retval;
265
            (retval + getHeaderLength()*2) : (retval + getHeaderLength()));
218
--
Line 228 Link Here
228
      rec.field_2_header = field_2_header;
276
      rec.field_2_unicode_flag = field_2_unicode_flag;
229
--
277
      rec.field_3_header = field_3_header;
(-)FooterRecord.java (-17 / +59 lines)
Line 76 Link Here
76
    private String            field_2_footer;
76
    private byte              field_2_unicode_flag;
77
--
77
    private String            field_3_footer;
Lines 122-123 Link Here
122
            field_2_footer     = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
123
            field_2_unicode_flag = data[ 2 + offset ];
123
                                            LittleEndian.ubyteToInt( field_1_footer_len) );
124
            if(isMultibyte())
124
--
125
            {
126
                field_3_footer = StringUtil.getFromUnicodeHigh(
127
                        data,3 + offset,LittleEndian.ubyteToInt(field_1_footer_len));
128
            }
129
            else
130
            {
131
                field_3_footer     = new String(data, 3 + offset, // [Shawn] Changed 1 to 3 for offset of string
132
                                           LittleEndian.ubyteToInt( field_1_footer_len) );
133
            }
Line 128 Link Here
138
     * see the unicode flag
139
     *
140
     * @return boolean flag
141
     *  true:footer string has at least one multibyte character
142
     */
143
     public boolean isMultibyte() {
144
         return ((field_2_unicode_flag & 0xFF) == 1);
145
    }
146
147
    /**
148
     * check the parameter has multibyte character
149
     *
150
     * @param value  string to check
151
     * @return  boolean result
152
     *  true:string has at least one multibyte character
153
     */
154
    private static boolean hasMultibyte(String value){
155
        if( value == null )return false;
156
        for(int i = 0 ; i < value.length() ; i++ ){
157
            char c = value.charAt(i);
158
            if(c > 0xFF )return true;
159
        }
160
        return false;
161
    }
162
163
    /**
Line 148 Link Here
148
        field_2_footer = footer;
184
        field_3_footer = footer;
149
--
185
        field_2_unicode_flag = 
186
            (byte) (hasMultibyte(field_3_footer) ? 1 : 0);
Line 172 Link Here
172
        return field_2_footer;
210
        return field_3_footer;
173
--
Line 196 Link Here
234
        short bytelen = (short)(isMultibyte() ?
235
            getFooterLength()*2 : getFooterLength() );
Line 198 Link Here
198
                              ( short ) ((len - 4) + getFooterLength()));
238
                              ( short ) ((len - 4) + bytelen ));
199
--
Line 202 Link Here
202
            StringUtil.putCompressedUnicode(getFooter(), data, 7 + offset); // [Shawn] Place the string in the correct offset
242
            data[ 6 + offset ] = field_2_unicode_flag;
203
--
243
            if(isMultibyte())
244
            {
245
                StringUtil.putUncompressedUnicode(getFooter(), data, 7 + offset);
246
            }
247
            else
248
            {
249
                StringUtil.putCompressedUnicode(getFooter(), data, 7 + offset); // [Shawn] Place the string in the correct offset
250
            }
Line 215 Link Here
215
        return retval + getFooterLength();
263
        return (isMultibyte() ? 
216
--
264
            (retval + getFooterLength()*2) : (retval + getFooterLength()));
Line 226 Link Here
226
      rec.field_2_footer = field_2_footer;
275
      rec.field_2_unicode_flag = field_2_unicode_flag;
227
--
276
      rec.field_3_footer = field_3_footer;

Return to bug 17039