From 988200c2b2205b751a07cb2a477d664049090236 Mon Sep 17 00:00:00 2001 From: "Andrew C. Oliver" Date: Wed, 15 May 2002 00:56:18 +0000 Subject: [PATCH] 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 --- .../org/apache/poi/generator/FieldIterator.java | 15 +++++++++++---- .../src/org/apache/poi/generator/RecordUtil.java | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java index 528b7de43..4badc9afd 100644 --- a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java +++ b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java @@ -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)) { diff --git a/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java b/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java index 3d704cdaa..84416346a 100644 --- a/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java +++ b/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java @@ -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 "";