Cisco Systems, Inc.

com.pcube.apps.engage.policy
Class IPListItem

java.lang.Object
  extended by com.pcube.apps.engage.common.ArrayElement
      extended by com.pcube.apps.engage.common.ListItem
          extended by com.pcube.apps.engage.policy.IPListItem
All Implemented Interfaces:
Formattable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class IPListItem
extends ListItem
implements java.io.Serializable, Formattable

An item in an IPList/IPRangeList. The item has an ip address and a mask.
Mask 32 is considered an ip address. If stating a mask X, the (32 - X) least significant bits of the ip range must be 0, otherwise the ipListItem is considered illegal.

See Also:
Serialized Form

Constructor Summary
IPListItem()
          IPListItem Constructor.
IPListItem(long newIp, byte newMask)
          IPListItem Constructor.
IPListItem(java.lang.String newStringIp, byte newMask)
          IPListItem Constructor.
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
           
 void fromStream(java.io.BufferedReader in, Formatter f)
          Method fromStream
 long getIp()
          Gets this IPListItem's ip.
 java.lang.String getIpAsString()
          Gets this IPListItem's ip's String representation.
 byte getMask()
          Gets this IPListItem's mask.
static boolean isIpRangeLegal(long ip, byte mask)
          Checks if an ip and a mask are consistent.
 void set(ListItem parm1)
          Sets this IPListItem to resemble another specific IPListItem.
 void toStream(java.io.PrintStream out, Formatter f)
          Method toStream
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPListItem

public IPListItem()
IPListItem Constructor.


IPListItem

public IPListItem(long newIp,
                  byte newMask)
IPListItem Constructor.

Parameters:
newIp - the ip
newMask - the mask
Throws:
java.lang.IllegalArgumentException - if the mask and ip are not consistent

IPListItem

public IPListItem(java.lang.String newStringIp,
                  byte newMask)
           throws java.lang.NumberFormatException
IPListItem Constructor.

Parameters:
newStringIp - the String representation of the ip
newMask - the mask
Throws:
java.lang.IllegalArgumentException - if the mask and ip are not consistent
java.lang.NumberFormatException - if the String representation is erroneous
Method Detail

isIpRangeLegal

public static boolean isIpRangeLegal(long ip,
                                     byte mask)
                              throws java.lang.IllegalArgumentException
Checks if an ip and a mask are consistent. For a mask X, the (32 - X) least significant bits of the ip range must be 0 to be considered a legal ip range.

Parameters:
ip - the ip
mask - the mask
Returns:
true if values are consistent, false otherwise
Throws:
java.lang.IllegalArgumentException

clone

public java.lang.Object clone()
Specified by:
clone in class ListItem
See Also:
ListItem.clone()

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
Specified by:
compareTo in class ListItem
See Also:
ListItem.compareTo(java.lang.Object)

fromStream

public void fromStream(java.io.BufferedReader in,
                       Formatter f)
                throws ImportExportException
Description copied from interface: Formattable
Method fromStream

Specified by:
fromStream in interface Formattable
Throws:
ImportExportException
See Also:
Formattable.fromStream(java.io.BufferedReader, com.pcube.apps.engage.common.Formatter)

getIp

public long getIp()
Gets this IPListItem's ip.

Returns:
this IPListItem's ip

getIpAsString

public java.lang.String getIpAsString()
Gets this IPListItem's ip's String representation.

Returns:
this IPListItem's ip's String representation

getMask

public byte getMask()
Gets this IPListItem's mask.

Returns:
this IPListItem's mask

set

public void set(ListItem parm1)
Sets this IPListItem to resemble another specific IPListItem.

Parameters:
parm1 - the IPListItem to resemble to.

toStream

public void toStream(java.io.PrintStream out,
                     Formatter f)
Description copied from interface: Formattable
Method toStream

Specified by:
toStream in interface Formattable
See Also:
Formattable.toStream(java.io.PrintStream, com.pcube.apps.engage.common.Formatter)

toString

public java.lang.String toString()
Specified by:
toString in class ListItem
See Also:
ListItem.toString()

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.