cvs diff cvs server: Diffing . cvs server: Diffing contrib cvs server: Diffing contrib/lib cvs server: Diffing contrib/src cvs server: Diffing contrib/src/org cvs server: Diffing contrib/src/org/apache cvs server: Diffing contrib/src/org/apache/poi cvs server: Diffing contrib/src/org/apache/poi/contrib cvs server: Diffing contrib/src/org/apache/poi/contrib/poibrowser cvs server: Diffing contrib/src/org/apache/poi/hssf cvs server: Diffing contrib/src/org/apache/poi/hssf/contrib cvs server: Diffing contrib/src/org/apache/poi/hssf/contrib/view cvs server: Diffing contrib/src/org/apache/poi/hssf/usermodel cvs server: Diffing contrib/src/org/apache/poi/hssf/usermodel/contrib cvs server: Diffing contrib/testcases cvs server: Diffing documentation cvs server: Diffing documentation/content cvs server: Diffing documentation/content/xdocs cvs server: Diffing documentation/content/xdocs/getinvolved cvs server: Diffing documentation/content/xdocs/hdf cvs server: Diffing documentation/content/xdocs/hpsf cvs server: Diffing documentation/content/xdocs/hssf cvs server: Diffing documentation/content/xdocs/news cvs server: Diffing documentation/content/xdocs/plan cvs server: Diffing documentation/content/xdocs/poifs cvs server: Diffing documentation/content/xdocs/poifs/html cvs server: Diffing documentation/content/xdocs/references cvs server: Diffing documentation/content/xdocs/resolutions cvs server: Diffing documentation/content/xdocs/trans cvs server: Diffing documentation/content/xdocs/trans/de cvs server: Diffing documentation/content/xdocs/trans/es cvs server: Diffing documentation/content/xdocs/trans/es/hssf cvs server: Diffing documentation/content/xdocs/utils cvs server: Diffing documentation/resources cvs server: Diffing documentation/resources/images cvs server: Diffing documentation/xdocs cvs server: Diffing documentation/xdocs/dtd cvs server: Diffing examples cvs server: Diffing examples/jsp cvs server: Diffing examples/lib cvs server: Diffing examples/src cvs server: Diffing examples/src/org cvs server: Diffing examples/src/org/apache cvs server: Diffing examples/src/org/apache/poi cvs server: Diffing examples/src/org/apache/poi/hpsf cvs server: Diffing examples/src/org/apache/poi/hpsf/examples cvs server: Diffing examples/src/org/apache/poi/hssf cvs server: Diffing examples/src/org/apache/poi/hssf/usermodel cvs server: Diffing examples/src/org/apache/poi/hssf/usermodel/examples cvs server: Diffing java cvs server: Diffing java/org cvs server: Diffing java/org/apache cvs server: Diffing java/org/apache/poi cvs server: Diffing java/org/apache/poi/dev cvs server: Diffing java/org/apache/poi/hpsf cvs server: Diffing java/org/apache/poi/hpsf/wellknown cvs server: Diffing java/org/apache/poi/hssf cvs server: Diffing java/org/apache/poi/hssf/dev cvs server: Diffing java/org/apache/poi/hssf/eventmodel cvs server: Diffing java/org/apache/poi/hssf/eventusermodel cvs server: Diffing java/org/apache/poi/hssf/model cvs server: Diffing java/org/apache/poi/hssf/record Index: java/org/apache/poi/hssf/record/BoundSheetRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java,v retrieving revision 1.8 diff -r1.8 BoundSheetRecord.java 141c141 < field_5_sheetname = StringUtil.getFromUnicodeHigh( data, 8 + offset, nameLength ); --- > field_5_sheetname = StringUtil.getFromUnicodeLE( data, 8 + offset, nameLength ); 303c303 < StringUtil.putUncompressedUnicode( getSheetname(), data, 12 + offset ); --- > StringUtil.putUnicodeLE( getSheetname(), data, 12 + offset ); Index: java/org/apache/poi/hssf/record/FontRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/FontRecord.java,v retrieving revision 1.9 diff -r1.9 FontRecord.java 172c172 < field_11_font_name = StringUtil.getFromUnicodeHigh(data, 16, --- > field_11_font_name = StringUtil.getFromUnicodeLE(data, 16, 582c582 < StringUtil.putUncompressedUnicode(getFontName(), data, 20 + offset); --- > StringUtil.putUnicodeLE(getFontName(), data, 20 + offset); Index: java/org/apache/poi/hssf/record/FormatRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/FormatRecord.java,v retrieving revision 1.9 diff -r1.9 FormatRecord.java 131c131 < field_4_formatstring = StringUtil.getFromUnicodeHigh( data, 5 + offset, field_3_unicode_len ); --- > field_4_formatstring = StringUtil.getFromUnicodeLE( data, 5 + offset, field_3_unicode_len ); 267c267 < StringUtil.putUncompressedUnicode( getFormatString(), data, 9 + offset ); --- > StringUtil.putUnicodeLE( getFormatString(), data, 9 + offset ); Index: java/org/apache/poi/hssf/record/LabelRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/LabelRecord.java,v retrieving revision 1.6 diff -r1.6 LabelRecord.java 155c155 < field_6_value = StringUtil.getFromUnicode(data, 8 + offset, --- > field_6_value = StringUtil.getFromUnicodeBE(data, 8 + offset, Index: java/org/apache/poi/hssf/record/SeriesTextRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java,v retrieving revision 1.5 diff -r1.5 SeriesTextRecord.java 136c136 < field_4_text = StringUtil.getFromUnicodeHigh(data, pos + 0x4 + offset, ((field_2_textLength *2)/2)); --- > field_4_text = StringUtil.getFromUnicodeLE(data, pos + 0x4 + offset, ((field_2_textLength *2)/2)); 175c175 < StringUtil.putUncompressedUnicodeHigh(field_4_text, data, 8 + offset + pos); --- > StringUtil.putUnicodeLE(field_4_text, data, 8 + offset + pos); Index: java/org/apache/poi/hssf/record/StringRecord.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/StringRecord.java,v retrieving revision 1.5 diff -r1.5 StringRecord.java 133c133 < field_3_string = StringUtil.getFromUnicode(data, 3 + offset, field_1_string_length ); --- > field_3_string = StringUtil.getFromUnicodeBE(data, 3 + offset, field_1_string_length ); 185c185 < StringUtil.putUncompressedUnicode(field_3_string, data, 7 + offset); --- > StringUtil.putUnicodeLE(field_3_string, data, 7 + offset); Index: java/org/apache/poi/hssf/record/UnicodeString.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/UnicodeString.java,v retrieving revision 1.10 diff -r1.10 UnicodeString.java 331c331 < StringUtil.putUncompressedUnicode(unicodeString, data, --- > StringUtil.putUnicodeLE(unicodeString, data, 343c343 < StringUtil.putUncompressedUnicode(getString(), data, --- > StringUtil.putUnicodeLE(getString(), data, cvs server: Diffing java/org/apache/poi/hssf/record/aggregates cvs server: Diffing java/org/apache/poi/hssf/record/formula cvs server: Diffing java/org/apache/poi/hssf/usermodel cvs server: Diffing java/org/apache/poi/hssf/util cvs server: Diffing java/org/apache/poi/poifs cvs server: Diffing java/org/apache/poi/poifs/common cvs server: Diffing java/org/apache/poi/poifs/dev cvs server: Diffing java/org/apache/poi/poifs/eventfilesystem cvs server: Diffing java/org/apache/poi/poifs/filesystem cvs server: Diffing java/org/apache/poi/poifs/property cvs server: Diffing java/org/apache/poi/poifs/storage cvs server: Diffing java/org/apache/poi/util Index: java/org/apache/poi/util/StringUtil.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/util/StringUtil.java,v retrieving revision 1.10 diff -r1.10 StringUtil.java 1c1,347 < /* * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and * "Apache POI" must not be used to endorse or promote products * derived from this software without prior written permission. For * written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * "Apache POI", nor may "Apache" appear in their name, without * prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */package org.apache.poi.util;import java.io.UnsupportedEncodingException;import java.text.NumberFormat;import java.text.FieldPosition;/** * Title: String Utility Description: Collection of string handling utilities * * Now it is quite confusing: the method pairs, in which * one of them write data and other read written data are: * putUncompressedUnicodeHigh and getFromUnicode * putUncompressedUnicode and getFromUnicodeHigh * *@author Andrew C. Oliver *@author Sergei Kozello (sergeikozello at mail.ru) *@created May 10, 2002 *@version 1.0 */public class StringUtil { private final static String ENCODING="ISO-8859-1"; /** * Constructor for the StringUtil object */ private StringUtil() { } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x16, 0x00 } -> 0x16 * *@param string the byte array to be converted *@param offset the initial offset into the * byte array. it is assumed that string[ offset ] and string[ offset + * 1 ] contain the first 16-bit unicode character *@param len *@return the converted string *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for * the byte array (i.e., is negative or is greater than or equal to * string.length) *@exception IllegalArgumentEx ception if len is too large (i.e., * there is not enough data in string to create a String of that * length) *@len the length of the final string */ public static String getFromUnicodeHigh(final byte[] string, final int offset, final int len) throws ArrayIndexOutOfBoundsException, IllegalArgumentException { if ((offset < 0) || (offset >= string.length)) { throw new ArrayIndexOutOfBoundsException("Illegal offset"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { throw new IllegalArgumentException("Illegal length"); } char[] chars = new char[ len ]; for ( int i = 0; i < chars.length; i++ ) { chars[i] = (char)( string[ offset + ( 2*i ) ] & 0xFF | ( string[ offset + ( 2*i+1 ) ] << 8 ) ); } return new String( chars ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x16, 0x00 } -> 0x16 * *@param string the byte array to be converted *@return the converted string */ public static String getFromUnicodeHigh( final byte[] string ) { return getFromUnicodeHigh( string, 0, string.length / 2 ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x00, 0x16 } -> 0x16 * *@param string the byte array to be converted *@param offset the initial offset into the * byte array. it is assumed that string[ offset ] and string[ offset + * 1 ] contain the first 16-bit unicode character *@param len *@return the converted string *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for * the byte array (i.e., is negative or is greater than or equal to * string.length) *@exception IllegalArgumentException if len is too large (i.e., * there is not enough data in string to create a String of that * length) *@len the length of the final string */ public static String getFromUnicode(final byte[] string, final int offset, final int len) throws ArrayIndexOutOfBoundsException, IllegalArgumentException { if ((offset < 0) || (offset >= string.length)) { throw new ArrayIndexOutOfBoundsException("Illegal offset"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { throw new IllegalArgumentException("Illegal length"); } char[] chars = new char[ len ]; for ( int i = 0; i < chars.length; i++ ) { chars[i] = (char)( ( string[ offset + ( 2*i ) ] << 8 ) + string[ offset + ( 2*i+1 ) ] ); } return new String( chars ); } /** * given a byte array of 16-bit unicode characters, compress to 8-bit and * return a string * * { 0x00, 0x16 } -> 0x16 * *@param string the byte array to be converted *@return the converted string */ public static String getFromUnicode(final byte[] string) { return getFromUnicode(string, 0, string.length / 2); } /** * read compressed unicode(8bit) * * @author Toshiaki Kamoshida(kamoshida.toshiaki at future dot co dot jp) * * @param string byte array to read * @param offset offset to read byte array * @param len length to read byte array * @return String generated String instance by reading byte array */ public static String getFromCompressedUnicode(final byte[] string, final int offset, final int len){ try{ return new String(string,offset,len,"ISO-8859-1"); } catch(UnsupportedEncodingException e){ throw new InternalError();/* unr eachable */ } } /** * write compressed unicode * *@param input the String containing the data to be written *@param output the byte array to which the data is to be written *@param offset an offset into the byte arrat at which the data is start * when written */ public static void putCompressedUnicode(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { output[offset + k] = (byte) input.charAt(k); } } /** * Write uncompressed unicode * *@param input the String containing the unicode data to be written *@param output the byte array to hold the uncompressed unicode *@param offset the offset to start writing into the byte array */ public static void putUncompressedUnicode(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { char c = input.charAt(k); output[offset + (2 * k)] = (byte) c; output[offset + (2 * k) + 1] = (byte) (c >> 8); } } /** * Write uncompressed unicode * *@param input the String containing the unicode data to be written *@param output the byte array to hold the uncompressed unicode *@param offset the offset to start writing into the byte array */ public static void putUncompressedUnicodeHigh(final String input, final byte[] output, final int offset) { int strlen = input.length(); for (int k = 0; k < strlen; k++) { char c = input.charAt(k); output[offset + (2 * k)] = (byte) (c >> 8); output[offset + (2 * k)] = (byte) c; } } /** * Description of the Method * *@param message Description of the Parameter *@param params Description of the Parameter *@return Description o f the Return Value */ public static String format(String message, Object[] params) { int currentParamNumber = 0; StringBuffer formattedMessage = new StringBuffer(); for (int i = 0; i < message.length(); i++) { if (message.charAt(i) == '%') { if (currentParamNumber >= params.length) { formattedMessage.append("?missing data?"); } else if ((params[currentParamNumber] instanceof Number) && (i + 1 < message.length())) { i += matchOptionalFormatting( (Number) params[currentParamNumber++], message.substring(i + 1), formattedMessage); } else { formattedMessage.append(params[currentParamNumber++].toString()); } } else { if ((message.charAt(i) == '\\') && (i + 1 < message.length()) && (message.charAt(i + 1) == '%')) { forma ttedMessage.append('%'); i++; } else { formattedMessage.append(message.charAt(i)); } } } return formattedMessage.toString(); } /** * Description of the Method * *@param number Description of the Parameter *@param formatting Description of the Parameter *@param outputTo Description of the Parameter *@return Description of the Return Value */ private static int matchOptionalFormatting(Number number, String formatting, StringBuffer outputTo) { NumberFormat numberFormat = NumberFormat.getInstance(); if ((0 < formatting.length()) && Character.isDigit(formatting.charAt(0))) { numberFormat.setMinimumIntegerDigits(Integer.parseInt(formatting.charAt(0) + "")); if ((2 < formatting.length()) && (formatting.charAt(1) == '.') && Character.isDigit(formatting.charAt(2))) { numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(2) + "")); numberFormat.format(number, outputTo, new FieldPosition(0)); return 3; } numberFormat.format(number, outputTo, new FieldPosition(0)); return 1; } else if ((0 < formatting.length()) && (formatting.charAt(0) == '.')) { if ((1 < formatting.length()) && Character.isDigit(formatting.charAt(1))) { numberFormat.setMaximumFractionDigits(Integer.parseInt(formatting.charAt(1) + "")); numberFormat.format(number, outputTo, new FieldPosition(0)); return 2; } } numberFormat.format(number, outputTo, new FieldPosition(0)); return 1; } /** * @return the encoding we want to use (ISO-8859-1) */ public static String getPreferredEncoding() { return ENCODING; }} \ No newline at end of file --- > > /* > * ==================================================================== > * The Apache Software License, Version 1.1 > * > * Copyright (c) 2003 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in > * the documentation and/or other materials provided with the > * distribution. > * > * 3. The end-user documentation included with the redistribution, > * if any, must include the following acknowledgment: > * "This product includes software developed by the > * Apache Software Foundation (http://www.apache.org/)." > * Alternately, this acknowledgment may appear in the software itself, > * if and wherever such third-party acknowledgments normally appear. > * > * 4. The names "Apache" and "Apache Software Foundation" and > * "Apache POI" must not be used to endorse or promote products > * derived from this software without prior written permission. For > * written permission, please contact apache@apache.org. > * > * 5. Products derived from this software may not be called "Apache", > * "Apache POI", nor may "Apache" appear in their name, without > * prior written permission of the Apache Software Foundation. > * > * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED > * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR > * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT > * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * ==================================================================== > * > * This software consists of voluntary contributions made by many > * individuals on behalf of the Apache Software Foundation. For more > * information on the Apache Software Foundation, please see > * . > */ > package org.apache.poi.util; > > import java.io.UnsupportedEncodingException; > import java.text.NumberFormat; > import java.text.FieldPosition; > import java.util.Arrays; > /** > * Title: String Utility Description: Collection of string handling utilities > * > * > *@author Andrew C. Oliver > *@author Sergei Kozello (sergeikozello at mail.ru) > *@author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp) > *@created May 10, 2002 > *@version 1.0 > */ > public class StringUtil { > private final static String ENCODING = "ISO-8859-1"; > /** > * Constructor for the StringUtil object > */ > private StringUtil() { > } > > /** > * given a byte array of 16-bit unicode characters, compress to 8-bit and > * return a string > * > * { 0x16, 0x00 } -> 0x16 > * > *@param string the byte array to be converted > *@param offset the initial offset into the > * byte array. it is assumed that string[ offset ] and string[ offset + > * 1 ] contain the first 16-bit unicode character > *@param len > *@return the converted string > *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for > * the byte array (i.e., is negative or is greater than or equal to > * string.length) > *@exception IllegalArgumentException if len is too large (i.e., > * there is not enough data in string to create a String of that > * length) > *@len the length of the final string > */ > public static String getFromUnicodeLE( > final byte[] string, > final int offset, > final int len) > throws ArrayIndexOutOfBoundsException, IllegalArgumentException { > if ((offset < 0) || (offset >= string.length)) { > throw new ArrayIndexOutOfBoundsException("Illegal offset"); > } > if ((len < 0) || (((string.length - offset) / 2) < len)) { > throw new IllegalArgumentException("Illegal length"); > } > > try { > return new String(string, offset, len * 2, "UTF-16LE"); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /*unreachable*/ > } > } > > /** > * given a byte array of 16-bit unicode characters, compress to 8-bit and > * return a string > * > * { 0x16, 0x00 } -> 0x16 > * > *@param string the byte array to be converted > *@return the converted string > */ > public static String getFromUnicodeLE(final byte[] string) { > return getFromUnicodeLE(string, 0, string.length / 2); > } > > /** > * given a byte array of 16-bit unicode characters, compress to 8-bit and > * return a string > * > * { 0x00, 0x16 } -> 0x16 > * > *@param string the byte array to be converted > **@param offset the initial offset into the > * byte array. it is assumed that string[ offset ] and string[ offset + > * 1 ] contain the first 16-bit unicode character > *@param len > *@return the converted string > *@exception ArrayIndexOutOfBoundsException if offset is out of bounds for > * the byte array (i.e., is negative or is greater than or equal to > * string.length) > *@exception IllegalArgumentException if len is too large (i.e., > * there is not enough data in string to create a String of that > * length) > *@len the length of the final string > */ > public static String getFromUnicodeBE( > final byte[] string, > final int offset, > final int len) > throws ArrayIndexOutOfBoundsException, IllegalArgumentException { > if ((offset < 0) || (offset >= string.length)) { > throw new ArrayIndexOutOfBoundsException("Illegal offset"); > } > if ((len < 0) || (((string.length - offset) / 2) < len)) { > throw new IllegalArgumentException("Illegal length"); > } > try { > return new String(string, offset, len * 2, "UTF-16BE"); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /*unreachable*/ > } > } > > /** > * given a byte array of 16-bit unicode characters, compress to 8-bit and > * return a string > * > * { 0x00, 0x16 } -> 0x16 > * > *@param string the byte array to be converted > *@return the converted string > */ > public static String getFromUnicodeBE(final byte[] string) { > return getFromUnicodeBE(string, 0, string.length / 2); > } > > /** > * read compressed unicode(8bit) > * > * @param string byte array to read > * @param offset offset to read byte array > * @param len length to read byte array > * @return String generated String instance by reading byte array > */ > public static String getFromCompressedUnicode( > final byte[] string, > final int offset, > final int len) { > try { > return new String(string, offset, len, "ISO-8859-1"); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /* unreachable */ > } > } > > /** > * write compressed unicode > * > *@param input the String containing the data to be written > *@param output the byte array to which the data is to be written > *@param offset an offset into the byte arrat at which the data is start > * when written > */ > public static void putCompressedUnicode( > final String input, > final byte[] output, > final int offset) { > try { > byte[] bytes = input.getBytes("ISO-8859-1"); > System.arraycopy(bytes, 0, output, offset, bytes.length); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /*unreachable*/ > } > } > > /** > * Write uncompressed unicode > * > *@param input the String containing the unicode data to be written > *@param output the byte array to hold the uncompressed unicode > *@param offset the offset to start writing into the byte array > */ > public static void putUnicodeLE( > final String input, > final byte[] output, > final int offset) { > try { > byte[] bytes = input.getBytes("UTF-16LE"); > System.arraycopy(bytes, 0, output, offset, bytes.length); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /*unreachable*/ > } > } > > /** > * Write uncompressed unicode > * > *@param input the String containing the unicode data to be written > *@param output the byte array to hold the uncompressed unicode > *@param offset the offset to start writing into the byte array > */ > public static void putUnicodeBE( > final String input, > final byte[] output, > final int offset) { > try { > byte[] bytes = input.getBytes("UTF-16BE"); > System.arraycopy(bytes, 0, output, offset, bytes.length); > } catch (UnsupportedEncodingException e) { > throw new InternalError(); /*unreachable*/ > } > } > > /** > * Description of the Method > * > *@param message Description of the Parameter > *@param params Description of the Parameter > *@return Description of the Return Value > */ > public static String format(String message, Object[] params) { > int currentParamNumber = 0; > StringBuffer formattedMessage = new StringBuffer(); > for (int i = 0; i < message.length(); i++) { > if (message.charAt(i) == '%') { > if (currentParamNumber >= params.length) { > formattedMessage.append("?missing data?"); > } else if ( > (params[currentParamNumber] instanceof Number) > && (i + 1 < message.length())) { > i > += matchOptionalFormatting( > (Number) params[currentParamNumber++], > message.substring(i + 1), > formattedMessage); > } else { > formattedMessage.append( > params[currentParamNumber++].toString()); > } > } else { > if ((message.charAt(i) == '\\') > && (i + 1 < message.length()) > && (message.charAt(i + 1) == '%')) { > formattedMessage.append('%'); > i++; > } else { > formattedMessage.append(message.charAt(i)); > } > } > } > return formattedMessage.toString(); > } > > /** > * Description of the Method > * > *@param number Description of the Parameter > *@param formatting Description of the Parameter > *@param outputTo Description of the Parameter > *@return Description of the Return Value > */ > private static int matchOptionalFormatting( > Number number, > String formatting, > StringBuffer outputTo) { > NumberFormat numberFormat = NumberFormat.getInstance(); > if ((0 < formatting.length()) > && Character.isDigit(formatting.charAt(0))) { > numberFormat.setMinimumIntegerDigits( > Integer.parseInt(formatting.charAt(0) + "")); > if ((2 < formatting.length()) > && (formatting.charAt(1) == '.') > && Character.isDigit(formatting.charAt(2))) { > numberFormat.setMaximumFractionDigits( > Integer.parseInt(formatting.charAt(2) + "")); > numberFormat.format(number, outputTo, new FieldPosition(0)); > return 3; > } > numberFormat.format(number, outputTo, new FieldPosition(0)); > return 1; > } else if ( > (0 < formatting.length()) && (formatting.charAt(0) == '.')) { > if ((1 < formatting.length()) > && Character.isDigit(formatting.charAt(1))) { > numberFormat.setMaximumFractionDigits( > Integer.parseInt(formatting.charAt(1) + "")); > numberFormat.format(number, outputTo, new FieldPosition(0)); > return 2; > } > } > numberFormat.format(number, outputTo, new FieldPosition(0)); > return 1; > } > > /** > * @return the encoding we want to use (ISO-8859-1) > */ > public static String getPreferredEncoding() { > return ENCODING; > } > } \ No newline at end of file cvs server: Diffing models cvs server: Diffing records cvs server: Diffing records/definitions cvs server: Diffing records/styles cvs server: Diffing resources cvs server: Diffing resources/devtools cvs server: Diffing resources/logos cvs server: Diffing scratchpad cvs server: Diffing scratchpad/lib cvs server: Diffing scratchpad/src cvs server: Diffing scratchpad/src/org cvs server: Diffing scratchpad/src/org/apache cvs server: Diffing scratchpad/src/org/apache/poi cvs server: Diffing scratchpad/src/org/apache/poi/generator cvs server: Diffing scratchpad/src/org/apache/poi/hdf cvs server: Diffing scratchpad/src/org/apache/poi/hdf/event cvs server: Diffing scratchpad/src/org/apache/poi/hdf/extractor cvs server: Diffing scratchpad/src/org/apache/poi/hdf/extractor/data cvs server: Diffing scratchpad/src/org/apache/poi/hdf/extractor/util cvs server: Diffing scratchpad/src/org/apache/poi/hdf/generator cvs server: Diffing scratchpad/src/org/apache/poi/hdf/model cvs server: Diffing scratchpad/src/org/apache/poi/hdf/model/hdftypes cvs server: Diffing scratchpad/src/org/apache/poi/hdf/model/hdftypes/definitions cvs server: Diffing scratchpad/src/org/apache/poi/hdf/model/util cvs server: Diffing scratchpad/src/org/apache/poi/hssf cvs server: Diffing scratchpad/src/org/apache/poi/hssf/usermodel cvs server: Diffing scratchpad/testcases cvs server: Diffing scratchpad/testcases/org cvs server: Diffing scratchpad/testcases/org/apache cvs server: Diffing scratchpad/testcases/org/apache/poi cvs server: Diffing scratchpad/testcases/org/apache/poi/hdf cvs server: Diffing scratchpad/testcases/org/apache/poi/hdf/data cvs server: Diffing scratchpad/testcases/org/apache/poi/hdf/model cvs server: Diffing testcases cvs server: Diffing testcases/org cvs server: Diffing testcases/org/apache cvs server: Diffing testcases/org/apache/poi cvs server: Diffing testcases/org/apache/poi/hpsf cvs server: Diffing testcases/org/apache/poi/hpsf/basic cvs server: Diffing testcases/org/apache/poi/hpsf/data cvs server: Diffing testcases/org/apache/poi/hssf cvs server: Diffing testcases/org/apache/poi/hssf/data cvs server: Diffing testcases/org/apache/poi/hssf/eventmodel cvs server: Diffing testcases/org/apache/poi/hssf/model cvs server: Diffing testcases/org/apache/poi/hssf/record cvs server: Diffing testcases/org/apache/poi/hssf/record/aggregates cvs server: Diffing testcases/org/apache/poi/hssf/record/formula cvs server: Diffing testcases/org/apache/poi/hssf/usermodel cvs server: Diffing testcases/org/apache/poi/hssf/util cvs server: Diffing testcases/org/apache/poi/poifs cvs server: Diffing testcases/org/apache/poi/poifs/eventfilesystem cvs server: Diffing testcases/org/apache/poi/poifs/filesystem cvs server: Diffing testcases/org/apache/poi/poifs/property cvs server: Diffing testcases/org/apache/poi/poifs/storage cvs server: Diffing testcases/org/apache/poi/util Index: testcases/org/apache/poi/util/TestStringUtil.java =================================================================== RCS file: /home/cvspublic/jakarta-poi/src/testcases/org/apache/poi/util/TestStringUtil.java,v retrieving revision 1.8 diff -r1.8 TestStringUtil.java 95c95 < StringUtil.getFromUnicode( test_data ) ); --- > StringUtil.getFromUnicodeBE( test_data ) ); 115c115 < StringUtil.getFromUnicode( test_data ) ); --- > StringUtil.getFromUnicodeBE( test_data ) ); 136c136 < StringUtil.getFromUnicodeHigh( test_data ) ); --- > StringUtil.getFromUnicodeLE( test_data ) ); 152c152 < StringUtil.getFromUnicode( test_data, 0, 15 ) ); --- > StringUtil.getFromUnicodeBE( test_data, 0, 15 ) ); 154c154 < StringUtil.getFromUnicode( test_data, 2, 15 ) ); --- > StringUtil.getFromUnicodeBE( test_data, 2, 15 ) ); 157c157 < StringUtil.getFromUnicode( test_data, -1, 16 ); --- > StringUtil.getFromUnicodeBE( test_data, -1, 16 ); 167c167 < StringUtil.getFromUnicode( test_data, 32, 16 ); --- > StringUtil.getFromUnicodeBE( test_data, 32, 16 ); 177c177 < StringUtil.getFromUnicode( test_data, 1, 16 ); --- > StringUtil.getFromUnicodeBE( test_data, 1, 16 ); 187c187 < StringUtil.getFromUnicode( test_data, 1, -1 ); --- > StringUtil.getFromUnicodeBE( test_data, 1, -1 ); 251c251 < StringUtil.putUncompressedUnicode( input, output, 0 ); --- > StringUtil.putUnicodeLE( input, output, 0 ); 257c257 < StringUtil.putUncompressedUnicode( input, output, --- > StringUtil.putUnicodeLE( input, output, 266c266 < StringUtil.putUncompressedUnicode( input, output, --- > StringUtil.putUnicodeLE( input, output, cvs server: Diffing testcases/org/apache/poi/util/data cvs server: Diffing types cvs server: Diffing types/definitions cvs server: Diffing types/styles *****CVS exited normally with code 1*****