summaryrefslogtreecommitdiff
path: root/java/common
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2012-01-27 12:19:57 +0000
committerRobert Godfrey <rgodfrey@apache.org>2012-01-27 12:19:57 +0000
commitfac38971d2943f7e7113ebaf1425ef731799d1f8 (patch)
tree80a2c48cb90eac58d86115b7ac8a8ac867510aca /java/common
parentadbaa8b9bb6629daecfdfb3efcaba24a485580ba (diff)
downloadqpid-python-fac38971d2943f7e7113ebaf1425ef731799d1f8.tar.gz
NO-JIRA: Ensure all control flow statements use braces (keeping CheckStyle happy)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1236647 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r--java/common/Composite.tpl15
-rw-r--r--java/common/src/main/java/org/apache/qpid/util/NetMatcher.java88
2 files changed, 76 insertions, 27 deletions
diff --git a/java/common/Composite.tpl b/java/common/Composite.tpl
index c3e4765c9c..ad166a0170 100644
--- a/java/common/Composite.tpl
+++ b/java/common/Composite.tpl
@@ -211,9 +211,13 @@ ${
if pack > 0:
if f.empty:
out(" if (value)\\n")
+ out(" {\\n")
out(" packing_flags |= $(f.flag_mask(pack));\\n")
+ out(" }\\n")
out(" else\\n")
- out(" packing_flags &= ~$(f.flag_mask(pack));")
+ out(" {\\n")
+ out(" packing_flags &= ~$(f.flag_mask(pack));\\n")
+ out(" }\\n")
else:
out(" packing_flags |= $(f.flag_mask(pack));")
}
@@ -301,6 +305,7 @@ for f in fields:
continue
if pack > 0:
out(" if ((packing_flags & $(f.flag_mask(pack))) != 0)\n ")
+ out(" {\n ")
pre = ""
post = ""
if f.type_node.name == "struct":
@@ -308,6 +313,8 @@ for f in fields:
elif f.type_node.name == "domain":
post = ".getValue()"
out(" enc.write$(f.coder)($(pre)this.$(f.name)$(post));\n")
+ if pack > 0:
+ out(" }\n")
}
}
@@ -322,6 +329,7 @@ for f in fields:
continue
if pack > 0:
out(" if ((packing_flags & $(f.flag_mask(pack))) != 0)\n ")
+ out(" {\n ")
pre = ""
post = ""
arg = ""
@@ -332,6 +340,8 @@ for f in fields:
pre = "%s.get(" % cname(f.type_node)
post = ")"
out(" this.$(f.name) = $(pre)dec.read$(f.coder)($(arg))$(post);\n")
+ if pack > 0:
+ out(" }\n")
}
}
@@ -343,7 +353,10 @@ ${
for f in fields:
if pack > 0:
out(" if ((packing_flags & $(f.flag_mask(pack))) != 0)\n ")
+ out(" {\n ")
out(' result.put("$(f.name)", $(f.get)());\n')
+ if pack > 0:
+ out(" }\n")
}
return result;
diff --git a/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java b/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
index 4c653e6ca0..971dd3fe2a 100644
--- a/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
+++ b/java/common/src/main/java/org/apache/qpid/util/NetMatcher.java
@@ -29,14 +29,20 @@ public class NetMatcher
public void initInetNetworks(final Collection nets)
{
networks = new ArrayList();
- for (Iterator iter = nets.iterator(); iter.hasNext(); ) try
+ for (Iterator iter = nets.iterator(); iter.hasNext(); )
{
- InetNetwork net = InetNetwork.getFromString((String) iter.next());
- if (!networks.contains(net)) networks.add(net);
- }
- catch (java.net.UnknownHostException uhe)
- {
- log("Cannot resolve address: " + uhe.getMessage());
+ try
+ {
+ InetNetwork net = InetNetwork.getFromString((String) iter.next());
+ if (!networks.contains(net))
+ {
+ networks.add(net);
+ }
+ }
+ catch (java.net.UnknownHostException uhe)
+ {
+ log("Cannot resolve address: " + uhe.getMessage());
+ }
}
networks.trimToSize();
}
@@ -44,14 +50,20 @@ public class NetMatcher
public void initInetNetworks(final String[] nets)
{
networks = new ArrayList();
- for (int i = 0; i < nets.length; i++) try
- {
- InetNetwork net = InetNetwork.getFromString(nets[i]);
- if (!networks.contains(net)) networks.add(net);
- }
- catch (java.net.UnknownHostException uhe)
+ for (int i = 0; i < nets.length; i++)
{
- log("Cannot resolve address: " + uhe.getMessage());
+ try
+ {
+ InetNetwork net = InetNetwork.getFromString(nets[i]);
+ if (!networks.contains(net))
+ {
+ networks.add(net);
+ }
+ }
+ catch (java.net.UnknownHostException uhe)
+ {
+ log("Cannot resolve address: " + uhe.getMessage());
+ }
}
networks.trimToSize();
}
@@ -71,10 +83,13 @@ public class NetMatcher
boolean sameNet = false;
- if (ip != null) for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext(); )
+ if (ip != null)
{
- InetNetwork network = (InetNetwork) iter.next();
- sameNet = network.contains(ip);
+ for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext(); )
+ {
+ InetNetwork network = (InetNetwork) iter.next();
+ sameNet = network.contains(ip);
+ }
}
return sameNet;
}
@@ -156,12 +171,21 @@ class InetNetwork
public static InetNetwork getFromString(String netspec) throws java.net.UnknownHostException
{
- if (netspec.endsWith("*")) netspec = normalizeFromAsterisk(netspec);
+ if (netspec.endsWith("*"))
+ {
+ netspec = normalizeFromAsterisk(netspec);
+ }
else
{
int iSlash = netspec.indexOf('/');
- if (iSlash == -1) netspec += "/255.255.255.255";
- else if (netspec.indexOf('.', iSlash) == -1) netspec = normalizeFromCIDR(netspec);
+ if (iSlash == -1)
+ {
+ netspec += "/255.255.255.255";
+ }
+ else if (netspec.indexOf('.', iSlash) == -1)
+ {
+ netspec = normalizeFromCIDR(netspec);
+ }
}
return new InetNetwork(InetAddress.getByName(netspec.substring(0, netspec.indexOf('/'))),
@@ -205,8 +229,12 @@ class InetNetwork
String[] masks = { "0.0.0.0/0.0.0.0", "0.0.0/255.0.0.0", "0.0/255.255.0.0", "0/255.255.255.0" };
char[] srcb = netspec.toCharArray();
int octets = 0;
- for (int i = 1; i < netspec.length(); i++) {
- if (srcb[i] == '.') octets++;
+ for (int i = 1; i < netspec.length(); i++)
+ {
+ if (srcb[i] == '.')
+ {
+ octets++;
+ }
}
return (octets == 0) ? masks[0] : netspec.substring(0, netspec.length() -1 ).concat(masks[octets]);
}
@@ -244,10 +272,18 @@ class InetNetwork
private static InetAddress getByAddress(byte[] ip) throws java.net.UnknownHostException
{
InetAddress addr = null;
- if (getByAddress != null) try {
- addr = (InetAddress) getByAddress.invoke(null, new Object[] { ip });
- } catch (IllegalAccessException e) {
- } catch (java.lang.reflect.InvocationTargetException e) {
+ if (getByAddress != null)
+ {
+ try
+ {
+ addr = (InetAddress) getByAddress.invoke(null, new Object[] { ip });
+ }
+ catch (IllegalAccessException e)
+ {
+ }
+ catch (java.lang.reflect.InvocationTargetException e)
+ {
+ }
}
if (addr == null) {