Esempio n. 1
0
  public void unrelateAcrossR301From(Graphelement_c target, boolean notifyChanges) {
    if (target == null) return;

    if (IsSupertypeGraphelement == null) return; // already unrelated

    if (target != IsSupertypeGraphelement) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CanvasPlugin.logError("Tried to unrelate from non-related instance across R301", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR301To(this);
    }

    if (IsSupertypeGraphelement != null) {

      m_elementid = IsSupertypeGraphelement.getElementid();
      if (IdAssigner.NULL_UUID.equals(m_elementid)) {
        m_elementid = IsSupertypeGraphelement.getElementidCachedValue();
      }
      IsSupertypeGraphelement = null;
      target.removeRef();
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_UNRELATED, this, target, "301", "");
        Ooaofgraphics.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
Esempio n. 2
0
  public void unrelateAcrossR39From(DataType_c target, boolean notifyChanges) {
    if (target == null) return;

    if (ContainsDataType == null) return; // already unrelated

    if (target != ContainsDataType) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R39", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR39To(this);
    }

    if (ContainsDataType != null) {

      m_dt_id = ContainsDataType.getDt_id();
      if (IdAssigner.NULL_UUID.equals(m_dt_id)) {
        m_dt_id = ContainsDataType.getDt_idCachedValue();
      }
      ContainsDataType = null;
      target.removeRef();
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_UNRELATED, this, target, "39", "");
        Ooaofooa.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
Esempio n. 3
0
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Data Type in Package.dispose call: ";
    DataType_c testR39Inst = DataType_c.getOneS_DTOnR39(this, false);

    if (testR39Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "39 ";
    }

    DataTypePackage_c testR39InstOth = DataTypePackage_c.getOneS_DPKOnR39(this, false);

    if (testR39InstOth != null) {
      delete_error = true;
      errorMsg = errorMsg + "39 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Data Type in Package", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Assign to Member.dispose call: ";
    Value_c testR609Inst = Value_c.getOneV_VALOnR609(this, false);

    if (testR609Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "609 ";
    }
    Value_c testR689Inst = Value_c.getOneV_VALOnR689(this, false);

    if (testR689Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "689 ";
    }
    Statement_c testR603Inst11 = Statement_c.getOneACT_SMTOnR603(this, false);

    if (testR603Inst11 != null) {
      delete_error = true;
      errorMsg = errorMsg + "603 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Assign to Member", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Component in Component.dispose call: ";
    Component_c testR4202Inst = Component_c.getOneC_COnR4202(this, false);

    if (testR4202Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "4202 ";
    }
    Component_c testR4203Inst = Component_c.getOneC_COnR4203(this, false);

    if (testR4203Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "4203 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Component in Component", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Bridge Invocation.dispose call: ";
    ActualParameter_c testR628Inst = ActualParameter_c.getOneV_PAROnR628(this, false);

    if (testR628Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "628 ";
    }
    Statement_c testR603Inst7 = Statement_c.getOneACT_SMTOnR603(this, false);

    if (testR603Inst7 != null) {
      delete_error = true;
      errorMsg = errorMsg + "603 ";
    }
    Bridge_c testR674Inst = Bridge_c.getOneS_BRGOnR674(this, false);

    if (testR674Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "674 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Bridge Invocation", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
Esempio n. 7
0
  public void unrelateAcrossR1013From(MessageArgument_c target, boolean notifyChanges) {
    if (target == null) return;

    if (IsSupertypeMessageArgument == null) return; // already unrelated

    if (target != IsSupertypeMessageArgument) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R1013", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR1013To(this);
    }

    if (IsSupertypeMessageArgument != null) {

      m_arg_id = IsSupertypeMessageArgument.getArg_id();
      IsSupertypeMessageArgument = null;
      target.removeRef();
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_UNRELATED, this, target, "1013", "");
        Ooaofooa.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Transient Value Reference.dispose call: ";
    Variable_c testR805Inst = Variable_c.getOneV_VAROnR805(this, false);

    if (testR805Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "805 ";
    }
    Value_c testR801Inst13 = Value_c.getOneV_VALOnR801(this, false);

    if (testR801Inst13 != null) {
      delete_error = true;
      errorMsg = errorMsg + "801 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Transient Value Reference", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Instance State Machine.dispose call: ";
    ModelClass_c testR518Inst = ModelClass_c.getOneO_OBJOnR518(this, false);

    if (testR518Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "518 ";
    }
    StateMachine_c testR517Inst1 = StateMachine_c.getOneSM_SMOnR517(this, false);

    if (testR517Inst1 != null) {
      delete_error = true;
      errorMsg = errorMsg + "517 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Instance State Machine", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public void unrelateAcrossR518From(ModelClass_c target, boolean notifyChanges) {
    if (target == null) return;

    if (ModelClass == null) return; // already unrelated

    if (target != ModelClass) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R518", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR518To(this);
    }

    if (ModelClass != null) {

      m_obj_id = ModelClass.getObj_id();
      if (IdAssigner.NULL_UUID.equals(m_obj_id)) {
        m_obj_id = ModelClass.getObj_idCachedValue();
      }
      ModelClass = null;
      target.removeRef();
      UmlProblem.removeXtUMLProblem(this, target);
      if (notifyChanges) {
        RelationshipChangeModelDelta change =
            new RelationshipChangeModelDelta(
                Modeleventnotification_c.DELTA_ELEMENT_UNRELATED, this, target, "518", "");
        Ooaofooa.getDefaultInstance().fireModelElementRelationChanged(change);
      }
    }
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Element In Move.dispose call: ";
    GraphicalElement_c testR25Inst = GraphicalElement_c.getOneGD_GEOnR25(this, false);

    if (testR25Inst != null) {
      delete_error = true;
      errorMsg = errorMsg + "25 ";
    }

    Model_c testR25InstOth = Model_c.getOneGD_MDOnR25(this, false);

    if (testR25InstOth != null) {
      delete_error = true;
      errorMsg = errorMsg + "25 ";
    }
    if (delete_error == true) {

      if (CanvasPlugin.getDefault().isDebugging()) {
        Ooaofgraphics.log.println(ILogger.DELETE, "Element In Move", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CanvasPlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
Esempio n. 12
0
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the GraphNode.dispose call: ";
    Graphelement_c testR301Inst1 = Graphelement_c.getOneDIM_GEOnR301(this, false);

    if (testR301Inst1 != null) {
      delete_error = true;
      errorMsg = errorMsg + "301 ";
    }
    Shape_c testR19Inst1 = Shape_c.getOneGD_SHPOnR19(this, false);

    if (testR19Inst1 != null) {
      delete_error = true;
      errorMsg = errorMsg + "19 ";
    }
    FloatingText_c testR19Inst2 = FloatingText_c.getOneGD_CTXTOnR19(this, false);

    if (testR19Inst2 != null) {
      delete_error = true;
      errorMsg = errorMsg + "19 ";
    }
    if (delete_error == true) {

      if (CanvasPlugin.getDefault().isDebugging()) {
        Ooaofgraphics.log.println(ILogger.DELETE, "GraphNode", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CanvasPlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public void unrelateAcrossR603From(Statement_c target, boolean notifyChanges) {
    if (target == null) return;

    if (IsSupertypeStatement == null) return; // already unrelated

    if (target != IsSupertypeStatement) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R603", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR603To(this);
    }

    if (IsSupertypeStatement != null) {

      m_statement_id = IsSupertypeStatement.getStatement_id();
      IsSupertypeStatement = null;
      target.removeRef();
    }
  }
  public void unrelateAcrossR805From(Variable_c target, boolean notifyChanges) {
    if (target == null) return;

    if (ReferencesVariable == null) return; // already unrelated

    if (target != ReferencesVariable) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R805", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR805To(this);
    }

    if (ReferencesVariable != null) {

      m_var_id = ReferencesVariable.getVar_id();
      ReferencesVariable = null;
      target.removeRef();
    }
  }
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Description Query.dispose call: ";
    Query_c testR9600Inst3 = Query_c.getOneSQU_QOnR9600(this, false);

    if (testR9600Inst3 != null) {
      delete_error = true;
      errorMsg = errorMsg + "9600 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Description Query", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public void unrelateAcrossR689From(Value_c target, boolean notifyChanges) {
    if (target == null) return;

    if (WritesValue == null) return; // already unrelated

    if (target != WritesValue) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R689", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR689To(this);
    }

    if (WritesValue != null) {

      m_l_value_id = WritesValue.getValue_id();
      WritesValue = null;
      target.removeRef();
    }
  }
Esempio n. 17
0
  public boolean delete() {
    boolean result = super.delete();
    boolean delete_error = false;
    String errorMsg =
        "The following relationships were not torn down by the Informal Argument.dispose call: ";
    MessageArgument_c testR1013Inst5 = MessageArgument_c.getOneMSG_AOnR1013(this, false);

    if (testR1013Inst5 != null) {
      delete_error = true;
      errorMsg = errorMsg + "1013 ";
    }
    if (delete_error == true) {

      if (CorePlugin.getDefault().isDebugging()) {
        Ooaofooa.log.println(ILogger.DELETE, "Informal Argument", errorMsg);
      } else {
        Exception e = new Exception();
        e.fillInStackTrace();
        CorePlugin.logError(errorMsg, e);
      }
    }
    return result;
  }
  public void unrelateAcrossR674From(Bridge_c target, boolean notifyChanges) {
    if (target == null) return;

    if (IsAnInvocationOfBridge == null) return; // already unrelated

    if (target != IsAnInvocationOfBridge) {
      Exception e = new Exception();
      e.fillInStackTrace();
      CorePlugin.logError("Tried to unrelate from non-related instance across R674", e);
      return;
    }

    if (target != null) {
      target.clearBackPointerR674To(this);
    }

    if (IsAnInvocationOfBridge != null) {

      m_brg_id = IsAnInvocationOfBridge.getBrg_id();
      IsAnInvocationOfBridge = null;
      target.removeRef();
    }
  }
  /** Called by the sax parser when the start of an element is encountered. */
  public void startElement(String nameSpaceURI, String local, String name, Attributes attrs)
      throws SAXException {
    try {
      Debug.println("processing " + name);
      if (name.compareTo(TagNames.CALLFLOW) == 0) {
        callFlow = new CallFlow();
        callFlow.instantiateOn = attrs.getValue(Attr.instantiateOn);
        callFlow.description = attrs.getValue(Attr.description);

      } else if (name.compareTo(TagNames.AGENT) == 0) {
        Agent agent = new Agent();
        agent.agentId = attrs.getValue(Attr.agentId);
        agent.userName = attrs.getValue(Attr.userName);
        agent.requestURI = attrs.getValue(Attr.requestURI);
        agent.host = attrs.getValue(Attr.host);
        agent.contactPort = attrs.getValue(Attr.contactPort);
        agent.contactHost = attrs.getValue(Attr.contactHost);
        addAgent(agent);
      } else if (name.compareTo(TagNames.EXPECT) == 0) {
        // Make sure there are no unexpected attributes.
        for (int i = 0; i < attrs.getLength(); i++) {
          String attrname = attrs.getLocalName(i);
          if (attrname.equals(Attr.enablingEvent)
              || attrname.equals(Attr.triggerMessage)
              || attrname.equals(Attr.generatedEvent)
              || attrname.equals(Attr.nodeId)
              || attrname.equals(Attr.onTrigger)
              || attrname.equals(Attr.onCompletion)) continue;
          else
            throw new SAXException(
                "Unkown attribute in expect: nodeId = "
                    + attrs.getValue(Attr.nodeId)
                    + " attribute name =  "
                    + attrname);
        }
        String enablingEvent = attrs.getValue(Attr.enablingEvent);
        String triggerMessage = attrs.getValue(Attr.triggerMessage);
        String generatedEvent = attrs.getValue(Attr.generatedEvent);
        String nodeId = attrs.getValue(Attr.nodeId);
        currentExpectNode = new Expect(callFlow, enablingEvent, generatedEvent, triggerMessage);
        String onTrigger = attrs.getValue(Attr.onTrigger);
        String onCompletion = attrs.getValue(Attr.onCompletion);
        currentExpectNode.onTrigger = onTrigger;
        currentExpectNode.onCompletion = onCompletion;
        currentExpectNode.nodeId = nodeId;
      } else if (name.compareTo(TagNames.SIP_REQUEST) == 0) {
        if (this.messageTemplateContext) {
          // This is a SIPRequest template node.
          for (int i = 0; i < attrs.getLength(); i++) {
            String attrname = attrs.getLocalName(i);
            if (!attrs.getLocalName(i).equals(Attr.templateId))
              throw new SAXException(
                  "Unkown attribute in SIP_REQUEST node " + " attribute name =  " + attrname);
          }
          messageTemplate = new SIPRequest();
          id = attrs.getValue(Attr.templateId);
          jythonCode = null;
        }
      } else if (name.compareTo(TagNames.SIP_RESPONSE) == 0) {
        if (this.messageTemplateContext) {
          messageTemplate = new SIPResponse();
          jythonCode = null;
          for (int i = 0; i < attrs.getLength(); i++) {
            String attrname = attrs.getLocalName(i);
            if (!attrs.getLocalName(i).equals(Attr.templateId))
              throw new SAXException(
                  "Unkown attribute in SIP_REQUEST node " + " attribute name =  " + attrname);
          }
          id = attrs.getValue(Attr.templateId);
        }
      } else if (name.compareTo(TagNames.STATUS_LINE) == 0) {
        String scode = attrs.getValue(Attr.statusCode);
        if (messageTemplateContext) {
          StatusLine statusLine = new StatusLine();
          try {
            int statusCode = Integer.parseInt(scode);
            statusLine.setStatusCode(statusCode);
          } catch (NumberFormatException ex) {
            throw new SAXException(ex.getMessage());
          }
          SIPResponse response = (SIPResponse) this.messageTemplate;
          response.setStatusLine(statusLine);
        } else {
          int statusCode = Integer.parseInt(scode);
          generatedMessage.addStatusLine(statusCode);
        }
      } else if (name.compareTo(TagNames.REQUEST_LINE) == 0) {
        String method = attrs.getValue(Attr.method);
        Debug.println("tagname = " + TagNames.REQUEST_LINE);
        Debug.println("messageTemplateContext = " + messageTemplateContext);
        if (messageTemplateContext) {
          for (int i = 0; i < attrs.getLength(); i++) {
            String attrname = attrs.getLocalName(i);
            if (attrs.getLocalName(i).equals(Attr.requestURI)
                || attrs.getLocalName(i).equals(Attr.method)) continue;
            else
              throw new SAXException(
                  "Unkown attribute in REQUEST_LINE node " + " attribute name =  " + attrname);
          }
          requestLine = new RequestLine();
          requestLine.setMethod(method);
          String requestURI = attrs.getValue(Attr.requestURI);
          StringMsgParser smp = new StringMsgParser();
          if (requestURI != null) {
            try {
              URI uri = smp.parseSIPUrl(requestURI);
              requestLine.setUri(uri);
            } catch (SIPParseException e) {
              throw new SAXException("Bad URL " + requestURI);
            }
          }
          SIPRequest request = (SIPRequest) messageTemplate;
          request.setRequestLine(requestLine);
        } else {
          for (int i = 0; i < attrs.getLength(); i++) {
            String attrname = attrs.getLocalName(i);
            if (attrs.getLocalName(i).equals(Attr.method)
                || attrs.getLocalName(i).equals(Attr.templateId)
                || attrs.getLocalName(i).equals(Attr.agentId)) continue;
            else
              throw new SAXException(
                  "Unkown attribute in REQUEST_LINE node " + " attribute name =  " + attrname);
          }
          String requestURI = attrs.getValue(Attr.requestURI);
          if (requestURI == null) {
            String agentId = attrs.getValue(Attr.agentId);
            if (agentId != null) {
              Agent agent = getAgent(agentId);
              if (agent == null) throw new SAXException("Missing requestURI or agent attribute");
              requestURI = agent.requestURI;
            }
          }
          generatedMessage.addRequestLine(method, requestURI);
        }
      } else if (name.compareTo(TagNames.FROM) == 0) {
        for (int i = 0; i < attrs.getLength(); i++) {
          String attrname = attrs.getLocalName(i);
          if (attrs.getLocalName(i).equals(Attr.displayName)
              || attrs.getLocalName(i).equals(Attr.userName)
              || attrs.getLocalName(i).equals(Attr.host)
              || attrs.getLocalName(i).equals(Attr.agentId)) continue;
          else
            throw new SAXException(
                "Unkown attribute in FROM node " + " attribute name =  " + attrname);
        }
        String displayName = attrs.getValue(Attr.displayName);
        String userName = attrs.getValue(Attr.userName);
        String hostName = attrs.getValue(Attr.host);
        String agentId = attrs.getValue(Attr.agentId);
        if (agentId != null) {
          Agent agent = getAgent(agentId);
          if (agent == null) throw new SAXException("agent not found " + agentId);
          if (displayName == null) displayName = agent.displayName;
          if (userName == null) userName = agent.userName;
          if (hostName == null) hostName = agent.host;
        }

        if (this.messageTemplateContext) {
          From from = new From();
          Address address = new Address();
          address.setDisplayName(displayName);
          URI uri = new URI();
          Host host = new Host();
          host.setHostname(hostName);
          uri.setHost(host);
          uri.setUser(userName);
          address.setAddrSpec(uri);
          from.setAddress(address);
          try {
            messageTemplate.attachHeader(from, false);
          } catch (SIPDuplicateHeaderException ex) {
            throw new SAXException(ex.getMessage());
          }
        } else {
          generatedMessage.addFromHeader(displayName, userName, hostName);
        }

      } else if (name.compareTo(TagNames.TO) == 0) {
        for (int i = 0; i < attrs.getLength(); i++) {
          String attrname = attrs.getLocalName(i);
          if (attrs.getLocalName(i).equals(Attr.templateId)
              || attrs.getLocalName(i).equals(Attr.host)
              || attrs.getLocalName(i).equals(Attr.agentId)
              || attrs.getLocalName(i).equals(Attr.userName)) continue;
          else
            throw new SAXException(
                "Unkown attribute in FROM node " + " attribute name =  " + attrname);
        }
        String displayName = attrs.getValue(Attr.displayName);
        String userName = attrs.getValue(Attr.userName);
        String hostName = attrs.getValue(Attr.host);
        String agentId = attrs.getValue(Attr.agentId);
        if (agentId != null) {
          Agent agent = getAgent(agentId);
          if (agent == null) throw new SAXException("agent not found " + agentId);
          if (displayName == null) displayName = agent.displayName;
          if (userName == null) userName = agent.userName;
          if (hostName == null) hostName = agent.host;
        }
        if (this.messageTemplateContext) {
          To to = new To();
          Address address = new Address();
          address.setDisplayName(displayName);
          URI uri = new URI();
          Host host = new Host();
          host.setHostname(hostName);
          uri.setHost(host);
          uri.setUser(userName);
          address.setAddrSpec(uri);
          to.setAddress(address);
          try {
            messageTemplate.attachHeader(to, false);
          } catch (SIPDuplicateHeaderException ex) {
            throw new SAXException(ex.getMessage());
          }
        } else {
          generatedMessage.addToHeader(displayName, userName, hostName);
        }
      } else if (name.compareTo(TagNames.CALLID) == 0) {
        String lid = attrs.getValue(Attr.localId);
        String host = attrs.getValue(Attr.host);
        if (this.messageTemplateContext) {
          CallID cid = new CallID();
          CallIdentifier cidf = new CallIdentifier(lid, host);
          cid.setCallIdentifier(cidf);
        } else {
          generatedMessage.addCallIdHeader();
        }
      } else if (name.compareTo(TagNames.CONTACT) == 0) {
        for (int i = 0; i < attrs.getLength(); i++) {
          String attrname = attrs.getLocalName(i);
          if (attrs.getLocalName(i).equals(Attr.displayName)
              || attrs.getLocalName(i).equals(Attr.userName)
              || attrs.getLocalName(i).equals(Attr.action)
              || attrs.getLocalName(i).equals(Attr.contactHost)
              || attrs.getLocalName(i).equals(Attr.contactPort)
              || attrs.getLocalName(i).equals(Attr.agentId)
              || attrs.getLocalName(i).equals(Attr.expires)) continue;
          else
            throw new SAXException(
                "Unkown attribute in CONTACT node " + " attribute name =  " + attrname);
        }
        String displayName = attrs.getValue(Attr.displayName);
        String userName = attrs.getValue(Attr.userName);
        String hostName = attrs.getValue(Attr.contactHost);
        String portString = attrs.getValue(Attr.contactPort);
        String expiryTimeString = attrs.getValue(Attr.expires);
        String action = attrs.getValue(Attr.action);
        String agentId = attrs.getValue(Attr.agentId);
        if (action == null) action = "proxy";
        if (agentId != null) {
          Agent agent = getAgent(agentId);
          if (displayName == null) displayName = agent.displayName;
          if (userName == null) userName = agent.userName;
          if (hostName == null) hostName = agent.contactHost;
          if (portString == null) portString = agent.contactPort;
        }

        if (this.messageTemplateContext) {
          // Generating a message template for the expires header.
          ContactList clist = new ContactList();
          Contact contact = new Contact();
          clist.add(contact);
          URI uri = new URI();
          Host host = new Host();
          host.setHostname(hostName);
          uri.setHost(host);
          uri.setUser(userName);

          if (portString != null) {
            int port = new Integer(portString).intValue();
            uri.setPort(port);
          }
          Address address = new Address();
          address.setAddrSpec(uri);
          contact.setAddress(address);
          if (expiryTimeString != null) {
            long expiryTimeSec = new Long(expiryTimeString).longValue();
            contact.setExpires(expiryTimeSec);
          }
          messageTemplate.attachHeader(clist, false);

        } else {
          int port = 5060;
          if (portString != null) port = new Integer(portString).intValue();
          long expiryTimeSec = 3600;
          if (expiryTimeString != null) {
            expiryTimeSec = new Long(expiryTimeString).longValue();
          }
          if (userName == null) throw new Exception("Missing attribute userName");
          if (action == null) action = Attr.proxy;
          String uri;
          if (hostName == null) {
            uri =
                SIPKeywords.SIP
                    + Separators.COLON
                    + userName
                    + Separators.AT
                    + EventEngine.theStack.getHostAddress()
                    + Separators.COLON
                    + EventEngine.theStack.getDefaultPort()
                    + Separators.SEMICOLON
                    + SIPKeywords.TRANSPORT
                    + Separators.EQUALS
                    + EventEngine.theStack.getDefaultTransport();
          } else
            uri =
                SIPKeywords.SIP
                    + Separators.COLON
                    + userName
                    + Separators.AT
                    + hostName
                    + ":"
                    + port;
          generatedMessage.addContactHeader(displayName, uri, expiryTimeSec, action);
        }

      } else if (name.compareTo(TagNames.GENERATE) == 0) {
        generateContext = true;

        if (currentExpectNode == null) {
          throw new SAXException("Bad element nesting.");
        }
        String id = attrs.getValue(Attr.messageId);
        String retransmit = attrs.getValue(Attr.retransmit);
        String delayString = attrs.getValue(Attr.delay);
        int delay = 0;
        if (delayString != null) {
          try {
            delay = Integer.parseInt(delayString);
          } catch (NumberFormatException ex) {
            throw new SAXException("Bad integer value " + delayString);
          }
        }

        generatedMessage = new GeneratedMessage(id, callFlow, currentExpectNode, retransmit);
        generatedMessage.delay = delay;
        currentExpectNode.addGeneratedMessage(generatedMessage);
      } else if (name.compareTo(TagNames.MESSAGE_TEMPLATES) == 0) {
        messageTemplateContext = true;
      } else if (name.compareTo(TagNames.JYTHON_CODE) == 0) {
        this.jythonCode = null;
      } else if (name.compareTo(TagNames.STATE_MACHINE) == 0) {
      } else if (name.compareTo(TagNames.AGENTS) == 0) {
      } else {
        throw new SAXException("Unkown tag " + name);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      ex.fillInStackTrace();
      throw new SAXException(ex.getMessage());
    }
  }