Package org.codehaus.aspectwerkz.expression.regexp

Examples of org.codehaus.aspectwerkz.expression.regexp.TypePattern


        // is that required ? how AJ syntax behaves ?



        TypePattern typePattern = node.getTypePattern();

        TypePattern realPattern = typePattern;



        // check if the arg is in the pointcut signature. In such a case, use the declared type

        //TODO can we improve that with a lazy attach of the realTypePattern to the node

        // and a method that always return the real pattern

        // It must be lazy since args are not added at info ctor time [can be refactored..]

        // do some filtering first to avoid unnecessary map lookup

       

        int pointcutArgIndex = -1;

        if (typePattern.getPattern().indexOf(".") < 0) {

            String boundedType = m_expressionInfo.getArgumentType(typePattern.getPattern());

            if (boundedType != null) {

                pointcutArgIndex = m_expressionInfo.getArgumentIndex(typePattern.getPattern());

                realPattern = TypePattern.compileTypePattern(boundedType, SubtypePatternType.NOT_HIERARCHICAL);

            }

        }

        // grab parameter from context

        ExpressionContext ctx = (ExpressionContext) data;

        ClassInfo argInfo = null;

        try {

            if (ctx.getReflectionInfo() instanceof MethodInfo) {

                argInfo = ((MethodInfo) ctx.getReflectionInfo()).getParameterTypes()[ctx.getCurrentTargetArgsIndex()];

            } else if (ctx.getReflectionInfo() instanceof ConstructorInfo) {

                argInfo = ((ConstructorInfo) ctx.getReflectionInfo()).getParameterTypes()[ctx

                        .getCurrentTargetArgsIndex()];

            } else if (ctx.getReflectionInfo() instanceof FieldInfo) {

                argInfo = ((FieldInfo) ctx.getReflectionInfo()).getType();

            } else if (ctx.getPointcutType().equals(PointcutType.HANDLER) && ctx.getReflectionInfo() instanceof ClassInfo) {

                argInfo = (ClassInfo) ctx.getReflectionInfo();

            }

        } catch (ArrayIndexOutOfBoundsException e) {

            // ExpressionContext args are exhausted

            return Boolean.FALSE;

        }

        if (realPattern.matchType(argInfo)) {

            return Boolean.TRUE;

        } else {
View Full Code Here


/**
* @author <a href="mailto:jboner@codehaus.org">Jonas Bon�r </a>
*/
public class ClassPatternTest extends TestCase {
    public void testMatchMethodName1() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.bar.SomeClass",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertFalse(classPattern.matches("SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertFalse(classPattern.matches("Class"));
        assertFalse(classPattern.matches(""));
    }
View Full Code Here

        assertFalse(classPattern.matches("Class"));
        assertFalse(classPattern.matches(""));
    }

    public void testMatchMethodName2() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.bar.*",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeOtherClass"));
        assertFalse(classPattern.matches("SomeClass"));
        assertFalse(classPattern.matches(""));
    }
View Full Code Here

        assertFalse(classPattern.matches("SomeClass"));
        assertFalse(classPattern.matches(""));
    }

    public void testMatchMethodName3() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.*.bar.SomeClass",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.hey.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.there.bar.SomeClass"));
        assertFalse(classPattern.matches("SomeClass"));
        assertFalse(classPattern.matches(""));
    }
View Full Code Here

        assertFalse(classPattern.matches("SomeClass"));
        assertFalse(classPattern.matches(""));
    }

    public void testMatchMethodName4() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.ba*.*",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.bag.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.ba.SomeClass"));
        assertFalse(classPattern.matches("foo.bear.SomeClass"));
        assertFalse(classPattern.matches("foo"));
    }
View Full Code Here

        assertFalse(classPattern.matches("foo.bear.SomeClass"));
        assertFalse(classPattern.matches("foo"));
    }

    public void testMatchClassName5() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo..",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.hey.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertFalse(classPattern.matches("foo"));
    }
View Full Code Here

        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertFalse(classPattern.matches("foo"));
    }

    public void testMatchClassName6() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "*",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.hey.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo"));
    }
View Full Code Here

        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo"));
    }

    public void testMatchClassName7() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "..",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.hey.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo"));
    }
View Full Code Here

        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo"));
    }

    public void testMatchClassName8() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.bar..*",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.bar.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.baz.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.baz.buzz.SomeClass"));
    }
View Full Code Here

        assertTrue(classPattern.matches("foo.bar.baz.SomeClass"));
        assertTrue(classPattern.matches("foo.bar.baz.buzz.SomeClass"));
    }

    public void testMatchClassName9() {
        TypePattern classPattern = Pattern.compileTypePattern(
                "foo.bar.Baz$Buzz",
                SubtypePatternType.NOT_HIERARCHICAL
        );
        assertTrue(classPattern.matches("foo.bar.Baz$Buzz"));
        assertFalse(classPattern.matches("foo.bar.Baz"));
    }
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.expression.regexp.TypePattern

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.