*/
public class HostConfig {
public static final int MIN_PORT_NUMBER = 0;
- public static final int MAX_PORT_NUMBER = (1<<16);
+
+ public static final int MAX_PORT_NUMBER = (1 << 16);
+
private InetAddress host;
+
private int portA = 0;
+
private int portB = 0;
-
+
public String getHostname() {
if (host == null)
return "localhost";
-
+
return host.getHostName();
}
-
+
public void setHostname(String hostname) {
try {
host = InetAddress.getByName(hostname);
throw new IllegalArgumentException("Hostname nicht gültig");
}
}
-
+
public int getPortA() {
return portA;
}
-
+
public void setPortA(int portA) {
if (!isValidPortnumber(portA))
- throw new IllegalArgumentException("Port ausserhalb des gültigen Bereichs");
+ throw new IllegalArgumentException(
+ "Port ausserhalb des gültigen Bereichs");
this.portA = portA;
}
private boolean isValidPortnumber(int portA) {
return ((portA > MIN_PORT_NUMBER) && (portA < MAX_PORT_NUMBER));
}
+
public int getPortB() {
return portB;
}
+
public void setPortB(int portB) {
if (!isValidPortnumber(portB))
- throw new IllegalArgumentException("Port ausserhalb des gültigen Bereichs");
+ throw new IllegalArgumentException(
+ "Port ausserhalb des gültigen Bereichs");
this.portB = portB;
}
-
+
}