Package org.apache.commons.digester3.plugins

Examples of org.apache.commons.digester3.plugins.Declaration


    @Test
    public void testMatch()
    {
        // test no defaults
        WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper( new RulesBase() );
        rules.add( "alpha", new TestRule( "Tom" ) );
        rules.add( "alpha", new TestRule( "Dick" ) );
        rules.add( "alpha", new TestRule( "Harry" ) );
        rules.addDefault( new TestRule( "Roger" ) );
        rules.addDefault( new TestRule( "Rabbit" ) );

        List<Rule> matches = rules.match( "", "alpha", null, null );
        assertEquals( "Wrong size (1)", 3, matches.size() );
        assertEquals( "Wrong order (1)", "Tom", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
        assertEquals( "Wrong order (2)", "Dick", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
        assertEquals( "Wrong order (3)", "Harry", ( (TestRule) matches.get( 2 ) ).getIdentifier() );

        matches = rules.match( "", "not-alpha", null, null );
        assertEquals( "Wrong size (2)", 2, matches.size() );
        assertEquals( "Wrong order (4)", "Roger", ( (TestRule) matches.get( 0 ) ).getIdentifier() );
        assertEquals( "Wrong order (5)", "Rabbit", ( (TestRule) matches.get( 1 ) ).getIdentifier() );
    }
View Full Code Here


     */
    public void handle( A annotation, Method element, RulesBinder rulesBinder )
    {
        if ( SUPPORTED_ARGS != element.getParameterTypes().length )
        {
            DigesterRule rule = annotation.annotationType().getAnnotation( DigesterRule.class );

            rulesBinder.addError( "Methods annotated with digester annotation rule @%s must have just one argument",
                                  rule.reflectsRule().getName() );
            return;
        }

        Object explicitTypesObject = getAnnotationValue( annotation );
        if ( explicitTypesObject == null || !explicitTypesObject.getClass().isArray()
View Full Code Here

                           boolean fireOnBegin, RulesBinder rulesBinder )
    {
        if ( annotation.annotationType().isAnnotationPresent( DigesterRule.class )
            && annotation.annotationType().isAnnotationPresent( CreationRule.class ) )
        {
            rulesBinder.install( new FromAnnotationsRuleModule()
            {

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

                Annotation[][] parameterAnnotations = method.getParameterAnnotations();
                Class<?>[] parameterTypes = method.getParameterTypes();
                for ( int i = 0; i < parameterTypes.length; i++ )
                {
                    visitElements( new MethodArgument( i, parameterTypes[i], parameterAnnotations[i] ) );
                }
            }
        }
    }
View Full Code Here

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

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

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

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

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

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

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

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

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

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

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

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

TOP

Related Classes of org.apache.commons.digester3.plugins.Declaration

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.