Class JidUtil
- java.lang.Object
-
- org.jxmpp.jid.util.JidUtil
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JidUtil.NotAEntityBareJidStringException
-
Constructor Summary
Constructors Constructor Description JidUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<EntityBareJid>
entityBareJidSetFrom(Collection<? extends CharSequence> jidStrings)
Convert the given collection of CharSequences to bare JIDs.static void
entityBareJidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super EntityBareJid> output, List<XmppStringprepException> exceptions)
Convert a collection of Strings to a Set ofEntityBareJid
's.static boolean
equals(Jid jidOne, Jid jidTwo)
Check if two JIDs are equals.static void
filterDomainFullJid(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 void
filterEntityBareJid(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 void
filterEntityFullJid(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 boolean
isTypicalValidEntityBareJid(CharSequence jid)
Check if the given CharSequence represents a typical and valid entity bare JID.static boolean
isValidEntityBareJid(CharSequence jid)
Check if the given CharSequence represents a valid entity bare JID.static Set<Jid>
jidSetFrom(String[] jids)
Convert the given array of Strings to JIDs.static Set<Jid>
jidSetFrom(Collection<? extends CharSequence> jidStrings)
Convert the given collection of CharSequences to JIDs.static void
jidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super Jid> output, List<XmppStringprepException> exceptions)
Convert a collection of Strings to a Set ofJid
's.static List<String>
toStringList(Collection<? extends Jid> jids)
Convert a collection of JIDs to a list of Strings representing those JIDs.static void
toStrings(Collection<? extends Jid> jids, Collection<? super String> jidStrings)
Convert a collection of JIDs to a Collection of Strings.static Set<String>
toStringSet(Collection<? extends Jid> jids)
convert a collection of JIDs to a set of Strings representing those JIDs.static EntityBareJid
validateEntityBareJid(CharSequence jidcs)
Check if the given CharSequence is a valid entity bare JID.static EntityBareJid
validateTypicalEntityBareJid(CharSequence jidcs)
Check if the given CharSequence is a typical and valid entity bare JID.
-
-
-
Constructor Detail
-
JidUtil
public JidUtil()
-
-
Method Detail
-
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 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 @{code jid} represents a valid entity bare JID, false otherwise
- See Also:
isValidEntityBareJid(CharSequence)
,EntityBareJid
-
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)
andvalidateEntityBareJid
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 @{code jid} represents a valid entity bare JID, false otherwise
- See Also:
EntityBareJid
-
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
jid
is not a valid bare JID, then this method will throw eitherJidUtil.NotAEntityBareJidStringException
orXmppStringprepException
. 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 ofEntityBareJid
's.If the optional argument
exceptions
is given, then allXmppStringprepException
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 convertedoutput
- the collection where the BareJid's will be added toexceptions
- 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 ofJid
's.If the optional argument
exceptions
is given, then allXmppStringprepException
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 convertedoutput
- the collection where the Jid's will be added toexceptions
- 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. Takesnull
values into consideration. Which means that this method will returntrue
if both JIDs arenull
.- Parameters:
jidOne
- The first JID to compare.jidTwo
- The second JID to compare.- Returns:
true
if both JIDs are equals.- Since:
- 0.7.0
-
-