public final class ViaHeaderImpl extends Object implements ViaHeader, SipHeader, Parameters
ParametersImpl because the way we parse the
Via-header we have already parsed the parameters. This because the Via-header
requires the branch parameter to be there and as such the framing of the
Via-header is done in a way that would complain if there are no params etc.ViaHeader.ViaHeaderBuilder| Constructor and Description |
|---|
ViaHeaderImpl(Buffer original,
Buffer transport,
Buffer host,
Buffer port,
List<Buffer[]> params)
Constructor mainly used by the
ViaHeader.frame(Buffer) method. |
ViaHeaderImpl(Buffer transport,
Buffer host,
int port,
Buffer branch)
Constructor used mainly by the
HeaderFactoryImpl |
| Modifier and Type | Method and Description |
|---|---|
ViaHeader |
clone() |
ViaHeader |
ensure()
As most things in this library are done lazily, such as framing headers, you can make sure
that a particular header has indeed been parsed to the more specific header type by calling
this method.
|
Buffer |
getBranch()
The branch-parameter is mandatory and as such should always be there.
|
void |
getBytes(Buffer dst) |
Buffer |
getHost() |
Buffer |
getName()
Get the name of the header
|
Buffer |
getParameter(Buffer name)
Get the value of the named parameter.
|
Buffer |
getParameter(String name)
Same as
Parameters.getParameter(Buffer). |
int |
getPort() |
Buffer |
getReceived() |
int |
getRPort()
Get the value of the rport parameter.
|
Buffer |
getTransport()
The protocol, which typically is "UDP", "TCP" or "TLS" but can really be
anything according to RFC3261.
|
int |
getTTL() |
Buffer |
getValue()
Get the value of the buffer
|
boolean |
hasRPort()
For a request, the rport value will not be filled out since the
downstream element will do so when it discovers the rport parameter on a
ViaHeader. |
boolean |
isSCTP()
Convenience method for checking whether the protocol is SCTP or not.
|
boolean |
isTCP()
Convenience method for checking whether the protocol is TCP or not.
|
boolean |
isTLS()
Convenience method for checking whether the protocol is TLS or not.
|
boolean |
isUDP()
Convenience method for checking whether the protocol is UDP or not.
|
void |
setBranch(Buffer branch) |
void |
setParameter(Buffer name,
Buffer value)
Sets the value of the specified parameter.
|
void |
setParameter(Buffer name,
java.util.function.Supplier<Buffer> value) |
void |
setReceived(Buffer received) |
void |
setRPort(int port) |
String |
toString() |
protected void |
transferValue(Buffer dst) |
void |
verify()
For a Via-header make sure that the branch parameter is present.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitframe, generateBranch, withpublic ViaHeaderImpl(Buffer original, Buffer transport, Buffer host, Buffer port, List<Buffer[]> params)
ViaHeader.frame(Buffer) method.public Buffer getParameter(Buffer name) throws SipParseException, IllegalArgumentException
Buffer, which can be checked with Buffer.isEmpty() or
Buffer.capacity(), which will return zero. As with any empty
Buffer, if you do Buffer.toString() you will be getting
an empty String back, which would be yet another way to check for
a flag parameter.getParameter in interface Parametersname - the name of the parameter we are looking for.SipParseException - in case anything goes wrong while extracting the parameter.IllegalArgumentException - in case the name is null.public Buffer getParameter(String name) throws SipParseException, IllegalArgumentException
Parameters.getParameter(Buffer).getParameter in interface ParametersSipParseException - in case anything goes wrong while extracting the parameter.IllegalArgumentException - in case the name is null.public void setParameter(Buffer name, Buffer value) throws SipParseException, IllegalArgumentException
ParameterssetParameter in interface Parametersname - the name of the parametervalue - the value of the parameter or null if you just want to set a
flag parameterSipParseException - in case anything goes wrong when setting the parameter.IllegalArgumentException - in case the name is null or empty.public void setParameter(Buffer name, java.util.function.Supplier<Buffer> value) throws SipParseException, IllegalArgumentException
setParameter in interface ParametersSipParseExceptionIllegalArgumentExceptionpublic Buffer getName()
public Buffer getTransport()
ViaHeadergetTransport in interface ViaHeaderpublic Buffer getValue()
public Buffer getReceived()
getReceived in interface ViaHeaderpublic void setReceived(Buffer received)
setReceived in interface ViaHeaderpublic boolean hasRPort()
ViaHeaderViaHeader. Hence, if you use ViaHeader.getRPort() you will not
correctly be able to determine whether this ViaHeader actually
has the rport parameter present or if it is simply not set yet. However,
this method will return true if the rport parameter exists on the
ViaHeader, irrespectively whether it has a value or not.public int getRPort()
ViaHeaderViaHeader. To make sure that the
ViaHeader indeed has the rport parameter set, use the
ViaHeader.hasRPort().public Buffer getBranch()
ViaHeaderSipHeader.verify() on your headers since that will
guarantee that they conform to whatever the various RFC's mandates.public boolean isUDP()
ViaHeaderpublic boolean isTCP()
ViaHeaderpublic boolean isTLS()
ViaHeaderpublic boolean isSCTP()
ViaHeaderpublic void verify()
throws SipParseException
verify in interface SipHeaderSipParseExceptionprotected void transferValue(Buffer dst)
public ViaHeader clone()
public ViaHeader ensure()
SipHeaderContactHeader but it is still in its "raw" form and therefore represented as a
SipHeader as opposed to an actual ContactHeader but by calling this method
you will force the library to actually fully frame it.Copyright © 2017. All Rights Reserved.