com.echomine.util
Class IPUtil

java.lang.Object
  extended by com.echomine.util.IPUtil

public class IPUtil
extends java.lang.Object

Contains some utility functions that is IP and host related.


Constructor Summary
IPUtil()
           
 
Method Summary
static java.lang.String convertIP(long ip)
          Converts a long representation of an IP into a string format "xx.xx.xx.xx"
static int deserializeIP(byte[] inbuf, int offset, java.lang.StringBuffer outbuf)
          Deserializes the IP from a given set of bytes.
static boolean isHostIPPrivate(java.lang.String ip)
          Checks whether an IP is private or not.
static int serializeIP(java.lang.String ip, byte[] outbuf, int offset)
          Serializes the IP from a given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IPUtil

public IPUtil()
Method Detail

isHostIPPrivate

public static boolean isHostIPPrivate(java.lang.String ip)
Checks whether an IP is private or not. This will check by the set standards of IANA who assigns blocks of IPs that are considered private use.


convertIP

public static java.lang.String convertIP(long ip)
Converts a long representation of an IP into a string format "xx.xx.xx.xx"


serializeIP

public static int serializeIP(java.lang.String ip,
                              byte[] outbuf,
                              int offset)
Serializes the IP from a given string. This is only IPv4 capable.

Parameters:
ip - The IP string in the "xx.xx.xx.xx" format
offset - the starting offset where the bytes will write to
outbuf - the results will be appened to this buffer
Returns:
the current offset after serializing

deserializeIP

public static int deserializeIP(byte[] inbuf,
                                int offset,
                                java.lang.StringBuffer outbuf)
Deserializes the IP from a given set of bytes. This is only IPv4 capable.

Parameters:
inbuf - the buffer that contains the IP in bytes
offset - the starting offset where deserialization occurs
outbuf - the results will be appened to this buffer
Returns:
the current offset after deserializing


Copyright © 2001-2005 Echomine. All Rights Reserved.