Package net.sf.jmatchparser.template

Examples of net.sf.jmatchparser.template.Parser


    if (ps == null) {
      ps = new MatchTemplate(PDARoundtripParser.class, "templates/" + template + ".jmt", "ISO-8859-1");
      ps.enableCoveredStatementsTracing();
      cachedScripts.put(template, ps);
    }
    Parser p = new Parser(ps);
    p.setLocal("lastupdate", lastupdate);
    for (int i = 0; i < extra.length; i += 2) {
      p.setLocal(extra[i], extra[i + 1]);
    }
    return p.parse(new FileInputStream(new File(dir, file)), "windows-1252", unmarshaller, resultClass);
  }
View Full Code Here


        if (!fileName.equals("SubFile"))
          throw new FileNotFoundException(fileName);
        return new BufferedReader(new StringReader(subtemplate));
      }
    }, "UnitTest", new BufferedReader(new StringReader(template)), new Formatter[0]);
    new Parser(tmpl).parse("abbc\n", "x");
  }
View Full Code Here

  }

  @Test
  public void testTemplateSources() throws Exception {
    try {
      new Parser(PlainMatchTemplateTests.class, "/META-INF/services/java.nio.charset.spi.CharsetProvider", "ISO-8859-1");
      Assert.fail();
    } catch (RuntimeException ex) {
      Assert.assertEquals("Cannot parse line:\n" +
          "  [java.nio.charset.spi.CharsetProvider:2]  sun.nio.cs.ext.ExtendedCharsets", ex.getMessage());
    }
    String filename = "build/1.jmf";
    new File("build").mkdirs();
    FileOutputStream fos = new FileOutputStream(filename);
    fos.write("ML X\r\n".getBytes());
    new Parser(filename, "ISO-8859-1").parse("X\n", "ignored");
    new Parser(null, "UnitTest", new BufferedReader(new StringReader("ML X\r\n"))).parse("X\n", "ignored");
    try {
      PlainMatchTemplateImpl.createTemplateImpl("nonsense", null, null, null, null);
    } catch (IllegalArgumentException ex) {
      Assert.assertEquals("Unsupported match template language!", ex.getMessage());
    }
View Full Code Here

    assertTemplateMatches(text, template, "<x/>");
  }

  public static void assertTemplateMatches(String text, String template, String resultXml) throws IOException, ParserException, ParserConfigurationException, TransformerException {
    MatchTemplate tmpl = new MatchTemplate("plain", null, "UnitTest", new BufferedReader(new StringReader(template)), new Formatter[0]);
    Document doc = new Parser(tmpl).parse(text, "x");
    Assert.assertEquals(resultXml, ParameterTests.xmlToString(doc));
  }
View Full Code Here

TOP

Related Classes of net.sf.jmatchparser.template.Parser

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.