Class 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 the CharSequence interface.

    This class is immutable.

    • Field Detail

      • STREAM_NAMESPACE_PREFIX

        public static final String STREAM_NAMESPACE_PREFIX
        The default namespace prefix "stream".
        See Also:
        Constant Field Values
      • CLOSING_STREAM_TAG

        public static final StreamElement CLOSING_STREAM_TAG
        The closing stream tag </stream:stream>. The toString() 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 form localpart@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 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.
        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 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.
        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 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.
      • 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.
      • getFrom

        public final Jid getFrom()
        Gets the 'from' attribute.
        Specified by:
        getFrom in interface SessionOpen
        Returns:
        The 'from' attribute.
        See Also:
        4.7.1. from
      • getTo

        public final Jid getTo()
        Gets the 'to' attribute.
        Specified by:
        getTo in interface SessionOpen
        Returns:
        The 'to' attribute.
        See Also:
        4.7.2. to
      • getId

        public final String getId()
        Gets the 'id' attribute.
        Specified by:
        getId in interface SessionOpen
        Returns:
        The 'id' attribute.
        See Also:
        4.7.3. id
      • 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
      • charAt

        public final char charAt​(int i)
        Specified by:
        charAt in interface CharSequence