Package java.util.regex

Examples of java.util.regex.PatternSyntaxException


        public GlobMatcher(String expression) throws PatternSyntaxException {
            this.expression = expression;
            try {
                pattern = new GlobCompiler().compile(expression);
            } catch (MalformedPatternException e) {
                throw new PatternSyntaxException(e.getMessage(), expression, 0);
            }
        }
View Full Code Here


    String[] patterns = listOfPatterns.split(SEPARATOR);
    for(String p: patterns) {
      int equalsPos = p.indexOf('=');
     
      if(equalsPos < 0 || equalsPos > (p.length() -2)) {
        throw new PatternSyntaxException(
            "pattern must be of form targ=pattern", p, -1);
      }
     
      String targ = p.substring(0, equalsPos);
      if(!targ.startsWith("tags.") && !ArrayUtils.contains(SEARCH_TARGS, targ)) {
        throw new PatternSyntaxException(
            "pattern doesn't start with recognized search target", p, -1);
      }
     
      Pattern pat = Pattern.compile(p.substring(equalsPos+1), Pattern.DOTALL);
      compiledPatterns.add(new SearchRule(pat, targ));
View Full Code Here

        in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
        out = new DataOutputStream(sock.getOutputStream());
        String cmd = in.readLine();
        if(!cmd.contains(" ")) {
         
          throw new PatternSyntaxException(
              "command should be keyword pattern, but no ' ' seen", cmd, -1);
        }
        String uppercased = cmd.substring(0, cmd.indexOf(' ')).toUpperCase();
        if(RAW.equals(uppercased))
          fmt = DataFormat.Raw;
        else if(WRITABLE.equals(uppercased))
          fmt = DataFormat.Writable;
        else if(ASCII_HEADER.equals(uppercased))
          fmt = DataFormat.Header;
        else {
          throw new PatternSyntaxException("bad command '" + uppercased+
              "' -- starts with neither '"+ RAW+ "' nor '"+ WRITABLE + " nor "
              + ASCII_HEADER+"'.", cmd, -1);
        }
       
        String cmdAfterSpace = cmd.substring(cmd.indexOf(' ')+1);
View Full Code Here

   
    /**
     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {
        PatternSyntaxException object = new PatternSyntaxException("TESTDESC", "TESTREGEX", 3);
        SerializationTest.verifySelf(object, PATTERNSYNTAXEXCEPTION_COMPARATOR);
    }
View Full Code Here

   
    /**
     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {
        PatternSyntaxException object = new PatternSyntaxException("TESTDESC",
                "TESTREGEX", 3);
        SerializationTest.verifyGolden(this, object,
                PATTERNSYNTAXEXCEPTION_COMPARATOR);
    }
View Full Code Here

        Pattern pattern = Pattern.compile( "(?s).*?([0-9]+\\.[0-9]+)(\\.([0-9]+))?.*" );

        Matcher matcher = pattern.matcher( output );
        if ( !matcher.matches() )
        {
            throw new PatternSyntaxException( "Unrecognized version of Javadoc: '" + output + "'", pattern.pattern(),
                                              pattern.toString().length() - 1 );
        }

        String version = matcher.group( 3 );
        if ( version == null )
View Full Code Here

    }
    return Pattern.compile(regex.toString());
  }

  private static void error(String message, String pattern, int pos) {
    throw new PatternSyntaxException(message, pattern, pos);
  }
View Full Code Here

        sock.setKeepAlive(USE_KEEPALIVE);
        in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
        String cmd = in.readLine();
        if(!cmd.contains(" ")) {
         
          throw new PatternSyntaxException(
              "command should be keyword pattern, but no ' ' seen", cmd, -1);
        }
        String uppercased = cmd.substring(0, cmd.indexOf(' ')).toUpperCase();
        if(RAW.equals(uppercased))
          sendRawBytes = true;
        else if(!WRITABLE.equals(uppercased)) {
          throw new PatternSyntaxException("bad command '" + uppercased+
              "' -- starts with neither '"+ RAW+ "' nor '"+ WRITABLE+"'.", cmd, -1);
        }
       
        String cmdAfterSpace = cmd.substring(cmd.indexOf(' ')+1);
        rules = new Filter(cmdAfterSpace);
View Full Code Here

        public GlobMatcher(String expression) throws PatternSyntaxException {
            try {
                _pattern = new GlobCompiler().compile(expression);
            } catch (MalformedPatternException e) {
                throw new PatternSyntaxException(e.getMessage(), expression, 0);
            }
        }
View Full Code Here

        Pattern pattern = Pattern.compile( "(?s).*?([0-9]+\\.[0-9]+)(\\.([0-9]+))?.*" );

        Matcher matcher = pattern.matcher( output );
        if ( !matcher.matches() )
        {
            throw new PatternSyntaxException( "Unrecognized version of Javadoc: '" + output + "'", pattern.pattern(),
                                              pattern.toString().length() - 1 );
        }

        String version = matcher.group( 3 );
        if ( version == null )
View Full Code Here

TOP

Related Classes of java.util.regex.PatternSyntaxException

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.