|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.voytechs.jnetstream.primitive.address.Address
com.voytechs.jnetstream.primitive.address.IpAddress
public class IpAddress
A Class for storing IP Addresses Currently is only designed to utilize IPv4 (32bit) addresses. Class also contains utility methods for DNS lookups. There are various functions for converting the IP address to a LONG. Why would you want to use a long for storage of an IP address, in my case I store IP address in a database as an UNSIGNED INT, java does not have unsigned numbers so you have to go to next bigger primitive type to store it or do like other implementations do store the address in a byte array.
| Field Summary |
|---|
| Fields inherited from class com.voytechs.jnetstream.primitive.address.Address |
|---|
address, debug, DEFAULT_NUMBER_BASE, format, separator |
| Constructor Summary | |
|---|---|
IpAddress(byte[] address)
Main constructor taking the array of bytes as the address. |
|
IpAddress(java.lang.String hostname)
Constructor taking a hostname. |
|
| Method Summary | |
|---|---|
java.lang.String |
getCanonicalHostname()
Gets the fully qualified domain name for this IP address. |
java.lang.String |
getDomainname()
Do a domain name lookup by use of DNS reverse lookup on the IP addresses |
java.lang.String |
getHostname()
Do a DNS lookup on our IP address by use of DNS reverse lookup. |
java.net.InetAddress |
getInetObject()
Returns the java.net.InetAddress object associated with this IpAddress. |
static void |
main(java.lang.String[] args)
Test function for IpAddress |
java.lang.String |
toString()
Convert to dot notation string representation of the address. |
| Methods inherited from class com.voytechs.jnetstream.primitive.address.Address |
|---|
AND, AND, byteArrayValue, compare, compare, compareTo, EOR, EOR, equals, getByte, getByte, getRadix, INVERT, INVERT, longToByteArray, OR, OR, parseByteArray, setAddress, setByteArrayAddress, setFormat, setFormat, setRadix, setSeparator, stringValue, toByteArray, toString, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IpAddress(byte[] address)
address - array of bytes making up the address.
java.lang.IllegalArgumentException - if number of bytes is not 4 or 32.
public IpAddress(java.lang.String hostname)
throws java.net.UnknownHostException
hostname - hostname or IP address in '.' notation initialize this address with.
java.net.UnknownHostException - if hostname can not be converted to an IP address. Addresses
in IPv4 '.' notation format always convert and this exception is never thrown.| Method Detail |
|---|
public java.lang.String getHostname()
public java.lang.String getCanonicalHostname()
public java.net.InetAddress getInetObject()
public java.lang.String getDomainname()
public java.lang.String toString()
toString in class Addresspublic static void main(java.lang.String[] args)
args - command line arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||