Refactored
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353656 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ba0ccc9a8
commit
150a9d0475
@ -107,21 +107,6 @@ public class FooterRecord
|
||||
return ((field_2_unicode_flag & 0xFF) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* check the parameter has multibyte character
|
||||
*
|
||||
* @param value string to check
|
||||
* @return boolean result
|
||||
* true:string has at least one multibyte character
|
||||
*/
|
||||
private static boolean hasMultibyte(String value){
|
||||
if( value == null )return false;
|
||||
for(int i = 0 ; i < value.length() ; i++ ){
|
||||
char c = value.charAt(i);
|
||||
if(c > 0xFF )return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the length of the footer string
|
||||
@ -146,7 +131,7 @@ public class FooterRecord
|
||||
{
|
||||
field_3_footer = footer;
|
||||
field_2_unicode_flag =
|
||||
(byte) (hasMultibyte(field_3_footer) ? 1 : 0);
|
||||
(byte) (StringUtil.hasMultibyte(field_3_footer) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,22 +107,6 @@ public class HeaderRecord
|
||||
return ((field_2_unicode_flag & 0xFF) == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* check the parameter has multibyte character
|
||||
*
|
||||
* @param value string to check
|
||||
* @return boolean result
|
||||
* true:string has at least one multibyte character
|
||||
*/
|
||||
private static boolean hasMultibyte(String value){
|
||||
if( value == null )return false;
|
||||
for(int i = 0 ; i < value.length() ; i++ ){
|
||||
char c = value.charAt(i);
|
||||
if(c > 0xFF )return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the length of the header string
|
||||
*
|
||||
@ -146,7 +130,7 @@ public class HeaderRecord
|
||||
{
|
||||
field_3_header = header;
|
||||
field_2_unicode_flag =
|
||||
(byte) (hasMultibyte(field_3_header) ? 1 : 0);
|
||||
(byte) (StringUtil.hasMultibyte(field_3_header) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -303,4 +303,32 @@ public class StringUtil {
|
||||
public static String getPreferredEncoding() {
|
||||
return ENCODING;
|
||||
}
|
||||
|
||||
/**
|
||||
* check the parameter has multibyte character
|
||||
*
|
||||
* @param value string to check
|
||||
* @return boolean result
|
||||
* true:string has at least one multibyte character
|
||||
*/
|
||||
public static boolean hasMultibyte(String value){
|
||||
if( value == null )return false;
|
||||
for(int i = 0 ; i < value.length() ; i++ ){
|
||||
char c = value.charAt(i);
|
||||
if(c > 0xFF )return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param format
|
||||
* @return true if format is Unicode.
|
||||
*/
|
||||
public static boolean isUnicodeFormat(final String format) {
|
||||
try {
|
||||
return !format.equals(new String(format.getBytes("ISO-8859-1"), "ISO-8859-1"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user