Package org.apache.tapestry.util

Examples of org.apache.tapestry.util.RegexpMatcher


     * Invoked by hivemind by default to initialize
     * service.
     */
    public void initializeService()
    {
        _matcher = new RegexpMatcher();
    }
View Full Code Here


     */

    public void validate(String value, String pattern, String errorKey)
    {
        if (_matcher == null)
            _matcher = new RegexpMatcher();

        if (_matcher.matches(pattern, value))
            return;

        throw new InvalidStringException(Tapestry.format(errorKey, value), value, getLocation());
View Full Code Here

public class TestRegexpMatcher extends TapestryTestCase
{

    public void testMatch()
    {
        RegexpMatcher m = new RegexpMatcher();

        assertTrue(m.matches("[a-z]+", "c"));
        assertTrue(m.matches("foo|foot", "foo"));
    }
View Full Code Here

        assertTrue(m.matches("foo|foot", "foo"));
    }

    public void test_Non_Match()
    {
        RegexpMatcher m = new RegexpMatcher();

        assert !m.matches("[0-9]+", "q");
        assert !m.matches("foo|efoot", "foot");
    }
View Full Code Here

        assert !m.matches("foo|efoot", "foot");
    }

    public void test_Bad_Pattern()
    {
        RegexpMatcher m = new RegexpMatcher();

        try
        {
            m.matches("[[[", "x");

            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
View Full Code Here

        }
    }

    public void testClear()
    {
        RegexpMatcher m = new RegexpMatcher();

        m.clear();
    }
View Full Code Here

        m.clear();
    }

    public void testContains()
    {
        RegexpMatcher m = new RegexpMatcher();

        assertTrue(m.contains("[a-z]+", "c"));
        assertTrue(m.contains("^(\\d{5}(-\\d{4})?)$", "06514"));
        assertTrue(m.contains("^(\\d{5}(-\\d{4})?)$", "06514-3149"));
        assertTrue(m.contains("foo|foot", "12foot12"));
    }
View Full Code Here

        assertTrue(m.contains("foo|foot", "12foot12"));
    }

    public void testNotContains()
    {
        RegexpMatcher m = new RegexpMatcher();

        assertTrue(!m.contains("[0-9]+", "q"));
        assertTrue(!m.contains("^(\\d{5}(-\\d{4})?)$", "0651"));
        assertTrue(!m.contains("^(\\d{5}(-\\d{4})?)$", "065147"));
        assertTrue(!m.contains("^(\\d{5}(-\\d{4})?)$", "06514-314"));
        assertTrue(!m.contains("^(\\d{5}(-\\d{4})?)$", "06514-31497"));
        assertTrue(!m.contains("^(foo|foot)$", "12foot12"));
    }
View Full Code Here

        assertTrue(!m.contains("^(foo|foot)$", "12foot12"));
    }

    public void testGetEscapedPatternStrings()
    {
        RegexpMatcher m = new RegexpMatcher();

        assertEquals(m.getEscapedPatternString("^\\d$"), "\\^\\\\d\\$");
    }
View Full Code Here

    /** @since 4.0 */

    public void test_Get_Matches()
    {
        RegexpMatcher m = new RegexpMatcher();

        String[] matches = m.getMatches("\\d+", "57,232 89 147", 0);

        assertEquals(new String[] { "57", "232", "89", "147" }, matches);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.util.RegexpMatcher

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.