You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by av...@apache.org on 2005/04/28 16:03:28 UTC
cvs commit: jakarta-poi/src/java/org/apache/poi/util StringUtil.java
avik 2005/04/28 07:03:28
Modified: src/java/org/apache/poi/hssf/record FooterRecord.java
HeaderRecord.java
src/java/org/apache/poi/util StringUtil.java
Log:
Refactored
Revision Changes Path
1.14 +1 -16 jakarta-poi/src/java/org/apache/poi/hssf/record/FooterRecord.java
Index: FooterRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/FooterRecord.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FooterRecord.java 28 Apr 2005 13:35:38 -0000 1.13
+++ FooterRecord.java 28 Apr 2005 14:03:28 -0000 1.14
@@ -107,21 +107,6 @@
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 @@
{
field_3_footer = footer;
field_2_unicode_flag =
- (byte) (hasMultibyte(field_3_footer) ? 1 : 0);
+ (byte) (StringUtil.hasMultibyte(field_3_footer) ? 1 : 0);
}
/**
1.14 +1 -17 jakarta-poi/src/java/org/apache/poi/hssf/record/HeaderRecord.java
Index: HeaderRecord.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/HeaderRecord.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- HeaderRecord.java 28 Apr 2005 13:35:38 -0000 1.13
+++ HeaderRecord.java 28 Apr 2005 14:03:28 -0000 1.14
@@ -108,22 +108,6 @@
}
/**
- * 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
*
* @param len length of the header string
@@ -146,7 +130,7 @@
{
field_3_header = header;
field_2_unicode_flag =
- (byte) (hasMultibyte(field_3_header) ? 1 : 0);
+ (byte) (StringUtil.hasMultibyte(field_3_header) ? 1 : 0);
}
/**
1.18 +28 -0 jakarta-poi/src/java/org/apache/poi/util/StringUtil.java
Index: StringUtil.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/util/StringUtil.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- StringUtil.java 23 Aug 2004 08:52:45 -0000 1.17
+++ StringUtil.java 28 Apr 2005 14:03:28 -0000 1.18
@@ -303,4 +303,32 @@
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;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/