All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jxmpp.jid.Jid Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
/**
 *
 * Copyright © 2014 Florian Schmaus
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jxmpp.jid;

/**
 * A XMPP JID.
 * 

* This is the super interface for all JID types. Every JID consists at least of * a domainpart. You can retrieve the escaped String with {@link #toString()} * or the unsecaped String of the JID with {@link #asUnescapedString()}. *

*/ public interface Jid extends Comparable, CharSequence { public String getDomain(); /** * Returns the escaped String representation of this JID. * * @return the escaped String representation of this JID. */ public String toString(); public String asUnescapedString(); public boolean isBareOrFullJid(); /** * Check if this is an instance of {@link BareJid}. * * @return true if this is an instance of BareJid */ public boolean isBareJid(); /** * Check if this is an instance of {@link FullJid}. * * @return true if this is an instance of FullJid */ public boolean isFullJid(); /** * Check if this is an instance of {@link DomainBareJid}. * * @return true if this is an instance of DomainBareJid */ public boolean isDomainBareJid(); /** * Check if this is an instance of {@link DomainFullJid}. * * @return true if this is an instance of DomainFullJid */ public boolean isDomainFullJid(); /** * Check if this is an instance of {@link BareJid} or {@link DomainBareJid}. * * @return true if this is an instance of BareJid or DomainBareJid */ public boolean hasNoResource(); public boolean hasResource(); public boolean hasLocalpart(); /** * Convert this Jid to a BareJid if possible. * * @return the corresponding BareJid or null. */ public BareJid asBareJidIfPossible(); /** * Convert this Jid to a FullJid if possible. * * @return the corresponding FullJid or null. */ public FullJid asFullJidIfPossible(); /** * Convert this Jid to a DomainBareJid if possible. * * @return the corresponding DomainBareJid or null. */ public DomainBareJid asDomainBareJidIfPossible(); /** * Convert this Jid to a DomainFullJid if possible. * * @return the corresponding DomainFullJid or null. */ public DomainFullJid asDomainFullJidIfPossible(); /** * Get the resourcepart of this JID or null. *

* If the JID is of form then this method returns 'resource'. If the JID no * resourcepart, then null is returned. *

* * @return the resource of this JID or null. */ public String getResourceOrNull(); /** * Get the localpart of this JID or null. *

* If the JID is of form then this method returns 'localpart'. If the JID has no * localpart, then null is returned. *

* * @return the localpart of this JID or null. */ public String getLocalpartOrNull(); /** * Check if this JID is the parent of another JID. The parent of relation is defined, under the * precondition that the JID parts (localpart, domainpart and resourcepart) are equal, as follows: *

*

	 * | this JID (parentOf) | other JID           | result |
	 * |---------------------+---------------------+--------|
	 * | dom.example         | dom.example         | true   |
	 * | dom.example         | dom.example/res     | true   |
	 * | dom.example         | [email protected]     | true   |
	 * | dom.example         | [email protected]/res | true   |
	 * | dom.example/res     | dom.exmple          | false  |
	 * | dom.example/res     | dom.example/res     | true   |
	 * | dom.example/res     | [email protected]     | false  |
	 * | dom.example/res     | [email protected]/res | false  |
	 * | [email protected]     | dom.example         | false  |
	 * | [email protected]     | dom.example/res     | false  |
	 * | [email protected]     | [email protected]     | true   |
	 * | [email protected]     | [email protected]/res | true   |
	 * | [email protected]/res | dom.example         | false  |
	 * | [email protected]/res | dom.example/res     | false  |
	 * | [email protected]/res | [email protected]     | false  |
	 * | [email protected]/res | [email protected]/res | true   |
	 * 
*

* * @param jid * the other JID to compare with * @return true if this JID is a parent of the given JID. */ public boolean isParentOf(Jid jid); /** * See {@link #isParentOf(Jid)}. * * @param bareJid * @return true if this JID is a parent of the given JID. */ public boolean isParentOf(BareJid bareJid); /** * See {@link #isParentOf(Jid)}. * * @param fullJid * @return true if this JID is a parent of the given JID. */ public boolean isParentOf(FullJid fullJid); /** * See {@link #isParentOf(Jid)}. * * @param domainBareJid * @return true if this JID is a parent of the given JID. */ public boolean isParentOf(DomainBareJid domainBareJid); /** * See {@link #isParentOf(Jid)}. * * @param domainFullJid * @return true if this JID is a parent of the given JID. */ public boolean isParentOf(DomainFullJid domainFullJid); /** * Return the downcasted instance of this Jid. This method is unsafe, make sure to check that this is actually of the type of are casting to. * * @return the downcasted instanced of this */ public T downcast(); /** * Compares the given CharSequence with this JID. Returns true if {@code equals(charSequence.toString()} would * return true. * * @param charSequence the CharSequence to compare this JID with. * @return true if if {@code equals(charSequence.toString()} would return true. * @see #equals(String) */ public boolean equals(CharSequence charSequence); /** * Compares the given String wit this JID. *

* Returns true if {@code toString().equals(string)}, that is if the String representation of this JID matches the given string. *

* * @param string the String to compare this JID with. * @return true if {@code toString().equals(string)}. */ public boolean equals(String string); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy