|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xnap.commons.util.PortRange
public class PortRange
Provides a data container for port ranges. All methods make sure that only valid ports are added.
PortRangeValidator
Field Summary | |
---|---|
static int |
MAX_PORT
|
static int |
MIN_PORT
|
Constructor Summary | |
---|---|
PortRange()
|
|
PortRange(int first,
int last)
|
|
PortRange(String range)
|
Method Summary | |
---|---|
void |
add(int port)
Adds port to the range. |
void |
add(int first,
int last)
Adds all ports that are first <= port <= last . |
void |
add(String range)
Adds a range as a string. |
ServerSocket |
bindRandom()
Tries to bind random ports from the range and returns the ServerSocket object if successful. |
boolean |
contains(int port)
Returns true, if port is in the range. |
int |
getRandom(int defaultPort)
Returns a random port from the range. |
Iterator<Integer> |
iterator()
Returns an iterator over all contained ports. |
Iterator<Integer> |
randomIterator()
Returns an iterator over a shuffeled instance. |
int |
size()
Returns the number of ports. |
String |
toString()
Returns an ordered string representation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MIN_PORT
public static final int MAX_PORT
Constructor Detail |
---|
public PortRange(int first, int last)
public PortRange(String range)
public PortRange()
Method Detail |
---|
public void add(int first, int last)
first
<= port <= last
.
public void add(int port)
port
to the range.
public void add(String range)
PortRangeValidator
public ServerSocket bindRandom()
ServerSocket
object if successful.
public boolean contains(int port)
public int getRandom(int defaultPort)
defaultPort
- a default port
public Iterator<Integer> iterator()
public Iterator<Integer> randomIterator()
public int size()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |