Class JidUtil
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<EntityBareJid> entityBareJidSetFrom(Collection<? extends CharSequence> jidStrings) Convert the given collection of CharSequences to bare JIDs.static voidentityBareJidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super EntityBareJid> output, List<XmppStringprepException> exceptions) Convert a collection of Strings to a Set ofEntityBareJid's.static booleanCheck if two JIDs are equals.static voidfilterDomainFullJid(Collection<? extends Jid> in, Collection<? super DomainFullJid> out) Filter all domain full JIDs.static List<DomainFullJid> filterDomainFullJidList(Collection<? extends Jid> input) Filter all domain full JIDs.static Set<DomainFullJid> filterDomainFullJidSet(Collection<? extends Jid> input) Filter all domain full JIDs.static voidfilterEntityBareJid(Collection<? extends Jid> in, Collection<? super EntityBareJid> out) Filter all entity bare JIDs.static List<EntityBareJid> filterEntityBareJidList(Collection<? extends Jid> input) Filter all entity bare JIDs.static Set<EntityBareJid> filterEntityBareJidSet(Collection<? extends Jid> input) Filter all entity bare JIDs.static voidfilterEntityFullJid(Collection<? extends Jid> in, Collection<? super EntityFullJid> out) Filter all entity full JIDs.static List<EntityFullJid> filterEntityFullJidList(Collection<? extends Jid> input) Filter all full JIDs.static Set<EntityFullJid> filterEntityFullJidSet(Collection<? extends Jid> input) Filter all full JIDs.static booleanCheck if the given CharSequence represents a typical and valid entity bare JID.static booleanCheck if the given CharSequence represents a valid entity bare JID.jidSetFrom(String[] jids) Convert the given array of Strings to JIDs.jidSetFrom(Collection<? extends CharSequence> jidStrings) Convert the given collection of CharSequences to JIDs.static voidjidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super Jid> output, List<XmppStringprepException> exceptions) Convert a collection of Strings to a Set ofJid's.toStringList(Collection<? extends Jid> jids) Convert a collection of JIDs to a list of Strings representing those JIDs.static voidtoStrings(Collection<? extends Jid> jids, Collection<? super String> jidStrings) Convert a collection of JIDs to a Collection of Strings.toStringSet(Collection<? extends Jid> jids) convert a collection of JIDs to a set of Strings representing those JIDs.static EntityBareJidCheck if the given CharSequence is a valid entity bare JID.static EntityBareJidCheck if the given CharSequence is a typical and valid entity bare JID.
-
Constructor Details
-
JidUtil
public JidUtil()
-
-
Method Details
-
isTypicalValidEntityBareJid
Check if the given CharSequence represents a typical and valid entity bare JID. This method does perform the same check asisValidEntityBareJid(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
jidrepresents a valid entity bare JID, false otherwise - See Also:
-
validateTypicalEntityBareJid
public static EntityBareJid validateTypicalEntityBareJid(CharSequence jidcs) throws JidUtil.NotAEntityBareJidStringException, XmppStringprepException Check if the given CharSequence is a typical and valid entity bare JID. This method does perform the same check asisValidEntityBareJid(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. WhereasisValidEntityBareJid(CharSequence)andvalidateEntityBareJidaccept 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
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
jidrepresents a valid entity bare JID, false otherwise - See Also:
-
validateEntityBareJid
public static EntityBareJid validateEntityBareJid(CharSequence jidcs) throws JidUtil.NotAEntityBareJidStringException, XmppStringprepException 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
jidis not a valid bare JID, then this method will throw eitherJidUtil.NotAEntityBareJidStringExceptionorXmppStringprepException. 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
Filter all entity bare JIDs.- Parameters:
input- the input collection.- Returns:
- a set containing all bare JIDs of the input collection.
-
filterEntityBareJidList
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
Filter all full JIDs.- Parameters:
input- the input collection.- Returns:
- a set containing all full JIDs of the input collection.
-
filterEntityFullJidList
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
Filter all domain full JIDs.- Parameters:
input- the input collection.- Returns:
- a set containing all domain full JIDs of the input collection.
-
filterDomainFullJidList
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 ofEntityBareJid's.If the optional argument
exceptionsis given, then allXmppStringprepExceptionthrown 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 convertedoutput- the collection where the BareJid's will be added toexceptions- the list of exceptions thrown while converting.
-
jidSetFrom
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
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 ofJid's.If the optional argument
exceptionsis given, then allXmppStringprepExceptionthrown 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 convertedoutput- the collection where the Jid's will be added toexceptions- the list of exceptions thrown while converting.
-
toStringList
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
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
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
Check if two JIDs are equals. Takesnullvalues into consideration. Which means that this method will returntrueif both JIDs arenull.- Parameters:
jidOne- The first JID to compare.jidTwo- The second JID to compare.- Returns:
trueif both JIDs are equals.- Since:
- 0.7.0
-