Support test expression

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-05-15 00:56:18 +00:00
parent cda1a3eb5e
commit 988200c2b2
2 changed files with 13 additions and 6 deletions

View File

@ -74,6 +74,12 @@ public class FieldIterator
offset = 0;
}
/**
* This utility function returns a fill method entry for a given field
*
* @param size - how big of an "int" or the name of the size field for a string
* @param type - int or string
*/
public String fillDecoder(String size, String type)
{
String javaType = RecordUtil.getType(size, type, 0);
@ -89,8 +95,8 @@ public class FieldIterator
result = "data[ 0x" + Integer.toHexString(offset) + " + offset ]";
else if (javaType.equals("double"))
result = "LittleEndian.getDouble(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (javaType.equals("ExcelString"))
result = "ExcelStringUtil.decodeExcelString(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (javaType.equals("String"))
result = "StringUtil.getFromUnicode(data, 0x" + Integer.toHexString(offset) + " + offset,"+ size + ")";
try
{
@ -101,6 +107,7 @@ public class FieldIterator
}
return result;
}
//position(),@name,@size,@type
public String serialiseEncoder( int fieldNumber, String fieldName, String size, String type)
@ -120,7 +127,7 @@ public class FieldIterator
else if (javaType.equals("double"))
result = "LittleEndian.putDouble(data, " + (offset+4) + " + offset, " + javaFieldName + ");";
else if (javaType.equals("ExcelString"))
result = "StringUtil.putUncompressedUnicode(getFontName(), data, 20 + offset);";
result = "StringUtil.putUncompressedUnicode("+ javaFieldName +", data, 20 + offset);";
try
{
@ -139,7 +146,7 @@ public class FieldIterator
if ("var".equals(size))
{
String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
return result + javaFieldName + ".sizeInBytes()";
return result + " ("+javaFieldName + ".length() *2)";
}
else if ("varword".equals(size))
{

View File

@ -136,7 +136,7 @@ public class RecordUtil
else if (type.equals("float") && "8".equals(size))
return pad(new StringBuffer("double"), padTo).toString();
else if (type.equals("string"))
return pad(new StringBuffer("ExcelString"), padTo).toString();
return pad(new StringBuffer("String"), padTo).toString();
return "short"; // if we don't know, default to short
}
@ -152,7 +152,7 @@ public class RecordUtil
else if (numeric && "2".equals(size))
result = pad(new StringBuffer("short"), padTo);
else if (type.equals("string"))
result = pad(new StringBuffer("ExcelString"), padTo);
result = pad(new StringBuffer("String"), padTo);
else
return "";