Fields Summary |
---|
public static Class | clazzClass handle. |
public static final String | NAMEVia header field label. |
public static final String | BRANCHThe branch parameter is included by every forking proxy. |
public static final String | HIDDENThe "hidden" paramter is included if this header field
was hidden by the upstream proxy. |
public static final String | RECEIVEDThe "received" parameter is added only for receiver-added Via Fields. |
public static final String | MADDRThe "maddr" parameter is designating the multicast address. |
public static final String | TTLThe "TTL" parameter is designating the time-to-live value. |
protected Protocol | sentProtocolSent protocol field. |
protected HostPort | sentBySent by field. |
protected String | commentComment field. |
Methods Summary |
---|
public java.lang.Object | clone()Clone - do a deep copy.
ViaHeader retval = new ViaHeader();
if (this.comment != null) retval.comment = new String(this.comment);
if (this.parameters != null) retval.parameters =
(NameValueList) parameters.clone();
if (this.sentBy != null) retval.sentBy = (HostPort)sentBy.clone();
if (this.sentProtocol != null)
retval.sentProtocol = (Protocol)sentProtocol.clone();
return retval;
|
public java.lang.String | encodeBody()Encodes the via header into a cannonical string.
String encoding = "";
encoding += sentProtocol.encode() + Separators.SP + sentBy.encode();
// Add the default port if there is no port specified.
if (! sentBy.hasPort()) encoding += Separators.COLON + "5060";
if (comment != null) {
encoding += Separators.LPAREN + comment + Separators.RPAREN;
}
encoding += encodeWithSep();
return encoding;
|
public boolean | equals(java.lang.Object other)Compares two via headers for equaltiy.
if (! this.getClass().equals(other.getClass())) {
return false;
}
ViaHeader that = (ViaHeader) other;
if (! this.sentProtocol.equals(that.sentProtocol)) {
return false;
}
if (! this.parameters.equals(that.parameters)) {
return false;
}
if (! this.sentBy.equals(that.sentBy)) {
return false;
}
return true;
|
public java.lang.String | getBranch()Gets the Branch parameter if it exists.
return super.getParameter(ViaHeader.BRANCH);
|
public java.lang.String | getComment()Accessor for the comment field.
return comment;
|
public java.lang.String | getHost()Gest the host name. (null if not yet set).
if (sentBy == null)
return null;
else {
Host host = sentBy.getHost();
if (host == null)
return null;
else return host.getHostname();
}
|
public java.lang.String | getMaddr()Gets the maddr parameter if it exists.
return super.getParameter(ViaHeader.MADDR);
|
public int | getPort()Port of the Via header.
if (sentBy == null)
return -1;
return sentBy.getPort();
|
public java.lang.String | getProtocolVersion()Gets the Protocol Version.
if (sentProtocol == null)
return null;
else
return sentProtocol.getProtocolVersion();
|
public java.lang.String | getReceived()Gets the received parameter if it exists.
return super.getParameter(ViaHeader.RECEIVED);
|
public HostPort | getSentBy()Accessor for the sentBy field
return sentBy;
|
public Protocol | getSentProtocol()Accessor for the sentProtocol field.
return sentProtocol;
|
public java.lang.String | getTTL()get the ttl parameter if it exists.
return super.getParameter(ViaHeader.TTL);
|
public java.lang.String | getTransport()Gets the current transport.
if (this.sentProtocol == null)
return null;
else return this.sentProtocol.getTransport();
|
public java.lang.Object | getValue()Gets the value portion of this header (does nto include the parameters).
return sentProtocol.encode() + " " + sentBy.encode();
|
public boolean | hasComment()Comment of the Via Header.
return comment != null;
|
public boolean | hasPort()Port of the Via Header.
if (sentBy == null)
return false;
return (getSentBy()).hasPort();
|
public void | removeComment()Removes the comment field.
comment = null;
|
public void | setBranch(java.lang.String branch)Sets the branch field.
BNF (RFC3261, p. 232):
via-branch = "branch" EQUAL token
super.setParameter(BRANCH, branch);
|
public void | setComment(java.lang.String c)Sets the comment member
comment = c;
|
public void | setHeaderValue(java.lang.String value)Sets the header value field (without parameters).
StringMsgParser smp = new StringMsgParser();
ViaList hl = null;
String strNewHeader = NAME + Separators.COLON + value;
try {
hl = (ViaList)smp.parseHeader(strNewHeader);
} catch (ParseException e) {
throw new IllegalArgumentException(e.toString());
}
if (hl.size() > 1) {
throw new IllegalArgumentException("Ivalid Via header " +
"value: " + value);
}
ViaHeader header = (ViaHeader)hl.elementAt(0);
// Copy the values from the header created from the parsed value
setSentBy(header.getSentBy());
setSentProtocol(header.getSentProtocol());
if (sentProtocol != null) {
setProtocolVersion(header.getProtocolVersion());
setTransport(header.getTransport());
}
if (sentBy != null) {
setHost(header.getHost());
setPort(header.getPort());
}
// IMPL_NOTE:
// System.out.println("new: '" + strNewHeader + "'");
// System.out.println("this: '" + strNewHeader + "'");
|
public void | setHost(java.lang.String host)Sets the host field.
BNF (RFC3261, p. 222):
host = hostname / IPv4address / IPv6reference
See setMaddr() for the full BNF.
this.sentBy.setHost(new Host(host));
|
public void | setHost(Host host)Sets the host field.
this.sentBy.setHost(host);
|
public void | setMaddr(java.lang.String maddr)Sets the maddr parameter.
BNF (RFC3261, p. 222, 232):
via-maddr = "maddr" EQUAL host
host = hostname / IPv4address / IPv6reference
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum / alphanum *( alphanum / "-" ) alphanum
toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum
IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
IPv6reference = "[" IPv6address "]"
IPv6address = hexpart [ ":" IPv4address ]
hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ]
hexseq = hex4 *( ":" hex4)
hex4 = 1*4HEXDIG
IMPL_NOTE: check maddr for validity.
super.setParameter(MADDR, maddr);
|
public void | setParameter(java.lang.String name, java.lang.String value)This function is overloaded in order to validate the parameters.
Sets the value of the specified parameter. If the parameter already
had a value it will be overwritten. A zero-length String indicates flag
parameter.
IMPL_NOTE: add a support for all parameters that are stored as
members of this class.
if (name.equalsIgnoreCase(ViaHeader.TTL)) {
setTTL(value);
} else if (name.equalsIgnoreCase(ViaHeader.RECEIVED)) {
setReceived(value);
} else {
super.setParameter(name, value);
}
|
public void | setPort(int port)Sets the port field.
BNF (RFC3261, p. 232):
port = 1*DIGIT
this.sentBy.setPort(port);
|
public void | setProtocolVersion(java.lang.String protocolVersion)Sets the Protocol Version.
BNF (RFC3261, p. 222, 232):
protocol-version = token
if (sentProtocol == null) sentProtocol = new Protocol();
sentProtocol.setProtocolVersion(protocolVersion);
|
public void | setReceived(java.lang.String received)Sets the 'received' parameter.
BNF (RFC3261, p. 223, 232):
via-received = "received" EQUAL (IPv4address / IPv6address)
IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
IPv6address = hexpart [ ":" IPv4address ]
hexpart = hexseq / hexseq "::" [ hexseq ] / "::" [ hexseq ]
hexseq = hex4 *( ":" hex4)
hex4 = 1*4HEXDIG
if (!Lexer.isValidIpv4Address(received) &&
!Lexer.isValidIpv6Address(received)) {
throw new IllegalArgumentException("Invalid IP address");
}
super.setParameter(RECEIVED, received);
|
public void | setSentBy(HostPort s)Sets the sentBy member
sentBy = s;
|
public void | setSentProtocol(Protocol s)Sets the sentProtocol member
sentProtocol = s;
|
public void | setTTL(java.lang.String strTTL)Sets the ttl parameter.
BNF (RFC3261, p. 232):
ttl = 1*3DIGIT ; 0 to 255
int ttl = 0;
try {
ttl = Integer.parseInt(strTTL);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Cannot parse TTL '" +
strTTL + "': " + e);
}
if (ttl < 0 || ttl > 255) {
throw new IllegalArgumentException("Invalid TTL: " + strTTL);
}
super.setParameter(TTL, strTTL);
|
public void | setTransport(java.lang.String transport)Sets the transport string.
BNF (RFC3261, p. 222, 232):
transport = "UDP" / "TCP" / "TLS" / "SCTP" / other-transport
if (sentProtocol == null) sentProtocol = new Protocol();
sentProtocol.setTransport(transport);
|