Opps. Looks like somewhere along the line a 1.4 dependancy was introduced. Committers: please compile with 1.3 before committing.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352918 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-11-14 23:25:20 +00:00
parent c8a456b706
commit c56f037aa4

View File

@ -1,4 +1,3 @@
/* ==================================================================== /* ====================================================================
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
@ -56,7 +55,6 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@ -85,8 +83,8 @@ public class UnicodeString
public UnicodeString() public UnicodeString()
{ {
}
}
public int hashCode() public int hashCode()
{ {
@ -96,6 +94,7 @@ public class UnicodeString
return field_1_charCount + stringHash; return field_1_charCount + stringHash;
} }
/** /**
* Our handling of equals is inconsistent with compareTo. The trouble is because we don't truely understand * Our handling of equals is inconsistent with compareTo. The trouble is because we don't truely understand
* rich text fields yet it's difficult to make a sound comparison. * rich text fields yet it's difficult to make a sound comparison.
@ -122,7 +121,6 @@ public class UnicodeString
* @param size - size of the data * @param size - size of the data
* @param data - the bytes of the string/fields * @param data - the bytes of the string/fields
*/ */
public UnicodeString(short id, short size, byte [] data) public UnicodeString(short id, short size, byte [] data)
{ {
super(id, size, data); super(id, size, data);
@ -131,7 +129,6 @@ public class UnicodeString
/** /**
* construct a unicode string from a string fragment + data * construct a unicode string from a string fragment + data
*/ */
public UnicodeString(short id, short size, byte [] data, String prefix) public UnicodeString(short id, short size, byte [] data, String prefix)
{ {
this(id, size, data); this(id, size, data);
@ -142,10 +139,8 @@ public class UnicodeString
/** /**
* NO OP * NO OP
*/ */
protected void validateSid(short id) protected void validateSid(short id)
{ {
// included only for interface compliance // included only for interface compliance
} }
@ -159,7 +154,10 @@ public class UnicodeString
field_3_string = new String(data, 3, getCharCount(), field_3_string = new String(data, 3, getCharCount(),
StringUtil.getPreferredEncoding()); StringUtil.getPreferredEncoding());
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); //commented out by glen. this is a 1.4 construct and we
//are supposed to compile on 1.3.
//throw new RuntimeException(e);
throw new RuntimeException(e.toString());
} }
} }
else else
@ -178,11 +176,9 @@ public class UnicodeString
/** /**
* get the number of characters in the string * get the number of characters in the string
* *
*
* @return number of characters * @return number of characters
* *
*/ */
public short getCharCount() public short getCharCount()
{ {
return field_1_charCount; return field_1_charCount;
@ -192,7 +188,6 @@ public class UnicodeString
* set the number of characters in the string * set the number of characters in the string
* @param cc - number of characters * @param cc - number of characters
*/ */
public void setCharCount(short cc) public void setCharCount(short cc)
{ {
field_1_charCount = cc; field_1_charCount = cc;
@ -204,7 +199,6 @@ public class UnicodeString
* @see #setString(String) * @see #setString(String)
* @see #getString() * @see #getString()
*/ */
public void setCharCount() public void setCharCount()
{ {
field_1_charCount = ( short ) field_3_string.length(); field_1_charCount = ( short ) field_3_string.length();
@ -217,7 +211,6 @@ public class UnicodeString
* @return optionflags bitmask * @return optionflags bitmask
* *
*/ */
public byte getOptionFlags() public byte getOptionFlags()
{ {
return field_2_optionflags; return field_2_optionflags;
@ -230,7 +223,6 @@ public class UnicodeString
* @param of optionflags bitmask * @param of optionflags bitmask
* *
*/ */
public void setOptionFlags(byte of) public void setOptionFlags(byte of)
{ {
field_2_optionflags = of; field_2_optionflags = of;
@ -243,7 +235,6 @@ public class UnicodeString
* @return String * @return String
* *
*/ */
public String getString() public String getString()
{ {
return field_3_string; return field_3_string;
@ -253,7 +244,6 @@ public class UnicodeString
* set the actual string this contains * set the actual string this contains
* @param string the text * @param string the text
*/ */
public void setString(String string) public void setString(String string)
{ {
field_3_string = string; field_3_string = string;
@ -268,7 +258,6 @@ public class UnicodeString
* @see #getDebugInfo() * @see #getDebugInfo()
* @return String value of the record * @return String value of the record
*/ */
public String toString() public String toString()
{ {
return getString(); return getString();
@ -281,7 +270,6 @@ public class UnicodeString
* @return String of output for biffviewer etc. * @return String of output for biffviewer etc.
* *
*/ */
public String getDebugInfo() public String getDebugInfo()
{ {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -294,6 +282,7 @@ public class UnicodeString
buffer.append(" .string = ").append(getString()) buffer.append(" .string = ").append(getString())
.append("\n"); .append("\n");
buffer.append("[/UNICODESTRING]\n"); buffer.append("[/UNICODESTRING]\n");
return buffer.toString(); return buffer.toString();
} }
@ -309,15 +298,12 @@ public class UnicodeString
// byte[] retval = new byte[ 3 + (getString().length() * charsize)]; // byte[] retval = new byte[ 3 + (getString().length() * charsize)];
LittleEndian.putShort(data, 0 + offset, getCharCount()); LittleEndian.putShort(data, 0 + offset, getCharCount());
data[ 2 + offset ] = getOptionFlags(); data[ 2 + offset ] = getOptionFlags();
// System.out.println("Unicode: We've got "+retval[2]+" for our option flag"); // System.out.println("Unicode: We've got "+retval[2]+" for our option flag");
try { try {
String unicodeString = new String unicodeString = new String(getString().getBytes("Unicode"),"Unicode");
String(getString().getBytes("Unicode"),"Unicode");
if (getOptionFlags() == 0) if (getOptionFlags() == 0)
{ {
StringUtil.putCompressedUnicode(unicodeString, data, 0x3 + StringUtil.putCompressedUnicode(unicodeString, data, 0x3 + offset);
offset);
} }
else else
{ {
@ -337,7 +323,9 @@ offset);
0x3 + offset); 0x3 + offset);
} }
} }
return getRecordSize(); return getRecordSize();
} }
private boolean isUncompressedUnicode() private boolean isUncompressedUnicode()
@ -364,9 +352,9 @@ offset);
* @param size size of data * @param size size of data
* @param offset of the records data (provided a big array of the file) * @param offset of the records data (provided a big array of the file)
*/ */
protected void fillFields(byte [] data, short size, int offset) protected void fillFields(byte [] data, short size, int offset)
{ {
} }
public int compareTo(Object obj) public int compareTo(Object obj)
@ -404,3 +392,4 @@ offset);
} }
} }