summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMili Verma <mili.verma@isode.com>2012-01-10 15:55:29 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-01-11 13:44:37 (GMT)
commitbe94e872d9423501c688c84c6cb945a420a5cb18 (patch)
tree77986e9e30282b526c0246bb6344c175b54ffb5f /src/com/isode/stroke/parser/payloadparsers/CommandParser.java
parentc9ff80a46b13b7d1987bf54cae87738a9baf552b (diff)
downloadstroke-be94e872d9423501c688c84c6cb945a420a5cb18.zip
stroke-be94e872d9423501c688c84c6cb945a420a5cb18.tar.bz2
Update review comment related stuff
This patch addresses some review comments: 1. Updates the Javadoc. 2. Disallows arguments from being null - throws NullPointerException. 3. Updates each test to use its own DummyEventLoop. Test-information: Unit tests pass.
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/CommandParser.java')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/CommandParser.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/CommandParser.java b/src/com/isode/stroke/parser/payloadparsers/CommandParser.java
index b94acfb..bb7fe27 100644
--- a/src/com/isode/stroke/parser/payloadparsers/CommandParser.java
+++ b/src/com/isode/stroke/parser/payloadparsers/CommandParser.java
@@ -33,7 +33,7 @@ public class CommandParser extends GenericPayloadParser<Command> {
private Type noteType_;
private FormParserFactory formParserFactory_;
private FormParser formParser_;
- private String currentText_;
+ private String currentText_ = "";
/**
* Constructor
@@ -51,7 +51,17 @@ public class CommandParser extends GenericPayloadParser<Command> {
}
public void handleStartElement(String element, String ns,
- AttributeMap attributes) {
+ final AttributeMap attributes) {
+ if (element == null) {
+ throw new NullPointerException("'element' must not be null");
+ }
+ if (ns == null) {
+ throw new NullPointerException("'ns' must not be null");
+ }
+ if (attributes == null) {
+ throw new NullPointerException("'attributes' must not be null");
+ }
+
++level_;
Command command = getPayloadInternal();
@@ -95,6 +105,13 @@ public class CommandParser extends GenericPayloadParser<Command> {
}
public void handleEndElement(String element, String ns) {
+ if (element == null) {
+ throw new NullPointerException("'element' must not be null");
+ }
+ if (ns == null) {
+ throw new NullPointerException("'ns' must not be null");
+ }
+
if (formParser_ != null) {
formParser_.handleEndElement(element, ns);
}
@@ -122,6 +139,10 @@ public class CommandParser extends GenericPayloadParser<Command> {
}
public void handleCharacterData(String data) {
+ if (data == null) {
+ throw new NullPointerException("'data' must not be null");
+ }
+
if (formParser_ != null) {
formParser_.handleCharacterData(data);
} else {
@@ -130,6 +151,10 @@ public class CommandParser extends GenericPayloadParser<Command> {
}
private static Action parseAction(String action) {
+ if (action == null) {
+ throw new NullPointerException("'action' must not be null");
+ }
+
return Action.getAction(action);
}