CADI.Common.Cache
Class DataBinsCacheManagement

java.lang.Object
  extended by CADI.Common.Cache.DataBinsCacheManagement
Direct Known Subclasses:
ClientCacheManagement, ProxyCacheManagement

public class DataBinsCacheManagement
extends java.lang.Object

This class implements some useful method fo the maganement of a databin cache.

Version:
1.0 2009/08/24
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
protected  CODParameters codParameters
          Definition in JPCParameters.codParameters.
static int EXPLICIT_FORM
          Allowed values for the cache type.
static int IMPLICIT_FORM
           
static int INDEX_RANGE
           
protected  DataBin mainHeaderDataBin
          Contains the main header codestream.
static int NUMBER_OF_BYTES
           
static int NUMBER_OF_LAYERS
           
protected  java.util.Map<java.lang.Long,DataBin> precinctsDataBins
          Is a hastable contains the received data for each precinct data-bin.
protected  SIZParameters sizParameters
          Definition in JPCParameters.sizParameters.
protected  int type
           
static int WILDCARD
          Allowed values fo the cache subtype.
 
Constructor Summary
DataBinsCacheManagement()
          Constructor.
 
Method Summary
 void addJPIPMessage(byte[] jpipMessageBody, int classIdentifier, long inClassIdentifier, boolean completeDataBin, long offset, int aux)
           
 void addJPIPMessage(JPIPMessage jpipMessage)
           
protected  java.util.ArrayList<CacheDescriptor> explicitForm(java.util.ArrayList<java.lang.Long> relevantPrecincts, int subType)
          Gets the cache descriptor following the explicit form.
protected  java.util.ArrayList<CacheDescriptor> explicitForm(int subType)
          Gets the cache descriptor following the explicit form.
 java.util.ArrayList<CacheDescriptor> getCacheDescriptor(ViewWindowField viewWindow, int type, int subType)
           
 DataBin getDataBin(int classIdentifier, long inClassIdentifier)
          Returns the byte array of the data-bin idientified by classIdentifier and the inClassIdentifier.
 byte[] getMainHeader()
          Returns the image main header if it is available, otherwise returns null.
 java.util.ArrayList<byte[]> getPrecinctDataBin(long inClassIdentifier)
          Returns the byte array of the data-bin idientified by inClassIdentifier.
 java.util.Set<java.lang.Long> getPrecinctDataBins()
           
protected  java.util.ArrayList<CacheDescriptor> implicitForm(java.util.ArrayList<java.lang.Long> relevantPrecincts)
          Gets the cache descriptor following the implicit form.
 boolean isCompleteMainHeader()
           
 boolean isInCache(ViewWindowField viewWindow)
          This method is used to check if a requested window of interest can be retrieved from the data stored in the cache.
 void list(java.io.PrintStream out)
          Prints this cache out to the specified output stream.
private static void printByteStream(byte[] buffer)
          Useful method for printing out a ByteStream.
 void reset()
          Sets the attributes to its initial values.
 void setSIZAndCODParamters(SIZParameters sizParameters, CODParameters codParameters)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mainHeaderDataBin

protected DataBin mainHeaderDataBin
Contains the main header codestream.


precinctsDataBins

protected java.util.Map<java.lang.Long,DataBin> precinctsDataBins
Is a hastable contains the received data for each precinct data-bin.


sizParameters

protected SIZParameters sizParameters
Definition in JPCParameters.sizParameters.


codParameters

protected CODParameters codParameters
Definition in JPCParameters.codParameters.


type

protected int type

EXPLICIT_FORM

public static final int EXPLICIT_FORM
Allowed values for the cache type.

Further information, see ISO/IEC 15444-9 sections C.8.1.2 y C.8.1.3

See Also:
Constant Field Values

IMPLICIT_FORM

public static final int IMPLICIT_FORM
See Also:
Constant Field Values

WILDCARD

public static final int WILDCARD
Allowed values fo the cache subtype.

Further information, see ISO/IEC 15444-9 sections C.8.1.2 y C.8.1.3

See Also:
Constant Field Values

INDEX_RANGE

public static final int INDEX_RANGE
See Also:
Constant Field Values

NUMBER_OF_LAYERS

public static final int NUMBER_OF_LAYERS
See Also:
Constant Field Values

NUMBER_OF_BYTES

public static final int NUMBER_OF_BYTES
See Also:
Constant Field Values
Constructor Detail

DataBinsCacheManagement

public DataBinsCacheManagement()
Constructor.

Method Detail

setSIZAndCODParamters

public void setSIZAndCODParamters(SIZParameters sizParameters,
                                  CODParameters codParameters)

addJPIPMessage

public void addJPIPMessage(JPIPMessage jpipMessage)
Parameters:
jpipMessage -

addJPIPMessage

public void addJPIPMessage(byte[] jpipMessageBody,
                           int classIdentifier,
                           long inClassIdentifier,
                           boolean completeDataBin,
                           long offset,
                           int aux)
Parameters:
jpipMessageBody - definition in JPIPMessage.messageBody
classIdentifier - definition in CADI.Common.Cache.CacheDescriptor#Class
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
completeDataBin - definition in JPIPMessageHeader.isLastByte
offset - definition in JPIPMessageHeader.msgOffset
aux - definition in JPIPMessageHeader.Aux

getDataBin

public DataBin getDataBin(int classIdentifier,
                          long inClassIdentifier)
Returns the byte array of the data-bin idientified by classIdentifier and the inClassIdentifier. If the data-bin is not in the cache, a null pointer is returned.

Parameters:
classIdentifier - definition in JPIPMessageHeader.classIdentifier
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
Returns:
the byte array of the data-bin. A null pointer if the data-bin is not in the cache.

getPrecinctDataBin

public final java.util.ArrayList<byte[]> getPrecinctDataBin(long inClassIdentifier)
Returns the byte array of the data-bin idientified by inClassIdentifier. If the data-bin is not in the cache, a null pointer is returned.

Parameters:
inClassIdentifier - definition in JPIPMessageHeader.inClassIdentifier
Returns:
the byte array of the data-bin. A null pointer if the data-bin is not in the cache.

getPrecinctDataBins

public final java.util.Set<java.lang.Long> getPrecinctDataBins()
Returns:

isCompleteMainHeader

public final boolean isCompleteMainHeader()
Returns:

getMainHeader

public final byte[] getMainHeader()
Returns the image main header if it is available, otherwise returns null.

Returns:
the main header if it is available.

reset

public void reset()
Sets the attributes to its initial values.


isInCache

public boolean isInCache(ViewWindowField viewWindow)
This method is used to check if a requested window of interest can be retrieved from the data stored in the cache.

Parameters:
viewWindow - definition in ViewWindowField.
Returns:
it will return true if the WOI can be recovered. Otherwise, it will return false.

getCacheDescriptor

public java.util.ArrayList<CacheDescriptor> getCacheDescriptor(ViewWindowField viewWindow,
                                                               int type,
                                                               int subType)
Parameters:
viewWindow -
type -
subtype -
Returns:

toString

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

list

public void list(java.io.PrintStream out)
Prints this cache out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

explicitForm

protected java.util.ArrayList<CacheDescriptor> explicitForm(java.util.ArrayList<java.lang.Long> relevantPrecincts,
                                                            int subType)
Gets the cache descriptor following the explicit form.

Parameters:
relevantPrecincts - an array list with the relevant precincts which will be included in the cache descriptor.
Returns:
an array list with the cache descriptors.

explicitForm

protected java.util.ArrayList<CacheDescriptor> explicitForm(int subType)
Gets the cache descriptor following the explicit form.

Returns:
an array list with the cache descriptors.

implicitForm

protected java.util.ArrayList<CacheDescriptor> implicitForm(java.util.ArrayList<java.lang.Long> relevantPrecincts)
Gets the cache descriptor following the implicit form.

Parameters:
relevantPrecincts - an array list with the relevant precincts which will be included in the cache descriptor.
Returns:
an array list with the cache descriptors.

printByteStream

private static void printByteStream(byte[] buffer)
Useful method for printing out a ByteStream. Only for debugging purposes.

Parameters:
buffer - the byte array to be printed.


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)