Exemplo n.º 1
0
  public static void main(String args[]) {
    Debug.enableAll();

    String input;
    String pattern;
    String result = null;
    String replacement;

    Perl5Util util = new Perl5Util();

    System.out.println("\nThis example performs ampersand replacement: & -> &amp");
    input =
        "<ILEC value=\"I have &0.>and &2<ILEC value=\"I have &1.\"/><ILEC value=\"I have &3.\"/>";

    String beginToken = "value=\"";
    String endToken = "\"/>";
    pattern = "&";
    replacement = "&amp";
    System.out.println("input = " + input);
    System.out.println("pattern = " + pattern);
    System.out.println("replacement = " + replacement);
    System.out.println("beginToken = " + beginToken);
    System.out.println("endToken = " + endToken);
    try {
      result = replaceAll(pattern, input, replacement, beginToken, endToken);
    } catch (FrameworkException e) {
    }
    System.out.println("main: result = " + result);

    System.out.println("\nThis example performs the bound replacement.");
    String patterns[] = {"\"", "'", "<", ">", "&"};
    String replacements[] = {"&quot", "&apos", "&lt", "&gt", "&amp"};
    beginToken = "name=\"";
    endToken = "/test_2>";
    input =
        "<Test0 value=\"I am \"string\" and I got <'>.\"/><Test1 value=\"I am another with &.\"/>";

    System.out.println("input = " + input);
    System.out.println("beginToken = " + beginToken);
    System.out.println("endToken = " + endToken);
    try {
      result = replaceAll(patterns, input, replacements, beginToken, endToken);
    } catch (FrameworkException e) {
    }
    System.out.println("\n\n\ndriver main: final result = " + result);

    return;
  } // main
Exemplo n.º 2
0
  public static void main(String[] args) {
    Debug.enableAll();
    String HEADER =
        "<HEADER>"
            + "<REQUEST value=\"LSR_ORDER\"/>"
            + "<SUB_REQUEST value=\"loop\"/>"
            + "<SUPPLIER value=\"VZE\"/>"
            + "</HEADER>";
    RequestHandlerClient sr = null;

    try {
      String xml = FileUtils.readFile(args[0]);
      MessageProcessorContext ctx = new MessageProcessorContext();
      ctx.set("NF_HEADER_LOCATION_PROP", HEADER);
      sr = new RequestHandlerClient();
      sr.serverName = "Nightfire.Router";
      NVPair[] result = sr.process(ctx, new MessageObject((Object) xml));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }