com.voytechs.jnetstream.primitive.address
Class IpNetmask
java.lang.Object
com.voytechs.jnetstream.primitive.address.Address
com.voytechs.jnetstream.primitive.address.IpNetmask
- All Implemented Interfaces:
- java.io.Serializable
public class IpNetmask
- extends Address
- Version:
- $Revision: 1.4 $
- Author:
- Mark Bednarczyk
- See Also:
- Serialized Form
|
Method Summary |
byte[] |
applyNetmask(Address ip)
This method applies the netmask to another IpNumber object
such as IpAddress or IpNetwork. |
byte[] |
applyNetmask(byte[] ip)
|
int |
getBitsInNetmask()
Return the number of bits turn on in a netmask. |
static void |
main(java.lang.String[] args)
Test function for IpNetmask |
static byte[] |
parseBitCount(int bits)
Converts into a long for a IP V4 netmask. |
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 |
IpNetmask
public IpNetmask(java.lang.String netmask)
- Parameters:
-
- Throws:
IpNetmask
public IpNetmask(int bitsInMask)
parseBitCount
public static byte[] parseBitCount(int bits)
- Converts into a long for a IP V4 netmask. Throws
an exception if bit count is greater than 32.
This is only a V4 convention.
getBitsInNetmask
public int getBitsInNetmask()
- Return the number of bits turn on in a netmask. This is use full
if you want to display the netmask as a slash with number of bits in mask.
- Returns:
- number of bits that are on in the netmask.
applyNetmask
public byte[] applyNetmask(Address ip)
- This method applies the netmask to another IpNumber object
such as IpAddress or IpNetwork. Netmask is ANDed with every byte
in the corresponding object. If number of bytes in the netmask
does not match the number in the IpNumber object then an IllegalArgumentException
is thrown.
- Returns:
- A new byte array is returned with mask applied to the ip number object.
applyNetmask
public byte[] applyNetmask(byte[] ip)
toString
public java.lang.String toString()
- Description copied from class:
Address
- Convert to dot notation string representation of the address
- Overrides:
toString in class Address
- Returns:
- IP address in the dot notation.
main
public static void main(java.lang.String[] args)
- Test function for IpNetmask
- Parameters:
args - command line arguments