@ Override public PmdRuleSet create ( ) { final SAXBuilder parser = new SAXBuilder ( ) ; final Document dom ; try { dom = parser . build ( source ) ; } catch ( JDOMException | IOException e ) { if ( messages != null ) { messages . addErrorText ( INVALID_INPUT + " : " + e . getMessage ( ) ) ; } LOG . error ( INVALID_INPUT , e ) ; return new PmdRuleSet ( ) ; } final Element eltResultset = dom . getRootElement ( ) ; final Namespace namespace = eltResultset . getNamespace ( ) ; final PmdRuleSet result = new PmdRuleSet ( ) ; final String name = eltResultset . getAttributeValue ( "name" ) ; final Element descriptionElement = getChild ( eltResultset , namespace ) ; result . setName ( name ) ; if ( descriptionElement != null ) { result . setDescription ( descriptionElement . getValue ( ) ) ; } for ( Element eltRule : getChildren ( eltResultset , "rule" , namespace ) ) { PmdRule pmdRule = new PmdRule ( eltRule . getAttributeValue ( "ref" ) ) ; pmdRule . setClazz ( eltRule . getAttributeValue ( "class" ) ) ; pmdRule . setName ( eltRule . getAttributeValue ( "name" ) ) ; pmdRule . setMessage ( eltRule . getAttributeValue ( "message" ) ) ; parsePmdPriority ( eltRule , pmdRule , namespace ) ; parsePmdProperties ( eltRule , pmdRule , namespace ) ; result . addRule ( pmdRule ) ; } return result ; }
Parses the given Reader for PmdRuleSets .