Class JidUtil

java.lang.Object
org.jxmpp.jid.util.JidUtil

public class JidUtil extends Object
  • Constructor Details

  • Method Details

    • isTypicalValidEntityBareJid

      public static boolean isTypicalValidEntityBareJid(CharSequence jid)
      Check if the given CharSequence represents a typical and valid entity bare JID. This method does perform the same check as isValidEntityBareJid(CharSequence) and additionally verifies that the domainpart of the JID contains at least one dot ('.') character.

      For more information about the different verification methods see validateEntityBareJid(CharSequence).

      Parameters:
      jid - the CharSequence to check.
      Returns:
      true if jid represents a valid entity bare JID, false otherwise
      See Also:
    • validateTypicalEntityBareJid

      Check if the given CharSequence is a typical and valid entity bare JID. This method does perform the same check as isValidEntityBareJid(CharSequence) and additionally verifies that the domainpart of the JID contains at least one dot ('.') character.

      The …TypicalValidEntityBareJid(CharSequence) methods are useful if you expect your users to always enter a FQDN as domainpart. Whereas isValidEntityBareJid(CharSequence) and validateEntityBareJid accept also inputs like "foo@example", the "is typical JID" methods require the domainpart to contain a dot, e.g. "foo@example.org".

      Parameters:
      jidcs - the JID CharSequence
      Returns:
      a BareJid instance representing the given JID CharSequence
      Throws:
      JidUtil.NotAEntityBareJidStringException - if the given CharSequence is not a bare JID.
      XmppStringprepException - if an error happens.
    • isValidEntityBareJid

      public static boolean isValidEntityBareJid(CharSequence jid)
      Check if the given CharSequence represents a valid entity bare JID. That is, it must consists exactly of a local- and a domainpart (<localpart@domainpart>).

      This method is meant to validate user input and give fast feedback (e.g. with a red or green light) about if the user entered CharSequence represents a bare JID.

      Parameters:
      jid - the CharSequence to check.
      Returns:
      true if jid represents a valid entity bare JID, false otherwise
      See Also:
    • validateEntityBareJid

      Check if the given CharSequence is a valid entity bare JID. That is, it must consists exactly of a local- and a domainpart (<localpart@domainpart>).

      This is a convenience method meant to validate user entered bare JIDs. If the given jid is not a valid bare JID, then this method will throw either JidUtil.NotAEntityBareJidStringException or XmppStringprepException. The NotABareJidStringException will contain a meaningful message explaining why the given CharSequence is not a valid bare JID (e.g. "does not contain a '@' character").

      Parameters:
      jidcs - the JID CharSequence
      Returns:
      a BareJid instance representing the given JID CharSequence
      Throws:
      JidUtil.NotAEntityBareJidStringException - if the given CharSequence is not a bare JID.
      XmppStringprepException - if an error happens.
    • filterEntityBareJid

      public static void filterEntityBareJid(Collection<? extends Jid> in, Collection<? super EntityBareJid> out)
      Filter all entity bare JIDs.
      Parameters:
      in - the input collection.
      out - the collection where the filtered JIDs are added to.
    • filterEntityBareJidSet

      public static Set<EntityBareJid> filterEntityBareJidSet(Collection<? extends Jid> input)
      Filter all entity bare JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a set containing all bare JIDs of the input collection.
    • filterEntityBareJidList

      public static List<EntityBareJid> filterEntityBareJidList(Collection<? extends Jid> input)
      Filter all entity bare JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a list containing all bare JIDs of the input collection.
    • filterEntityFullJid

      public static void filterEntityFullJid(Collection<? extends Jid> in, Collection<? super EntityFullJid> out)
      Filter all entity full JIDs.
      Parameters:
      in - the input collection.
      out - the collection where the filtered JIDs are added to.
    • filterEntityFullJidSet

      public static Set<EntityFullJid> filterEntityFullJidSet(Collection<? extends Jid> input)
      Filter all full JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a set containing all full JIDs of the input collection.
    • filterEntityFullJidList

      public static List<EntityFullJid> filterEntityFullJidList(Collection<? extends Jid> input)
      Filter all full JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a list containing all full JIDs of the input collection.
    • filterDomainFullJid

      public static void filterDomainFullJid(Collection<? extends Jid> in, Collection<? super DomainFullJid> out)
      Filter all domain full JIDs.
      Parameters:
      in - the input collection.
      out - the collection where the filtered JIDs are added to.
    • filterDomainFullJidSet

      public static Set<DomainFullJid> filterDomainFullJidSet(Collection<? extends Jid> input)
      Filter all domain full JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a set containing all domain full JIDs of the input collection.
    • filterDomainFullJidList

      public static List<DomainFullJid> filterDomainFullJidList(Collection<? extends Jid> input)
      Filter all domain full JIDs.
      Parameters:
      input - the input collection.
      Returns:
      a list containing all domain full JIDs of the input collection.
    • entityBareJidSetFrom

      public static Set<EntityBareJid> entityBareJidSetFrom(Collection<? extends CharSequence> jidStrings)
      Convert the given collection of CharSequences to bare JIDs.
      Parameters:
      jidStrings - the collection of CharSequences.
      Returns:
      a set of bare JIDs.
    • entityBareJidsFrom

      public static void entityBareJidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super EntityBareJid> output, List<XmppStringprepException> exceptions)
      Convert a collection of Strings to a Set of EntityBareJid's.

      If the optional argument exceptions is given, then all XmppStringprepException thrown while converting will be added to the list. Otherwise, if an XmppStringprepExceptions is thrown, it will be wrapped in a AssertionError Exception and throw.

      Parameters:
      jidStrings - the strings that are going to get converted
      output - the collection where the BareJid's will be added to
      exceptions - the list of exceptions thrown while converting.
    • jidSetFrom

      public static Set<Jid> jidSetFrom(String[] jids)
      Convert the given array of Strings to JIDs.

      Note that errors while converting the Strings will be silently ignored.

      Parameters:
      jids - a array of JID Strings.
      Returns:
      a set of JIDs.
    • jidSetFrom

      public static Set<Jid> jidSetFrom(Collection<? extends CharSequence> jidStrings)
      Convert the given collection of CharSequences to JIDs.
      Parameters:
      jidStrings - the collection of CharSequences.
      Returns:
      a set of JIDs.
    • jidsFrom

      public static void jidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super Jid> output, List<XmppStringprepException> exceptions)
      Convert a collection of Strings to a Set of Jid's.

      If the optional argument exceptions is given, then all XmppStringprepException thrown while converting will be added to the list. Otherwise, if an XmppStringprepExceptions is thrown, it will be wrapped in a AssertionError Exception and throw.

      Parameters:
      jidStrings - the strings that are going to get converted
      output - the collection where the Jid's will be added to
      exceptions - the list of exceptions thrown while converting.
    • toStringList

      public static List<String> toStringList(Collection<? extends Jid> jids)
      Convert a collection of JIDs to a list of Strings representing those JIDs.
      Parameters:
      jids - a collection of JIDs.
      Returns:
      a list of Strings.
    • toStringSet

      public static Set<String> toStringSet(Collection<? extends Jid> jids)
      convert a collection of JIDs to a set of Strings representing those JIDs.
      Parameters:
      jids - a collection of JIDs.
      Returns:
      a set of String.
    • toStrings

      public static void toStrings(Collection<? extends Jid> jids, Collection<? super String> jidStrings)
      Convert a collection of JIDs to a Collection of Strings.
      Parameters:
      jids - the collection of Strings to convert.
      jidStrings - the collection of Strings to append to.
    • equals

      public static boolean equals(Jid jidOne, Jid jidTwo)
      Check if two JIDs are equals. Takes null values into consideration. Which means that this method will return true if both JIDs are null.
      Parameters:
      jidOne - The first JID to compare.
      jidTwo - The second JID to compare.
      Returns:
      true if both JIDs are equals.
      Since:
      0.7.0