Adds support for undefined Jingle reason codes.

fix-message-formatting
paweldomas 11 years ago
parent 746526fc81
commit 3cede77878

@ -115,7 +115,12 @@ public enum Reason
* A reason indicating that the party supports none of the offered * A reason indicating that the party supports none of the offered
* transport methods. * transport methods.
*/ */
UNSUPPORTED_TRANSPORTS("unsupported-transports"); UNSUPPORTED_TRANSPORTS("unsupported-transports"),
/**
* A reason created for unsupported reasons(not defined in this enum).
*/
UNDEFINED("undefined");
/** /**
* The name of this direction. * The name of this direction.
@ -153,19 +158,16 @@ public String toString()
* @param reasonValueStr the action <tt>String</tt> that we'd like to * @param reasonValueStr the action <tt>String</tt> that we'd like to
* parse. * parse.
* @return a <tt>JingleAction</tt> value corresponding to the specified * @return a <tt>JingleAction</tt> value corresponding to the specified
* <tt>jingleValueStr</tt>. * <tt>jingleValueStr</tt>. Returns {@link #UNDEFINED} for invalid
* <tt>jingleValueStr</tt> values.
* *
* @throws IllegalArgumentException in case <tt>reasonValueStr</tt> is
* not a valid media direction.
*/ */
public static Reason parseString(String reasonValueStr) public static Reason parseString(String reasonValueStr)
throws IllegalArgumentException
{ {
for (Reason value : values()) for (Reason value : values())
if (value.toString().equals(reasonValueStr)) if (value.toString().equals(reasonValueStr))
return value; return value;
throw new IllegalArgumentException( return UNDEFINED;
reasonValueStr + " is not a valid reason");
} }
} }

Loading…
Cancel
Save