public static NaaccrDictionary readDictionary ( Reader reader ) throws IOException { try { NaaccrDictionary dictionary = ( NaaccrDictionary ) instanciateXStream ( ) . fromXML ( reader ) ; // default value for specifications if ( dictionary . getSpecificationVersion ( ) == null ) dictionary . setSpecificationVersion ( SpecificationVersion . SPEC_1_0 ) ; // default value for record types if ( dictionary . getItems ( ) != null ) for ( NaaccrDictionaryItem item : dictionary . getItems ( ) ) if ( item . getRecordTypes ( ) == null ) item . setRecordTypes ( NaaccrFormat . ALL_RECORD_TYPES ) ; // let's not validate the internal dictionaries, we know they are valid String uri = dictionary . getDictionaryUri ( ) ; if ( uri == null || uri . trim ( ) . isEmpty ( ) ) throw new IOException ( "'dictionaryUri' attribute is required" ) ; else if ( ! BASE_DICTIONARY_URI_PATTERN . matcher ( uri ) . matches ( ) && ! DEFAULT_USER_DICTIONARY_URI_PATTERN . matcher ( uri ) . matches ( ) ) { List < String > errors = validateUserDictionary ( dictionary ) ; if ( ! errors . isEmpty ( ) ) throw new IOException ( errors . get ( 0 ) ) ; } return dictionary ; } catch ( XStreamException ex ) { throw new IOException ( "Unable to read dictionary" , ex ) ; } }
Reads a dictionary from the provided reader .