FileDocCategorySizeDatePackage
HDFFieldIterator.javaAPI DocApache Poi 3.0.14367Mon Jan 01 18:55:24 GMT 2007org.apache.poi.hdf.generator

HDFFieldIterator

public class HDFFieldIterator extends org.apache.poi.generator.FieldIterator
This class overrides FieldIterator to handle HDF specific types

Fields Summary
Constructors Summary
public HDFFieldIterator()

    
Methods Summary
public java.lang.StringfillDecoder(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.StringserialiseEncoder(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;