diff --git a/src/org/ice4j/attribute/UnknownAttributesAttribute.java b/src/org/ice4j/attribute/UnknownAttributesAttribute.java index e5038d5..9c3cd4d 100644 --- a/src/org/ice4j/attribute/UnknownAttributesAttribute.java +++ b/src/org/ice4j/attribute/UnknownAttributesAttribute.java @@ -35,7 +35,6 @@ import org.ice4j.*; * @author Emil Ivov * @version 0.1 */ - public class UnknownAttributesAttribute extends Attribute { /** @@ -151,9 +150,9 @@ public class UnknownAttributesAttribute extends Attribute binValue[offset++] = (byte) (getDataLength() & 0x00FF); - Iterator attributes = getAttributes(); + Iterator attributes = getAttributes(); while (attributes.hasNext()) { - char att = ((Character)attributes.next()).charValue(); + char att = attributes.next().charValue(); binValue[offset++] = (byte)(att>>8); binValue[offset++] = (byte)(att & 0x00FF); } @@ -224,7 +223,5 @@ public class UnknownAttributesAttribute extends Attribute (attributeValue[offset++]) ); addAttributeID(attributeID); } - } - } diff --git a/src/org/ice4j/ice/NetworkUtils.java b/src/org/ice4j/ice/NetworkUtils.java index 1102ecb..d2fbd1f 100644 --- a/src/org/ice4j/ice/NetworkUtils.java +++ b/src/org/ice4j/ice/NetworkUtils.java @@ -380,8 +380,7 @@ public class NetworkUtils { try { - Method method - = iface.getClass().getMethod("isLoopback", new Class[]{}); + Method method = iface.getClass().getMethod("isLoopback"); return ((Boolean)method.invoke(iface, new Object[]{})) .booleanValue(); @@ -413,11 +412,9 @@ public class NetworkUtils { try { - Method method - = iface.getClass().getMethod("isUp", new Class[]{}); + Method method = iface.getClass().getMethod("isUp"); - return ((Boolean)method.invoke(iface, new Object[]{})) - .booleanValue(); + return ((Boolean)method.invoke(iface)).booleanValue(); } catch(Throwable t) { @@ -445,11 +442,9 @@ public class NetworkUtils { try { - Method method - = iface.getClass().getMethod("isVirtual", new Class[]{}); + Method method = iface.getClass().getMethod("isVirtual"); - return ((Boolean)method.invoke(iface, new Object[]{})) - .booleanValue(); + return ((Boolean)method.invoke(iface)).booleanValue(); } catch(Throwable t) { diff --git a/src/org/ice4j/message/Message.java b/src/org/ice4j/message/Message.java index 111a2dc..dd2b09a 100644 --- a/src/org/ice4j/message/Message.java +++ b/src/org/ice4j/message/Message.java @@ -243,17 +243,15 @@ public abstract class Message public char getDataLength() { char length = 0; - Attribute att = null; - Iterator iter = attributes.entrySet().iterator(); - while (iter.hasNext()) { - att = (Attribute)((Map.Entry)iter.next()).getValue(); + for (Attribute att : attributes.values()) + { length += att.getDataLength() + Attribute.HEADER_LENGTH; } if((length % 4) > 0) { - length += (4 - (length % 4)); + length += (4 - (length % 4)); } return length; @@ -484,10 +482,8 @@ public abstract class Message return false; //compare attributes - Iterator iter = attributes.entrySet().iterator(); - while (iter.hasNext()) { - Attribute localAtt = (Attribute)((Map.Entry)iter.next()).getValue(); - + for (Attribute localAtt : attributes.values()) + { if(!localAtt.equals(msg.getAttribute(localAtt.getAttributeType()))) return false; } @@ -495,7 +491,6 @@ public abstract class Message return true; } - /** * Returns a binary representation of this message. * @return a binary representation of this message. @@ -522,11 +517,8 @@ public abstract class Message System.arraycopy(getTransactionID(), 0, binMsg, offset, TRANSACTION_ID_LENGTH); offset+=TRANSACTION_ID_LENGTH; - Iterator iter = attributes.entrySet().iterator(); - while (iter.hasNext()) { - - Attribute attribute = (Attribute)((Map.Entry)iter.next()).getValue(); - + for (Attribute attribute : attributes.values()) + { byte[] attBinValue = attribute.encode(); System.arraycopy(attBinValue, 0, binMsg, offset, attBinValue.length); offset += attBinValue.length; diff --git a/test/org/ice4j/TransactionSupportTests.java b/test/org/ice4j/TransactionSupportTests.java index ed8501d..f416e2f 100644 --- a/test/org/ice4j/TransactionSupportTests.java +++ b/test/org/ice4j/TransactionSupportTests.java @@ -357,7 +357,7 @@ public class TransactionSupportTests extends TestCase requestCollector.waitForRequest(); //verify - Vector reqs = requestCollector.getRequestsForTransaction( + Vector reqs = requestCollector.getRequestsForTransaction( bindingRequest.getTransactionID()); assertTrue("A retransmissions of the request was sent too early", reqs.size() < 2); diff --git a/test/test/Ice.java b/test/test/Ice.java index ae41a21..47d2df2 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -82,13 +82,11 @@ public class Ice { try { - Method method - = iface.getClass().getMethod("isLoopback", new Class[]{}); + Method method = iface.getClass().getMethod("isLoopback"); System.out.println("It works!"); - return ((Boolean)method.invoke(iface, new Object[]{})) - .booleanValue(); + return ((Boolean)method.invoke(iface)).booleanValue(); } catch(Throwable t) { @@ -107,13 +105,11 @@ public class Ice { try { - Method method - = iface.getClass().getMethod("isUp", new Class[]{}); + Method method = iface.getClass().getMethod("isUp"); System.out.println("It works!"); - return ((Boolean)method.invoke(iface, new Object[]{})) - .booleanValue(); + return ((Boolean)method.invoke(iface)).booleanValue(); } catch(Throwable t) { @@ -129,13 +125,11 @@ public class Ice { try { - Method method - = iface.getClass().getMethod("isVirtual", new Class[]{}); + Method method = iface.getClass().getMethod("isVirtual"); System.out.println("It works!"); - return ((Boolean)method.invoke(iface, new Object[]{})) - .booleanValue(); + return ((Boolean)method.invoke(iface)).booleanValue(); } catch(Throwable t) {