refactored

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353665 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Avik Sengupta 2005-05-02 05:26:13 +00:00
parent bac3426bd4
commit ee35b34b52
3 changed files with 9 additions and 9 deletions

View File

@ -1996,7 +1996,6 @@ public class Workbook implements Model
maxformatid = maxformatid >= (short) 0xa4 ? (short) ( maxformatid + 1 ) : (short) 0xa4; //Starting value from M$ empiracle study.
rec.setIndexCode( maxformatid );
rec.setFormatStringLength( (byte) format.length() );
rec.setUnicodeFlag(StringUtil.isUnicodeFormat(format));
rec.setFormatString( format );
int pos = 0;

View File

@ -36,7 +36,7 @@ public class FormatRecord
{
public final static short sid = 0x41e;
private short field_1_index_code;
private short field_2_formatstring_len;
private short field_3_unicode_len; // unicode string length
private boolean field_3_unicode_flag; // it is not undocumented - it is unicode flag
private String field_4_formatstring;
@ -85,7 +85,7 @@ public class FormatRecord
field_1_index_code = LittleEndian.getShort(data, 0 + offset);
// field_2_formatstring_len = data[ 2 + offset ];
field_3_unicode_len = LittleEndian.getShort( data, 2 + offset );
field_2_formatstring_len = field_3_unicode_len;
field_3_unicode_flag = ( data[ 4 + offset ] & (byte)0x01 ) != 0;
@ -120,7 +120,7 @@ public class FormatRecord
public void setFormatStringLength(byte len)
{
field_2_formatstring_len = len;
field_3_unicode_len = len;
}
@ -144,6 +144,7 @@ public class FormatRecord
public void setFormatString(String fs)
{
field_4_formatstring = fs;
setUnicodeFlag(StringUtil.isUnicodeString(fs));
}
/**
@ -165,10 +166,10 @@ public class FormatRecord
* @see #getFormatString()
*/
public short getFormatStringLength()
/* public short getFormatStringLength()
{
return field_3_unicode_flag ? field_3_unicode_len : field_2_formatstring_len;
}
}*/
/**
* get whether the string is unicode

View File

@ -322,11 +322,11 @@ public class StringUtil {
/**
* @param format
* @return true if format is Unicode.
* @return true if string needs Unicode to be represented.
*/
public static boolean isUnicodeFormat(final String format) {
public static boolean isUnicodeString(final String value) {
try {
return !format.equals(new String(format.getBytes("ISO-8859-1"), "ISO-8859-1"));
return !value.equals(new String(value.getBytes("ISO-8859-1"), "ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
return true;
}