Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.voytechs.jnetstream.primitive.address
Class IpNetmask  view IpNetmask download IpNetmask.java

java.lang.Object
  extended bycom.voytechs.jnetstream.primitive.address.Address
      extended bycom.voytechs.jnetstream.primitive.address.IpNetmask

public class IpNetmask
extends Address

Version:
$Revision: 1.1.1.1 $

Field Summary
private  int bitsInMask
           
 
Fields inherited from class com.voytechs.jnetstream.primitive.address.Address
address, debug, DEFAULT_NUMBER_BASE, format, separator
 
Constructor Summary
IpNetmask(int bitsInMask)
           
IpNetmask(java.lang.String netmask)
           
 
Method Summary
 byte[] applyNetmask(Address ip)
          This method applies the netmask to another IpNumber object such as IpAddress or IpNetwork.
 byte[] applyNetmask(byte[] ip)
           
private static int countBits(byte[] byteArray)
           
 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
 

Field Detail

bitsInMask

private int bitsInMask
Constructor Detail

IpNetmask

public IpNetmask(java.lang.String netmask)

IpNetmask

public IpNetmask(int bitsInMask)
Method Detail

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.


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.


applyNetmask

public byte[] applyNetmask(byte[] ip)

countBits

private static int countBits(byte[] byteArray)

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

main

public static void main(java.lang.String[] args)
Test function for IpNetmask