HDFFieldIteratorpublic class HDFFieldIterator extends org.apache.poi.generator.FieldIterator This class overrides FieldIterator to handle HDF specific types |
Constructors Summary |
---|
public HDFFieldIterator()
|
Methods Summary |
---|
public java.lang.String | fillDecoder(java.lang.String size, java.lang.String type)
String result = "";
if (type.equals("short[]"))
result = "LittleEndian.getSimpleShortArray(data, 0x" + Integer.toHexString(offset) + " + offset," + size + ")";
else if (type.equals("byte[]"))
result = "LittleEndian.getByteArray(data, 0x" + Integer.toHexString(offset) + " + offset," + size + ")";
else if (type.equals("BorderCode"))
result = "new BorderCode(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (type.equals("DateAndTime"))
result = "new DateAndTime(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (size.equals("2"))
result = "LittleEndian.getShort(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (size.equals("4"))
result = "LittleEndian.getInt(data, 0x" + Integer.toHexString(offset) + " + offset)";
else if (size.equals("1"))
result = "data[ 0x" + Integer.toHexString(offset) + " + offset ]";
else if (type.equals("double"))
result = "LittleEndian.getDouble(data, 0x" + Integer.toHexString(offset) + " + offset)";
try
{
offset += Integer.parseInt(size);
}
catch (NumberFormatException ignore)
{
}
return result;
| public java.lang.String | serialiseEncoder(int fieldNumber, java.lang.String fieldName, java.lang.String size, java.lang.String type)
//String javaType = RecordUtil.getType(size, type, 0);
String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
String result = "";
if (type.equals("short[]"))
result = "LittleEndian.putShortArray(data, 0x" + Integer.toHexString(offset) + " + offset, " + javaFieldName + ");";
else if (type.equals("byte[]"))
result = "System.arraycopy(" + javaFieldName + ", 0, data, 0x" + Integer.toHexString(offset) + " + offset, " + javaFieldName + ".length);";
else if (type.equals("BorderCode"))
result = javaFieldName + ".serialize(data, 0x" + Integer.toHexString(offset) + " + offset);";
else if (type.equals("DateAndTime"))
result = javaFieldName + ".serialize(data, 0x" + Integer.toHexString(offset) + " + offset);";
else if (size.equals("2"))
result = "LittleEndian.putShort(data, 0x" + Integer.toHexString(offset) + " + offset, (short)" + javaFieldName + ");";
else if (size.equals("4"))
result = "LittleEndian.putInt(data, 0x" + Integer.toHexString(offset) + " + offset, " + javaFieldName + ");";
else if (size.equals("1"))
result = "data[ 0x" + Integer.toHexString(offset) + " + offset] = " + javaFieldName + ";";
else if (type.equals("double"))
result = "LittleEndian.putDouble(data, 0x" + Integer.toHexString(offset) + " + offset, " + javaFieldName + ");";
try
{
offset += Integer.parseInt(size);
}
catch (NumberFormatException ignore)
{
}
return result;
|
|