mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
More forgiving with values from incoming packets.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1967 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
0e1a1a0feb
commit
5673eca059
4 changed files with 22 additions and 1 deletions
|
@ -154,6 +154,10 @@ public class IQ extends Packet {
|
||||||
* @return the corresponding Type.
|
* @return the corresponding Type.
|
||||||
*/
|
*/
|
||||||
public static Type fromString(String type) {
|
public static Type fromString(String type) {
|
||||||
|
if (type == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
type = type.toLowerCase();
|
||||||
if (GET.toString().equals(type)) {
|
if (GET.toString().equals(type)) {
|
||||||
return GET;
|
return GET;
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,6 +269,10 @@ public class Message extends Packet {
|
||||||
* @return the Type corresponding to the String.
|
* @return the Type corresponding to the String.
|
||||||
*/
|
*/
|
||||||
public static Type fromString(String type) {
|
public static Type fromString(String type) {
|
||||||
|
if (type == null) {
|
||||||
|
return NORMAL;
|
||||||
|
}
|
||||||
|
type = type.toLowerCase();
|
||||||
if (CHAT.toString().equals(type)) {
|
if (CHAT.toString().equals(type)) {
|
||||||
return CHAT;
|
return CHAT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,10 @@ public class Presence extends Packet {
|
||||||
* Returns the type constant associated with the String value.
|
* Returns the type constant associated with the String value.
|
||||||
*/
|
*/
|
||||||
public static Type fromString(String value) {
|
public static Type fromString(String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return AVAILABLE;
|
||||||
|
}
|
||||||
|
value = value.toLowerCase();
|
||||||
if ("unavailable".equals(value)) {
|
if ("unavailable".equals(value)) {
|
||||||
return UNAVAILABLE;
|
return UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +310,8 @@ public class Presence extends Packet {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return AVAILABLE;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
else if (value.equals("chat")) {
|
value = value.toLowerCase();
|
||||||
|
if (value.equals("chat")) {
|
||||||
return CHAT;
|
return CHAT;
|
||||||
}
|
}
|
||||||
else if (value.equals("away")) {
|
else if (value.equals("away")) {
|
||||||
|
|
|
@ -276,6 +276,10 @@ public class RosterPacket extends IQ {
|
||||||
public static final ItemStatus UNSUBCRIPTION_PENDING = new ItemStatus("unsubscribe");
|
public static final ItemStatus UNSUBCRIPTION_PENDING = new ItemStatus("unsubscribe");
|
||||||
|
|
||||||
public static ItemStatus fromString(String value) {
|
public static ItemStatus fromString(String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
value = value.toLowerCase();
|
||||||
if ("unsubscribe".equals(value)) {
|
if ("unsubscribe".equals(value)) {
|
||||||
return SUBSCRIPTION_PENDING;
|
return SUBSCRIPTION_PENDING;
|
||||||
}
|
}
|
||||||
|
@ -329,6 +333,10 @@ public class RosterPacket extends IQ {
|
||||||
public static final ItemType BOTH = new ItemType("both");
|
public static final ItemType BOTH = new ItemType("both");
|
||||||
|
|
||||||
public static ItemType fromString(String value) {
|
public static ItemType fromString(String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
value = value.toLowerCase();
|
||||||
if ("none".equals(value)) {
|
if ("none".equals(value)) {
|
||||||
return NONE;
|
return NONE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue