📄 sstcontinuerecord.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: SSTContinueRecord.java
package jxl.write.biff;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.biff.*;
class SSTContinueRecord extends WritableRecordData
{
private String firstString;
private boolean includeLength;
private int firstStringLength;
private ArrayList strings;
private ArrayList stringLengths;
private byte data[];
private int byteCount;
private static int maxBytes = 8224;
public SSTContinueRecord()
{
super(Type.CONTINUE);
byteCount = 0;
strings = new ArrayList(50);
stringLengths = new ArrayList(50);
}
public int setFirstString(String s, boolean b)
{
includeLength = b;
firstStringLength = s.length();
int bytes = 0;
if(!includeLength)
bytes = s.length() * 2 + 1;
else
bytes = s.length() * 2 + 3;
if(bytes <= maxBytes)
{
firstString = s;
byteCount += bytes;
return 0;
} else
{
int charsAvailable = includeLength ? (maxBytes - 4) / 2 : (maxBytes - 2) / 2;
firstString = s.substring(0, charsAvailable);
byteCount = maxBytes - 1;
return s.length() - charsAvailable;
}
}
public int getOffset()
{
return byteCount;
}
public int add(String s)
{
int bytes = s.length() * 2 + 3;
if(byteCount >= maxBytes - 5)
return s.length();
stringLengths.add(new Integer(s.length()));
if(bytes + byteCount < maxBytes)
{
strings.add(s);
byteCount += bytes;
return 0;
} else
{
int bytesLeft = maxBytes - 3 - byteCount;
int charsAvailable = bytesLeft % 2 != 0 ? (bytesLeft - 1) / 2 : bytesLeft / 2;
strings.add(s.substring(0, charsAvailable));
byteCount += charsAvailable * 2 + 3;
return s.length() - charsAvailable;
}
}
public byte[] getData()
{
data = new byte[byteCount];
int pos = 0;
if(includeLength)
{
IntegerHelper.getTwoBytes(firstStringLength, data, 0);
data[2] = 1;
pos = 3;
} else
{
data[0] = 1;
pos = 1;
}
StringHelper.getUnicodeBytes(firstString, data, pos);
pos += firstString.length() * 2;
Iterator i = strings.iterator();
String s = null;
int length = 0;
for(int count = 0; i.hasNext(); count++)
{
s = (String)i.next();
length = ((Integer)stringLengths.get(count)).intValue();
IntegerHelper.getTwoBytes(length, data, pos);
data[pos + 2] = 1;
StringHelper.getUnicodeBytes(s, data, pos + 3);
pos += s.length() * 2 + 3;
}
return data;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -