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

HDFRecordUtil

public class HDFRecordUtil extends org.apache.poi.generator.RecordUtil
This class overrides RecordUtil to handle HDF specific types

Fields Summary
Constructors Summary
public HDFRecordUtil()

    
Methods Summary
public static java.lang.StringgetBitFieldFunction(java.lang.String name, java.lang.String bitMask, java.lang.String parentType, java.lang.String withType)

        String type = getBitFieldType(name, bitMask, parentType);

        String retVal = new String();
        if(withType.equals("true"))
        {
            retVal = type + " ";
        }
        if(type.equals("boolean"))
        {
            retVal += "is" + getFieldName1stCap(name, 0);
        }
        else
        {
            retVal +="get" + getFieldName1stCap(name, 0);
        }
        return retVal;

    
public static java.lang.StringgetBitFieldGet(java.lang.String name, java.lang.String bitMask, java.lang.String parentType, java.lang.String parentField)

        String type = getBitFieldType(name, bitMask, parentType);

        String retVal = null;

        if(type.equals("boolean"))
            retVal = name + ".isSet(" + parentField + ");";
        else
            retVal = "( " + type + " )" + name + ".getValue(" + parentField + ");";

        return retVal;

    
public static java.lang.StringgetBitFieldSet(java.lang.String name, java.lang.String bitMask, java.lang.String parentType, java.lang.String parentField)

        String type = getBitFieldType(name, bitMask, parentType);

        String retVal = null;

        if(type.equals("boolean"))
            retVal = "(" + parentType + ")" + getFieldName(name, 0) + ".setBoolean(" + parentField + ", value)";
        else
            retVal = "(" + parentType + ")" + getFieldName(name, 0) + ".setValue(" + parentField + ", value)";
        return retVal;
    
public static java.lang.StringgetBitFieldType(java.lang.String name, java.lang.String bitMask, java.lang.String parentType)

        byte parentSize = 0;
        byte numBits = 0;
        int mask = (int)Long.parseLong(bitMask.substring(2), 16);

        if (parentType.equals("byte"))
            parentSize = 8;
        else if (parentType.equals("short"))
            parentSize = 16;
        else if (parentType.equals("int"))
            parentSize = 32;

        for (int x = 0; x < parentSize; x++)
        {
            int temp = mask;
            numBits += (temp >> x) & 0x1;
        }

        if(numBits == 1)
        {
            return "boolean";
        }
        else if (numBits < 8)
        {
            return "byte";
        }
        else if (numBits < 16)
        {
            return "short";
        }
        else
        {
            return "int";
        }
    
public static java.lang.StringgetType(java.lang.String size, java.lang.String type, int padTo)


        return type;
    
public static java.lang.StringgetType1stCap(java.lang.String size, java.lang.String type, int padTo)

        StringBuffer result = new StringBuffer();
        result.append(type);
        result = pad(result, padTo);
        result.setCharAt(0, Character.toUpperCase(result.charAt(0)));

        return result.toString();