Java tutorial
package io.bigfs.network; //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program. If not, see <http://www.gnu.org/licenses/>. import com.google.common.net.InetAddresses; import java.net.InetSocketAddress; /** * User: ibrahimyilmaz * Date: 6/7/13 * Time: 11:21 PM * Represents Address [host:port] for BigFSNode */ public class NodeAddress { private String mHost; private int mPort; public NodeAddress(String host, int port) throws InvalidNodeAddressException { if (!validateHostAddress(host)) throw new InvalidNodeAddressException(); this.mHost = host; this.mPort = port; } private boolean validateHostAddress(String host) { return InetAddresses.isInetAddress(host); } public String getHost() { return mHost; } public void setHost(String mHost) { this.mHost = mHost; } public int getPort() { return mPort; } public void setPort(int mPort) { this.mPort = mPort; } public InetSocketAddress toInetSocketAddress() { return new InetSocketAddress(this.mHost, this.mPort); } }