org.jdiameter.client.impl.parser
Class ElementParser

java.lang.Object
  extended by org.jdiameter.client.impl.parser.ElementParser
All Implemented Interfaces:
IElementParser
Direct Known Subclasses:
MessageParser

public class ElementParser
extends java.lang.Object
implements IElementParser


Constructor Summary
ElementParser()
           
 
Method Summary
 byte[] addressToBytes(java.net.InetAddress address)
          Convert InetAddress to byte array representation
 java.net.InetAddress bytesToAddress(byte[] rawData)
          Convert byte array to InetAddress
 java.util.Date bytesToDate(byte[] rawData)
          Convert byte array to date
 double bytesToDouble(byte[] rawData)
          Convert byte array to double
 float bytesToFloat(byte[] rawData)
          Convert byte array to float
 int bytesToInt(byte[] rawData)
          Convert byte array to int
 long bytesToLong(byte[] rawData)
          Convert byte array to long
<T> T
bytesToObject(java.lang.Class<?> iface, byte[] rawdata)
          Convert byte array to specefied object
 java.lang.String bytesToOctetString(byte[] rawData)
          Convert byte array to octet string
 java.lang.String bytesToUtf8String(byte[] rawData)
          Convert byte array to utf8 string
 byte[] dateToBytes(java.util.Date date)
          Convert Date to byte array representation
 byte[] float32ToBytes(float value)
          Convert float to byte array representation
 byte[] float64ToBytes(double value)
          Convert double to byte array representation
 byte[] int32ToBytes(int value)
          Convert int to byte array representation
 byte[] int64ToBytes(long value)
          Convert long to byte array representation
 byte[] intU32ToBytes(long value)
          Convert long to 4-byte array representation
 byte[] objectToBytes(java.lang.Object data)
          Convert specefied object to byte array representation
 byte[] octetStringToBytes(java.lang.String value)
          Convert octet string to byte array representation
protected  java.nio.ByteBuffer prepareBuffer(byte[] bytes, int len)
           
 byte[] utf8StringToBytes(java.lang.String value)
          Convert utf8 string to byte array representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementParser

public ElementParser()
Method Detail

bytesToInt

public int bytesToInt(byte[] rawData)
               throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to int

Specified by:
bytesToInt in interface IElementParser
Parameters:
rawData - byte representation of int value
Returns:
int value
Throws:
org.jdiameter.api.AvpDataException

bytesToLong

public long bytesToLong(byte[] rawData)
                 throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to long

Specified by:
bytesToLong in interface IElementParser
Parameters:
rawData - byte representation of long value
Returns:
long value
Throws:
org.jdiameter.api.AvpDataException

bytesToFloat

public float bytesToFloat(byte[] rawData)
                   throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to float

Specified by:
bytesToFloat in interface IElementParser
Parameters:
rawData - byte representation of float value
Returns:
float value
Throws:
org.jdiameter.api.AvpDataException

bytesToDouble

public double bytesToDouble(byte[] rawData)
                     throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to double

Specified by:
bytesToDouble in interface IElementParser
Parameters:
rawData - byte representation of double value
Returns:
double value
Throws:
org.jdiameter.api.AvpDataException

prepareBuffer

protected java.nio.ByteBuffer prepareBuffer(byte[] bytes,
                                            int len)

bytesToOctetString

public java.lang.String bytesToOctetString(byte[] rawData)
                                    throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to octet string

Specified by:
bytesToOctetString in interface IElementParser
Parameters:
rawData - byte representation of octet string value
Returns:
octet string value
Throws:
org.jdiameter.api.AvpDataException

bytesToUtf8String

public java.lang.String bytesToUtf8String(byte[] rawData)
                                   throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to utf8 string

Specified by:
bytesToUtf8String in interface IElementParser
Parameters:
rawData - byte representation of utf8 string value
Returns:
utf8 string value
Throws:
org.jdiameter.api.AvpDataException

bytesToDate

public java.util.Date bytesToDate(byte[] rawData)
                           throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to date

Specified by:
bytesToDate in interface IElementParser
Parameters:
rawData - byte representation of date value
Returns:
date value
Throws:
org.jdiameter.api.AvpDataException

bytesToAddress

public java.net.InetAddress bytesToAddress(byte[] rawData)
                                    throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to InetAddress

Specified by:
bytesToAddress in interface IElementParser
Parameters:
rawData - byte representation of InetAddress value
Returns:
InetAddress value
Throws:
org.jdiameter.api.AvpDataException

int32ToBytes

public byte[] int32ToBytes(int value)
Description copied from interface: IElementParser
Convert int to byte array representation

Specified by:
int32ToBytes in interface IElementParser
Parameters:
value - int value
Returns:
byte array

intU32ToBytes

public byte[] intU32ToBytes(long value)
Description copied from interface: IElementParser
Convert long to 4-byte array representation

Specified by:
intU32ToBytes in interface IElementParser
Parameters:
value - long value
Returns:
byte array

int64ToBytes

public byte[] int64ToBytes(long value)
Description copied from interface: IElementParser
Convert long to byte array representation

Specified by:
int64ToBytes in interface IElementParser
Parameters:
value - long value
Returns:
byte array

float32ToBytes

public byte[] float32ToBytes(float value)
Description copied from interface: IElementParser
Convert float to byte array representation

Specified by:
float32ToBytes in interface IElementParser
Parameters:
value - float value
Returns:
byte array

float64ToBytes

public byte[] float64ToBytes(double value)
Description copied from interface: IElementParser
Convert double to byte array representation

Specified by:
float64ToBytes in interface IElementParser
Parameters:
value - double value
Returns:
byte array

octetStringToBytes

public byte[] octetStringToBytes(java.lang.String value)
                          throws DecodeException
Description copied from interface: IElementParser
Convert octet string to byte array representation

Specified by:
octetStringToBytes in interface IElementParser
Parameters:
value - octet string value
Returns:
byte array
Throws:
DecodeException

utf8StringToBytes

public byte[] utf8StringToBytes(java.lang.String value)
                         throws DecodeException
Description copied from interface: IElementParser
Convert utf8 string to byte array representation

Specified by:
utf8StringToBytes in interface IElementParser
Parameters:
value - utf8 string value
Returns:
byte array
Throws:
DecodeException

addressToBytes

public byte[] addressToBytes(java.net.InetAddress address)
Description copied from interface: IElementParser
Convert InetAddress to byte array representation

Specified by:
addressToBytes in interface IElementParser
Parameters:
address - InetAddress value
Returns:
byte array

dateToBytes

public byte[] dateToBytes(java.util.Date date)
Description copied from interface: IElementParser
Convert Date to byte array representation

Specified by:
dateToBytes in interface IElementParser
Parameters:
date - Date value
Returns:
byte array

bytesToObject

public <T> T bytesToObject(java.lang.Class<?> iface,
                           byte[] rawdata)
                throws org.jdiameter.api.AvpDataException
Description copied from interface: IElementParser
Convert byte array to specefied object

Specified by:
bytesToObject in interface IElementParser
Parameters:
iface - type of object
rawdata - byte representation of InetAddress value
Returns:
object instance
Throws:
org.jdiameter.api.AvpDataException

objectToBytes

public byte[] objectToBytes(java.lang.Object data)
                     throws DecodeException
Description copied from interface: IElementParser
Convert specefied object to byte array representation

Specified by:
objectToBytes in interface IElementParser
Parameters:
data - object
Returns:
byte array
Throws:
DecodeException


Copyright © 2008. All Rights Reserved.