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.BuilderCOMPACT_NAME, NAMECANNOT_CAST_HEADER_OF_TYPE, UNABLE_TO_PARSE_OUT_THE_HEADER_NAME_DUE_TO_UNDERLYING_IO_EXCEPTION| Constructor and Description |
|---|
ViaHeaderImpl(Buffer via,
Buffer transport,
Buffer host,
int port,
List<Buffer[]> params,
int indexOfBranch,
int indexOfReceived,
int indexOfRPort) |
| Modifier and Type | Method and Description |
|---|---|
ViaHeader |
clone() |
ViaHeader.Builder |
copy()
Everything within the pkts.io SIP module are immutable so if you actually want
to change anything you have to create a copy, which will return a specific Builder
for that header.
|
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 |
setParameter(Buffer name,
Buffer value)
Sets the value of the specified parameter.
|
void |
setParameter(Buffer name,
java.util.function.Supplier<Buffer> value) |
String |
toString() |
void |
verify()
For a Via-header make sure that the branch parameter is present.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbuilder, frame, generateBranch, isViaHeader, toViaHeader, withHost, withHostcreate, frame, getBufferSize, getNameStr, is, is, isAddressParametersHeader, isCallIdHeader, isContactHeader, isContentLengthHeader, isContentTypeHeader, isCSeqHeader, isExpiresHeader, isFromHeader, isMaxForwardsHeader, isRecordRouteHeader, isRouteHeader, isSubjectHeader, isSystemHeader, isToHeader, toAddressParametersHeader, toCallIdHeader, toContactHeader, toContentLengthHeader, toContentTypeHeader, toCSeqHeader, toExpiresHeader, toFromHeader, toMaxForwardsHeader, toRecordRouteHeader, toRouteHeader, toToHeaderpublic ViaHeaderImpl(Buffer via, Buffer transport, Buffer host, int port, List<Buffer[]> params, int indexOfBranch, int indexOfReceived, int indexOfRPort)
via - the actual value of the via header, which cannot be changed and is what
we will be using when transferring this value to external sources. Note, it says the VALUE of the
Via-header, hence the actual header name ("Via") must NOT be part of this buffer.transport - the parsed transporthost - the parsed hostport - the parsed port or negative 1 if it isn't set.params - all the parameters such as the branch and the rport parameterindexOfBranch - the index of the branch parameterindexOfReceived - the index of the received parameterindexOfRPort - the index of the rport parameterpublic 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 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 SipHeaderSipParseExceptionpublic 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.
Note, if the header is successfully parsed into a more explicit header type you may
still not really know what to cast it so in order to make life somewhat easier you can
use the isXXXHeader methods (such as SipHeader.isAddressParametersHeader() to
check what type it possible can be and then use the corresponding toXXXHeader to
"cast" it.public ViaHeader.Builder copy()
SipHeaderCopyright © 2016. All Rights Reserved.