Class GroupJID

java.lang.Object
org.xmpp.packet.JID
org.jivesoftware.openfire.group.GroupJID
All Implemented Interfaces:
Serializable, Comparable<org.xmpp.packet.JID>

public class GroupJID extends org.xmpp.packet.JID
This class is designed to identify and manage custom JIDs that represent Groups (rather than Users or Components). The node for a GroupJID is the group name encoded as base32hex. This allows us to preserve special characters and upper/lower casing within the group name. The encoded group name is valid according to the RFC6122 rules for a valid node and does not require further JID escaping. We use an MD5 hash of the group name as the resource value to help distinguish Group JIDs from regular JIDs in the local domain when they are persisted in the DB or over the network.
Author:
Tom Evans
See Also:
  • Field Summary

    Fields inherited from class org.xmpp.packet.JID

    DOMAINPREP_CACHE, NODEPREP_CACHE, RESOURCEPREP_CACHE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a JID representing a Group.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.xmpp.packet.JID
    Override the base class implementation to retain the resource identifier for group JIDs.
    int
    compareTo(org.xmpp.packet.JID jid)
     
    static org.xmpp.packet.JID
    fromJID(org.xmpp.packet.JID jid)
    Returns a JID from the given JID.
    static org.xmpp.packet.JID
    Creates a JID from the given string.
    Returns the group name corresponding to this JID.
    static boolean
    isGroup(org.xmpp.packet.JID jid)
    Check a JID to determine whether it represents a group.
    static boolean
    isGroup(org.xmpp.packet.JID jid, boolean groupMustExist)
    Check a JID to determine whether it represents a group.
    Override the base class implementation to retain the resource identifier for group JIDs.

    Methods inherited from class org.xmpp.packet.JID

    domainprep, equals, equals, escapeNode, getDomain, getNode, getResource, hashCode, nodeprep, resourceprep, toFullJID, toString, unescapeNode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GroupJID

      public GroupJID(String name)
      Construct a JID representing a Group.
      Parameters:
      name - A group name for the local domain
  • Method Details

    • getGroupName

      public String getGroupName()
      Returns the group name corresponding to this JID.
      Returns:
      The name for the corresponding group
    • asBareJID

      public org.xmpp.packet.JID asBareJID()
      Override the base class implementation to retain the resource identifier for group JIDs.
      Overrides:
      asBareJID in class org.xmpp.packet.JID
      Returns:
      This JID, as a group JID
    • toBareJID

      public String toBareJID()
      Override the base class implementation to retain the resource identifier for group JIDs.
      Overrides:
      toBareJID in class org.xmpp.packet.JID
      Returns:
      The full JID rendered as a string
    • compareTo

      public int compareTo(org.xmpp.packet.JID jid)
      Specified by:
      compareTo in interface Comparable<org.xmpp.packet.JID>
      Overrides:
      compareTo in class org.xmpp.packet.JID
    • isGroup

      public static boolean isGroup(org.xmpp.packet.JID jid)
      Check a JID to determine whether it represents a group. If the given JID is an instance of this class, it is a group JID. Otherwise, calculate the hash to determine whether the JID can be resolved to a group.
      Parameters:
      jid - A JID, possibly representing a group
      Returns:
      true if the given jid represents a group in the local domain
    • isGroup

      public static boolean isGroup(org.xmpp.packet.JID jid, boolean groupMustExist) throws GroupNotFoundException
      Check a JID to determine whether it represents a group. If the given JID is an instance of this class, it is a group JID. Otherwise, calculate the hash to determine whether the JID can be resolved to a group. This method also optionally validates that the corresponding group actually exists in the local domain.
      Parameters:
      jid - A JID, possibly representing a group
      groupMustExist - If true, validate that the corresponding group actually exists
      Returns:
      true if the given jid represents a group in the local domain
      Throws:
      GroupNotFoundException - The JID represents a group, but the group does not exist
    • fromJID

      public static org.xmpp.packet.JID fromJID(org.xmpp.packet.JID jid)
      Returns a JID from the given JID. If the JID represents a group, returns an instance of this class, otherwise returns the given JID.
      Parameters:
      jid - A JID, possibly representing a group
      Returns:
      A new GroupJID if the given JID represents a group, or the given JID
    • fromString

      public static org.xmpp.packet.JID fromString(String jid)
      Creates a JID from the given string. If the string represents a group, return an instance of this class, otherwise returns a regular JID.
      Parameters:
      jid - A JID, possibly representing a group
      Returns:
      A JID with a type appropriate to its content
      Throws:
      IllegalArgumentException - the given string is not a valid JID