summaryrefslogtreecommitdiff
path: root/java/client
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/client
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/client')
-rw-r--r--java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java5
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQDestination.java25
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java147
5 files changed, 141 insertions, 40 deletions
diff --git a/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java b/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
index f4e17c5c4c..9548eab4c5 100644
--- a/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
+++ b/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java
@@ -205,7 +205,9 @@ public class OptionParser
if (op.startsWith("'"))
{
if (!op.endsWith("'"))
+ {
throw new IllegalArgumentException(" The option " + op + " needs to be inside quotes");
+ }
return op.substring(1,op.length() -1);
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
index 7acb73c2ad..e96689b7b1 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
@@ -50,7 +50,10 @@ public class AMQConnectionURL implements ConnectionURL
public AMQConnectionURL(String fullURL) throws URLSyntaxException
{
- if (fullURL == null) throw new IllegalArgumentException("URL cannot be null");
+ if (fullURL == null)
+ {
+ throw new IllegalArgumentException("URL cannot be null");
+ }
_url = fullURL;
_options = new HashMap<String, String>();
_brokers = new LinkedList<BrokerDetails>();
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index b910dbe7da..76828afd6a 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -109,11 +109,26 @@ public abstract class AMQDestination implements Destination, Referenceable
public static AddressOption getOption(String str)
{
- if ("always".equals(str)) return ALWAYS;
- else if ("never".equals(str)) return NEVER;
- else if ("sender".equals(str)) return SENDER;
- else if ("receiver".equals(str)) return RECEIVER;
- else throw new IllegalArgumentException(str + " is not an allowed value");
+ if ("always".equals(str))
+ {
+ return ALWAYS;
+ }
+ else if ("never".equals(str))
+ {
+ return NEVER;
+ }
+ else if ("sender".equals(str))
+ {
+ return SENDER;
+ }
+ else if ("receiver".equals(str))
+ {
+ return RECEIVER;
+ }
+ else
+ {
+ throw new IllegalArgumentException(str + " is not an allowed value");
+ }
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java b/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
index 1ae25eb1ed..b00ac7e34b 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/TypedBytesContentReader.java
@@ -455,7 +455,7 @@ class TypedBytesContentReader implements TypedBytesCodes
ByteBuffer dup = _data.duplicate();
int pos = _data.position();
byte b;
- while((b = _data.get()) != 0);
+ while((b = _data.get()) != 0) {};
dup.limit(_data.position()-1);
return _charsetDecoder.decode(dup).toString();
diff --git a/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java b/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java
index 65d1fd8e84..7bc1322e02 100644
--- a/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java
+++ b/java/client/src/main/java/org/apache/qpid/collections/ReferenceMap.java
@@ -81,7 +81,8 @@ import java.util.Set;
*
* @author Paul Jack
*/
-public class ReferenceMap extends AbstractMap {
+public class ReferenceMap extends AbstractMap
+{
/**
* For serialization.
@@ -285,7 +286,10 @@ public class ReferenceMap extends AbstractMap {
this.valueType = valueType;
int v = 1;
- while (v < capacity) v *= 2;
+ while (v < capacity)
+ {
+ v *= 2;
+ }
this.table = new Entry[v];
this.loadFactor = loadFactor;
@@ -373,12 +377,18 @@ public class ReferenceMap extends AbstractMap {
* @return the entry associated with that key, or null
* if the key is not in this map
*/
- private Entry getEntry(Object key) {
- if (key == null) return null;
+ private Entry getEntry(Object key)
+ {
+ if (key == null)
+ {
+ return null;
+ }
int hash = key.hashCode();
int index = indexFor(hash);
- for (Entry entry = table[index]; entry != null; entry = entry.next) {
- if ((entry.hash == hash) && key.equals(entry.getKey())) {
+ for (Entry entry = table[index]; entry != null; entry = entry.next)
+ {
+ if ((entry.hash == hash) && key.equals(entry.getKey()))
+ {
return entry;
}
}
@@ -390,7 +400,8 @@ public class ReferenceMap extends AbstractMap {
* Converts the given hash code into an index into the
* hash table.
*/
- private int indexFor(int hash) {
+ private int indexFor(int hash)
+ {
// mix the bits to avoid bucket collisions...
hash += ~(hash << 15);
hash ^= (hash >>> 10);
@@ -458,10 +469,18 @@ public class ReferenceMap extends AbstractMap {
int index = indexFor(hash);
Entry previous = null;
Entry entry = table[index];
- while (entry != null) {
- if (entry.purge(ref)) {
- if (previous == null) table[index] = entry.next;
- else previous.next = entry.next;
+ while (entry != null)
+ {
+ if (entry.purge(ref))
+ {
+ if (previous == null)
+ {
+ table[index] = entry.next;
+ }
+ else
+ {
+ previous.next = entry.next;
+ }
this.size--;
return;
}
@@ -502,7 +521,10 @@ public class ReferenceMap extends AbstractMap {
public boolean containsKey(Object key) {
purge();
Entry entry = getEntry(key);
- if (entry == null) return false;
+ if (entry == null)
+ {
+ return false;
+ }
return entry.getValue() != null;
}
@@ -516,7 +538,10 @@ public class ReferenceMap extends AbstractMap {
public Object get(Object key) {
purge();
Entry entry = getEntry(key);
- if (entry == null) return null;
+ if (entry == null)
+ {
+ return null;
+ }
return entry.getValue();
}
@@ -533,11 +558,20 @@ public class ReferenceMap extends AbstractMap {
* is null
*/
public Object put(Object key, Object value) {
- if (key == null) throw new NullPointerException("null keys not allowed");
- if (value == null) throw new NullPointerException("null values not allowed");
+ if (key == null)
+ {
+ throw new NullPointerException("null keys not allowed");
+ }
+ if (value == null)
+ {
+ throw new NullPointerException("null values not allowed");
+ }
purge();
- if (size + 1 > threshold) resize();
+ if (size + 1 > threshold)
+ {
+ resize();
+ }
int hash = key.hashCode();
int index = indexFor(hash);
@@ -567,7 +601,10 @@ public class ReferenceMap extends AbstractMap {
* the key was not in the map
*/
public Object remove(Object key) {
- if (key == null) return null;
+ if (key == null)
+ {
+ return null;
+ }
purge();
int hash = key.hashCode();
int index = indexFor(hash);
@@ -575,8 +612,13 @@ public class ReferenceMap extends AbstractMap {
Entry entry = table[index];
while (entry != null) {
if ((hash == entry.hash) && key.equals(entry.getKey())) {
- if (previous == null) table[index] = entry.next;
- else previous.next = entry.next;
+ if (previous == null)
+ {
+ table[index] = entry.next;
+ }
+ else{
+ previous.next = entry.next;
+ }
this.size--;
modCount++;
return entry.getValue();
@@ -594,7 +636,7 @@ public class ReferenceMap extends AbstractMap {
public void clear() {
Arrays.fill(table, null);
size = 0;
- while (queue.poll() != null); // drain the queue
+ while (queue.poll() != null) {}; // drain the queue
}
@@ -617,8 +659,14 @@ public class ReferenceMap extends AbstractMap {
}
public boolean contains(Object o) {
- if (o == null) return false;
- if (!(o instanceof Map.Entry)) return false;
+ if (o == null)
+ {
+ return false;
+ }
+ if (!(o instanceof Map.Entry))
+ {
+ return false;
+ }
Map.Entry e = (Map.Entry)o;
Entry e2 = getEntry(e.getKey());
return (e2 != null) && e.equals(e2);
@@ -661,7 +709,10 @@ public class ReferenceMap extends AbstractMap {
* @return a set view of this map's keys
*/
public Set keySet() {
- if (keySet != null) return keySet;
+ if (keySet != null)
+ {
+ return keySet;
+ }
keySet = new AbstractSet() {
public int size() {
return ReferenceMap.this.size();
@@ -707,7 +758,10 @@ public class ReferenceMap extends AbstractMap {
* @return a collection view of this map's values.
*/
public Collection values() {
- if (values != null) return values;
+ if (values != null)
+ {
+ return values;
+ }
values = new AbstractCollection() {
public int size() {
return ReferenceMap.this.size();
@@ -767,21 +821,36 @@ public class ReferenceMap extends AbstractMap {
public Object setValue(Object object) {
Object old = getValue();
- if (valueType > HARD) ((Reference)value).clear();
+ if (valueType > HARD)
+ {
+ ((Reference)value).clear();
+ }
value = toReference(valueType, object, hash);
return old;
}
public boolean equals(Object o) {
- if (o == null) return false;
- if (o == this) return true;
- if (!(o instanceof Map.Entry)) return false;
+ if (o == null)
+ {
+ return false;
+ }
+ if (o == this)
+ {
+ return true;
+ }
+ if (!(o instanceof Map.Entry))
+ {
+ return false;
+ }
Map.Entry entry = (Map.Entry)o;
Object key = entry.getKey();
Object value = entry.getValue();
- if ((key == null) || (value == null)) return false;
+ if ((key == null) || (value == null))
+ {
+ return false;
+ }
return key.equals(getKey()) && value.equals(getValue());
}
@@ -801,7 +870,10 @@ public class ReferenceMap extends AbstractMap {
boolean r = (keyType > HARD) && (key == ref);
r = r || ((valueType > HARD) && (value == ref));
if (r) {
- if (keyType > HARD) ((Reference)key).clear();
+ if (keyType > HARD)
+ {
+ ((Reference)key).clear();
+ }
if (valueType > HARD) {
((Reference)value).clear();
} else if (purgeValues) {
@@ -854,7 +926,10 @@ public class ReferenceMap extends AbstractMap {
}
nextKey = e.getKey();
nextValue = e.getValue();
- if (nextNull()) entry = entry.next;
+ if (nextNull())
+ {
+ entry = entry.next;
+ }
}
return true;
}
@@ -873,7 +948,10 @@ public class ReferenceMap extends AbstractMap {
protected Entry nextEntry() {
checkMod();
- if (nextNull() && !hasNext()) throw new NoSuchElementException();
+ if (nextNull() && !hasNext())
+ {
+ throw new NoSuchElementException();
+ }
previous = entry;
entry = entry.next;
currentKey = nextKey;
@@ -891,7 +969,10 @@ public class ReferenceMap extends AbstractMap {
public void remove() {
checkMod();
- if (previous == null) throw new IllegalStateException();
+ if (previous == null)
+ {
+ throw new IllegalStateException();
+ }
ReferenceMap.this.remove(currentKey);
previous = null;
currentKey = null;