Package org.apache.commons.digester3.binder

Examples of org.apache.commons.digester3.binder.CallParamBuilder


     */
    @Test
    public void testMandatoryProperties()
        throws SAXException, IOException
    {
        Digester digester = newLoader( new AbstractRulesModule()
        {

            @Override
            protected void configure()
            {
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public void handle( CallParam annotation, MethodArgument element, RulesBinder rulesBinder )
    {
        CallParamBuilder builder = rulesBinder
            .forPattern( annotation.pattern() )
            .withNamespaceURI( annotation.namespaceURI() )
            .callParam()
            .ofIndex( element.getIndex() )
            .fromAttribute( annotation.attributeName().length() > 0 ? annotation.attributeName() : null );

        if ( annotation.fromStack() )
        {
            builder.withStackIndex( annotation.stackIndex() );
        }
    }
View Full Code Here

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

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

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

    /**
     * {@inheritDoc}
     */
    public void handle( SetProperty annotation, Field element, RulesBinder rulesBinder )
    {
        SetPropertiesBuilder builder = rulesBinder
            .forPattern( annotation.pattern() )
            .withNamespaceURI( annotation.namespaceURI() )
            .setProperties();

        if ( annotation.attributeName() != null && annotation.attributeName().length() > 0
            && !element.getName().equals( annotation.attributeName() ) )
        {
            builder.addAlias( annotation.attributeName(), element.getName() );
        }
    }
View Full Code Here

        // or id is specified in the xml file.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class, TextLabel.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );
View Full Code Here

        // not to have one of plugin-class or plugin-id specified
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );
View Full Code Here

        // plugin base class.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class, Object.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );

        Container root = new Container();
        digester.push( root );
View Full Code Here

    {
        // * tests that when a PluginCreateRule is defined with a default
        // class, that the default class is instantiated when no class
        // or id is specified in the xml file.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class, TextLabel.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );
View Full Code Here

        throws Exception
    {
        // * tests that when there is no default plugin, it is an error
        // not to have one of plugin-class or plugin-id specified
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );
View Full Code Here

        throws Exception
    {
        // * tests that the default plugin must implement or extend the
        // plugin base class.
        Digester digester = new Digester();
        PluginRules rc = new PluginRules();
        digester.setRules( rc );

        PluginCreateRule pcr = new PluginCreateRule( Widget.class, Object.class );
        digester.addRule( "root/widget", pcr );
        digester.addSetNext( "root/widget", "addChild" );
View Full Code Here

TOP

Related Classes of org.apache.commons.digester3.binder.CallParamBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.