aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network/Login.java
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2012-03-18 17:45:15 +0100
committerBananeweizen <Bananeweizen@gmx.de>2012-03-18 17:45:15 +0100
commit762d3dfbd8059b10393a791a2e6990827c3634df (patch)
tree6a9d8a05fa6efec83112b1952391f1c249a5e72e /main/src/cgeo/geocaching/network/Login.java
parent660e6d1f3c79199f883d04db97620cefc722d240 (diff)
downloadcgeo-762d3dfbd8059b10393a791a2e6990827c3634df.zip
cgeo-762d3dfbd8059b10393a791a2e6990827c3634df.tar.gz
cgeo-762d3dfbd8059b10393a791a2e6990827c3634df.tar.bz2
static code analysis and other fixes
* NumberParsingExceptions, NullPointerExceptions * StringBuilder instead of StringBuffer * access rights * interfaces instead of classes * ...
Diffstat (limited to 'main/src/cgeo/geocaching/network/Login.java')
-rw-r--r--main/src/cgeo/geocaching/network/Login.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/network/Login.java b/main/src/cgeo/geocaching/network/Login.java
index 8db370d..7d43fa8 100644
--- a/main/src/cgeo/geocaching/network/Login.java
+++ b/main/src/cgeo/geocaching/network/Login.java
@@ -322,19 +322,23 @@ public abstract class Login {
public static String[] getViewstates(String page) {
// Get the number of viewstates.
// If there is only one viewstate, __VIEWSTATEFIELDCOUNT is not present
-
+
if (page == null) { // no network access
return null;
}
-
+
int count = 1;
final Matcher matcherViewstateCount = GCConstants.PATTERN_VIEWSTATEFIELDCOUNT.matcher(page);
if (matcherViewstateCount.find()) {
- count = Integer.parseInt(matcherViewstateCount.group(1));
+ try {
+ count = Integer.parseInt(matcherViewstateCount.group(1));
+ } catch (NumberFormatException e) {
+ Log.e(Settings.tag, "getViewStates", e);
+ }
}
-
+
String[] viewstates = new String[count];
-
+
// Get the viewstates
int no;
final Matcher matcherViewstates = GCConstants.PATTERN_VIEWSTATES.matcher(page);
@@ -344,11 +348,16 @@ public abstract class Login {
no = 0;
}
else {
- no = Integer.parseInt(sno);
+ try {
+ no = Integer.parseInt(sno);
+ } catch (NumberFormatException e) {
+ Log.e(Settings.tag, "getViewStates", e);
+ no = 0;
+ }
}
viewstates[no] = matcherViewstates.group(2);
}
-
+
if (viewstates.length != 1 || viewstates[0] != null) {
return viewstates;
}
@@ -382,7 +391,7 @@ public abstract class Login {
static public String[] requestViewstates(final String uri, final Parameters params, boolean xContentType, boolean my) {
final HttpResponse response = Network.request(uri, params, xContentType, my, false);
-
+
return getViewstates(Network.getResponseData(response));
}