public synchronized void addRoute(SIPMessage sipMessage) {   try { if (LogWriter.needsLogging) { sipStack.logWriter.logMessage("addRoute: dialogState: " + this + "state = " + this.getState());
private void addRoute(RecordRouteList recordRouteList) { if (this.isClientDialog()) {    this.routeList = new RouteList();  ListIterator li = recordRouteList.listIterator(recordRouteList .size()); while (li.hasPrevious()) { RecordRoute rr = (RecordRoute) li.previous(); AddressImpl addr = (AddressImpl) rr.getAddress(); Route route = new Route(); route.setAddress((AddressImpl) ((AddressImpl) rr.getAddress()) .clone()); route.setParameters((NameValueList) rr.getParameters().clone()); this.routeList.add(route);
    public synchronized void addRoute(SIPMessage sipMessage) {        // cannot add route list after the dialog is initialized.        try {            if (LogWriter.needsLogging) {                sipStack.logWriter.logMessage("addRoute: dialogState: " + this                        + "state = " + this.getState());            }            if (this.dialogState == CONFIRMED_STATE                    || this.dialogState == COMPLETED_STATE                    || this.dialogState == TERMINATED_STATE)                return;            if (!isServer()) {                // I am CLIENT dialog.                if (sipMessage instanceof SIPResponse) {                    SIPResponse sipResponse = (SIPResponse) sipMessage;                    if (sipResponse.getStatusCode() == 100) {                        // Do nothing for trying messages.                        return;                    }                    RecordRouteList rrlist = sipMessage.getRecordRouteHeaders();                    // Add the route set from the incoming response in reverse                    // order                    if (rrlist != null) {                        this.addRoute(rrlist);                    } else {                        // Set the rotue list to the last seen route list.                        this.routeList = new RouteList();                    }                    ContactList contactList = sipMessage.getContactHeaders();                    if (contactList != null) {                        this.addRoute(contactList);                    }                }            } else {                if (sipMessage instanceof SIPRequest) {                    // Incoming Request has the route list                    RecordRouteList rrlist = sipMessage.getRecordRouteHeaders();                    // Add the route set from the incoming response in reverse                    // order                    if (rrlist != null) {                        this.addRoute(rrlist);                    } else {                        // Set the rotue list to the last seen route list.                        this.routeList = new RouteList();                    }                    // put the contact header from the incoming request into                    // the route set.                    ContactList contactList = sipMessage.getContactHeaders();                    if (contactList != null) {                        this.addRoute(contactList);                    }                }            }        } finally {            if (LogWriter.needsLogging) {                sipStack.logWriter.logStackTrace();                sipStack.logWriter                        .logMessage("added a route = " + routeList.encode()                                + "contactRoute = " + contactRoute);            }        }    }