public interface SipHeader
extends java.lang.Cloneable
Represents any header in SIP.
All SipHeader
s in this API are created through a set of factory methods as well as
through builders. Any header that is simple in nature, as in it only contains a single value,
such as the MaxForwardsHeader
, can be created directly through a create
method on the the corresponding interface of that header. Headers that are constructed through
many arguments, or have ambiguous arguments, are created through builders. Finally, all headers
have a frame
method that takes a Buffer
and will attempt to frame the
content into a specific header. Note it frames the header and as such does not verify
every aspect of the header since speed is important.
Example: create a simple header directly, such as the MaxForwardsHeader
.
MaxForwardsHeader header = MaxForwardsHeader.create(20);
Example: create a header using the builder-pattern, such as a ToHeader
.
ToHeader header = ToHeader.with().user("alice").host("example.com").build();
Note, by default most things are done lazily in order to speed things up. As such, you may
successfully construct a header but it may in fact miss important information. If you are
building an application where you want to be 100% sure that a header is correct according to the
BNF in rfc 3261 then call verify()
.
Modifier and Type | Method and Description |
---|---|
SipHeader |
clone() |
SipHeader |
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.
|
static SipHeader |
frame(Buffer value)
Create a new
SipHeader based on the buffer. |
void |
getBytes(Buffer dst) |
Buffer |
getName()
Get the name of the header
|
Buffer |
getValue()
Get the value of the buffer
|
void |
verify() |
Buffer getName()
Buffer getValue()
void verify() throws SipParseException
SipParseException
void getBytes(Buffer dst)
SipHeader clone()
static SipHeader frame(Buffer value) throws SipParseException
SipHeader
based on the buffer. Each SipHeader
will override this
factory method to parse the header into a more specialized header.
Note, the header returned really is a SipHeader
and is NOT e.g. a ToHeader
.
If you really need to parse it as a ToHeader
you should use theheader
- the raw headerSipHeader
.SipParseException
- in case the header is not a correct formatted header.SipHeader ensure()
ContactHeader
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 © 2014. All Rights Reserved.