Class JidUtil
- java.lang.Object
-
- org.jxmpp.jid.util.JidUtil
-
public class JidUtil extends java.lang.Object
-
-
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 java.util.Set<EntityBareJid>
entityBareJidSetFrom(java.util.Collection<? extends java.lang.CharSequence> jidStrings)
Convert the given collection of CharSequences to bare JIDs.static void
entityBareJidsFrom(java.util.Collection<? extends java.lang.CharSequence> jidStrings, java.util.Collection<? super EntityBareJid> output, java.util.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(java.util.Collection<? extends Jid> in, java.util.Collection<? super DomainFullJid> out)
Filter all domain full JIDs.static java.util.List<DomainFullJid>
filterDomainFullJidList(java.util.Collection<? extends Jid> input)
Filter all domain full JIDs.static java.util.Set<DomainFullJid>
filterDomainFullJidSet(java.util.Collection<? extends Jid> input)
Filter all domain full JIDs.static void
filterEntityBareJid(java.util.Collection<? extends Jid> in, java.util.Collection<? super EntityBareJid> out)
Filter all entity bare JIDs.static java.util.List<EntityBareJid>
filterEntityBareJidList(java.util.Collection<? extends Jid> input)
Filter all entity bare JIDs.static java.util.Set<EntityBareJid>
filterEntityBareJidSet(java.util.Collection<? extends Jid> input)
Filter all entity bare JIDs.static void
filterEntityFullJid(java.util.Collection<? extends Jid> in, java.util.Collection<? super EntityFullJid> out)
Filter all entity full JIDs.static java.util.List<EntityFullJid>
filterEntityFullJidList(java.util.Collection<? extends Jid> input)
Filter all full JIDs.static java.util.Set<EntityFullJid>
filterEntityFullJidSet(java.util.Collection<? extends Jid> input)
Filter all full JIDs.static boolean
isTypicalValidEntityBareJid(java.lang.CharSequence jid)
Check if the given CharSequence represents a typical and valid entity bare JID.static boolean
isValidEntityBareJid(java.lang.CharSequence jid)
Check if the given CharSequence represents a valid entity bare JID.static java.util.Set<Jid>
jidSetFrom(java.lang.String[] jids)
Convert the given array of Strings to JIDs.static java.util.Set<Jid>
jidSetFrom(java.util.Collection<? extends java.lang.CharSequence> jidStrings)
Convert the given collection of CharSequences to JIDs.static void
jidsFrom(java.util.Collection<? extends java.lang.CharSequence> jidStrings, java.util.Collection<? super Jid> output, java.util.List<XmppStringprepException> exceptions)
Convert a collection of Strings to a Set ofJid
's.static java.util.List<java.lang.String>
toStringList(java.util.Collection<? extends Jid> jids)
Convert a collection of JIDs to a list of Strings representing those JIDs.static void
toStrings(java.util.Collection<? extends Jid> jids, java.util.Collection<? super java.lang.String> jidStrings)
Convert a collection of JIDs to a Collection of Strings.static java.util.Set<java.lang.String>
toStringSet(java.util.Collection<? extends Jid> jids)
convert a collection of JIDs to a set of Strings representing those JIDs.static EntityBareJid
validateEntityBareJid(java.lang.CharSequence jidcs)
Check if the given CharSequence is a valid entity bare JID.static EntityBareJid
validateTypicalEntityBareJid(java.lang.CharSequence jidcs)
Check if the given CharSequence is a typical and valid entity bare JID.
-
-
-
Method Detail
-
isTypicalValidEntityBareJid
public static boolean isTypicalValidEntityBareJid(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.util.Collection<? extends Jid> in, java.util.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 java.util.Set<EntityBareJid> filterEntityBareJidSet(java.util.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 java.util.List<EntityBareJid> filterEntityBareJidList(java.util.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(java.util.Collection<? extends Jid> in, java.util.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 java.util.Set<EntityFullJid> filterEntityFullJidSet(java.util.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 java.util.List<EntityFullJid> filterEntityFullJidList(java.util.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(java.util.Collection<? extends Jid> in, java.util.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 java.util.Set<DomainFullJid> filterDomainFullJidSet(java.util.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 java.util.List<DomainFullJid> filterDomainFullJidList(java.util.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 java.util.Set<EntityBareJid> entityBareJidSetFrom(java.util.Collection<? extends java.lang.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(java.util.Collection<? extends java.lang.CharSequence> jidStrings, java.util.Collection<? super EntityBareJid> output, java.util.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 java.util.Set<Jid> jidSetFrom(java.lang.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 java.util.Set<Jid> jidSetFrom(java.util.Collection<? extends java.lang.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(java.util.Collection<? extends java.lang.CharSequence> jidStrings, java.util.Collection<? super Jid> output, java.util.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 java.util.List<java.lang.String> toStringList(java.util.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 java.util.Set<java.lang.String> toStringSet(java.util.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(java.util.Collection<? extends Jid> jids, java.util.Collection<? super java.lang.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
-
-