Package java.util

Examples of java.util.Scanner.match()


        }

        s = new Scanner("test1234\n1234 test");
        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        int number = s.nextInt();
        assertEquals(1234, number);
View Full Code Here


        assertEquals(0, matchResult.start());
        assertEquals(4, matchResult.end());

        int number = s.nextInt();
        assertEquals(1234, number);
        matchResult = s.match();
        assertEquals(4, matchResult.start());
        assertEquals(8, matchResult.end());

        result = s.next();
        assertEquals("1234", result);
View Full Code Here

        assertEquals(4, matchResult.start());
        assertEquals(8, matchResult.end());

        result = s.next();
        assertEquals("1234", result);
        matchResult = s.match();
        assertEquals(9, matchResult.start());
        assertEquals(13, matchResult.end());

        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
View Full Code Here

        assertEquals(9, matchResult.start());
        assertEquals(13, matchResult.end());

        result = s.findInLine(Pattern.compile("test"));
        assertEquals("test", result);
        matchResult = s.match();
        assertEquals(14, matchResult.start());
        assertEquals(18, matchResult.end());
       
        s = new Scanner("test\u0085\ntest");
        result = s.findInLine("est");
View Full Code Here

    {
        Scanner scanner = new Scanner( new ByteArrayInputStream( message.getBytes() ) );
        String foundString = scanner.findWithinHorizon( ".*line (\\d+):(\\d+): *([^\\n]*).*", message.length() ); //$NON-NLS-1$
        if ( foundString != null )
        {
            MatchResult result = scanner.match();
            if ( result.groupCount() == 3 )
            {
                ExceptionMessage exceptionMessage = new ExceptionMessage();
                exceptionMessage.lineNumber = result.group( 1 );
                exceptionMessage.columnNumber = result.group( 2 );
View Full Code Here

      contentTypeScanner.close();
      throw new BatchException(BatchException.INVALID_CONTENT_TYPE.addContent(HttpContentType.MULTIPART_MIXED));
    }
    if (contentTypeScanner.hasNext(REG_EX_BOUNDARY_PARAMETER)) {
      contentTypeScanner.next(REG_EX_BOUNDARY_PARAMETER);
      MatchResult result = contentTypeScanner.match();
      contentTypeScanner.close();
      if (result.groupCount() == 1 && result.group(1).trim().matches(REG_EX_BOUNDARY)) {
        return trimQuota(result.group(1).trim());
      } else {
        throw new BatchException(BatchException.INVALID_BOUNDARY);
View Full Code Here

    Scanner acceptHeaderScanner = new Scanner(headerValue);
    acceptHeaderScanner.useDelimiter(",\\s?");
    while (acceptHeaderScanner.hasNext()) {
      if (acceptHeaderScanner.hasNext(REG_EX_ACCEPT_WITH_Q_FACTOR)) {
        acceptHeaderScanner.next(REG_EX_ACCEPT_WITH_Q_FACTOR);
        MatchResult result = acceptHeaderScanner.match();
        if (result.groupCount() == 2) {
          String acceptHeaderValue = result.group(1);
          double qualityFactor = result.group(2) != null ? Double.parseDouble(result.group(2)) : 1d;
          qualityFactor = getQualityFactor(acceptHeaderValue, qualityFactor);
          Accept acceptHeader = new Accept().setQuality(qualityFactor).setValue(acceptHeaderValue);
View Full Code Here

    acceptLanguageScanner.useDelimiter(",\\s?");

    while (acceptLanguageScanner.hasNext()) {
      if (acceptLanguageScanner.hasNext(REG_EX_ACCEPT_LANGUAGES_WITH_Q_FACTOR)) {
        acceptLanguageScanner.next(REG_EX_ACCEPT_LANGUAGES_WITH_Q_FACTOR);
        MatchResult result = acceptLanguageScanner.match();
        if (result.groupCount() == 2) {
          String languagerange = result.group(1);
          double qualityFactor = result.group(2) != null ? Double.parseDouble(result.group(2)) : 1d;
          acceptTree.add(new Accept().setQuality(qualityFactor).setValue(languagerange));
        } else {
View Full Code Here

      URI uriObject = new URI(uri);
      if (uriObject.isAbsolute()) {
        Pattern regexRequestUri = Pattern.compile(baseUri + "/([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
View Full Code Here

        }
      } else {
        Pattern regexRequestUri = Pattern.compile("([^/][^?]*)(\\?.*)?");
        if (uriScanner.hasNext(regexRequestUri)) {
          uriScanner.next(regexRequestUri);
          MatchResult result = uriScanner.match();
          if (result.groupCount() == 2) {
            odataPathSegmentsAsString = result.group(1);
            queryParametersAsString = result.group(2) != null ? result.group(2) : "";
          } else {
            uriScanner.close();
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.