CADI.Server.Cache
Class ServerCache

java.lang.Object
  extended by CADI.Server.Cache.ServerCache
Direct Known Subclasses:
JPCServerCache

public abstract class ServerCache
extends java.lang.Object

This class is a prototype for all subclasses which implement a cache. Then, these classes have to inherit this abstract class.

Version:
1.0 2007/10/26
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
protected  boolean isCompleteMainHeader
          Indicates if the main header codestream is complete or no.
protected  int lengthOfMainHeaderSent
          Contains the number of bytes of the main header that have been sent.
protected  java.util.Hashtable<java.lang.Long,java.lang.Long> precinctDataBinLengths
          The meaning is the same as precinctDataBinOffsets, but for lengths.
protected  java.util.Hashtable<java.lang.Long,java.lang.Long> precinctDataBinOffsets
          It is a hash table that storages the lengths of delivered data-bins.
 
Constructor Summary
ServerCache()
           
 
Method Summary
protected  void addElementPrecinctDataBin(long inClassIdentifier, long offset, long length)
          Adds offset and length.
abstract  void createCache(ServerLogicalTarget logicalTarget)
          This method has to initialize all variables/structures that will be used in the next methods calls.
 int getMainHeaderSent()
          Returns the number of bytes of the main header which has been sent.
 long getPrecinctDataBinLength(long inClassIdentifier)
          Returns the length of the data-bin.
 long getPrecinctDataBinOffset(long inClassIdentifier)
          Returns the offset of the data-bin.
 boolean isCompleteMainHeader()
          Indicates if the main header has been sent or not.
 void list(java.io.PrintStream out)
          Prints this Client Capabilities and Preferences fields out to the specified output stream.
 void reset()
          Resets the variables to its initials values.
 java.lang.String toString()
           
abstract  void update(java.util.ArrayList<CacheDescriptor> descriptor)
          Updates the server cache with data client has sent or with data sent from the server to the client.
 void update(int classIdentifier, boolean aditive, long inClassIdentifier, long numberOfBytes)
          Updates the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lengthOfMainHeaderSent

protected int lengthOfMainHeaderSent
Contains the number of bytes of the main header that have been sent.


isCompleteMainHeader

protected boolean isCompleteMainHeader
Indicates if the main header codestream is complete or no.


precinctDataBinOffsets

protected java.util.Hashtable<java.lang.Long,java.lang.Long> precinctDataBinOffsets
It is a hash table that storages the lengths of delivered data-bins. The key of the hash is the unique data-bin identifier calculated as:
I = t + (c + s x num_components) + num_tiles
where,
  I is the unique identifier of the precinct within its codestream;
  t is the index (startin from 0) of the tile to which the precinct belongs;
  c is the index (starting from 0) of the image component to which the precinct belongs;
  s is a sequence number which identifies the precinct within its tile-component.
And values of the hash is the offset.


precinctDataBinLengths

protected java.util.Hashtable<java.lang.Long,java.lang.Long> precinctDataBinLengths
The meaning is the same as precinctDataBinOffsets, but for lengths.

Constructor Detail

ServerCache

public ServerCache()
Method Detail

createCache

public abstract void createCache(ServerLogicalTarget logicalTarget)
This method has to initialize all variables/structures that will be used in the next methods calls.

This method will only be called once after the object is created.

Parameters:
logicalTarget -

update

public abstract void update(java.util.ArrayList<CacheDescriptor> descriptor)
Updates the server cache with data client has sent or with data sent from the server to the client.


update

public final void update(int classIdentifier,
                         boolean aditive,
                         long inClassIdentifier,
                         long numberOfBytes)
Updates the cache.

Parameters:
Class - definition in CADI.Common.Cache.CacheDescriptor#Class
aditive - definition in CacheDescriptor.aditive
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
numberOfBytes - definition in CacheDescriptor.numberOfBytes

getMainHeaderSent

public final int getMainHeaderSent()
Returns the number of bytes of the main header which has been sent.

Returns:
main header's number of bytes sent.

isCompleteMainHeader

public final boolean isCompleteMainHeader()
Indicates if the main header has been sent or not.

Returns:
true if the main header is complete, false if it is not.

getPrecinctDataBinOffset

public final long getPrecinctDataBinOffset(long inClassIdentifier)
Returns the offset of the data-bin.

Parameters:
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
Returns:
the offset of the data-bin.

getPrecinctDataBinLength

public final long getPrecinctDataBinLength(long inClassIdentifier)
Returns the length of the data-bin.

Parameters:
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
Returns:
the length of the data-bin.

reset

public void reset()
Resets the variables to its initials values.


addElementPrecinctDataBin

protected void addElementPrecinctDataBin(long inClassIdentifier,
                                         long offset,
                                         long length)
Adds offset and length.

Parameters:
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
offset - definition in JPIPMessageHeader.msgOffset
length - definition in JPIPMessageHeader.msgLength

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

list

public void list(java.io.PrintStream out)
Prints this Client Capabilities and Preferences fields out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)