org.tinyradius.attribute
Class IpAttribute

java.lang.Object
  extended by org.tinyradius.attribute.RadiusAttribute
      extended by org.tinyradius.attribute.IpAttribute

public class IpAttribute
extends RadiusAttribute

This class represents a Radius attribute for an IP number.


Constructor Summary
IpAttribute()
          Constructs an empty IP attribute.
IpAttribute(int type, long ipNum)
          Constructs an IP attribute.
IpAttribute(int type, java.lang.String value)
          Constructs an IP attribute.
 
Method Summary
 java.lang.String getAttributeValue()
          Returns the attribute value (IP number) as a string of the format "xx.xx.xx.xx".
 long getIpAsLong()
          Returns the IP number as a 32 bit unsigned number.
 void readAttribute(byte[] data, int offset, int length)
          Check attribute length.
 void setAttributeValue(java.lang.String value)
          Sets the attribute value (IP number).
 void setIpAsLong(long ip)
          Sets the IP number represented by this IpAttribute as a 32 bit unsigned number.
 
Methods inherited from class org.tinyradius.attribute.RadiusAttribute
createRadiusAttribute, createRadiusAttribute, createRadiusAttribute, getAttributeData, getAttributeType, getAttributeTypeObject, getDictionary, getVendorId, setAttributeData, setAttributeType, setDictionary, setVendorId, toString, writeAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IpAttribute

public IpAttribute()
Constructs an empty IP attribute.


IpAttribute

public IpAttribute(int type,
                   java.lang.String value)
Constructs an IP attribute.

Parameters:
type - attribute type code
value - value, format: xx.xx.xx.xx

IpAttribute

public IpAttribute(int type,
                   long ipNum)
Constructs an IP attribute.

Parameters:
type - attribute type code
ipNum - value as a 32 bit unsigned int
Method Detail

getAttributeValue

public java.lang.String getAttributeValue()
Returns the attribute value (IP number) as a string of the format "xx.xx.xx.xx".

Overrides:
getAttributeValue in class RadiusAttribute
Returns:
value
See Also:
RadiusAttribute.getAttributeValue()

setAttributeValue

public void setAttributeValue(java.lang.String value)
Sets the attribute value (IP number). String format: "xx.xx.xx.xx".

Overrides:
setAttributeValue in class RadiusAttribute
Parameters:
value - value as a string
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
See Also:
RadiusAttribute.setAttributeValue(java.lang.String)

getIpAsLong

public long getIpAsLong()
Returns the IP number as a 32 bit unsigned number. The number is returned in a long because Java does not support unsigned ints.

Returns:
IP number

setIpAsLong

public void setIpAsLong(long ip)
Sets the IP number represented by this IpAttribute as a 32 bit unsigned number.

Parameters:
ip -

readAttribute

public void readAttribute(byte[] data,
                          int offset,
                          int length)
                   throws RadiusException
Check attribute length.

Overrides:
readAttribute in class RadiusAttribute
Throws:
RadiusException
See Also:
RadiusAttribute.readAttribute(byte[], int, int)