Rational Developer for i
7.5.0

com.ibm.etools.systems.as400.debug.protocol
Class PROTOCOL_Base

java.lang.Object
  extended by com.ibm.etools.systems.as400.debug.protocol.PROTOCOL_Base
Direct Known Subclasses:
PEBPList, PEveryClause, PFunctCustTable, PRepGetExceptions, PRepGetLanguages, PRepGetViews, PRepTypesAndRepsGetNext, PROTOCOL_ChangeItem, PROTOCOL_ChangePacket, PROTOCOL_Reply, PROTOCOL_Request, PStdAttribute, PStdExpression2, PStdNameValuePair, PStdProperty, PStdTime, PStdView, PViewData, PViews

public abstract class PROTOCOL_Base
extends Object

The base class that all EPDC classes extend


Field Summary
protected  byte[] _byteBuffer
           
static byte DISPLAYDETAIL
           
 
Constructor Summary
  PROTOCOL_Base()
          Used to create a reply/request for output
protected PROTOCOL_Base(byte[] byteBuffer, PROTOCOL_EngineSession engineSession)
          Used to decode an input reply/request
 
Method Summary
protected  int bytesAvailable()
           
protected static void dumpEPDC(byte[] bytes, PROTOCOL_EngineSession engineSession, int packetType)
           
protected abstract  int fixedLen()
          Return the total length of the fixed component including any base fixed length Each reply/request must implement this to return the "fixed" portion of their protocol.
protected  byte[] getByteBuffer()
           
protected  DataInputStream getDataInputStream()
          Return the input stream
protected  PROTOCOL_EngineSession getEPDCEngineSession()
           
protected  int getEPDCVersion()
          Check the EPDC version.
 String getInternalName()
          This is for internal use only.
protected  int getOffset()
          Returns the current offset in the buffer
protected static short getPlatformIdentifier()
           
protected static int intAsBytes(int integer, byte[] bytes, int offset)
          Converts an integer to an array of bytes and stores it in the supplied byte array at the offset
protected  void markOffset()
          Marks the current position in the buffer This must be used after the fixed portion of the EPDC request/reply has been read in.
protected  void posBuffer(int offset)
          Positions the buffer at the offset passed
protected  byte readChar()
          Reads in a character (1 byte)
protected  com.ibm.etools.systems.as400.debug.protocol.PExtString readExtString()
          Reads an EExtString from the current offset.
protected  int readInt()
          Reads in an integer (4 bytes)
protected  int readOffset()
          Reads in a offset (4 bytes)
protected  short readShort()
          Reads in a short (2 bytes)
protected  com.ibm.etools.systems.as400.debug.protocol.PStdString readStdString()
          Reads an EStdString from the current offset.
 void setEPDCEngineSession(PROTOCOL_EngineSession engineSession)
          Need to set the EPDC version before each request is written out.
protected  void skipBytes(int num)
          Skips bytes...
protected  int totalBytes()
           
protected static int totalBytes(PROTOCOL_Base object)
           
protected abstract  int varLen()
          Return the total length of the variable component including any *base* variable length Return the length of the variable component Each reply/request must implement this to return the length of the variable portion of its protocol e.g.
protected  void writeChar(DataOutputStream os, byte b)
          Writes a EPDC Character to the output stream
abstract  void writeFormattedEPDC(DataOutputStream dataOutputStream, byte formatFlags)
          Write to the output stream an XML formatted representation of this EPDC class NOTE: This method should be implemented in all EPDC classes
protected  void writeInt(DataOutputStream os, int d)
          Writes an int (4 bytes) to an output stream
protected  void writeOffset(DataOutputStream os, int offset)
          Writes an offset (4 bytes) to an output stream
protected static int writeOffsetOrZero(DataOutputStream os, int offset, PROTOCOL_Base object)
           
protected  void writeShort(DataOutputStream os, short s)
          Writes a short (2 bytes) to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAYDETAIL

public static final byte DISPLAYDETAIL
See Also:
Constant Field Values

_byteBuffer

protected transient byte[] _byteBuffer
Constructor Detail

PROTOCOL_Base

protected PROTOCOL_Base(byte[] byteBuffer,
                        PROTOCOL_EngineSession engineSession)
Used to decode an input reply/request

Parameters:
engineSession -
Throws:
IOException - if an I/O error occurs

PROTOCOL_Base

public PROTOCOL_Base()
Used to create a reply/request for output

Method Detail

fixedLen

protected abstract int fixedLen()
Return the total length of the fixed component including any base fixed length Each reply/request must implement this to return the "fixed" portion of their protocol. e.g. this.fixedLen() + super.fixedLen()


varLen

protected abstract int varLen()
Return the total length of the variable component including any *base* variable length Return the length of the variable component Each reply/request must implement this to return the length of the variable portion of its protocol e.g. this.varLen() + super.varLen()


skipBytes

protected final void skipBytes(int num)
                        throws IOException
Skips bytes... can be used to skip reserved fields

Throws:
IOException - if an I/O error occurs

readChar

protected final byte readChar()
                       throws IOException
Reads in a character (1 byte)

Throws:
IOException - if an I/O error occurs

writeChar

protected final void writeChar(DataOutputStream os,
                               byte b)
                        throws IOException
Writes a EPDC Character to the output stream

Throws:
IOException - if an I/O error occur

readShort

protected final short readShort()
                         throws IOException
Reads in a short (2 bytes)

Throws:
IOException - if an I/O error occurs

writeShort

protected final void writeShort(DataOutputStream os,
                                short s)
                         throws IOException
Writes a short (2 bytes) to an output stream

Throws:
IOException - if an I/O error occurs

readInt

protected final int readInt()
                     throws IOException
Reads in an integer (4 bytes)

Throws:
IOException - if an I/O error occurs

writeInt

protected final void writeInt(DataOutputStream os,
                              int d)
                       throws IOException
Writes an int (4 bytes) to an output stream

Throws:
IOException - if an I/O error occurs

readOffset

protected final int readOffset()
                        throws IOException
Reads in a offset (4 bytes)

Throws:
IOException - if an I/O error occurs

writeOffset

protected final void writeOffset(DataOutputStream os,
                                 int offset)
                          throws IOException
Writes an offset (4 bytes) to an output stream

Throws:
IOException - if an I/O error occurs

readStdString

protected final com.ibm.etools.systems.as400.debug.protocol.PStdString readStdString()
                                                                              throws IOException
Reads an EStdString from the current offset.

Throws:
IOException - if an I/O error occurs

readExtString

protected final com.ibm.etools.systems.as400.debug.protocol.PExtString readExtString()
                                                                              throws IOException
Reads an EExtString from the current offset. The difference between EExtString and EStdString is in their size, the former is 4 bytes and the latter is only 2 bytes.

Throws:
IOException - if an I/O error occurs

writeOffsetOrZero

protected static final int writeOffsetOrZero(DataOutputStream os,
                                             int offset,
                                             PROTOCOL_Base object)
                                      throws IOException
Throws:
IOException

getOffset

protected final int getOffset()
Returns the current offset in the buffer


markOffset

protected final void markOffset()
                         throws IOException
Marks the current position in the buffer This must be used after the fixed portion of the EPDC request/reply has been read in. This allows offsets to be processed properly

Throws:
IOException - if an I/O error occurs

posBuffer

protected final void posBuffer(int offset)
                        throws IOException
Positions the buffer at the offset passed

Throws:
IOException - if an I/O error occurs

totalBytes

protected int totalBytes()

totalBytes

protected static int totalBytes(PROTOCOL_Base object)

getPlatformIdentifier

protected static final short getPlatformIdentifier()

setEPDCEngineSession

public final void setEPDCEngineSession(PROTOCOL_EngineSession engineSession)
Need to set the EPDC version before each request is written out. This is due to some requests having a different set of parameters based on the EPDC version.


getEPDCVersion

protected final int getEPDCVersion()
Check the EPDC version. This is used for a number of requests that have different set of parameters based on the version of EPDC. If the enginesession is not set then this is an error!


getEPDCEngineSession

protected final PROTOCOL_EngineSession getEPDCEngineSession()

getDataInputStream

protected DataInputStream getDataInputStream()
Return the input stream


getByteBuffer

protected byte[] getByteBuffer()

bytesAvailable

protected int bytesAvailable()
Returns:
the bytes left to retrieve

dumpEPDC

protected static void dumpEPDC(byte[] bytes,
                               PROTOCOL_EngineSession engineSession,
                               int packetType)

intAsBytes

protected static final int intAsBytes(int integer,
                                      byte[] bytes,
                                      int offset)
Converts an integer to an array of bytes and stores it in the supplied byte array at the offset

Parameters:
integer - to be converted
bytes - byte array
offset - offset in byte array
Returns:
next offset in byte array

getInternalName

public String getInternalName()
This is for internal use only. The default will return the name of the class. Where it is meaningful this should overridden

Returns:
internal string name for the request or reply

writeFormattedEPDC

public abstract void writeFormattedEPDC(DataOutputStream dataOutputStream,
                                        byte formatFlags)
Write to the output stream an XML formatted representation of this EPDC class NOTE: This method should be implemented in all EPDC classes

Parameters:
dataOutputStream -
displayInfol - flags used to indicate detail to output

Rational Developer for i
7.5.0

Copyright 2009 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.