newResponse = new SIPResponse(); try { newResponse.setStatusCode(statusCode); } catch (ParseException ex) { throw new IllegalArgumentException("Bad code " + statusCode); } if (reasonPhrase != null) newResponse.setReasonPhrase(reasonPhrase); else newResponse .setReasonPhrase(SIPResponse.getReasonPhrase(statusCode)); headerIterator = getHeaders(); while (headerIterator.hasNext()) { nextHeader = (SIPHeader) headerIterator.next(); if (nextHeader instanceof From || nextHeader instanceof To || nextHeader instanceof ViaList || nextHeader instanceof CallID || (statusCode / 100 <= 2 && statusCode / 100 > 1 && nextHeader instanceof RecordRouteList)  || nextHeader instanceof CSeq  ||  nextHeader instanceof TimeStamp) {
String reasonPhrase = SIPResponse.getReasonPhrase(statusCode); return this.createResponse(statusCode, reasonPhrase);
	public SIPResponse createResponse(int statusCode, String reasonPhrase) {		SIPResponse newResponse;		Iterator headerIterator;		SIPHeader nextHeader;		newResponse = new SIPResponse();		try {			newResponse.setStatusCode(statusCode);		} catch (ParseException ex) {			throw new IllegalArgumentException("Bad code " + statusCode);		}		if (reasonPhrase != null)			newResponse.setReasonPhrase(reasonPhrase);		else			newResponse					.setReasonPhrase(SIPResponse.getReasonPhrase(statusCode));		headerIterator = getHeaders();		while (headerIterator.hasNext()) {			nextHeader = (SIPHeader) headerIterator.next();			if (nextHeader instanceof From					|| nextHeader instanceof To					|| nextHeader instanceof ViaList					|| nextHeader instanceof CallID					|| (statusCode / 100 <= 2 && statusCode / 100 > 1 && 						nextHeader instanceof RecordRouteList)					// No record routing for error and 100					|| nextHeader instanceof CSeq					// We just copy TimeStamp for all headers (not just 100).					||  nextHeader instanceof TimeStamp) {				try {										newResponse.attachHeader((SIPHeader) nextHeader.clone(),							false);				} catch (SIPDuplicateHeaderException e) {					e.printStackTrace();				}			}		}		if (newResponse.getStatusCode() == 100) {			// Trying is never supposed to have the tag parameter set.			newResponse.getTo().removeParameter("tag");		}		return newResponse;	}