Package org.apache.oro.text.perl

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


   protected boolean isValidPath(String path) {
        if (path == null) {
            return false;
        }

        Perl5Util pathMatcher = new Perl5Util();

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

        //if (path.endsWith("/")) {
        //    return false;
View Full Code Here


     *  <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

     * @param fields The search fields
     * @return A string
     */
    private String buildQuery(ArrayList<SearchField> fields)
    {
      Perl5Util util = new Perl5Util();
     
      String query = "";
     
      // Loop through the fields building the search query as we go.
      for (SearchField field : fields)
      { 
        // if the field is empty, then skip it and try a later one.
        if (field.getQuery() == null)
          continue;
       
        // Add the conjunction for everything but the first field.
        if (fields.indexOf(field) > 0)
          query += " " + field.getConjunction() + " ";
           
        // Two cases, one if a specific search field is specified or if
        // ANY is given then just a general search is performed.
            if ("ANY".equals(field.getField()))
            {
              // No field specified,
              query += "(" + field.getQuery() + ")";
            }
            else
            {  
              // Specific search field specified, add the field specific field.
             
              // Replace singe quote's with double quotes (only if they match)
              String subquery = util.substitute("s/\'(.*)\'/\"$1\"/g", field.getQuery());
             
              // If the field is not quoted ...
              if (!util.match("/\".*\"/", subquery))
                {
                // ... then seperate each word and re-specify the search field.
                    subquery = util.substitute("s/ / " + field.getField() + ":/g", subquery);
                }
             
              // Put the subquery into the general query
              query += "("+field.getField()+":"+subquery+")";
            }
View Full Code Here

     * regular expressions.
     * @testng.test groups = "functest", "util"
     */
    public void testFindScript()
    {
        Perl5Util util = new Perl5Util();
        String expr = "/(?:<script.*?>)((\\n|.)*?)(?:<\\/script>)/";
       
        assertTrue(util.match(expr, JAVASCRIPT_NOCOMMENT));
       
        MatchResult result = util.getMatch();
        assertNotNull(result);
        assertEquals(3, result.groups());
        assertEquals("if (document.updateObject) { document.updateObject.progressFinished('updateId');}",
                result.group(1));
    }
View Full Code Here

     * regular expressions.
     * @testng.test groups = "functest", "util"
     */
    public void testFindMultipleScripts()
    {
        Perl5Util util = new Perl5Util();
        String expr = "/(?:<script.*?>)((\\n|.)*?)(?:<\\/script>)/";
       
        assertTrue(util.match(expr, MULTI_JAVASCRIPT_NOCOMMENT));
       
        MatchResult result = util.getMatch();
        assertNotNull(result);
        assertEquals(3, result.groups());
        assertEquals("if (document.updateObject) { document.updateObject.progressFinished('updateId');}"
                + "if (document.updateObject) { document.updateObject.progressFinished('updateId');}",
                result.group(1));
View Full Code Here

        {
            contents += "\n";
        }

        // Convert most markup.
        Perl5Util perl = new Perl5Util();
        for (int i = 0; i < perLineREs.length; i += 2)
        {
            contents = perl.substitute(makeSubstRE(i), contents);
        }

        // Convert closing curlies.
        if (perl.match("m/javascript/i", contents))
        {
            // ASSUMPTION: JavaScript is indented, WM is not.
            contents = perl.substitute("s/\n}/\n#end/g", contents);
        }
        else
        {
            contents = perl.substitute("s/(\n\\s*)}/$1#end/g", contents);
            contents = perl.substitute("s/#end\\s*\n\\s*#else/#else/g",
                                       contents);
        }

        return contents;
    }
View Full Code Here

    public boolean isValid(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

     * 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

    /**
     * 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

     */
    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

TOP

Related Classes of org.apache.oro.text.perl.Perl5Util

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.