public final class StreamHeader extends java.lang.Object implements SessionOpen, java.lang.CharSequence
Represents the XMPP stream header.
StreamHeader streamHeader = StreamHeader.initialClientToServer(from, to, Locale.GERMAN);
streamHeader.writeTo(xmlStreamWriter);
The toString()
method of this class returns the XML string of the stream header, which is emphasized by the implementation of the CharSequence
interface.
This class is immutable.
Modifier and Type | Field and Description |
---|---|
static StreamElement |
CLOSING_STREAM_TAG
The closing stream tag
</stream:stream> . |
static java.lang.String |
LOCAL_NAME
The local name of the stream header.
|
static java.lang.String |
STREAM_NAMESPACE
|
static java.lang.String |
STREAM_NAMESPACE_PREFIX
The default namespace prefix “stream”.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int i) |
static StreamHeader |
create(Jid from,
Jid to,
java.lang.String id,
java.lang.String version,
java.util.Locale lang,
java.lang.String contentNamespace,
javax.xml.namespace.QName... additionalNamespaces)
Creates a stream header.
|
java.util.List<javax.xml.namespace.QName> |
getAdditionalNamespaces()
Gets additional namespaces other than the content namespace and the stream namespace.
|
java.lang.String |
getContentNamespace()
Gets the content namespace, i.e. the namespace which has no prefix.
|
Jid |
getFrom()
Gets the ‘from’ attribute.
|
java.lang.String |
getId()
Gets the ‘id’ attribute.
|
java.util.Locale |
getLanguage()
Gets the ‘xml:lang’ attribute.
|
Jid |
getTo()
Gets the ‘to’ attribute.
|
java.lang.String |
getVersion()
Gets the ‘version’ attribute.
|
static StreamHeader |
initialClientToServer(Jid from,
Jid to,
java.util.Locale lang,
javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for client-to-server streams.
|
static StreamHeader |
initialClientToServer(Jid from,
Jid to,
java.util.Locale lang,
java.lang.String contentNamespace,
javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for client-to-server or component-to-server streams.
|
static StreamHeader |
initialServerToServer(Jid from,
Jid to,
java.util.Locale lang,
javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for server-to-server streams.
|
int |
length() |
static StreamHeader |
responseClientToServer(Jid from,
Jid to,
java.lang.String id,
java.util.Locale lang,
javax.xml.namespace.QName... additionalNamespaces)
Creates a response stream header for client-to-server streams.
|
static StreamHeader |
responseServerToServer(Jid from,
Jid to,
java.lang.String id,
java.util.Locale lang,
javax.xml.namespace.QName... additionalNamespaces)
Creates a response stream header for server-to-server streams.
|
java.lang.CharSequence |
subSequence(int i,
int i1) |
java.lang.String |
toString() |
void |
writeTo(javax.xml.stream.XMLStreamWriter writer)
Writes the stream header to a
XMLStreamWriter . |
public static final java.lang.String STREAM_NAMESPACE
public static final java.lang.String STREAM_NAMESPACE_PREFIX
The default namespace prefix “stream”.
public static final java.lang.String LOCAL_NAME
The local name of the stream header.
public static final StreamElement CLOSING_STREAM_TAG
The closing stream tag </stream:stream>
. The toString()
method returns the XML string.
public static StreamHeader create(Jid from, Jid to, java.lang.String id, java.lang.String version, java.util.Locale lang, java.lang.String contentNamespace, javax.xml.namespace.QName... additionalNamespaces)
Creates a stream header. In contrary to the other factory methods, this one does not perform any logical checks on the input parameters, i.e. it does not distinguish between client-to-server, server-to-server, initiating and responding entity.
from
- The XMPP identity of the principal controlling the client, i.e., a JID of the form localpart@domainpart>
.to
- A domainpart that the initiating entity knows or expects the receiving entity to service.id
- The stream id.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.contentNamespace
- The content namespace.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public static StreamHeader initialClientToServer(Jid from, Jid to, java.util.Locale lang, javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for client-to-server streams.
from
- The XMPP identity of the principal controlling the client, i.e., a JID of the form localpart@domainpart>
.to
- A domainpart that the initiating entity knows or expects the receiving entity to service.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public static StreamHeader initialClientToServer(Jid from, Jid to, java.util.Locale lang, java.lang.String contentNamespace, javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for client-to-server or component-to-server streams.
from
- The XMPP identity of the principal controlling the client, i.e., a JID of the form localpart@domainpart>
.to
- A domainpart that the initiating entity knows or expects the receiving entity to service.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.contentNamespace
- The content namespace.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public static StreamHeader responseClientToServer(Jid from, Jid to, java.lang.String id, java.util.Locale lang, javax.xml.namespace.QName... additionalNamespaces)
Creates a response stream header for client-to-server streams.
from
- One of the receiving entity’s FQDNs.to
- The bare JID specified in the ‘from’ attribute of the initial stream headerid
- A unique identifier for the stream, called a “stream ID”.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public static StreamHeader initialServerToServer(Jid from, Jid to, java.util.Locale lang, javax.xml.namespace.QName... additionalNamespaces)
Creates an initial stream header for server-to-server streams.
from
- One of the configured FQDNs of the server, i.e., a JID of the form <domainpart>
.to
- A domainpart that the initiating entity knows or expects the receiving entity to service.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public static StreamHeader responseServerToServer(Jid from, Jid to, java.lang.String id, java.util.Locale lang, javax.xml.namespace.QName... additionalNamespaces)
Creates a response stream header for server-to-server streams.
from
- One of the receiving entity’s FQDNs.to
- The domainpart specified in the ‘from’ attribute of the initial stream header.id
- A unique identifier for the stream, called a “stream ID”.lang
- An entity’s preferred or default language for any human-readable XML character data to be sent over the stream.additionalNamespaces
- Any optional additional namespace declarations. Each QName element must have a namespace URI and a prefix set.public final void writeTo(javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
Writes the stream header to a XMLStreamWriter
.
writer
- The writer.javax.xml.stream.XMLStreamException
- If writing to the writer fails.public final Jid getFrom()
Gets the ‘from’ attribute.
getFrom
in interface SessionOpen
public final Jid getTo()
Gets the ‘to’ attribute.
getTo
in interface SessionOpen
public final java.lang.String getId()
Gets the ‘id’ attribute.
getId
in interface SessionOpen
public final java.util.Locale getLanguage()
Gets the ‘xml:lang’ attribute.
getLanguage
in interface SessionOpen
public final java.lang.String getVersion()
Gets the ‘version’ attribute.
getVersion
in interface SessionOpen
public final java.lang.String getContentNamespace()
Gets the content namespace, i.e. the namespace which has no prefix.
public final java.util.List<javax.xml.namespace.QName> getAdditionalNamespaces()
Gets additional namespaces other than the content namespace and the stream namespace.
public final int length()
length
in interface java.lang.CharSequence
public final char charAt(int i)
charAt
in interface java.lang.CharSequence
public final java.lang.CharSequence subSequence(int i, int i1)
subSequence
in interface java.lang.CharSequence
public final java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
Copyright © 2014–2019 XMPP.rocks. All rights reserved.