Package tigase.xmpp.jid
Class JID
java.lang.Object
tigase.xmpp.jid.JID
- All Implemented Interfaces:
Comparable<JID>
The class defines an instance of a single XMPP JID identifier. When the object is created all parameters are checked
and processed through the stringprep. An exception is thrown in case of a stringprep processing error.
Created: Dec 28, 2009 10:48:04 PM
Created: Dec 28, 2009 10:48:04 PM
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
Method Summary
Modifier and TypeMethodDescriptionint
Method compares theJID
instance with a given object.The method returns a copy of theJID
instance with removed resource part.copyWithResource
(String resource) The method returns a copy of theJID
instance with a different resource part given as a parameter.copyWithResourceNS
(String resource) The method returns a copy of theJID
instance with a different resource part given as a parameter.boolean
Method compares whether thisJID
instance represents the same user JID as the one given in parameter.Method returnsBareJID
instance for this JID.Method returns a domain part of theJID
instance.Method a localpart (nickname) of theJID
instance.Method a resource part of theJID
instance.int
hashCode()
Method returns a hash code calculated for theJID
instance.boolean
static JID
jidInstance
(String jid) Constructs a newJID
instance using a JID parameter given as aString
instance.static JID
jidInstance
(String localpart, String domain) Constructs a newJID
instance using givenString
parameters.static JID
jidInstance
(String localpart, String domain, String resource) Constructs a newJID
instance using givenString
parameters.static JID
jidInstance
(BareJID bareJid) Creates a newJID
instance using givenBareJID
instance as a parameter.static JID
jidInstance
(BareJID bareJid, String p_resource) Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part.static JID
jidInstanceNS
(String jid) Constructs a newJID
instance using a JID parameter given as aString
instance.static JID
jidInstanceNS
(String localpart, String domain) Constructs a newJID
instance using givenString
parameters.static JID
jidInstanceNS
(String localpart, String domain, String resource) Constructs a newJID
instance using givenString
parameters.static JID
jidInstanceNS
(BareJID bareJid) Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part.static JID
jidInstanceNS
(BareJID bareJid, String p_resource) Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part.toString()
Method returns aString
representation of theJID
instance.
-
Method Details
-
jidInstance
Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part.
As theBareJID
instances are immutable the constructor doesn't create a copy of the givenBareJID
, instead it saves the reference to a given object.
The resource parameter is parsed, checked and run through the stringprep processing. In case of stringprep error, an exception is thrown.- Parameters:
bareJid
- is aBareJID
instance used to create theJID
instance.p_resource
- is aString
instance representing JID's resource part.- Returns:
JID
class instance.- Throws:
TigaseStringprepException
- exception if there was an error during stringprep processing or null if passed string/domain was null or effectively empty..
-
jidInstance
Creates a newJID
instance using givenBareJID
instance as a parameter. The resource part is set to null.
As theBareJID
instances are immutable the constructor doesn't create a copy of the givenBareJID
, instead it saves the reference to a given object.- Parameters:
bareJid
- is aBareJID
instance used to create theJID
instance.- Returns:
JID
class instance.
-
jidInstance
Constructs a newJID
instance using a JID parameter given as aString
instance. The parameter is parsed, checked and run through stringprep processing. An exception is thrown if there is an error while the JID is checked.- Parameters:
jid
- a JID parameter given as aString
instance.- Returns:
JID
class instance.- Throws:
TigaseStringprepException
- exception if there was an error during stringprep processing or null if passed string/domain was null or effectively empty..
-
jidInstance
Constructs a newJID
instance using givenString
parameters.
All theString
parameters are parsed, checked and run through the stringprep processing. In case of stringprep error, an exception is thrown.- Parameters:
localpart
- is aString
instance representing JID's localpart (nickname) part.domain
- is aString
instance representing JID's domain part.- Returns:
JID
class instance.- Throws:
TigaseStringprepException
- exception if there was an error during stringprep processing or null if passed string/domain was null or effectively empty..
-
jidInstance
public static JID jidInstance(String localpart, String domain, String resource) throws TigaseStringprepException Constructs a newJID
instance using givenString
parameters.
All theString
parameters are parsed, checked and run through the stringprep processing. In case of stringprep error, an exception is thrown.- Parameters:
localpart
- is aString
instance representing JID's localpart (nickname) part.domain
- is aString
instance representing JID's domain part.resource
- is aString
instance representing JID's resource part.- Returns:
JID
class instance.- Throws:
TigaseStringprepException
- exception if there was an error during stringprep processing or if passed string/domain was null or effectively empty..
-
jidInstanceNS
Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part. Note, this method does not perform stringprep processing on input parameters.
As theBareJID
instances are immutable the constructor doesn't create a copy of the givenBareJID
, instead it saves the reference to a given object.- Parameters:
bareJid
- is aBareJID
instance used to create theJID
instance.- Returns:
JID
class instance or null if passed string/domain was null or effectively empty.
-
jidInstanceNS
Constructs a newJID
instance using givenBareJID
instance as user bare JID andString
instance as a resource part. Note, this method does not perform stringprep processing on input parameters.
As theBareJID
instances are immutable the constructor doesn't create a copy of the givenBareJID
, instead it saves the reference to a given object.- Parameters:
bareJid
- is aBareJID
instance used to create theJID
instance.p_resource
- is aString
instance representing JID's resource part.- Returns:
JID
class instance or null if passed string/domain was null or effectively empty.
-
jidInstanceNS
Constructs a newJID
instance using a JID parameter given as aString
instance. Note, this method does not perform stringprep processing on input parameters and it returnsnull
if null is passed as parameter. The method does not throwNullPointerException
if theString
passed is null.- Parameters:
jid
- a JID parameter given as aString
instance.- Returns:
JID
class instance or null.
-
jidInstanceNS
Constructs a newJID
instance using givenString
parameters. Note, this method does not perform stringprep processing on input parameters.- Parameters:
localpart
- is aString
instance representing JID's localpart (nickname) part.domain
- is aString
instance representing JID's domain part.resource
- is aString
instance representing JID's resource part.- Returns:
JID
class instance.
-
jidInstanceNS
Constructs a newJID
instance using givenString
parameters. Note, this method does not perform stringprep processing on input parameters.- Parameters:
localpart
- is aString
instance representing JID's localpart (nickname) part.domain
- is aString
instance representing JID's domain part.- Returns:
JID
class instance.
-
hasResource
public boolean hasResource() -
compareTo
Method compares theJID
instance with a given object. The implementation fulfills the specification contract and returns a value as you would expect from the call:jid_1.toString().compareTo(jid_2.toString())
- Specified by:
compareTo
in interfaceComparable<JID>
- Parameters:
o
- is aJID
instance to compare to.- Returns:
- an integer value which is a result of comparing the two objects.
-
copyWithResource
The method returns a copy of theJID
instance with a different resource part given as a parameter.- Parameters:
resource
- is aString
instance representing JID's new resource part.- Returns:
- a new instance of the
JID
class with a new resource part. - Throws:
TigaseStringprepException
- if resource stringprep processing fails.
-
copyWithResourceNS
The method returns a copy of theJID
instance with a different resource part given as a parameter.- Parameters:
resource
- is aString
instance representing JID's new resource part.- Returns:
- a new instance of the
JID
class with a new resource part.
-
copyWithoutResource
The method returns a copy of theJID
instance with removed resource part. The result is similar to theBareJID
instance, however there are APIs which requireJID
object to use.- Returns:
- a new instance of the
JID
class with removed resource part.
-
equals
Method compares whether thisJID
instance represents the same user JID as the one given in parameter. It returnstrue
of all: the localpart (nickname), domain part, and the resource part are the same for both objects. -
getBareJID
Method returnsBareJID
instance for this JID.- Returns:
- a
BareJID
instance.
-
getDomain
Method returns a domain part of theJID
instance.- Returns:
- a domain part of the
JID
instance.
-
getLocalpart
Method a localpart (nickname) of theJID
instance.- Returns:
- a localpart (nickname) of the
JID
instance.
-
getResource
Method a resource part of theJID
instance.- Returns:
- a resource part of the
JID
instance.
-
hashCode
public int hashCode()Method returns a hash code calculated for theJID
instance. -
toString
Method returns aString
representation of theJID
instance.
-