clarification of ArrayPtg size increment

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@694620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-09-12 07:03:00 +00:00
parent 658057a44a
commit 9b9d63275a
1 changed files with 34 additions and 30 deletions

View File

@ -56,20 +56,21 @@ public abstract class Ptg implements Cloneable {
/** /**
* @deprecated - use readTokens() * @deprecated - use readTokens()
*/ */
public static Stack createParsedExpressionTokens(short size, RecordInputStream in) public static Stack createParsedExpressionTokens(short size, RecordInputStream in) {
{
Stack stack = new Stack(); Stack stack = new Stack();
int pos = 0; int pos = 0;
List arrayPtgs = null; List arrayPtgs = null;
while ( pos < size ) while (pos < size) {
{
Ptg ptg = Ptg.createPtg( in ); Ptg ptg = Ptg.createPtg( in );
if (ptg instanceof ArrayPtg) { if (ptg instanceof ArrayPtg) {
if (arrayPtgs == null) if (arrayPtgs == null) {
arrayPtgs = new ArrayList(5); arrayPtgs = new ArrayList(5);
}
arrayPtgs.add(ptg); arrayPtgs.add(ptg);
pos += 8; pos += ArrayPtg.PLAIN_TOKEN_SIZE;
} else pos += ptg.getSize(); } else {
pos += ptg.getSize();
}
stack.push( ptg ); stack.push( ptg );
} }
if(pos != size) { if(pos != size) {
@ -118,7 +119,7 @@ public abstract class Ptg implements Cloneable {
case MemAreaPtg.sid: return new MemAreaPtg(in); // 0x26, 0x46, 0x66 case MemAreaPtg.sid: return new MemAreaPtg(in); // 0x26, 0x46, 0x66
case MemErrPtg.sid: return new MemErrPtg(in); // 0x27, 0x47, 0x67 case MemErrPtg.sid: return new MemErrPtg(in); // 0x27, 0x47, 0x67
case MemFuncPtg.sid: return new MemFuncPtg(in); // 0x29, 0x49, 0x69 case MemFuncPtg.sid: return new MemFuncPtg(in); // 0x29, 0x49, 0x69
case RefErrorPtg.sid: return new RefErrorPtg(in);// 0x2a, 0x4a, 0x6a case RefErrorPtg.sid: return new RefErrorPtg(in); // 0x2a, 0x4a, 0x6a
case AreaErrPtg.sid: return new AreaErrPtg(in); // 0x2b, 0x4b, 0x6b case AreaErrPtg.sid: return new AreaErrPtg(in); // 0x2b, 0x4b, 0x6b
case RefNPtg.sid: return new RefNPtg(in); // 0x2c, 0x4c, 0x6c case RefNPtg.sid: return new RefNPtg(in); // 0x2c, 0x4c, 0x6c
case AreaNPtg.sid: return new AreaNPtg(in); // 0x2d, 0x4d, 0x6d case AreaNPtg.sid: return new AreaNPtg(in); // 0x2d, 0x4d, 0x6d
@ -262,11 +263,14 @@ public abstract class Ptg implements Cloneable {
ptg.writeBytes(array, pos + offset); ptg.writeBytes(array, pos + offset);
if (ptg instanceof ArrayPtg) { if (ptg instanceof ArrayPtg) {
if (arrayPtgs == null) if (arrayPtgs == null) {
arrayPtgs = new ArrayList(5); arrayPtgs = new ArrayList(5);
}
arrayPtgs.add(ptg); arrayPtgs.add(ptg);
pos += 8; pos += ArrayPtg.PLAIN_TOKEN_SIZE;
} else pos += ptg.getSize(); } else {
pos += ptg.getSize();
}
} }
if (arrayPtgs != null) { if (arrayPtgs != null) {
for (int i=0;i<arrayPtgs.size();i++) { for (int i=0;i<arrayPtgs.size();i++) {