Examples of Perl5Util


Examples of org.apache.oro.text.perl.Perl5Util

        if ( authority == null )
        {
            return false;
        }

        Perl5Util authorityMatcher = new Perl5Util();
        Perl5Util matchIPV4Pat = new Perl5Util();

        if ( !authorityMatcher.match( AUTHORITY_PATTERN, authority ) )
        {
            return false;
        }

        boolean ipV4Address = false;
        boolean hostname = false;
        // check if authority is IP address or hostname
        String hostIP = authorityMatcher.group( PARSE_AUTHORITY_HOST_IP );
        ipV4Address = matchIPV4Pat.match( IP_V4_DOMAIN_PATTERN, hostIP );

        if ( ipV4Address )
        {
            // this is an IP address so check components
            for ( int i = 1; i <= 4; i++ )
            {
                String ipSegment = matchIPV4Pat.group( i );
                if ( ipSegment == null || ipSegment.length() <= 0 )
                {
                    return false;
                }

                try
                {
                    if ( Integer.parseInt( ipSegment ) > 255 )
                    {
                        return false;
                    }
                }
                catch ( NumberFormatException e )
                {
                    return false;
                }

            }
        }
        else
        {
            // Domain is hostname name
            Perl5Util domainMatcher = new Perl5Util();
            hostname = domainMatcher.match( DOMAIN_PATTERN, hostIP );
        }

        //rightmost hostname will never start with a digit.
        if ( hostname )
        {
            String[] domainSegment = new String[10];
            boolean match = true;
            int segmentCount = 0;
            int segmentLength = 0;
            Perl5Util atomMatcher = new Perl5Util();

            while ( match )
            {
                match = atomMatcher.match( ATOM_PATTERN, hostIP );
                if ( match )
                {
                    domainSegment[segmentCount] = atomMatcher.group( 1 );
                    segmentLength = domainSegment[segmentCount].length() + 1;
                    hostIP = ( segmentLength >= hostIP.length() ) ? "" : hostIP.substring( segmentLength );

                    segmentCount++;
                }
            }
            String topLevel = domainSegment[segmentCount - 1];
            // don't check toplevel when we have only a server name like localhost
            if ( segmentCount != 1 && (topLevel.length() < 2 ) )
            {
                return false;
            }

            // First letter of top level must be a alpha
            Perl5Util alphaMatcher = new Perl5Util();
            if ( !alphaMatcher.match( ALPHA_PATTERN, topLevel.substring( 0, 1 ) ) )
            {
                return false;
            }
        }

        if ( !hostname && !ipV4Address )
        {
            return false;
        }

        String port = authorityMatcher.group( PARSE_AUTHORITY_PORT );
        if ( port != null )
        {
            Perl5Util portMatcher = new Perl5Util();
            if ( !portMatcher.match( PORT_PATTERN, port ) )
            {
                return false;
            }
        }
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

        if ( path == null )
        {
            return false;
        }

        Perl5Util pathMatcher = new Perl5Util();

        if ( !pathMatcher.match( PATH_PATTERN, path ) )
        {
            return false;
        }

        int slash2Count = countToken( "//", path );
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

        if ( query == null )
        {
            return true;
        }

        Perl5Util queryMatcher = new Perl5Util();
        return queryMatcher.match( QUERY_PATTERN, query );
    }
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

     *  <tr><td>p4.user</td><td>User</td></tr>
     *  </table>
     */
    public void init() {

        util = new Perl5Util();

        //Get default P4 settings from environment - Mark would have done something cool with
        //introspection here.....:-)
        String tmpprop;
        if ((tmpprop = getProject().getProperty("p4.port")) != null) {
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

        String output = p4change.backslash(input);
        assertEquals("comment with a \\/ inside", output);
    }

    public void testSubstitute(){
        Perl5Util util = new Perl5Util();
        String tosubstitute = "xx<here>xx";
        String input = p4change.backslash("/a/b/c/");
        String output = util.substitute("s/<here>/" + input + "/", tosubstitute);
        assertEquals("xx/a/b/c/xx", output);
    }
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

    boolean isEmail(String email) {
        if (email == null) {
            return false;
        }

        Perl5Util matchAsciiPat = new Perl5Util();
        if (!matchAsciiPat.match(LEGAL_ASCII_PATTERN, email)) {
            return false;
        }

        // Check the whole email address structure
        Perl5Util emailMatcher = new Perl5Util();
        if (!emailMatcher.match(EMAIL_PATTERN, email)) {
            return false;
        }

        if (email.endsWith(".")) {
            return false;
        }

        if (!isValidUser(emailMatcher.group(1))) {
            return false;
        }

        if (!isValidDomain(emailMatcher.group(2))) {
            return false;
        }

        return true;
    }
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

     * Returns true if the domain component of an email address is valid.
     * @param domain being validatied.
     */
    protected boolean isValidDomain(String domain) {
        boolean symbolic = false;
        Perl5Util ipAddressMatcher = new Perl5Util();

        if (ipAddressMatcher.match(IP_DOMAIN_PATTERN, domain)) {
            if (!isValidIpAddress(ipAddressMatcher)) {
                return false;
            }
        } else {
            // Domain is symbolic name
            Perl5Util domainMatcher = new Perl5Util();
            symbolic = domainMatcher.match(DOMAIN_PATTERN, domain);
        }

        if (symbolic) {
            if (!isValidSymbolicDomain(domain)) {
                return false;
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

    /**
     * Returns true if the user component of an email address is valid.
     * @param user being validated
     */
    protected boolean isValidUser(String user) {
        Perl5Util userMatcher = new Perl5Util();
        return userMatcher.match(USER_PATTERN, user);
    }
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

     */
    protected boolean isValidSymbolicDomain(String domain) {
        String[] domainSegment = new String[10];
        boolean match = true;
        int i = 0;
        Perl5Util atomMatcher = new Perl5Util();

        while (match) {
            match = atomMatcher.match(ATOM_PATTERN, domain);
            if (match) {
                domainSegment[i] = atomMatcher.group(1);
                int l = domainSegment[i].length() + 1;
                domain =
                        (l >= domain.length())
                        ? ""
                        : domain.substring(l);
View Full Code Here

Examples of org.apache.oro.text.perl.Perl5Util

public RegexTester(String attribute, String test) {
    super(attribute, test);
    initialize();
}
protected void initialize() {
    regexMatcher = new Perl5Util();
    pattern = PATTERN_DELIMITER + testValue + PATTERN_DELIMITER;
}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.