org.apache.jdo.impl.fostore
Class UpdateRequest

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.AbstractRequest
      extended byorg.apache.jdo.impl.fostore.AbstractFieldRequest
          extended byorg.apache.jdo.impl.fostore.InsertRequest
              extended byorg.apache.jdo.impl.fostore.UpdateRequest
All Implemented Interfaces:
FieldManager, Request

class UpdateRequest
extends InsertRequest

Represents a request to change one or more fields of a persistent object in the store.

Author:
Dave Bristor

Field Summary
private  java.util.BitSet dirtyFields
          Fields which are to be verified in database, in case of optimistic transaction.
protected  FOStoreSchemaUID fsuid
          uid corresponding to the same java.lang.Class that initializes jdoClass.
protected  JDOClass jdoClass
          Class meta data of the object represented by the constructor's given state manager
protected static int LENGTH_COOKIE
           
private  java.util.BitSet loadedFields
          Fields which are to be updated.
(package private) static org.apache.commons.logging.Log logger
          Logger
protected static I18NHelper msg
           
private  boolean optimistic
          If true, update happens in context of an optimistic transaction.
protected  FOStoreOutput out
          Stream to which request writes itself.
protected  FOStorePMF pmf
          PersistenceManagerFactory via which request is being done.
protected  StateManagerInternal sm
          The state manager which is the subject of this request.
 
Constructor Summary
(package private) UpdateRequest(StateManagerInternal sm, Message m, FOStorePMF pmf, java.util.BitSet loadedFields, java.util.BitSet dirtyFields, boolean optimistic)
           
 
Method Summary
 void doRequest()
          Does whatever it is that the kind of request does in actually making a request of the store.
protected  void doRequestBody()
          Provides the information necessary to do an UpdateRequest.
 boolean fetchBooleanField(int fieldNum)
           
 byte fetchByteField(int fieldNum)
           
 char fetchCharField(int fieldNum)
           
 double fetchDoubleField(int fieldNum)
           
 float fetchFloatField(int fieldNum)
           
 int fetchIntField(int fieldNum)
           
 long fetchLongField(int fieldNum)
           
 java.lang.Object fetchObjectField(int fieldNum)
           
 short fetchShortField(int fieldNum)
           
 java.lang.String fetchStringField(int fieldNum)
           
protected  RequestId getId()
           
protected  OID getOID()
           
 StateManagerInternal getStateManager()
          Get the StateManager associated with this request, null if none.
 void handleReply(Status status, java.io.DataInput in, int length)
          Handles reply data from an UpdateReply.
 void storeBooleanField(int fieldNum, boolean value)
          Provides the means by which the value of a boolean field can be given by a StateManager to an object that needs the value.
 void storeByteField(int fieldNum, byte value)
          Provides the means by which the value of a byte field can be given by a StateManager to an object that needs the value.
 void storeCharField(int fieldNum, char value)
          Provides the means by which the value of a char field can be given by a StateManager to an object that needs the value.
 void storeDoubleField(int fieldNum, double value)
          Provides the means by which the value of a double field can be given by a StateManager to an object that needs the value.
 void storeFloatField(int fieldNum, float value)
          Provides the means by which the value of a field can be given by a StateManager to an object that needs the value.
 void storeIntField(int fieldNum, int value)
          Provides the means by which the value of a int field can be given by a StateManager to an object that needs the value.
 void storeLongField(int fieldNum, long value)
          Provides the means by which the value of a long field can be given by a StateManager to an object that needs the value.
 void storeObjectField(int fieldNum, java.lang.Object value)
          Provides the means by which the value of an Object field can be given by a StateManager to an object that needs the value.
 void storeShortField(int fieldNum, short value)
          Provides the means by which the value of a short field can be given by a StateManager to an object that needs the value.
 void storeStringField(int fieldNum, java.lang.String value)
          Provides the means by which the value of a String field can be given by a StateManager to an object that needs the value.
protected  int writeBlock(int[] fields, boolean identifying)
          Writes a data block, which consists of the values of the specified fields, plus the CLID's and corresponding class names of referenced objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loadedFields

private final java.util.BitSet loadedFields
Fields which are to be updated.


dirtyFields

private final java.util.BitSet dirtyFields
Fields which are to be verified in database, in case of optimistic transaction.


optimistic

private final boolean optimistic
If true, update happens in context of an optimistic transaction.


sm

protected StateManagerInternal sm
The state manager which is the subject of this request.


pmf

protected final FOStorePMF pmf
PersistenceManagerFactory via which request is being done.


out

protected final FOStoreOutput out
Stream to which request writes itself.


jdoClass

protected JDOClass jdoClass
Class meta data of the object represented by the constructor's given state manager


fsuid

protected FOStoreSchemaUID fsuid
uid corresponding to the same java.lang.Class that initializes jdoClass.


msg

protected static final I18NHelper msg

logger

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


LENGTH_COOKIE

protected static final int LENGTH_COOKIE
See Also:
Constant Field Values
Constructor Detail

UpdateRequest

UpdateRequest(StateManagerInternal sm,
              Message m,
              FOStorePMF pmf,
              java.util.BitSet loadedFields,
              java.util.BitSet dirtyFields,
              boolean optimistic)
Method Detail

doRequestBody

protected void doRequestBody()
                      throws java.io.IOException
Provides the information necessary to do an UpdateRequest. The format of this request is (aside from the request header):
 optimistic: boolean
 oid: OID
 data block
 length: int
 InsertRequest's doRequestBody - written data
 
The oid and data block are written only if optimistic is true.

Overrides:
doRequestBody in class InsertRequest
Throws:
java.io.IOException
See Also:
AbstractRequest.doRequestBody()

handleReply

public void handleReply(Status status,
                        java.io.DataInput in,
                        int length)
                 throws java.io.IOException
Handles reply data from an UpdateReply. The format of this reply is
 oid: OID
 

Specified by:
handleReply in interface Request
Overrides:
handleReply in class InsertRequest
Throws:
java.io.IOException
See Also:
Request.handleReply(org.apache.jdo.impl.fostore.Status, java.io.DataInput, int)

storeBooleanField

public void storeBooleanField(int fieldNum,
                              boolean value)
Description copied from interface: FieldManager
Provides the means by which the value of a boolean field can be given by a StateManager to an object that needs the value.

Specified by:
storeBooleanField in interface FieldManager
Overrides:
storeBooleanField in class AbstractFieldRequest
See Also:
FieldManager.storeBooleanField(int fieldNum, boolean value)

storeCharField

public void storeCharField(int fieldNum,
                           char value)
Description copied from interface: FieldManager
Provides the means by which the value of a char field can be given by a StateManager to an object that needs the value.

Specified by:
storeCharField in interface FieldManager
Overrides:
storeCharField in class AbstractFieldRequest
See Also:
FieldManager.storeCharField(int fieldNum, char value)

storeByteField

public void storeByteField(int fieldNum,
                           byte value)
Description copied from interface: FieldManager
Provides the means by which the value of a byte field can be given by a StateManager to an object that needs the value.

Specified by:
storeByteField in interface FieldManager
Overrides:
storeByteField in class AbstractFieldRequest
See Also:
FieldManager.storeByteField(int fieldNum, byte value)

storeShortField

public void storeShortField(int fieldNum,
                            short value)
Description copied from interface: FieldManager
Provides the means by which the value of a short field can be given by a StateManager to an object that needs the value.

Specified by:
storeShortField in interface FieldManager
Overrides:
storeShortField in class AbstractFieldRequest
See Also:
FieldManager.storeShortField(int fieldNum, short value)

storeIntField

public void storeIntField(int fieldNum,
                          int value)
Description copied from interface: FieldManager
Provides the means by which the value of a int field can be given by a StateManager to an object that needs the value.

Specified by:
storeIntField in interface FieldManager
Overrides:
storeIntField in class AbstractFieldRequest
See Also:
FieldManager.storeIntField(int fieldNum, int value)

storeLongField

public void storeLongField(int fieldNum,
                           long value)
Description copied from interface: FieldManager
Provides the means by which the value of a long field can be given by a StateManager to an object that needs the value.

Specified by:
storeLongField in interface FieldManager
Overrides:
storeLongField in class AbstractFieldRequest
See Also:
FieldManager.storeLongField(int fieldNum, long value)

storeFloatField

public void storeFloatField(int fieldNum,
                            float value)
Description copied from interface: FieldManager
Provides the means by which the value of a field can be given by a StateManager to an object that needs the value.

Specified by:
storeFloatField in interface FieldManager
Overrides:
storeFloatField in class AbstractFieldRequest
See Also:
FieldManager.storeFloatField(int fieldNum, float value)

storeDoubleField

public void storeDoubleField(int fieldNum,
                             double value)
Description copied from interface: FieldManager
Provides the means by which the value of a double field can be given by a StateManager to an object that needs the value.

Specified by:
storeDoubleField in interface FieldManager
Overrides:
storeDoubleField in class AbstractFieldRequest
See Also:
FieldManager.storeDoubleField(int fieldNum, double value)

storeStringField

public void storeStringField(int fieldNum,
                             java.lang.String value)
Description copied from interface: FieldManager
Provides the means by which the value of a String field can be given by a StateManager to an object that needs the value.

Specified by:
storeStringField in interface FieldManager
Overrides:
storeStringField in class AbstractFieldRequest
See Also:
FieldManager.storeStringField(int fieldNum, String value)

storeObjectField

public void storeObjectField(int fieldNum,
                             java.lang.Object value)
Description copied from interface: FieldManager
Provides the means by which the value of an Object field can be given by a StateManager to an object that needs the value.

Specified by:
storeObjectField in interface FieldManager
Overrides:
storeObjectField in class AbstractFieldRequest
See Also:
FieldManager.storeObjectField(int fieldNum, Object value)

getOID

protected OID getOID()

writeBlock

protected int writeBlock(int[] fields,
                         boolean identifying)
                  throws java.io.IOException
Writes a data block, which consists of the values of the specified fields, plus the CLID's and corresponding class names of referenced objects.

Parameters:
fields - Field numbers of the fields to be written
identifying - If true, write before/flushed image fields, otherwise write current fields.
Returns:
Position in output stream at which data block starts
Throws:
java.io.IOException

fetchBooleanField

public boolean fetchBooleanField(int fieldNum)
Specified by:
fetchBooleanField in interface FieldManager
See Also:
FieldManager.fetchBooleanField(int fieldNum)

fetchCharField

public char fetchCharField(int fieldNum)
Specified by:
fetchCharField in interface FieldManager
See Also:
FieldManager.fetchCharField(int fieldNum)

fetchByteField

public byte fetchByteField(int fieldNum)
Specified by:
fetchByteField in interface FieldManager
See Also:
FieldManager.fetchByteField(int fieldNum)

fetchShortField

public short fetchShortField(int fieldNum)
Specified by:
fetchShortField in interface FieldManager
See Also:
FieldManager.fetchShortField(int fieldNum)

fetchIntField

public int fetchIntField(int fieldNum)
Specified by:
fetchIntField in interface FieldManager
See Also:
FieldManager.fetchIntField(int fieldNum)

fetchLongField

public long fetchLongField(int fieldNum)
Specified by:
fetchLongField in interface FieldManager
See Also:
FieldManager.fetchLongField(int fieldNum)

fetchFloatField

public float fetchFloatField(int fieldNum)
Specified by:
fetchFloatField in interface FieldManager
See Also:
FieldManager.fetchFloatField(int fieldNum)

fetchDoubleField

public double fetchDoubleField(int fieldNum)
Specified by:
fetchDoubleField in interface FieldManager
See Also:
FieldManager.fetchDoubleField(int fieldNum)

fetchStringField

public java.lang.String fetchStringField(int fieldNum)
Specified by:
fetchStringField in interface FieldManager
See Also:
FieldManager.fetchStringField(int fieldNum)

fetchObjectField

public java.lang.Object fetchObjectField(int fieldNum)
Specified by:
fetchObjectField in interface FieldManager
See Also:
FieldManager.fetchObjectField(int fieldNum)

getId

protected RequestId getId()

doRequest

public final void doRequest()
                     throws java.io.IOException
Description copied from interface: Request
Does whatever it is that the kind of request does in actually making a request of the store.

Specified by:
doRequest in interface Request
Throws:
java.io.IOException - in case of errors with the stream.
See Also:
Request.doRequest()

getStateManager

public StateManagerInternal getStateManager()
Get the StateManager associated with this request, null if none.

Specified by:
getStateManager in interface Request
Returns:
the StateManager.