Package org.apache.commons.digester3.binder

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


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

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


    /**
     * {@inheritDoc}
     */
    public void handle( CallMethod annotation, Method element, RulesBinder rulesBinder )
    {
        CallMethodBuilder callMethodBuilder = rulesBinder
            .forPattern( annotation.pattern() )
            .withNamespaceURI( annotation.namespaceURI() )
            .callMethod( element.getName() )
            .withParamTypes( element.getParameterTypes() );

        if ( annotation.usingElementBodyAsArgument() )
        {
            callMethodBuilder.usingElementBodyAsArgument();
        }
    }
View Full Code Here

     */
    @Override
    protected void bindRule( LinkedRuleBuilder linkedRuleBuilder, Attributes attributes )
        throws Exception
    {
        CallMethodBuilder builder = linkedRuleBuilder.callMethod( attributes.getValue( "methodname" ) );

        // Select which element is to be the target. Default to zero,
        // ie the top object on the stack.
        int targetOffset = 0;
        String targetOffsetStr = attributes.getValue( "targetoffset" );
        if ( targetOffsetStr != null )
        {
            targetOffset = Integer.parseInt( targetOffsetStr );
            builder.withTargetOffset( targetOffset );
        }

        builder.useExactMatch( "true".equalsIgnoreCase( attributes.getValue( "useExactMatch" ) ) );

        String paramCountStr = attributes.getValue( "paramcount" );
        if ( paramCountStr != null )
        {
            int paramCount = Integer.parseInt( attributes.getValue( "paramcount" ) );

            builder.withParamCount( paramCount );
        }

        String paramTypesStr = attributes.getValue( "paramtypes" );
        if ( paramTypesStr != null && paramTypesStr.length() > 0 )
        {
            StringTokenizer tokens = new StringTokenizer( paramTypesStr, " \t\n\r," );
            String[] paramTypeNames = new String[tokens.countTokens()];
            int counter = 0;
            while ( tokens.hasMoreTokens() )
            {
                paramTypeNames[counter++] = tokens.nextToken();
            }
            builder.withParamTypes( paramTypeNames );
        }

        if ( "true".equalsIgnoreCase( attributes.getValue( "usingElementBodyAsArgument" ) ) )
        {
            builder.usingElementBodyAsArgument();
        }
    }
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.CallMethodBuilder

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.