if( name == null )
{
throw new IllegalArgumentException();
}
Attribute attribute = null;
for( Attribute attr : state.getAttributes() )
{
if( name.equalsIgnoreCase( attr.getName().content() ) )
{
attribute = attr;
break;
}
}
String string = null;
if( value != null )
{
string = state.service( MasterConversionService.class ).convert( value, String.class );
}
if( string == null )
{
if( attribute != null )
{
state.getAttributes().remove( attribute );
}
}
else
{
if( attribute == null )
{
attribute = state.getAttributes().insert();
attribute.setName( name );
}
attribute.setValue( string );
}
}