projects
/
zxing.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Small style stuff
[zxing.git]
/
android
/
src
/
com
/
google
/
zxing
/
client
/
android
/
wifi
/
NetworkUtil.java
diff --git
a/android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
b/android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
index
9a84d43
..
6463435
100644
(file)
--- a/
android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
+++ b/
android/src/com/google/zxing/client/android/wifi/NetworkUtil.java
@@
-16,6
+16,8
@@
package com.google.zxing.client.android.wifi;
package com.google.zxing.client.android.wifi;
+import java.util.regex.Pattern;
+
import android.text.TextUtils;
/**
import android.text.TextUtils;
/**
@@
-28,6
+30,8
@@
import android.text.TextUtils;
*/
final class NetworkUtil {
*/
final class NetworkUtil {
+ private static final Pattern HEX_DIGITS = Pattern.compile("[0-9A-Fa-f]+");
+
private NetworkUtil() {
}
private NetworkUtil() {
}
@@
-46,21
+50,8
@@
final class NetworkUtil {
int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
int lastPos = string.length() - 1;
if (lastPos < 0 || (string.charAt(0) == '"' && string.charAt(lastPos) == '"')) {
return string;
- }
- return '\"' + string + '\"';
- }
-
- private static boolean isHex(CharSequence key) {
- if (key == null){
- return false;
}
}
- for (int i = key.length() - 1; i >= 0; i--) {
- char c = key.charAt(i);
- if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) {
- return false;
- }
- }
- return true;
+ return '\"' + string + '\"';
}
/**
}
/**
@@
-72,9
+63,9
@@
final class NetworkUtil {
if (wepKey == null) {
return false;
}
if (wepKey == null) {
return false;
}
- int len = wepKey.length();
+ int len
gth
= wepKey.length();
// WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
// WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
- return (len
== 10 || len == 26 || len == 58) && isHex(wepKey
);
+ return (len
gth == 10 || length == 26 || length == 58) && HEX_DIGITS.matcher(wepKey).matches(
);
}
}
-}
+}
\ No newline at end of file