question: boolean validateAttrSet ( AttrSet attrSet ) throws UMSException { AttrSet reqAttrs = getRequiredAttributeSet ( ) ; AttrSet optionalAttrs = getOptionalAttributeSet ( ) ; if ( reqAttrs == null && optionalAttrs == null ) { throw new UMSException ( i18n . getString ( IUMSConstants . TEMPLATE_NO_ATTR ) ) ; } String [ ] attrNames = attrSet . getAttributeNames ( ) ; int attrSetSize = ( attrNames != null ) ? attrNames . length : - 1 ; String attrName = null ; if ( reqAttrs != null ) { Enumeration attrEnum = reqAttrs . getAttributes ( ) ; while ( attrEnum . hasMoreElements ( ) ) { Attr anAttr = ( Attr ) attrEnum . nextElement ( ) ; if ( ! attrSet . contains ( anAttr . getName ( ) ) ) { if ( anAttr . size ( ) > 0 ) { attrSet . add ( ( Attr ) anAttr . clone ( ) ) ; } else { attrName = anAttr . getName ( ) ; String args [ ] = new String [ 1 ] ; args [ 0 ] = attrName ; String msg = i18n . getString ( IUMSConstants . NO_VALUE , args ) ; throw new UMSException ( msg ) ; } } } } if ( optionalAttrs != null && optionalAttrs . contains ( "*" ) ) { return true ; } boolean attrAllowed = false ; for ( int i = 0 ; i < attrSetSize ; i ++ ) { attrAllowed = false ; attrName = attrNames [ i ] ; if ( reqAttrs != null && reqAttrs . contains ( attrName ) ) { attrAllowed = true ; } else if ( optionalAttrs != null && optionalAttrs . contains ( attrName ) ) { attrAllowed = true ; } if ( ! attrAllowed ) { String args [ ] = new String [ 1 ] ; args [ 0 ] = attrName ; String msg = i18n . getString ( IUMSConstants . ATTR_NOT_ALLOWED , args ) ; throw new UMSException ( msg ) ; } } return true ; }
target:  Validate attrSet according to the definition of required and optional attributes defined in the template.