コード例 #1
0
  public static void test1()
      throws ParException, EvaluationException, ConfigurationException, FilterException,
          IOException {
    logger.info("\n\t>>>>>>>>>>>>>>>>> test1 create a LineImageFilter");

    // line 3: abcdef gh "@@ @@ @@ @@@" - ab cd ef gh line 3
    // line 14: DESVAR, 2, 2.0  - "DESVAR, ## , ####" - DESVAR, 2 , 2.0

    LineImageFilter lif =
        new LineImageFilter(
            new File(
                new File("..").getCanonicalPath()
                    + File.separator
                    + "data"
                    + File.separator
                    + "paramTest.dat"),
            "DESVAR, ## , ####",
            4,
            14);

    Var x1 = new Var("x1");
    x1.setFilter(lif);

    System.out.println("x1 value:\n" + x1.getValue());
  }
コード例 #2
0
  public static void test2()
      throws ParException, EvaluationException, ConfigurationException, FilterException,
          IOException {
    logger.info("\n\t>>>>>>>>>>>>>>>>> test2 create a FileFilter/RegexGroupFilter");

    // line 3: abcdef gh "@@ @@ @@ @@@" - ab cd ef gh line 3
    // line 14: DESVAR, 2, 2.0 - "DESVAR, ## , ####" - DESVAR, 2 , 2.0

    FileFilter ff =
        new FileFilter(
            new File(
                new File("..").getCanonicalPath()
                    + File.separator
                    + "data"
                    + File.separator
                    + "paramTest.dat"));
    // "DESVAR,\\s(\\d+),\\s(\\d+.\\d*)"
    // DESVAR, 0, 0.0
    // DESVAR, 1, 1.0
    // DESVAR, 2, 2.0
    // DESVAR, 3, 3.0

    RegexGroupFilter rgf = new RegexGroupFilter("DESVAR,\\s(\\d+),\\s(\\d+.\\d*)", 2, 14);
    ff.setTextFilter(rgf);

    Var x1 = new Var("x1");
    x1.setFilter(ff);

    System.out.println("x1 value:\n" + x1.getValue());
  }
コード例 #3
0
  public static void test4()
      throws ParException, EvaluationException, ConfigurationException, FilterException,
          IOException {
    logger.info("\n\t>>>>>>>>>>>>>>>>> test4 create a FileFilter/LineSplitFilter");

    // line 3: abcdef gh "@@ @@ @@ @@@" - ab cd ef gh line 3
    // line 14: DESVAR, 2, 2.0 - "DESVAR, ## , ####" - DESVAR, 2 , 2.0

    FileFilter ff =
        new FileFilter(
            new File(
                new File("..").getCanonicalPath()
                    + File.separator
                    + "data"
                    + File.separator
                    + "paramTest.dat"));
    // "\\d+\\.{0,1}\\d*" - matches: [DESVAR, 2, 2.0]
    // DESVAR, 0, 0.0
    // DESVAR, 1, 1.0
    // DESVAR, 2, 2.0
    // DESVAR, 3, 3.0

    LineSplitFilter lsf = new LineSplitFilter(",\\s", 2, 14);
    ff.setTextFilter(lsf);

    Var x1 = new Var("x1");
    x1.setFilter(ff);

    System.out.println("x1 value:\n" + x1.getValue());
  }