Package org.apache.oro.text.regex

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


        // Since we have no way of knowing the auto-generated variables in the SQL,
        // we simply try to extract it from the SQL
        Pattern             declarePattern     = new Perl5Compiler().compile("DECLARE @([\\S]+) [^@]+@([\\S]+)");
        PatternMatcherInput input              = new PatternMatcherInput(sql);
        PatternMatcher      matcher            = new Perl5Matcher();
        String[]            tableNameVars      = { "tablename", "tablename", "tablename" };
        String[]            constraintNameVars = { "constraintname", "constraintname", "constraintname" };

        for (int idx = 0; (idx < 3) && matcher.contains(input, declarePattern); idx++)
        {
            MatchResult result = matcher.getMatch();

            tableNameVars[idx]      = result.group(1);
            constraintNameVars[idx] = result.group(2);
            input.setCurrentOffset(result.endOffset(2));
        }
View Full Code Here


        String sql = createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE);

        // Since we have no way of knowing the auto-generated variables in the SQL,
        // we simply try to extract it from the SQL
        Pattern        declarePattern    = new Perl5Compiler().compile("DECLARE @([\\S]+) [^@]+@([\\S]+)");
        PatternMatcher matcher           = new Perl5Matcher();
        String         tableNameVar      = "tablename";
        String         constraintNameVar = "constraintname";

        if (matcher.contains(sql, declarePattern))
        {
            tableNameVar      = matcher.getMatch().group(1);
            constraintNameVar = matcher.getMatch().group(2);
        }
        assertEqualsIgnoringWhitespaces(
            "SET quoted_identifier on;\n"+
            "SET quoted_identifier on;\n"+
            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'escapedcharacters')\n"+
View Full Code Here

      if (column.getTypeCode() == Types.TIMESTAMP)
      {
        // Sql Server maintains the default values for DATE/TIME jdbc types, so we have to
        // migrate the default value to TIMESTAMP
        PatternMatcher matcher   = new Perl5Matcher();
        Timestamp      timestamp = null;
 
        if (matcher.matches(defaultValue, _isoDatePattern))
        {
          timestamp = new Timestamp(Date.valueOf(matcher.getMatch().group(1)).getTime());
        }
        else if (matcher.matches(defaultValue, _isoTimePattern))
        {
          timestamp = new Timestamp(Time.valueOf(matcher.getMatch().group(1)).getTime());
        }
        if (timestamp != null)
        {
          defaultValue = timestamp.toString();
        }
View Full Code Here

            enteredValue = newEnteredValue;
            validationError = null;
   
            if (enteredValue != null) {
                // try to split it
                PatternMatcher matcher = new Perl5Matcher();
                if (matcher.matches(enteredValue, aggregateDefinition.getSplitPattern())) {
                    MatchResult matchResult = matcher.getMatch();
                    Iterator iterator = aggregateDefinition.getSplitMappingsIterator();
                    while (iterator.hasNext()) {
                        SplitMapping splitMapping = (SplitMapping)iterator.next();
                        String result = matchResult.group(splitMapping.getGroup());
                        // Since we know the fields are guaranteed to have a string datatype, we
View Full Code Here

      else
        return hasFailMessage() ? getFailMessage() : new ValidationError(new I18nMessage("validation.string.regexp", new String[] {regexp}, Constants.I18N_CATALOGUE));
    }
   
    private boolean matchesRegExp(String string) {
        PatternMatcher matcher = new Perl5Matcher();
        return matcher.matches(string, pattern);
    }
View Full Code Here

        {
        if (column.getTypeCode() == Types.TIMESTAMP)
        {
          // Sybase maintains the default values for DATE/TIME jdbc types, so we have to
          // migrate the default value to TIMESTAMP
          PatternMatcher matcher   = new Perl5Matcher();
          Timestamp      timestamp = null;
   
          if (matcher.matches(column.getDefaultValue(), _isoDatePattern))
          {
            timestamp = new Timestamp(Date.valueOf(matcher.getMatch().group(1)).getTime());
          }
          else if (matcher.matches(column.getDefaultValue(), _isoTimePattern))
          {
            timestamp = new Timestamp(Time.valueOf(matcher.getMatch().group(1)).getTime());
          }
          if (timestamp != null)
          {
            column.setDefaultValue(timestamp.toString());
          }
View Full Code Here

      column.setTypeCode(Types.TIMESTAMP);

      // we also reverse the ISO-format adaptation, and adjust the default value to timestamp
      if (column.getDefaultValue() != null)
      {
        PatternMatcher matcher   = new Perl5Matcher();
        Timestamp      timestamp = null;
 
        if (matcher.matches(column.getDefaultValue(), _oracleIsoTimestampPattern))
        {
          String timestampVal = matcher.getMatch().group(1);

          timestamp = Timestamp.valueOf(timestampVal);
        }
        else if (matcher.matches(column.getDefaultValue(), _oracleIsoDatePattern))
        {
          String dateVal = matcher.getMatch().group(1);

          timestamp = new Timestamp(Date.valueOf(dateVal).getTime());
        }
        else if (matcher.matches(column.getDefaultValue(), _oracleIsoTimePattern))
        {
          String timeVal = matcher.getMatch().group(1);

          timestamp = new Timestamp(Time.valueOf(timeVal).getTime());
        }
        if (timestamp != null)
        {
View Full Code Here

    if (column.getDefaultValue() != null)
    {
      if (column.getTypeCode() == Types.TIME)
      {
        PatternMatcher matcher = new Perl5Matcher();

        // Db2 returns "HH24.MI.SS"
        if (matcher.matches(column.getDefaultValue(), _db2TimePattern))
        {
          StringBuffer newDefault = new StringBuffer();

          newDefault.append("'");
          // the hour
          newDefault.append(matcher.getMatch().group(1));
          newDefault.append(":");
          // the minute
          newDefault.append(matcher.getMatch().group(2));
          newDefault.append(":");
          // the second
          newDefault.append(matcher.getMatch().group(3));
          newDefault.append("'");

          column.setDefaultValue(newDefault.toString());
        }
      }
      else if (column.getTypeCode() == Types.TIMESTAMP)
      {
        PatternMatcher matcher = new Perl5Matcher();

        // Db2 returns "YYYY-MM-DD-HH24.MI.SS.FF"
        if (matcher.matches(column.getDefaultValue(), _db2TimestampPattern))
        {
          StringBuffer newDefault = new StringBuffer();

          newDefault.append("'");
          // group 1 is the date which has the correct format
          newDefault.append(matcher.getMatch().group(1));
          newDefault.append(" ");
          // the hour
          newDefault.append(matcher.getMatch().group(2));
          newDefault.append(":");
          // the minute
          newDefault.append(matcher.getMatch().group(3));
          newDefault.append(":");
          // the second
          newDefault.append(matcher.getMatch().group(4));
          // optionally, the fraction
          if ((matcher.getMatch().groups() > 4) && (matcher.getMatch().group(4) != null))
          {
            newDefault.append(matcher.getMatch().group(5));
          }
          newDefault.append("'");

          column.setDefaultValue(newDefault.toString());
        }
View Full Code Here

  patterns = new Pattern[raw_pat.length];
  substitutions = new String[raw_pat.length];
  int realsize = 0;

  PatternCompiler compiler = new Perl5Compiler();
  PatternMatcher matcher = new Perl5Matcher();
 
  for (int i=0; i<raw_pat.length; i++) {
      try {
    if (matcher.matches(raw_pat[i], dec_pat)) {
        patterns[realsize] =
      compiler.compile(matcher.getMatch().group(1));
        substitutions[realsize] = matcher.getMatch().group(2);
        realsize++;
    }
      } catch (MalformedPatternException ex) {
    // bad configuration...
      }
View Full Code Here

    }

    public ReplyInterface ingoingFilter(RequestInterface request) {
  Request req = (Request) request;
  String  requrl = req.getURL().toExternalForm();
  PatternMatcher matcher = new Perl5Matcher();
  Pattern pat[] = getPatterns();
  if (pat == null || pat.length == 0)
      return null;
  String sub[] = getSubstitutions();
  String result = null;
  for (int i=0; i< pat.length; i++) {
      if (matcher.matches(requrl, pat[i])) {
    Substitution s = new Perl5Substitution(sub[i]);
    result = Util.substitute(matcher, pat[i], s, requrl,
           Util.SUBSTITUTE_ALL);
    break;
      }
View Full Code Here

TOP

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

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.