Package rocks.xmpp.core.stream.model
Class StreamHeader
- java.lang.Object
-
- rocks.xmpp.core.stream.model.StreamHeader
-
- All Implemented Interfaces:
CharSequence,LanguageElement,SessionOpen,StreamElement
public final class StreamHeader extends Object implements SessionOpen, CharSequence
Represents the XMPP stream header.Usage
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 theCharSequenceinterface.This class is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static StreamElementCLOSING_STREAM_TAGThe closing stream tag</stream:stream>.static StringLOCAL_NAMEThe local name of the stream header.static StringSTREAM_NAMESPACEhttp://etherx.jabber.org/streamsstatic StringSTREAM_NAMESPACE_PREFIXThe default namespace prefix "stream".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int i)static StreamHeadercreate(Jid from, Jid to, String id, String version, Locale lang, String contentNamespace, QName... additionalNamespaces)Creates a stream header.List<QName>getAdditionalNamespaces()Gets additional namespaces other than the content namespace and the stream namespace.StringgetContentNamespace()Gets the content namespace, i.e. the namespace which has no prefix.JidgetFrom()Gets the 'from' attribute.StringgetId()Gets the 'id' attribute.LocalegetLanguage()Gets the 'xml:lang' attribute.JidgetTo()Gets the 'to' attribute.StringgetVersion()Gets the 'version' attribute.static StreamHeaderinitialClientToServer(Jid from, Jid to, Locale lang, String contentNamespace, QName... additionalNamespaces)Creates an initial stream header for client-to-server or component-to-server streams.static StreamHeaderinitialClientToServer(Jid from, Jid to, Locale lang, QName... additionalNamespaces)Creates an initial stream header for client-to-server streams.static StreamHeaderinitialServerToServer(Jid from, Jid to, Locale lang, QName... additionalNamespaces)Creates an initial stream header for server-to-server streams.intlength()static StreamHeaderresponseClientToServer(Jid from, Jid to, String id, Locale lang, QName... additionalNamespaces)Creates a response stream header for client-to-server streams.static StreamHeaderresponseServerToServer(Jid from, Jid to, String id, Locale lang, QName... additionalNamespaces)Creates a response stream header for server-to-server streams.CharSequencesubSequence(int i, int i1)StringtoString()voidwriteTo(XMLStreamWriter writer)Writes the stream header to aXMLStreamWriter.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Field Detail
-
STREAM_NAMESPACE
public static final String STREAM_NAMESPACE
http://etherx.jabber.org/streams- See Also:
- Constant Field Values
-
STREAM_NAMESPACE_PREFIX
public static final String STREAM_NAMESPACE_PREFIX
The default namespace prefix "stream".- See Also:
- Constant Field Values
-
LOCAL_NAME
public static final String LOCAL_NAME
The local name of the stream header.- See Also:
- Constant Field Values
-
CLOSING_STREAM_TAG
public static final StreamElement CLOSING_STREAM_TAG
The closing stream tag</stream:stream>. ThetoString()method returns the XML string.
-
-
Method Detail
-
create
public static StreamHeader create(Jid from, Jid to, String id, String version, Locale lang, String contentNamespace, 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.- Parameters:
from- The XMPP identity of the principal controlling the client, i.e., a JID of the formlocalpart@domainpart>.to- A domainpart that the initiating entity knows or expects the receiving entity to service.id- The stream id.version- The XMPP version.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.- Returns:
- The stream header.
-
initialClientToServer
public static StreamHeader initialClientToServer(Jid from, Jid to, Locale lang, QName... additionalNamespaces)
Creates an initial stream header for client-to-server streams.- Parameters:
from- The XMPP identity of the principal controlling the client, i.e., a JID of the formlocalpart@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.- Returns:
- The stream header.
-
initialClientToServer
public static StreamHeader initialClientToServer(Jid from, Jid to, Locale lang, String contentNamespace, QName... additionalNamespaces)
Creates an initial stream header for client-to-server or component-to-server streams.- Parameters:
from- The XMPP identity of the principal controlling the client, i.e., a JID of the formlocalpart@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.- Returns:
- The stream header.
-
responseClientToServer
public static StreamHeader responseClientToServer(Jid from, Jid to, String id, Locale lang, QName... additionalNamespaces)
Creates a response stream header for client-to-server streams.- Parameters:
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.- Returns:
- The stream header.
-
initialServerToServer
public static StreamHeader initialServerToServer(Jid from, Jid to, Locale lang, QName... additionalNamespaces)
Creates an initial stream header for server-to-server streams.- Parameters:
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.- Returns:
- The stream header.
-
responseServerToServer
public static StreamHeader responseServerToServer(Jid from, Jid to, String id, Locale lang, QName... additionalNamespaces)
Creates a response stream header for server-to-server streams.- Parameters:
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.- Returns:
- The stream header.
-
writeTo
public final void writeTo(XMLStreamWriter writer) throws XMLStreamException
Writes the stream header to aXMLStreamWriter.- Parameters:
writer- The writer.- Throws:
XMLStreamException- If writing to the writer fails.
-
getFrom
public final Jid getFrom()
Gets the 'from' attribute.- Specified by:
getFromin interfaceSessionOpen- Returns:
- The 'from' attribute.
- See Also:
- 4.7.1. from
-
getTo
public final Jid getTo()
Gets the 'to' attribute.- Specified by:
getToin interfaceSessionOpen- Returns:
- The 'to' attribute.
- See Also:
- 4.7.2. to
-
getId
public final String getId()
Gets the 'id' attribute.- Specified by:
getIdin interfaceSessionOpen- Returns:
- The 'id' attribute.
- See Also:
- 4.7.3. id
-
getLanguage
public final Locale getLanguage()
Gets the 'xml:lang' attribute.- Specified by:
getLanguagein interfaceLanguageElement- Returns:
- The 'xml:lang' attribute.
- See Also:
- 4.7.4. xml:lang
-
getVersion
public final String getVersion()
Gets the 'version' attribute.- Specified by:
getVersionin interfaceSessionOpen- Returns:
- The XMPP version.
- See Also:
- 4.7.5. version
-
getContentNamespace
public final String getContentNamespace()
Gets the content namespace, i.e. the namespace which has no prefix.- Returns:
- The content namespace.
- See Also:
- 4.8.3. XMPP Content Namespaces
-
getAdditionalNamespaces
public final List<QName> getAdditionalNamespaces()
Gets additional namespaces other than the content namespace and the stream namespace.- Returns:
- The namespaces.
- See Also:
- 4.8.4. Other Namespaces
-
length
public final int length()
- Specified by:
lengthin interfaceCharSequence
-
charAt
public final char charAt(int i)
- Specified by:
charAtin interfaceCharSequence
-
subSequence
public final CharSequence subSequence(int i, int i1)
- Specified by:
subSequencein interfaceCharSequence
-
toString
public final String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
-