Code Review
/
dmaap
/
datarouter.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Removing code smells
[dmaap/datarouter.git]
/
datarouter-node
/
src
/
main
/
java
/
org
/
onap
/
dmaap
/
datarouter
/
node
/
SubnetMatcher.java
diff --git
a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/SubnetMatcher.java
b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/SubnetMatcher.java
index
6f74df4
..
2f51012
100644
(file)
--- a/
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/SubnetMatcher.java
+++ b/
datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/SubnetMatcher.java
@@
-25,33
+25,34
@@
package org.onap.dmaap.datarouter.node;
/**
package org.onap.dmaap.datarouter.node;
/**
- * Compare IP addresses as byte arrays to a subnet specified as a CIDR
+ * Compare IP addresses as byte arrays to a subnet specified as a CIDR
.
*/
public class SubnetMatcher {
*/
public class SubnetMatcher {
+
private byte[] sn;
private int len;
private int mask;
/**
private byte[] sn;
private int len;
private int mask;
/**
- * Construct a subnet matcher given a CIDR
+ * Construct a subnet matcher given a CIDR
.
*
* @param subnet The CIDR to match
*/
public SubnetMatcher(String subnet) {
*
* @param subnet The CIDR to match
*/
public SubnetMatcher(String subnet) {
- int i = subnet.lastIndexOf('/');
- if (i == -1) {
+ int i
ndex
= subnet.lastIndexOf('/');
+ if (i
ndex
== -1) {
sn = NodeUtils.getInetAddress(subnet);
len = sn.length;
} else {
sn = NodeUtils.getInetAddress(subnet);
len = sn.length;
} else {
- len = Integer.parseInt(subnet.substring(i + 1));
- sn = NodeUtils.getInetAddress(subnet.substring(0, i));
+ len = Integer.parseInt(subnet.substring(i
ndex
+ 1));
+ sn = NodeUtils.getInetAddress(subnet.substring(0, i
ndex
));
mask = ((0xff00) >> (len % 8)) & 0xff;
len /= 8;
}
}
/**
mask = ((0xff00) >> (len % 8)) & 0xff;
len /= 8;
}
}
/**
- * Is the IP address in the CIDR
?
+ * Is the IP address in the CIDR
.
*
* @param addr the IP address as bytes in network byte order
* @return true if the IP address matches.
*
* @param addr the IP address as bytes in network byte order
* @return true if the IP address matches.