org.apache.jdo.impl.fostore
Class Reply

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.Reply
All Implemented Interfaces:
java.io.DataOutput

class Reply
extends java.lang.Object
implements java.io.DataOutput

Represents the result of processing a request.

Author:
Dave Bristor

Field Summary
private  boolean closed
           
(package private) static org.apache.commons.logging.Log logger
          Logger
private static org.apache.jdo.util.I18NHelper msg
          I18N support.
private  FOStoreOutput out
           
private  int replyDataPosition
           
private  RequestId requestId
           
private  Status status
           
private  int statusPosition
           
private static boolean verbose
           
private static int VERSION_NUMBER
          The version number of the current protocol.
 
Constructor Summary
(package private) Reply(RequestId requestId, FOStoreOutput out)
           
 
Method Summary
private  void assertNotClosed()
           
(package private)  int beginStash()
           
(package private)  void endStash(int length, int pos)
           
(package private) static java.lang.String getExceptionMessage(java.lang.Throwable t)
          Indicate whether status reported to client is to be verbose or not.
(package private)  int getPos()
           
(package private)  Status getStatus()
           
(package private)  void setPos(int pos)
           
(package private)  void setStatus(Status status)
          Sets the status of this reply.
(package private)  void setStatus(Status status, java.lang.String message)
          Sets the status of this reply.
(package private)  void setStatus(Status status, java.lang.String message, java.lang.Throwable t)
          Sets the status of this reply.
(package private)  void setStatus(Status status, java.lang.Throwable t)
          Sets the status of this reply.
(package private) static void verifyVersionNumber(java.io.DataInput in)
          Verify the Reply version number.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeBytes(java.lang.String s)
           
 void writeChar(int v)
           
 void writeChars(java.lang.String s)
           
(package private)  void writeCLID(CLID clid)
          Writes a CLID in this reply at the current position.
 void writeDouble(double v)
           
 void writeFloat(float v)
           
 void writeInt(int v)
           
 void writeLong(long v)
           
(package private)  void writeOID(OID oid)
          Writes an OID in this reply at the current position.
 void writeShort(int v)
           
 void writeUTF(java.lang.String str)
           
(package private) static void writeVersionNumber(java.io.DataOutput out)
          Write the version number at the current position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestId

private final RequestId requestId

out

private final FOStoreOutput out

status

private Status status

statusPosition

private final int statusPosition

replyDataPosition

private final int replyDataPosition

closed

private boolean closed

VERSION_NUMBER

private static final int VERSION_NUMBER
The version number of the current protocol. In future, this version number can be used to identify mismatches in protocol. The format is (short)major; (byte)minor; (byte)patch Only use major for compatibility checks; always bump major when incompatibly changing protocol.

Note that this version number corresponds to that used in the entire stream of reply data, not for an individual reply.

See Also:
Constant Field Values

msg

private static final org.apache.jdo.util.I18NHelper msg
I18N support.


logger

static final org.apache.commons.logging.Log logger
Logger


verbose

private static boolean verbose
Constructor Detail

Reply

Reply(RequestId requestId,
      FOStoreOutput out)
throws java.io.IOException
Method Detail

getExceptionMessage

static java.lang.String getExceptionMessage(java.lang.Throwable t)
Indicate whether status reported to client is to be verbose or not.


setStatus

void setStatus(Status status)
         throws java.io.IOException
Sets the status of this reply. Status can be set only one time. Once it has been set, further write methods will throw a FOStoreFatalInternalException.

Parameters:
status - Indication of result of processing a request.
Throws:
java.io.IOException

setStatus

void setStatus(Status status,
               java.lang.Throwable t)
         throws java.io.IOException
Sets the status of this reply. Status can be set only one time. Once it has been set, further write methods will throw a FOStoreFatalInternalException.

Parameters:
status - Indication of result of processing a request.
t - Detail on cause of errors.
Throws:
java.io.IOException

setStatus

void setStatus(Status status,
               java.lang.String message,
               java.lang.Throwable t)
         throws java.io.IOException
Sets the status of this reply. Status can be set only one time. Once it has been set, further write methods will throw a FOStoreFatalInternalException.

Parameters:
status - Indication of result of processing a request.
message - detailed message.
t - Detail on cause of errors.
Throws:
java.io.IOException

setStatus

void setStatus(Status status,
               java.lang.String message)
         throws java.io.IOException
Sets the status of this reply. Status can be set only one time. Once it has been set, further write methods will throw a FOStoreFatalInternalException.

Parameters:
status - Indication of result of processing a request.
message - Detail on cause of errors.
Throws:
java.io.IOException

getStatus

Status getStatus()
Returns:
The Status value of the reply. May return null.

writeVersionNumber

static void writeVersionNumber(java.io.DataOutput out)
                        throws java.io.IOException
Write the version number at the current position.

Throws:
java.io.IOException

verifyVersionNumber

static void verifyVersionNumber(java.io.DataInput in)
                         throws java.io.IOException
Verify the Reply version number.

Throws:
javax.jdo.JDOFatalUserException - if the version number does not match that in the caller's JVM.
java.io.IOException

writeOID

void writeOID(OID oid)
        throws java.io.IOException
Writes an OID in this reply at the current position.

Parameters:
oid - The OID which is written.
Throws:
java.io.IOException

writeCLID

void writeCLID(CLID clid)
         throws java.io.IOException
Writes a CLID in this reply at the current position.

Parameters:
clid - The CLID which is written.
Throws:
java.io.IOException

beginStash

int beginStash()
         throws java.io.IOException
Throws:
java.io.IOException
See Also:
FOStoreOutput.beginStash()

endStash

void endStash(int length,
              int pos)
        throws java.io.IOException
Throws:
java.io.IOException
See Also:
FOStoreOutput.endStash(int, int)

getPos

int getPos()
Returns:
Current position in Reply's output stream.

setPos

void setPos(int pos)
      throws java.io.IOException
Parameters:
pos - New postion in Reply's output stream.
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Throws:
java.io.IOException

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Specified by:
writeBoolean in interface java.io.DataOutput
Throws:
java.io.IOException

writeByte

public void writeByte(int v)
               throws java.io.IOException
Specified by:
writeByte in interface java.io.DataOutput
Throws:
java.io.IOException

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException
Specified by:
writeBytes in interface java.io.DataOutput
Throws:
java.io.IOException

writeChar

public void writeChar(int v)
               throws java.io.IOException
Specified by:
writeChar in interface java.io.DataOutput
Throws:
java.io.IOException

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException
Specified by:
writeChars in interface java.io.DataOutput
Throws:
java.io.IOException

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException
Specified by:
writeDouble in interface java.io.DataOutput
Throws:
java.io.IOException

writeFloat

public void writeFloat(float v)
                throws java.io.IOException
Specified by:
writeFloat in interface java.io.DataOutput
Throws:
java.io.IOException

writeInt

public void writeInt(int v)
              throws java.io.IOException
Specified by:
writeInt in interface java.io.DataOutput
Throws:
java.io.IOException

writeLong

public void writeLong(long v)
               throws java.io.IOException
Specified by:
writeLong in interface java.io.DataOutput
Throws:
java.io.IOException

writeShort

public void writeShort(int v)
                throws java.io.IOException
Specified by:
writeShort in interface java.io.DataOutput
Throws:
java.io.IOException

writeUTF

public void writeUTF(java.lang.String str)
              throws java.io.IOException
Specified by:
writeUTF in interface java.io.DataOutput
Throws:
java.io.IOException

assertNotClosed

private void assertNotClosed()