Package org.apache.oro.text.regex

Examples of org.apache.oro.text.regex.Perl5Compiler


     * @throws org.nanocontainer.aop.MalformedRegularExpressionException
     *          if the regular expression is
     *          invalid.
     */
    public NameMatchesComponentPointcut(String regex) throws MalformedRegularExpressionException {
        Perl5Compiler compiler = new Perl5Compiler();
        try {
            pattern = compiler.compile(regex);
        } catch (MalformedPatternException e) {
            throw new MalformedRegularExpressionException("malformed component name regular expression", e);
        }
    }
View Full Code Here


    Vector patterns;
    Vector ids;
    PatternMatcher matcher;
   
    public PropsMatcher(InputStream is) throws IOException {
        PatternCompiler compiler=new Perl5Compiler();
        matcher=new Perl5Matcher();

        // read in a properties file
        Vector v=readPropertiesVector(is);
       
        patterns=new Vector();
        ids=new Vector(v.size());

        // prepare separate vectors of compiled patterns
        // and mapped ids
        for(int i=0;i<v.size();i++) {
            String[] temp=(String[]) v.elementAt(i);

            // compile a pattern
            try {
                Pattern p=compiler.compile(temp[0]);
                patterns.addElement(p);
                // save the id
                ids.addElement(temp[1]);
            } catch (MalformedPatternException mpe) {
                // omit entry, give warning*
 
View Full Code Here

  private static List<Rule> readConfigurationFile(Reader reader)
    throws IOException, MalformedPatternException {

    BufferedReader in=new BufferedReader(reader);
    Perl5Compiler compiler=new Perl5Compiler();
    List<Rule> rules=new ArrayList<Rule>();
    String line;
      
    while((line=in.readLine())!=null) {
      if (line.length() == 0)
        continue;
      char first=line.charAt(0);
      boolean sign=false;
      switch (first) {
      case '+' :
        sign=true;
        break;
      case '-' :
        sign=false;
        break;
      case ' ' : case '\n' : case '#' :           // skip blank & comment lines
        continue;
      default :
        throw new IOException("Invalid first character: "+line);
      }

      String regex=line.substring(1);

      Rule rule=new Rule();
      rule.pattern=(Perl5Pattern) compiler.compile(regex);
      rule.sign=sign;
      rule.regex=regex;
      rules.add(rule);
    }
View Full Code Here

        }
        buff.append('$');

        Pattern result = null;
        try {
            Perl5Compiler compiler = new Perl5Compiler();
            result = compiler.compile(buff.toString());
        } catch (MalformedPatternException exception) {
            // coding error if this gets thrown here...
            throw new InvalidRegexpException(pattern);
        }
        return result;
View Full Code Here

    private String[] getStartCommand() throws Exception {
        ArrayList args = new ArrayList();

        if (_serverStart != null) {
            Perl5Compiler compiler = new Perl5Compiler();
            Pattern pattern = compiler.compile("'.*'|[^\\s]*");
            Perl5Matcher matcher = new Perl5Matcher();
            PatternMatcherInput input = new PatternMatcherInput(_serverStart);

            while (matcher.contains(input, pattern)) {
                String arg = matcher.getMatch().toString();
View Full Code Here

    private Map _escapedPatternStrings = new HashMap();

    protected Pattern compilePattern(String pattern)
    {
        if (_patternCompiler == null)
            _patternCompiler = new Perl5Compiler();

        try
        {
            return _patternCompiler.compile(pattern, Perl5Compiler.SINGLELINE_MASK | Perl5Compiler.READ_ONLY_MASK);
        }
View Full Code Here

    private TemplateTokenFactory _factory;

    public TemplateParser()
    {
        Perl5Compiler compiler = new Perl5Compiler();

        try
        {
            _simpleIdPattern = compiler.compile(SIMPLE_ID_PATTERN);
            _implicitIdPattern = compiler.compile(IMPLICIT_ID_PATTERN);
        }
        catch (MalformedPatternException ex)
        {
            throw new ApplicationRuntimeException(ex);
        }
View Full Code Here

        }

        // compile splitpattern
        Element splitElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "split", true);
        String patternString = DomHelper.getAttribute(splitElement, "pattern");
        Perl5Compiler compiler = new Perl5Compiler();
        Pattern pattern = null;
        try {
            pattern = compiler.compile(patternString, Perl5Compiler.READ_ONLY_MASK);
        } catch (MalformedPatternException e) {
            throw new Exception("Invalid regular expression at " + DomHelper.getLocation(splitElement) + ": " + e.getMessage());
        }
        aggregateDefinition.setSplitPattern(pattern, patternString);
View Full Code Here

        RegExpValidationRule rule = new RegExpValidationRule();

        String regexp = DomHelper.getAttribute(validationRuleElement, "pattern");
        buildFailMessage(validationRuleElement, rule);

        Perl5Compiler compiler = new Perl5Compiler();
        Pattern pattern = null;
        try {
            pattern = compiler.compile(regexp, Perl5Compiler.READ_ONLY_MASK);
        } catch (MalformedPatternException e) {
            throw new Exception("Invalid regular expression at " + DomHelper.getLocation(validationRuleElement) + ": " + e.getMessage());
        }
        rule.setPattern(regexp, pattern);
View Full Code Here

        }

        // compile splitpattern
        Element splitElement = DomHelper.getChildElement(widgetElement, Constants.DEFINITION_NS, "split", true);
        String patternString = DomHelper.getAttribute(splitElement, "pattern");
        Perl5Compiler compiler = new Perl5Compiler();
        Pattern pattern = null;
        try {
            pattern = compiler.compile(patternString, Perl5Compiler.READ_ONLY_MASK);
        } catch (MalformedPatternException e) {
            throw new Exception("Invalid regular expression at " + DomHelper.getLocation(splitElement) + ": " + e.getMessage());
        }
        aggregateDefinition.setSplitPattern(pattern, patternString);
View Full Code Here

TOP

Related Classes of org.apache.oro.text.regex.Perl5Compiler

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.