private boolean processRecord ( List < String > record ) throws MPXJException { boolean done = false ; XerRecordType type = RECORD_TYPE_MAP . get ( record . get ( 0 ) ) ; if ( type == null ) { throw new MPXJException ( MPXJException . INVALID_FORMAT ) ; } switch ( type ) { case HEADER : { processHeader ( record ) ; break ; } case TABLE : { m_currentTableName = record . get ( 1 ) . toLowerCase ( ) ; m_skipTable = ! REQUIRED_TABLES . contains ( m_currentTableName ) ; if ( m_skipTable ) { m_currentTable = null ; } else { m_currentTable = new LinkedList < Row > ( ) ; m_tables . put ( m_currentTableName , m_currentTable ) ; } break ; } case FIELDS : { if ( m_skipTable ) { m_currentFieldNames = null ; } else { m_currentFieldNames = record . toArray ( new String [ record . size ( ) ] ) ; for ( int loop = 0 ; loop < m_currentFieldNames . length ; loop ++ ) { m_currentFieldNames [ loop ] = m_currentFieldNames [ loop ] . toLowerCase ( ) ; } } break ; } case DATA : { if ( ! m_skipTable ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; for ( int loop = 1 ; loop < record . size ( ) ; loop ++ ) { String fieldName = m_currentFieldNames [ loop ] ; String fieldValue = record . get ( loop ) ; XerFieldType fieldType = FIELD_TYPE_MAP . get ( fieldName ) ; if ( fieldType == null ) { fieldType = XerFieldType . STRING ; } Object objectValue ; if ( fieldValue . length ( ) == 0 ) { objectValue = null ; } else { switch ( fieldType ) { case DATE : { try { objectValue = m_df . parseObject ( fieldValue ) ; } catch ( ParseException ex ) { objectValue = fieldValue ; } break ; } case CURRENCY : case DOUBLE : case DURATION : { try { objectValue = Double . valueOf ( m_numberFormat . parse ( fieldValue . trim ( ) ) . doubleValue ( ) ) ; } catch ( ParseException ex ) { objectValue = fieldValue ; } break ; } case INTEGER : { objectValue = Integer . valueOf ( fieldValue . trim ( ) ) ; break ; } default : { objectValue = fieldValue ; break ; } } } map . put ( fieldName , objectValue ) ; } Row currentRow = new MapRow ( map ) ; m_currentTable . add ( currentRow ) ; // // Special case - we need to know the default currency format // ahead of time, so process each row as we get it so that // we can correctly parse currency values in later tables. // if ( m_currentTableName . equals ( "currtype" ) ) { processCurrency ( currentRow ) ; } } break ; } case END : { done = true ; break ; } default : { break ; } } return done ; }
Handles a complete record at a time stores it in a form ready for further processing .