📄 sstrecord.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: SSTRecord.java
package jxl.write.biff;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.biff.*;
class SSTRecord extends WritableRecordData
{
private int numReferences;
private int numStrings;
private ArrayList strings;
private ArrayList stringLengths;
private byte data[];
private int byteCount;
private static int maxBytes = 8216;
public SSTRecord(int numRefs, int s)
{
super(Type.SST);
numReferences = numRefs;
numStrings = s;
byteCount = 0;
strings = new ArrayList(50);
stringLengths = new ArrayList(50);
}
public int add(String s)
{
int bytes = s.length() * 2 + 3;
if(byteCount >= maxBytes - 5)
return s.length() <= 0 ? -1 : 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 int getOffset()
{
return byteCount + 8;
}
public byte[] getData()
{
data = new byte[byteCount + 8];
IntegerHelper.getFourBytes(numReferences, data, 0);
IntegerHelper.getFourBytes(numStrings, data, 4);
int pos = 8;
int count = 0;
Iterator i = strings.iterator();
String s = null;
int length = 0;
while(i.hasNext())
{
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;
count++;
}
return data;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -