|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xnap.util.PortRange
public class PortRange
Provides a data container for port ranges. All methods make sure that only valid ports are added.
xnap.util.prefs.PortRangeValidator
Nested Class Summary | |
---|---|
static class |
PortRange.IntIterator
An iterator over Integer objects. |
Field Summary | |
---|---|
static int |
MAX_PORT
|
static int |
MIN_PORT
|
Constructor Summary | |
---|---|
PortRange()
|
|
PortRange(int first,
int last)
|
|
PortRange(java.lang.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(java.lang.String range)
Adds a range as a string. |
java.net.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. |
java.util.Iterator |
iterator()
Returns an iterator over all contained ports. |
PortRange.IntIterator |
random()
Returns an iterator over a shuffeled instance. |
int |
size()
Returns the number of ports. |
java.lang.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(java.lang.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(java.lang.String range)
xnap.util.prefs.PortRangeValidator
public java.net.ServerSocket bindRandom()
ServerSocket
object if successful.
public boolean contains(int port)
public int getRandom(int defaultPort)
defaultPort
- a default port
public java.util.Iterator iterator()
public PortRange.IntIterator random()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |