Methods Summary |
---|
public void | addSubRecord(int index, java.lang.Object element)
subrecords.add( index, element );
|
public boolean | addSubRecord(java.lang.Object o)
return subrecords.add( o );
|
public void | clearSubRecords()
subrecords.clear();
|
public java.lang.Object | clone()
ObjRecord rec = new ObjRecord();
for ( Iterator iterator = subrecords.iterator(); iterator.hasNext(); )
rec.addSubRecord(( (Record) iterator.next() ).clone());
return rec;
|
protected void | fillFields(org.apache.poi.hssf.record.RecordInputStream in)
subrecords = new ArrayList();
//Check if this can be continued, if so then the
//following wont work properly
int subSize = 0;
byte[] subRecordData = in.readRemainder();
RecordInputStream subRecStream = new RecordInputStream(new ByteArrayInputStream(subRecordData));
while(subRecStream.hasNextRecord()) {
subRecStream.nextRecord();
Record subRecord = SubRecord.createSubRecord(subRecStream);
subSize += subRecord.getRecordSize();
subrecords.add(subRecord);
}
/**
* Check if the RecordInputStream skipped EndSubRecord,
* if it did then append it explicitly.
* See Bug 41242 for details.
*/
if (subRecordData.length - subSize == 4){
subrecords.add(new EndSubRecord());
}
/* JMH the size present/not present in the code below
needs to be considered in the RecordInputStream??
int pos = offset;
while (pos - offset <= size-2) // atleast one "short" must be present
{
short subRecordSid = LittleEndian.getShort(data, pos);
short subRecordSize = -1; // set default to "< 0"
if (pos-offset <= size-4) { // see if size info is present, else default to -1
subRecordSize = LittleEndian.getShort(data, pos + 2);
}
Record subRecord = SubRecord.createSubRecord(subRecordSid, subRecordSize, data, pos + 4);
subrecords.add(subRecord);
pos += subRecord.getRecordSize();
}*/
|
public int | getRecordSize()Size of record (excluding 4 byte header)
int size = 0;
for ( Iterator iterator = subrecords.iterator(); iterator.hasNext(); )
{
Record record = (Record) iterator.next();
size += record.getRecordSize();
}
return 4 + size;
|
public short | getSid()
return sid;
|
public java.util.List | getSubRecords()
return subrecords;
|
public int | serialize(int offset, byte[] data)
int pos = 0;
LittleEndian.putShort(data, 0 + offset, sid);
LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
pos = offset + 4;
for ( Iterator iterator = subrecords.iterator(); iterator.hasNext(); )
{
Record record = (Record) iterator.next();
pos += record.serialize(pos, data);
}
return getRecordSize();
|
public java.lang.String | toString()
StringBuffer buffer = new StringBuffer();
buffer.append("[OBJ]\n");
for ( Iterator iterator = subrecords.iterator(); iterator.hasNext(); )
{
Record record = (Record) iterator.next();
buffer.append("SUBRECORD: " + record.toString());
}
buffer.append("[/OBJ]\n");
return buffer.toString();
|
protected void | validateSid(short id)Checks the sid matches the expected side for this record
if (id != sid)
{
throw new RecordFormatException("Not an OBJ record");
}
|