protected void bindRule()

in commons-digester3-core/src/main/java/org/apache/commons/digester3/xmlrules/CallParamRule.java [39:69]


    protected void bindRule( final LinkedRuleBuilder linkedRuleBuilder, final Attributes attributes )
        throws Exception
    {
        final int paramIndex = Integer.parseInt( attributes.getValue( "paramnumber" ) );
        final CallParamBuilder builder = linkedRuleBuilder.callParam().ofIndex( paramIndex );

        final String attributeName = attributes.getValue( "attrname" );
        final String fromStack = attributes.getValue( "from-stack" );
        final String stackIndex = attributes.getValue( "stack-index" );

        if ( attributeName == null )
        {
            if ( stackIndex != null )
            {
                builder.withStackIndex( Integer.parseInt( stackIndex ) );
            }
            else if ( fromStack != null )
            {
                builder.fromStack( Boolean.parseBoolean( fromStack ) );
            }
        }
        else
        {
            if ( fromStack != null )
            {
                // specifying both from-stack and attribute name is not allowed
                throw new IllegalArgumentException( "Attributes from-stack and attrname cannot both be present." );
            }
            builder.fromAttribute( attributeName );
        }
    }