private Map < String , TaskError > parseConfigFile ( URL configURL ) { Map < String , TaskError > knownErrors = new LinkedHashMap < String , TaskError > ( ) ; try { Element root = getRootElement ( configURL ) ; NodeList elements = root . getChildNodes ( ) ; for ( int i = 0 ; i < elements . getLength ( ) ; ++ i ) { Node node = elements . item ( i ) ; if ( ! ( node instanceof Element ) ) { continue ; } Element element = ( Element ) node ; if ( matched ( element , "error" ) ) { String name = element . getAttribute ( "name" ) ; String pattern = "" ; String description = "" ; NodeList fields = element . getChildNodes ( ) ; for ( int j = 0 ; j < fields . getLength ( ) ; ++ j ) { Node fieldNode = fields . item ( j ) ; if ( ! ( fieldNode instanceof Element ) ) { continue ; } Element field = ( Element ) fieldNode ; if ( matched ( field , "pattern" ) ) { pattern = getText ( field ) ; } else if ( matched ( field , "description" ) ) { description = getText ( field ) ; } } TaskError taskError = new TaskError ( name , pattern , description ) ; LOG . info ( "Adding TaskError " + taskError ) ; knownErrors . put ( name , taskError ) ; } } } catch ( IOException ie ) { LOG . error ( "Error parsing config file " + configURL , ie ) ; } return knownErrors ; }
Parse the error . xml file which contains the error