check for null in jid parser
This commit is contained in:
parent
fa45ceabc9
commit
9e10c3841e
|
@ -8,6 +8,7 @@ public class InvalidJidException extends Exception {
|
||||||
public final static String INVALID_PART_LENGTH = "JID part must be between 0 and 1023 characters";
|
public final static String INVALID_PART_LENGTH = "JID part must be between 0 and 1023 characters";
|
||||||
public final static String INVALID_CHARACTER = "JID contains an invalid character";
|
public final static String INVALID_CHARACTER = "JID contains an invalid character";
|
||||||
public final static String STRINGPREP_FAIL = "The STRINGPREP operation has failed for the given JID";
|
public final static String STRINGPREP_FAIL = "The STRINGPREP operation has failed for the given JID";
|
||||||
|
public final static String IS_NULL = "JID can not be NULL";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@code Exception} that includes the current stack trace.
|
* Constructs a new {@code Exception} that includes the current stack trace.
|
||||||
|
|
|
@ -60,6 +60,8 @@ public final class Jid {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Jid(final String jid) throws InvalidJidException {
|
private Jid(final String jid) throws InvalidJidException {
|
||||||
|
if (jid == null) throw new InvalidJidException(InvalidJidException.IS_NULL);
|
||||||
|
|
||||||
// Hackish Android way to count the number of chars in a string... should work everywhere.
|
// Hackish Android way to count the number of chars in a string... should work everywhere.
|
||||||
final int atCount = jid.length() - jid.replace("@", "").length();
|
final int atCount = jid.length() - jid.replace("@", "").length();
|
||||||
final int slashCount = jid.length() - jid.replace("/", "").length();
|
final int slashCount = jid.length() - jid.replace("/", "").length();
|
||||||
|
|
Loading…
Reference in New Issue