Nothing really, just applies tiny formatting changes.

This commit is contained in:
lubomir.marinov 2010-02-25 08:38:27 +00:00
parent 890ddfd96d
commit 16f592bc27
5 changed files with 16 additions and 35 deletions

View File

@ -48,6 +48,7 @@ public class TransportAddress
public TransportAddress(String hostname, int port, Transport transport) public TransportAddress(String hostname, int port, Transport transport)
{ {
super(hostname, port); super(hostname, port);
this.transport = transport; this.transport = transport;
} }
@ -71,9 +72,7 @@ public class TransportAddress
public TransportAddress(byte[] ipAddress, int port, Transport transport) public TransportAddress(byte[] ipAddress, int port, Transport transport)
throws UnknownHostException throws UnknownHostException
{ {
super(InetAddress.getByAddress(ipAddress), port); this(InetAddress.getByAddress(ipAddress), port, transport);
this.transport = transport;
} }
/** /**
@ -88,8 +87,7 @@ public class TransportAddress
*/ */
public TransportAddress(InetSocketAddress address, Transport transport) public TransportAddress(InetSocketAddress address, Transport transport)
{ {
super(address.getAddress(), address.getPort()); this(address.getAddress(), address.getPort(), transport);
this.transport = transport;
} }
/** /**
@ -112,6 +110,7 @@ public class TransportAddress
public TransportAddress(InetAddress address, int port, Transport transport) public TransportAddress(InetAddress address, int port, Transport transport)
{ {
super(address, port); super(address, port);
this.transport = transport; this.transport = transport;
} }
@ -137,7 +136,7 @@ public class TransportAddress
*/ */
public String toString() public String toString()
{ {
return super.toString() + "/"+getTransport(); return super.toString() + "/" + getTransport();
} }
/** /**
@ -148,7 +147,6 @@ public class TransportAddress
public String getHostAddress() public String getHostAddress()
{ {
InetAddress addr = getAddress(); InetAddress addr = getAddress();
String addressStr = addr.getHostAddress(); String addressStr = addr.getHostAddress();
if(addr instanceof Inet6Address) if(addr instanceof Inet6Address)
@ -234,12 +232,8 @@ public class TransportAddress
*/ */
public boolean canReach(TransportAddress dst) public boolean canReach(TransportAddress dst)
{ {
if (dst.getTransport() != getTransport()) return
return false; (getTransport() == dst.getTransport())
&& (isIPv6() != dst.isIPv6());
if( isIPv6() != dst.isIPv6())
return false;
return true;
} }
} }

View File

@ -18,7 +18,6 @@ import org.ice4j.attribute.*;
* @author Emil Ivov * @author Emil Ivov
* @author Sebastien Vincent * @author Sebastien Vincent
*/ */
public class MessageFactory public class MessageFactory
{ {
private static final Logger logger = private static final Logger logger =
@ -171,7 +170,6 @@ public class MessageFactory
return bindingResponse; return bindingResponse;
} }
/** /**
* Creates a binding error response according to the specified error code * Creates a binding error response according to the specified error code
* and unknown attributes. * and unknown attributes.
@ -257,7 +255,6 @@ public class MessageFactory
unknownAttributes); unknownAttributes);
} }
/** /**
* Creates a binding error response with an ERROR-CODE attribute. * Creates a binding error response with an ERROR-CODE attribute.
* *
@ -301,6 +298,7 @@ public class MessageFactory
public static Request createAllocateRequest() public static Request createAllocateRequest()
{ {
Request allocateRequest = new Request(); Request allocateRequest = new Request();
try try
{ {
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST); allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
@ -310,7 +308,6 @@ public class MessageFactory
//there should be no exc here since we're the creators. //there should be no exc here since we're the creators.
logger.log(Level.FINE, "Failed to set message type.", ex); logger.log(Level.FINE, "Failed to set message type.", ex);
} }
return allocateRequest; return allocateRequest;
} }
@ -330,7 +327,6 @@ public class MessageFactory
{ {
allocateRequest.setMessageType(Message.ALLOCATE_REQUEST); allocateRequest.setMessageType(Message.ALLOCATE_REQUEST);
/* XXX add enum somewhere for transport number */ /* XXX add enum somewhere for transport number */
if(protocol != 6 && protocol != 17) if(protocol != 6 && protocol != 17)
{ {
@ -500,5 +496,4 @@ public class MessageFactory
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Shared Secret Support is not currently implemented"); "Shared Secret Support is not currently implemented");
} }
} }

View File

@ -15,7 +15,6 @@ import org.ice4j.*;
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
public class Response extends Message public class Response extends Message
{ {
@ -24,7 +23,6 @@ public class Response extends Message
*/ */
Response() Response()
{ {
} }
/** /**
@ -45,5 +43,4 @@ public class Response extends Message
super.setMessageType(responseType); super.setMessageType(responseType);
} }
} }

View File

@ -13,6 +13,7 @@ import java.util.logging.*;
import org.ice4j.*; import org.ice4j.*;
import org.ice4j.message.*; import org.ice4j.message.*;
/** /**
* The entry point to the Stun4J stack. The class is used to start, stop and * The entry point to the Stun4J stack. The class is used to start, stop and
* configure the stack. * configure the stack.
@ -59,7 +60,7 @@ public class StunStack
/** /**
* A dispatcher for incoming requests event; * 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 * Returns a reference to the singleton StunStack instance. If the stack
@ -372,7 +373,6 @@ public class StunStack
StunServerTransaction sTran = serverTransactions.get(serverTid); StunServerTransaction sTran = serverTransactions.get(serverTid);
if( sTran != null) if( sTran != null)
{ {
//requests from this transaction have already been seen //requests from this transaction have already been seen
//retransmit the response if there was any //retransmit the response if there was any
logger.finest("found an existing transaction"); logger.finest("found an existing transaction");
@ -414,9 +414,7 @@ public class StunStack
{ {
TransactionID tid TransactionID tid
= TransactionID.createTransactionID(msg.getTransactionID()); = TransactionID.createTransactionID(msg.getTransactionID());
StunClientTransaction tran = clientTransactions.remove(tid);
StunClientTransaction tran =
clientTransactions.remove(tid);
if(tran != null) if(tran != null)
{ {

View File

@ -15,18 +15,18 @@ import java.util.*;
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
public class TransactionID public class TransactionID
{ {
/** /**
* The id itself * 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. * 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. * A hashcode for hashtable storage.
@ -93,7 +93,6 @@ public class TransactionID
return tid; return tid;
} }
/** /**
* Returns the transaction id byte array (length 12). * Returns the transaction id byte array (length 12).
* @return the transaction ID byte array. * @return the transaction ID byte array.
@ -110,9 +109,7 @@ public class TransactionID
*/ */
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if(!(obj instanceof TransactionID))
if( obj == null
|| !(obj instanceof TransactionID))
return false; return false;
if(this == obj) if(this == obj)