Package java.util

Examples of java.util.Scanner.findWithinHorizon()


        String regex = "tag\\d+\\s*\\d+\\.\\d\\s*\\d+\\s*\\d+\\s*\\d+\\.\\d\\s*(\\d+)";
        Pattern statLinePattern = Pattern.compile(regex);
        Scanner scanner = new Scanner(new File("target/statisticsLog-timeslicebug.log"));

        int totalCount = 0;
        while (scanner.findWithinHorizon(statLinePattern, 0) != null) {
            totalCount += Integer.parseInt(scanner.match().group(1));
        }
        assertEquals(testThreads.length * TestLoggingThread.STOP_WATCH_COUNT, totalCount);
    }

View Full Code Here


   */
  public void ParseReport(File report, String charset, String reportRegEx, List<Warning> warnings) throws java.io.FileNotFoundException {
    Scanner scanner = new Scanner(report, charset);
    Pattern p = Pattern.compile(reportRegEx, Pattern.MULTILINE);
    CxxUtils.LOG.debug("Using pattern : '" + p.toString() + "'");
    while (scanner.findWithinHorizon(p, 0) != null) {
      String filename = scanner.match().group(1);
      String line = scanner.match().group(2);
      String msg = scanner.match().group(3);
      String id = scanner.match().group(4).replaceAll("=$", "");
      CxxUtils.LOG.debug("Scanner-matches file='" + filename + "' line='" + line + "' id='" + id + "' msg=" + msg);
View Full Code Here

   */
  public void ParseReport(File report, String charset, String reportRegEx, List<Warning> warnings) throws java.io.FileNotFoundException {
    Scanner scanner = new Scanner(report, charset);
    Pattern p = Pattern.compile(reportRegEx, Pattern.MULTILINE);
    CxxUtils.LOG.debug("Using pattern : '" + p.toString() + "'");
    while (scanner.findWithinHorizon(p, 0) != null) {
      String filename = scanner.match().group(1);
      String line = scanner.match().group(2);
      String id = scanner.match().group(3);
      String msg = scanner.match().group(4);
      CxxUtils.LOG.debug("Scanner-matches file='" + filename + "' line='" + line + "' id='" + id + "' msg=" + msg);
View Full Code Here

    if (this.ignoreFailures) return false;
    failureCount = 0;
    Scanner resultFileScanner;
    Pattern errorPattern = Pattern.compile(REQUEST_FAILURE_PATTERN);
    resultFileScanner = new Scanner(file);
    while (resultFileScanner.findWithinHorizon(errorPattern, 0) != null) {
      failureCount++;
    }
    resultFileScanner.close();

    return this.failureCount > 0;
View Full Code Here

    public static ParseResult parseExpression(String string) {
        Scanner scanner = new Scanner(string.trim());
        ParseResult parseResult = new ParseResult();

        Pattern p = Pattern.compile("<>|([>|<]?=?)"); //$NON-NLS-1$
        String opToken = scanner.findWithinHorizon(p, 2);
        if (isNotEmpty(opToken)) {
            parseResult.setMatchType(MatchType.parse(opToken));
            while (scanner.hasNext()) {
                parseResult.setValueToMatch(scanner.next());
            }
View Full Code Here

     *      the corresponding {@link ExceptionMessage}, or <code>null</code>
     */
    private static ExceptionMessage parseExceptionMessage( String message )
    {
        Scanner scanner = new Scanner( new ByteArrayInputStream( message.getBytes() ) );
        String foundString = scanner.findWithinHorizon( ".*line (\\d+):(\\d+): *([^\\n]*).*", message.length() );
        if ( foundString != null )
        {
            MatchResult result = scanner.match();
            if ( result.groupCount() == 3 )
            {
View Full Code Here

        }
    }

    public static String stripVersion(String text) {
        Scanner scanner = new Scanner(text);
        String versionNums = scanner.findWithinHorizon("(\\d+)(\\.\\d+)(\\.\\d+)?", 0);
        String version = "";
        if (versionNums != null) {
            MatchResult groups = scanner.match();
            for (int i = 1; i <= groups.groupCount() && groups.group(i) != null; i++) // yes, truly 1-indexed
                version += groups.group(i);
View Full Code Here

        Scanner sc    = new Scanner(pro.getErrorStream());
       
        System.out.println("Empezamos");
       
        Pattern durPattern = Pattern.compile("(?<=Duration: )[^,]*");
        String dur = sc.findWithinHorizon(durPattern, 0);
       
        if (dur == null)
                throw new RuntimeException("No se puede parsear la duración");
        String[] hms = dur.split(":");
       
View Full Code Here

       
        System.out.println("Duración total: " + totalSecs + " segundos");
       
        Pattern timePattern = Pattern.compile("(?<=time=)[\\d.]*");
        String match;
        while (null != (match = sc.findWithinHorizon(timePattern, 0))) {
            double progress = Double.parseDouble(match) / totalSecs;
            System.out.printf("Progreso: %.2f%%%n", progress * 100);
        }
       
        System.out.println("Terminamos");
View Full Code Here

    public void whenFindPatternInHorizon_thenFound() throws IOException {
        final String expectedValue = "world";
        final FileInputStream inputStream = new FileInputStream("src/test/resources/test_read.in");
        final Scanner scanner = new Scanner(inputStream);

        String result = scanner.findWithinHorizon("wo..d", 5);
        assertNull(result);

        result = scanner.findWithinHorizon("wo..d", 100);
        assertEquals(expectedValue, result);
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.