net.sourceforge.jwap.wsp
Class WSPDecoder

java.lang.Object
  |
  +--net.sourceforge.jwap.wsp.WSPDecoder

public class WSPDecoder
extends java.lang.Object

This class can be used to extract WSP Primitives from a byte array. The decoder maintains a pointer (index) into the byte array which is increased when calling one of the getter-methods. E.g. calling getUint8() to read a octet will increase the index by one.

Author:
Michel Marti

Constructor Summary
WSPDecoder(byte[] data)
          Construct a new WSP Decoder
 
Method Summary
 byte[] getBytes(int count)
           
 java.lang.String getCString()
           
 java.util.Date getDateValue()
           
 long getIntegerValue()
          Returns a short- or long-integer
 long getLongInteger()
           
 byte getOctet()
           
 int getRemainingOctets()
           
 short getShortInteger()
           
 java.lang.String getString(int length)
           
 java.lang.String getTextString()
           
 int getUint16()
           
 int getUint32()
           
 short getUint8()
           
 long getUintVar()
           
 long getValueLength()
           
 boolean isEOF()
           
 boolean isLongInteger()
           
 boolean isShortInteger()
          isShortInteger tests if the next value is a short int.
 boolean isString()
          isString tests if the next value is a string.
 int pos()
           
 int pos(int position)
           
 int seek(int offset)
          Modify the array index
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSPDecoder

public WSPDecoder(byte[] data)
Construct a new WSP Decoder
Parameters:
data - the data to operate on
Method Detail

getOctet

public byte getOctet()

getUint8

public short getUint8()

getUint16

public int getUint16()

getUint32

public int getUint32()

getUintVar

public long getUintVar()

getCString

public java.lang.String getCString()

getTextString

public java.lang.String getTextString()

getBytes

public byte[] getBytes(int count)

isEOF

public boolean isEOF()

getRemainingOctets

public int getRemainingOctets()

seek

public int seek(int offset)
Modify the array index
Parameters:
offset - the offset (might be negative to seek backwards)
Returns:
the new position of the index

pos

public int pos(int position)

pos

public int pos()

getString

public java.lang.String getString(int length)

getIntegerValue

public long getIntegerValue()
Returns a short- or long-integer

getValueLength

public long getValueLength()

getShortInteger

public short getShortInteger()

getLongInteger

public long getLongInteger()

getDateValue

public java.util.Date getDateValue()

isShortInteger

public boolean isShortInteger()
isShortInteger tests if the next value is a short int.

isLongInteger

public boolean isLongInteger()

isString

public boolean isString()
isString tests if the next value is a string.