Commit b2e18788 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Handle invalid show element in presence.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/3_3_1_branch@8894 b35dd754-fafc-0310-a699-88a17e54d16e
parent 59918e0b
......@@ -8,6 +8,7 @@
package org.xmpp.packet;
import org.dom4j.Element;
import org.jivesoftware.util.Log;
import java.util.Iterator;
......@@ -16,7 +17,7 @@ import java.util.Iterator;
* network availability and to notify other entities of that availability.
* Presence packets are also used to negotiate and manage subscriptions to the
* presence of other entities.<p>
*
* <p/>
* A presence optionally has a {@link Type}.
*
* @author Matt Tucker
......@@ -81,9 +82,8 @@ public class Presence extends Packet {
/**
* Returns true if the presence type is "available". This is a
* convenience method that is equivalent to:
*
* <p/>
* <pre>getType() == null</pre>
*
*/
public boolean isAvailable() {
return getType() == null;
......@@ -114,7 +114,7 @@ public class Presence extends Packet {
* @see Type
*/
public void setType(Type type) {
element.addAttribute("type", type==null?null:type.toString());
element.addAttribute("type", type == null ? null : type.toString());
}
/**
......@@ -133,8 +133,14 @@ public class Presence extends Packet {
return null;
}
else {
try {
return Show.valueOf(show);
}
catch (IllegalArgumentException e) {
Log.error("Unable to retrieve show value for " + show);
return null;
}
}
}
/**
......@@ -243,7 +249,7 @@ public class Presence extends Packet {
* given name and namespace. If no matching element is found,
* <tt>null</tt> will be returned. This is a convenience method to avoid
* manipulating this underlying packet's Element instance directly.<p>
*
* <p/>
* Child elements in extended namespaces are used to extend the features
* of XMPP. Examples include a "user is typing" indicator and invitations to
* group chat rooms. Although any valid XML can be included in a child element
......@@ -257,7 +263,7 @@ public class Presence extends Packet {
* is no matching child element.
*/
public Element getChildElement(String name, String namespace) {
for (Iterator i=element.elementIterator(name); i.hasNext(); ) {
for (Iterator i = element.elementIterator(name); i.hasNext();) {
Element element = (Element)i.next();
if (element.getNamespaceURI().equals(namespace)) {
return element;
......@@ -271,7 +277,7 @@ public class Presence extends Packet {
* namespace. The newly created Element is returned. This is a
* convenience method to avoid manipulating this underlying packet's
* Element instance directly.<p>
*
* <p/>
* Child elements in extended namespaces are used to extend the features
* of XMPP. Examples include a "user is typing" indicator and invitations to
* group chat rooms. Although any valid XML can be included in a child element
......@@ -300,7 +306,7 @@ public class Presence extends Packet {
* Represents the type of a presence packet. Note: the presence is assumed
* to be "available" when the type attribute of the packet is <tt>null</tt>.
* The valid types are:
*
* <p/>
* <ul>
* <li>{@link #unavailable Presence.Type.unavailable} -- signals that the
* entity is no longer available for communication.
......@@ -362,7 +368,7 @@ public class Presence extends Packet {
/**
* Represents the presence "show" value. Note: a <tt>null</tt> "show" value is the
* default, which means "available". Valid values are:
*
* <p/>
* <ul>
* <li>{@link #chat Presence.Show.chat} -- the entity or resource is actively
* interested in chatting.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment