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 TypeMethodDescriptionintMethod compares theJIDinstance with a given object.The method returns a copy of theJIDinstance with removed resource part.copyWithResource(String resource) The method returns a copy of theJIDinstance with a different resource part given as a parameter.copyWithResourceNS(String resource) The method returns a copy of theJIDinstance with a different resource part given as a parameter.booleanMethod compares whether thisJIDinstance represents the same user JID as the one given in parameter.Method returnsBareJIDinstance for this JID.Method returns a domain part of theJIDinstance.Method a localpart (nickname) of theJIDinstance.Method a resource part of theJIDinstance.inthashCode()Method returns a hash code calculated for theJIDinstance.booleanstatic JIDjidInstance(String jid) Constructs a newJIDinstance using a JID parameter given as aStringinstance.static JIDjidInstance(String localpart, String domain) Constructs a newJIDinstance using givenStringparameters.static JIDjidInstance(String localpart, String domain, String resource) Constructs a newJIDinstance using givenStringparameters.static JIDjidInstance(BareJID bareJid) Creates a newJIDinstance using givenBareJIDinstance as a parameter.static JIDjidInstance(BareJID bareJid, String p_resource) Constructs a newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part.static JIDjidInstanceNS(String jid) Constructs a newJIDinstance using a JID parameter given as aStringinstance.static JIDjidInstanceNS(String localpart, String domain) Constructs a newJIDinstance using givenStringparameters.static JIDjidInstanceNS(String localpart, String domain, String resource) Constructs a newJIDinstance using givenStringparameters.static JIDjidInstanceNS(BareJID bareJid) Constructs a newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part.static JIDjidInstanceNS(BareJID bareJid, String p_resource) Constructs a newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part.toString()Method returns aStringrepresentation of theJIDinstance.
-
Method Details
-
jidInstance
Constructs a newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part.
As theBareJIDinstances 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 aBareJIDinstance used to create theJIDinstance.p_resource- is aStringinstance representing JID's resource part.- Returns:
JIDclass 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 newJIDinstance using givenBareJIDinstance as a parameter. The resource part is set to null.
As theBareJIDinstances are immutable the constructor doesn't create a copy of the givenBareJID, instead it saves the reference to a given object.- Parameters:
bareJid- is aBareJIDinstance used to create theJIDinstance.- Returns:
JIDclass instance.
-
jidInstance
Constructs a newJIDinstance using a JID parameter given as aStringinstance. 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 aStringinstance.- Returns:
JIDclass 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 newJIDinstance using givenStringparameters.
All theStringparameters are parsed, checked and run through the stringprep processing. In case of stringprep error, an exception is thrown.- Parameters:
localpart- is aStringinstance representing JID's localpart (nickname) part.domain- is aStringinstance representing JID's domain part.- Returns:
JIDclass 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 newJIDinstance using givenStringparameters.
All theStringparameters are parsed, checked and run through the stringprep processing. In case of stringprep error, an exception is thrown.- Parameters:
localpart- is aStringinstance representing JID's localpart (nickname) part.domain- is aStringinstance representing JID's domain part.resource- is aStringinstance representing JID's resource part.- Returns:
JIDclass 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 newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part. Note, this method does not perform stringprep processing on input parameters.
As theBareJIDinstances are immutable the constructor doesn't create a copy of the givenBareJID, instead it saves the reference to a given object.- Parameters:
bareJid- is aBareJIDinstance used to create theJIDinstance.- Returns:
JIDclass instance or null if passed string/domain was null or effectively empty.
-
jidInstanceNS
Constructs a newJIDinstance using givenBareJIDinstance as user bare JID andStringinstance as a resource part. Note, this method does not perform stringprep processing on input parameters.
As theBareJIDinstances are immutable the constructor doesn't create a copy of the givenBareJID, instead it saves the reference to a given object.- Parameters:
bareJid- is aBareJIDinstance used to create theJIDinstance.p_resource- is aStringinstance representing JID's resource part.- Returns:
JIDclass instance or null if passed string/domain was null or effectively empty.
-
jidInstanceNS
Constructs a newJIDinstance using a JID parameter given as aStringinstance. Note, this method does not perform stringprep processing on input parameters and it returnsnullif null is passed as parameter. The method does not throwNullPointerExceptionif theStringpassed is null.- Parameters:
jid- a JID parameter given as aStringinstance.- Returns:
JIDclass instance or null.
-
jidInstanceNS
Constructs a newJIDinstance using givenStringparameters. Note, this method does not perform stringprep processing on input parameters.- Parameters:
localpart- is aStringinstance representing JID's localpart (nickname) part.domain- is aStringinstance representing JID's domain part.resource- is aStringinstance representing JID's resource part.- Returns:
JIDclass instance.
-
jidInstanceNS
Constructs a newJIDinstance using givenStringparameters. Note, this method does not perform stringprep processing on input parameters.- Parameters:
localpart- is aStringinstance representing JID's localpart (nickname) part.domain- is aStringinstance representing JID's domain part.- Returns:
JIDclass instance.
-
hasResource
public boolean hasResource() -
compareTo
Method compares theJIDinstance 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:
compareToin interfaceComparable<JID>- Parameters:
o- is aJIDinstance to compare to.- Returns:
- an integer value which is a result of comparing the two objects.
-
copyWithResource
The method returns a copy of theJIDinstance with a different resource part given as a parameter.- Parameters:
resource- is aStringinstance representing JID's new resource part.- Returns:
- a new instance of the
JIDclass with a new resource part. - Throws:
TigaseStringprepException- if resource stringprep processing fails.
-
copyWithResourceNS
The method returns a copy of theJIDinstance with a different resource part given as a parameter.- Parameters:
resource- is aStringinstance representing JID's new resource part.- Returns:
- a new instance of the
JIDclass with a new resource part.
-
copyWithoutResource
The method returns a copy of theJIDinstance with removed resource part. The result is similar to theBareJIDinstance, however there are APIs which requireJIDobject to use.- Returns:
- a new instance of the
JIDclass with removed resource part.
-
equals
Method compares whether thisJIDinstance represents the same user JID as the one given in parameter. It returnstrueof all: the localpart (nickname), domain part, and the resource part are the same for both objects. -
getBareJID
Method returnsBareJIDinstance for this JID.- Returns:
- a
BareJIDinstance.
-
getDomain
Method returns a domain part of theJIDinstance.- Returns:
- a domain part of the
JIDinstance.
-
getLocalpart
Method a localpart (nickname) of theJIDinstance.- Returns:
- a localpart (nickname) of the
JIDinstance.
-
getResource
Method a resource part of theJIDinstance.- Returns:
- a resource part of the
JIDinstance.
-
hashCode
public int hashCode()Method returns a hash code calculated for theJIDinstance. -
toString
Method returns aStringrepresentation of theJIDinstance.
-