From 16f592bc278f4064b77ff05185f2c011d5ad2028 Mon Sep 17 00:00:00 2001 From: "lubomir.marinov" Date: Thu, 25 Feb 2010 08:38:27 +0000 Subject: [PATCH] Nothing really, just applies tiny formatting changes. --- src/org/ice4j/TransportAddress.java | 22 ++++++++-------------- src/org/ice4j/message/MessageFactory.java | 7 +------ src/org/ice4j/message/Response.java | 3 --- src/org/ice4j/stack/StunStack.java | 8 +++----- src/org/ice4j/stack/TransactionID.java | 11 ++++------- 5 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/org/ice4j/TransportAddress.java b/src/org/ice4j/TransportAddress.java index fadaf49..6599d6f 100644 --- a/src/org/ice4j/TransportAddress.java +++ b/src/org/ice4j/TransportAddress.java @@ -48,6 +48,7 @@ public class TransportAddress public TransportAddress(String hostname, int port, Transport transport) { super(hostname, port); + this.transport = transport; } @@ -71,9 +72,7 @@ public class TransportAddress public TransportAddress(byte[] ipAddress, int port, Transport transport) throws UnknownHostException { - super(InetAddress.getByAddress(ipAddress), port); - - this.transport = transport; + this(InetAddress.getByAddress(ipAddress), port, transport); } /** @@ -88,8 +87,7 @@ public class TransportAddress */ public TransportAddress(InetSocketAddress address, Transport transport) { - super(address.getAddress(), address.getPort()); - this.transport = transport; + this(address.getAddress(), address.getPort(), transport); } /** @@ -112,6 +110,7 @@ public class TransportAddress public TransportAddress(InetAddress address, int port, Transport transport) { super(address, port); + this.transport = transport; } @@ -137,7 +136,7 @@ public class TransportAddress */ public String toString() { - return super.toString() + "/"+getTransport(); + return super.toString() + "/" + getTransport(); } /** @@ -148,7 +147,6 @@ public class TransportAddress public String getHostAddress() { InetAddress addr = getAddress(); - String addressStr = addr.getHostAddress(); if(addr instanceof Inet6Address) @@ -234,12 +232,8 @@ public class TransportAddress */ public boolean canReach(TransportAddress dst) { - if (dst.getTransport() != getTransport()) - return false; - - if( isIPv6() != dst.isIPv6()) - return false; - - return true; + return + (getTransport() == dst.getTransport()) + && (isIPv6() != dst.isIPv6()); } } diff --git a/src/org/ice4j/message/MessageFactory.java b/src/org/ice4j/message/MessageFactory.java index a2a0180..85a346d 100644 --- a/src/org/ice4j/message/MessageFactory.java +++ b/src/org/ice4j/message/MessageFactory.java @@ -18,7 +18,6 @@ import org.ice4j.attribute.*; * @author Emil Ivov * @author Sebastien Vincent */ - public class MessageFactory { private static final Logger logger = @@ -171,7 +170,6 @@ public class MessageFactory return bindingResponse; } - /** * Creates a binding error response according to the specified error code * and unknown attributes. @@ -257,7 +255,6 @@ public class MessageFactory unknownAttributes); } - /** * Creates a binding error response with an ERROR-CODE attribute. * @@ -301,6 +298,7 @@ public class MessageFactory public static Request createAllocateRequest() { Request allocateRequest = new Request(); + try { allocateRequest.setMessageType(Message.ALLOCATE_REQUEST); @@ -310,7 +308,6 @@ public class MessageFactory //there should be no exc here since we're the creators. logger.log(Level.FINE, "Failed to set message type.", ex); } - return allocateRequest; } @@ -330,7 +327,6 @@ public class MessageFactory { allocateRequest.setMessageType(Message.ALLOCATE_REQUEST); - /* XXX add enum somewhere for transport number */ if(protocol != 6 && protocol != 17) { @@ -500,5 +496,4 @@ public class MessageFactory throw new UnsupportedOperationException( "Shared Secret Support is not currently implemented"); } - } diff --git a/src/org/ice4j/message/Response.java b/src/org/ice4j/message/Response.java index 61974c8..8cd83a4 100644 --- a/src/org/ice4j/message/Response.java +++ b/src/org/ice4j/message/Response.java @@ -15,7 +15,6 @@ import org.ice4j.*; * * @author Emil Ivov */ - public class Response extends Message { @@ -24,7 +23,6 @@ public class Response extends Message */ Response() { - } /** @@ -45,5 +43,4 @@ public class Response extends Message super.setMessageType(responseType); } - } diff --git a/src/org/ice4j/stack/StunStack.java b/src/org/ice4j/stack/StunStack.java index b40df39..2164faa 100644 --- a/src/org/ice4j/stack/StunStack.java +++ b/src/org/ice4j/stack/StunStack.java @@ -13,6 +13,7 @@ import java.util.logging.*; import org.ice4j.*; import org.ice4j.message.*; + /** * The entry point to the Stun4J stack. The class is used to start, stop and * configure the stack. @@ -59,7 +60,7 @@ public class StunStack /** * A dispatcher for incoming requests event; */ - private EventDispatcher eventDispatcher = new EventDispatcher(); + private final EventDispatcher eventDispatcher = new EventDispatcher(); /** * Returns a reference to the singleton StunStack instance. If the stack @@ -372,7 +373,6 @@ public class StunStack StunServerTransaction sTran = serverTransactions.get(serverTid); if( sTran != null) { - //requests from this transaction have already been seen //retransmit the response if there was any logger.finest("found an existing transaction"); @@ -414,9 +414,7 @@ public class StunStack { TransactionID tid = TransactionID.createTransactionID(msg.getTransactionID()); - - StunClientTransaction tran = - clientTransactions.remove(tid); + StunClientTransaction tran = clientTransactions.remove(tid); if(tran != null) { diff --git a/src/org/ice4j/stack/TransactionID.java b/src/org/ice4j/stack/TransactionID.java index 94db12e..643a7e5 100644 --- a/src/org/ice4j/stack/TransactionID.java +++ b/src/org/ice4j/stack/TransactionID.java @@ -15,18 +15,18 @@ import java.util.*; * * @author Emil Ivov */ - public class TransactionID { /** * The id itself */ - private byte transactionID[] = new byte[12]; + private final byte transactionID[] = new byte[12]; /** * The object to use to generate the rightmost 8 bytes of the id. */ - private static Random random = new Random(System.currentTimeMillis()); + private static final Random random + = new Random(System.currentTimeMillis()); /** * A hashcode for hashtable storage. @@ -93,7 +93,6 @@ public class TransactionID return tid; } - /** * Returns the transaction id byte array (length 12). * @return the transaction ID byte array. @@ -110,9 +109,7 @@ public class TransactionID */ public boolean equals(Object obj) { - - if( obj == null - || !(obj instanceof TransactionID)) + if(!(obj instanceof TransactionID)) return false; if(this == obj)