Methods Summary |
---|
public static org.apache.poi.hssf.record.Record[] | createRecord(org.apache.poi.hssf.record.RecordInputStream in)create a record, if there are MUL records than multiple records
are returned digested into the non-mul form.
Record retval = null;
Record[] realretval = null;
try
{
Constructor constructor =
( Constructor ) recordsMap.get(new Short(in.getSid()));
if (constructor != null)
{
retval = ( Record ) constructor.newInstance(new Object[]
{
in
});
}
else
{
retval = new UnknownRecord(in);
}
}
catch (Exception introspectionException)
{
throw new RecordFormatException("Unable to construct record instance" , introspectionException);
}
if (retval instanceof RKRecord)
{
RKRecord rk = ( RKRecord ) retval;
NumberRecord num = new NumberRecord();
num.setColumn(rk.getColumn());
num.setRow(rk.getRow());
num.setXFIndex(rk.getXFIndex());
num.setValue(rk.getRKNumber());
retval = num;
}
else if (retval instanceof DBCellRecord)
{
retval = null;
}
else if (retval instanceof MulRKRecord)
{
MulRKRecord mrk = ( MulRKRecord ) retval;
realretval = new Record[ mrk.getNumColumns() ];
for (int k = 0; k < mrk.getNumColumns(); k++)
{
NumberRecord nr = new NumberRecord();
nr.setColumn(( short ) (k + mrk.getFirstColumn()));
nr.setRow(mrk.getRow());
nr.setXFIndex(mrk.getXFAt(k));
nr.setValue(mrk.getRKNumberAt(k));
realretval[ k ] = nr;
}
}
else if (retval instanceof MulBlankRecord)
{
MulBlankRecord mb = ( MulBlankRecord ) retval;
realretval = new Record[ mb.getNumColumns() ];
for (int k = 0; k < mb.getNumColumns(); k++)
{
BlankRecord br = new BlankRecord();
br.setColumn(( short ) (k + mb.getFirstColumn()));
br.setRow(mb.getRow());
br.setXFIndex(mb.getXFAt(k));
realretval[ k ] = br;
}
}
if (realretval == null)
{
realretval = new Record[ 1 ];
realretval[ 0 ] = retval;
}
return realretval;
|
public static short[] | getAllKnownRecordSIDs()
short[] results = new short[ recordsMap.size() ];
int i = 0;
for (Iterator iterator = recordsMap.keySet().iterator();
iterator.hasNext(); )
{
Short sid = ( Short ) iterator.next();
results[ i++ ] = sid.shortValue();
}
return results;
|
protected java.util.Iterator | listeners()used for unit tests to test the registration of record listeners.
return listeners.iterator();
|
public void | processRecords(java.io.InputStream in)Create an array of records from an input stream
Record last_record = null;
RecordInputStream recStream = new RecordInputStream(in);
while (recStream.hasNextRecord()) {
recStream.nextRecord();
Record[] recs = createRecord(recStream); // handle MulRK records
if (recs.length > 1)
{
for (int k = 0; k < recs.length; k++)
{
if ( last_record != null ) {
if (throwRecordEvent(last_record) == false && abortable == true) {
last_record = null;
break;
}
}
last_record =
recs[ k ]; // do to keep the algorythm homogenous...you can't
} // actually continue a number record anyhow.
}
else
{
Record record = recs[ 0 ];
if (record != null)
{
if (last_record != null) {
if (throwRecordEvent(last_record) == false && abortable == true) {
last_record = null;
break;
}
}
last_record = record;
}
}
}
if (last_record != null) {
throwRecordEvent(last_record);
}
|
private static java.util.Map | recordsToMap(java.lang.Class[] records)gets the record constructors and sticks them in the map by SID
Map result = new HashMap();
Constructor constructor;
for (int i = 0; i < records.length; i++)
{
Class record = null;
short sid = 0;
record = records[ i ];
try
{
sid = record.getField("sid").getShort(null);
constructor = record.getConstructor(new Class[]
{
RecordInputStream.class
});
}
catch (Exception illegalArgumentException)
{
throw new RecordFormatException(
"Unable to determine record types");
}
result.put(new Short(sid), constructor);
}
return result;
|
public void | registerListener(org.apache.poi.hssf.eventmodel.ERFListener listener, short[] sids)Register a listener for records. These can be for all records
or just a subset.
if (sids == null)
sids = sidscache;
ERFListener wrapped = new ListenerWrapper(listener, sids, abortable);
listeners.add(wrapped);
|
private boolean | throwRecordEvent(org.apache.poi.hssf.record.Record record)sends the record event to all registered listeners.
boolean result = true;
Iterator i = listeners.iterator();
while (i.hasNext()) {
result = ((ERFListener) i.next()).processRecord(record);
if (abortable == true && result == false) {
break;
}
}
return result;
|