예제 #1
0
  @Override
  protected void execute() {
    String find = ""; // Default empty string
    Packet pfind = findport.receive();
    if (pfind != null) {
      find = (String) pfind.getContent();
      drop(pfind);
    }
    findport.close();

    String repl = " "; // Default empty string
    Packet prepl = replport.receive();
    if (prepl != null) {
      repl = (String) prepl.getContent();
      drop(prepl);
    }
    replport.close();

    Packet pin;
    while ((pin = inport.receive()) != null) {
      String out = "";
      String in = (String) pin.getContent();
      out = in.replaceAll(find, repl);
      drop(pin);

      Packet pout = create(out);
      outport.send(pout);
    }
  }
예제 #2
0
 @Override
 protected void execute() {
   Packet p;
   outport.send(create("1"));
   int i = 10000;
   while ((p = inport.receive()) != null) {
     if (i-- == 0) {
       drop(p);
       outport.close();
       break;
     }
     outport.send(p);
   }
 }
예제 #3
0
  @Override
  protected void execute() {

    Packet p;
    while ((p = _inport.receive()) != null) {
      String text = (String) p.getContent();

      String[] parts = text.split(",");
      String note = parts[0].trim();
      String duration = parts[1].trim();
      int[] intArray = {Integer.parseInt(note), Integer.parseInt(duration)};
      drop(p);
      _outport.send(create(intArray));
    }
  }