private void createFieldMap ( byte [ ] data ) { int index = 0 ; int lastDataBlockOffset = 0 ; int dataBlockIndex = 0 ; while ( index < data . length ) { long mask = MPPUtility . getInt ( data , index + 0 ) ; //mask = mask << 4; int dataBlockOffset = MPPUtility . getShort ( data , index + 4 ) ; //int metaFlags = MPPUtility.getByte(data, index + 8); FieldType type = getFieldType ( MPPUtility . getInt ( data , index + 12 ) ) ; int category = MPPUtility . getShort ( data , index + 20 ) ; //int sizeInBytes = MPPUtility.getShort(data, index + 22); //int metaIndex = MPPUtility.getInt(data, index + 24); // // Categories // // 02 - Short values [RATE_UNITS, WORKGROUP, ACCRUE, TIME_UNITS, PRIORITY, TASK_TYPE, CONSTRAINT, ACCRUE, PERCENTAGE, SHORT, WORK_UNITS] - BOOKING_TYPE, EARNED_VALUE_METHOD, DELIVERABLE_TYPE, RESOURCE_REQUEST_TYPE - we have as string in MPXJ???? // 03 - Int values [DURATION, INTEGER] - Recalc outline codes as Boolean? // 05 - Rate, Number [RATE, NUMERIC] // 08 - String (and some durations!!!) [STRING, DURATION] // 0B - Boolean (meta block 0?) - [BOOLEAN] // 13 - Date - [DATE] // 48 - GUID - [GUID] // 64 - Boolean (meta block 1?)- [BOOLEAN] // 65 - Work, Currency [WORK, CURRENCY] // 66 - Units [UNITS] // 1D - Raw bytes [BINARY, ASCII_STRING] - Exception: outline code indexes, they are integers, but stored as part of a binary block int varDataKey ; if ( useTypeAsVarDataKey ( ) ) { Integer substitute = substituteVarDataKey ( type ) ; if ( substitute == null ) { varDataKey = ( MPPUtility . getInt ( data , index + 12 ) & 0x0000FFFF ) ; } else { varDataKey = substitute . intValue ( ) ; } } else { varDataKey = MPPUtility . getByte ( data , index + 6 ) ; } FieldLocation location ; int metaBlock ; switch ( category ) { case 0x0B : { location = FieldLocation . META_DATA ; metaBlock = 0 ; break ; } case 0x64 : { location = FieldLocation . META_DATA ; metaBlock = 1 ; break ; } default : { metaBlock = 0 ; if ( dataBlockOffset != 65535 ) { location = FieldLocation . FIXED_DATA ; if ( dataBlockOffset < lastDataBlockOffset ) { ++ dataBlockIndex ; } lastDataBlockOffset = dataBlockOffset ; int typeSize = getFixedDataFieldSize ( type ) ; if ( dataBlockOffset + typeSize > m_maxFixedDataSize [ dataBlockIndex ] ) { m_maxFixedDataSize [ dataBlockIndex ] = dataBlockOffset + typeSize ; } } else { if ( varDataKey != 0 ) { location = FieldLocation . VAR_DATA ; } else { location = FieldLocation . UNKNOWN ; } } break ; } } FieldItem item = new FieldItem ( type , location , dataBlockIndex , dataBlockOffset , varDataKey , mask , metaBlock ) ; if ( m_debug ) { System . out . println ( ByteArrayHelper . hexdump ( data , index , 28 , false ) + " " + item + " mpxjDataType=" + item . getType ( ) . getDataType ( ) + " index=" + index ) ; } m_map . put ( type , item ) ; index += 28 ; } }
Generic method used to create a field map from a block of data .