uk.ac.vamsas.client.simpleclient
Class SimpleClientAppdata

java.lang.Object
  extended byuk.ac.vamsas.client.simpleclient.SimpleClientAppdata
All Implemented Interfaces:
IClientAppdata

public class SimpleClientAppdata
extends java.lang.Object
implements IClientAppdata

Author:
jimp Access interface to data chunks read from a VamsasArchiveReader stream (or byte buffer input stream) or written to a VamsasArchive stream. // TODO: get VamsasArchiveReader from sclient

Field Summary
protected  boolean accessedDocument
          has the session's document been accessed to get the AppData entrys?
protected  ApplicationData appsGlobal
          set by extractAppData
protected  User usersData
          set by extractAppData
 
Constructor Summary
protected SimpleClientAppdata(ClientDocument clientdoc)
          state flags - accessed ClientAppdata - accessed UserAppdata => inputStream from embedded xml or jar entry of backup has been created - set ClientAppdata - set UserAppdata => an output stream has been created and written to - or a data chunk has been written.
 
Method Summary
protected  void closeForWriting()
          flush and close outstanding output streams.
protected  void finalize()
           
 byte[] getClientAppdata()
           
 AppDataInputStream getClientInputStream()
           
 AppDataOutputStream getClientOutputStream()
           
 byte[] getUserAppdata()
           
 AppDataInputStream getUserInputStream()
           
 AppDataOutputStream getUserOutputStream()
           
 boolean hasClientAppdata()
           
 boolean hasUserAppdata()
           
protected  boolean isModified()
           
 void setClientAppdata(byte[] data)
          set the non-User-specific application data
 void setUserAppdata(byte[] data)
          set the User-specific application data
protected  void updateAnAppdataEntry(VamsasArchive vdoc, AppData appd, SessionFile apdjar)
          copy data from the appData jar file to an appropriately referenced jar or Data entry for the given ApplicationData Assumes the JarFile is properly closed.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accessedDocument

protected boolean accessedDocument
has the session's document been accessed to get the AppData entrys?


appsGlobal

protected ApplicationData appsGlobal
set by extractAppData


usersData

protected User usersData
set by extractAppData

Constructor Detail

SimpleClientAppdata

protected SimpleClientAppdata(ClientDocument clientdoc)
state flags - accessed ClientAppdata - accessed UserAppdata => inputStream from embedded xml or jar entry of backup has been created - set ClientAppdata - set UserAppdata => an output stream has been created and written to - or a data chunk has been written. - need flag for switching between embedded and jar entry mode ? - always write a jar entry for a stream. - need code for rewind and overwriting if the set*Appdata methods are called more than once. - need flags for streams to except a call to set*Appdata when an output stream exists and is open. - need

Parameters:
clientdoc - The ClientDocument instance that this IClientAppData is accessing
Method Detail

getClientAppdata

public byte[] getClientAppdata()
Specified by:
getClientAppdata in interface IClientAppdata
Returns:
byte array containing the Client's non-user specific application data

getClientInputStream

public AppDataInputStream getClientInputStream()
Specified by:
getClientInputStream in interface IClientAppdata
Returns:
non-user specific data input stream

getUserAppdata

public byte[] getUserAppdata()
Specified by:
getUserAppdata in interface IClientAppdata
Returns:
byte array containing the Client's user specific application data

getUserInputStream

public AppDataInputStream getUserInputStream()
Specified by:
getUserInputStream in interface IClientAppdata
Returns:
user specific data input stream

updateAnAppdataEntry

protected void updateAnAppdataEntry(VamsasArchive vdoc,
                                    AppData appd,
                                    SessionFile apdjar)
                             throws java.io.IOException
copy data from the appData jar file to an appropriately referenced jar or Data entry for the given ApplicationData Assumes the JarFile is properly closed.

Parameters:
vdoc - session Document handler
appd - the AppData whose block is being updated
apdjar - the new data in a Jar written by this class
Throws:
java.io.IOException

getClientOutputStream

public AppDataOutputStream getClientOutputStream()
Specified by:
getClientOutputStream in interface IClientAppdata
Returns:
non-user specific data output stream

getUserOutputStream

public AppDataOutputStream getUserOutputStream()
Specified by:
getUserOutputStream in interface IClientAppdata
Returns:
user specific data output stream

hasClientAppdata

public boolean hasClientAppdata()
Specified by:
hasClientAppdata in interface IClientAppdata
Returns:
true if Client's non-user specific application data is non-zero length.

hasUserAppdata

public boolean hasUserAppdata()
Specified by:
hasUserAppdata in interface IClientAppdata
Returns:
true if User's Client Application data is non-zero length

setClientAppdata

public void setClientAppdata(byte[] data)
Description copied from interface: IClientAppdata
set the non-User-specific application data

Specified by:
setClientAppdata in interface IClientAppdata
Parameters:
data - - the new non-user-specific data

setUserAppdata

public void setUserAppdata(byte[] data)
Description copied from interface: IClientAppdata
set the User-specific application data

Specified by:
setUserAppdata in interface IClientAppdata
Parameters:
data - - the new user-specific data

closeForWriting

protected void closeForWriting()
                        throws java.io.IOException
flush and close outstanding output streams. - do this before checking data length.

Throws:
java.io.IOException

isModified

protected boolean isModified()
Returns:
true if any AppData blocks have to be updated in session Jar

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable