poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sack...@apache.org
Subject cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hdf/generator HDFFieldIterator.java
Date Thu, 05 Jun 2003 02:00:07 GMT
sackley     2003/06/04 19:00:07

  Modified:    src/scratchpad/src/org/apache/poi/hdf/generator
                        HDFFieldIterator.java
  Log:
  Added code to allow XML generated classes to write themselves
  
  Revision  Changes    Path
  1.3       +39 -4     jakarta-poi/src/scratchpad/src/org/apache/poi/hdf/generator/HDFFieldIterator.java
  
  Index: HDFFieldIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hdf/generator/HDFFieldIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HDFFieldIterator.java	30 Apr 2003 04:38:59 -0000	1.2
  +++ HDFFieldIterator.java	5 Jun 2003 02:00:07 -0000	1.3
  @@ -55,6 +55,7 @@
   package org.apache.poi.hdf.generator;
   
   import org.apache.poi.generator.FieldIterator;
  +import org.apache.poi.generator.RecordUtil;
   
   /**
    * This class overrides FieldIterator to handle HDF specific types
  @@ -65,16 +66,17 @@
       public HDFFieldIterator()
       {
       }
  +
       public String fillDecoder(String size, String type)
       {
   
           String result = "";
   
           if (type.equals("short[]"))
  -            result = "LittleEndian.getSimpleShortArray(data, 0x" + Integer.toHexString(offset)
+ " + offset, size)";
  +            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)";
  -        if (size.equals("2"))
  +            result = "LittleEndian.getByteArray(data, 0x" + Integer.toHexString(offset)
+ " + offset," + size + ")";
  +        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)";
  @@ -92,4 +94,37 @@
           }
           return result;
       }
  -}
  \ No newline at end of file
  +
  +    public String serialiseEncoder( int fieldNumber, String fieldName, String size, String
type)
  +    {
  +        String javaType = RecordUtil.getType(size, type, 0);
  +        String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
  +
  +        String result = "";
  +
  +
  +        if (javaType.equals("short[]"))
  +            result = "LittleEndian.putShortArray(data, 0x" + Integer.toHexString(offset)
+ " + offset, " + javaFieldName + ");";
  +        else if (javaType.equals("byte[]"))
  +            result = "LittleEndian.putByteArray(data, 0x" + Integer.toHexString(offset)
+ " + offset, " + javaFieldName + ");";
  +        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 (javaType.equals("double"))
  +            result = "LittleEndian.putDouble(data, 0x" + Integer.toHexString(offset) +
" + offset, " + javaFieldName + ");";
  +
  +        try
  +        {
  +            offset += Integer.parseInt(size);
  +        }
  +        catch (NumberFormatException ignore)
  +        {
  +        }
  +        return result;
  +
  +    }
  +
  +}
  
  
  

Mime
View raw message