Ejemplo n.º 1
0
  public static void main(String args[]) throws ParseException {
    String to[] = {
      "Replaces: 12345th5z8z\n",
      "Replaces: 12345th5z8z;to-tag=tozght6-45;from-tag=fromzght789-337-2\n",
    };

    for (int i = 0; i < to.length; i++) {
      ReplacesParser tp = new ReplacesParser(to[i]);
      Replaces t = (Replaces) tp.parse();
      System.out.println("Parsing => " + to[i]);
      System.out.print("encoded = " + t.encode() + "==> ");
      System.out.println(
          "callId " + t.getCallId() + " from-tag=" + t.getFromTag() + " to-tag=" + t.getToTag());
    }
  }
Ejemplo n.º 2
0
  /**
   * parse the String message
   *
   * @return SIPHeader (CallID object)
   * @throws ParseException if the message does not respect the spec.
   */
  public SIPHeader parse() throws ParseException {
    if (debug) dbg_enter("parse");
    try {
      headerName(TokenTypes.REPLACES_TO);

      Replaces replaces = new Replaces();
      this.lexer.SPorHT();
      String callId = lexer.byteStringNoSemicolon();
      this.lexer.SPorHT();
      super.parse(replaces);
      replaces.setCallId(callId);
      return replaces;
    } finally {
      if (debug) dbg_leave("parse");
    }
  }