public class PrecinctDataBin extends DataBin
Further information, see ISO/IEC 15444-9 section A.2
Modifier and Type | Field and Description |
---|---|
private DataBinStream |
dataStream
Object containing the stream of data.
|
private long |
inClassIdentifier
Definition in
JPIPMessageHeader.inClassIdentifier |
private java.util.ArrayList<java.lang.Integer> |
lengths
Records the cumulated lengths of the completed packets.
|
private java.util.ArrayList<java.lang.Integer> |
numCompletedPackets
An array list which indicates the last full layer achieved with the data
stored in the
dataBin array list. |
classIdentifier, complete
EXTENDED_PRECINCT, EXTENDED_TILE, MAIN_HEADER, METADATA, PRECINCT, TILE, TILE_HEADER
Constructor and Description |
---|
PrecinctDataBin(long inClassIdentifier)
Constructor.
|
PrecinctDataBin(long inClassIdentifier,
int numLayers)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addStream(byte[] data,
long offset,
boolean complete,
int numCompletedPackets)
Adds a precinct data-bin message to the cache.
|
long |
available() |
long |
getInClasIdentifier()
Returns the
inClassIdentifier attribute. |
int |
getLastCompleteLayer(long dataBinLength)
Returns the last completed layer achieved at the byte
dataBinLength
|
int |
getLastCompleteLayerNew(long dataBinLength) |
long |
getLength()
Definition in
DataBinStream.getLength() . |
long |
getNumBytesLeft()
Definition in
DataBinStream.getNumBytesLeft() . |
int |
getNumCompletePackets()
Returns the number of completed packets.
|
int |
getPacketLength(int layer)
Returns the length of the packet
layer . |
int |
getPacketOffset(int layer)
Returns the offset in the data bin of the packet
layer . |
long |
getPos()
Definition in
DataBinStream.getPos() . |
boolean |
isPacketCompleted(int layer)
Returns
true if the packet layer is enterely in
the cache. |
void |
list(java.io.PrintStream out)
Prints this DataBin out to the specified output stream.
|
void |
listData(java.io.PrintStream out)
Prints this DataBin out to the specified output stream.
|
byte |
readByte()
Definition in
DataBinStream.readByte() . |
void |
readFully(byte[] b)
Definition in
DataBinStream.readFully(byte[]) . |
void |
readFully(byte[] b,
int off,
int len)
Definition in
DataBinStream.readFully(byte[], int, int) . |
void |
reset()
Set attributes to its initial values.
|
private void |
saveCompletedPacketsAndLengths(int completedPacket,
int length) |
void |
seek(long offset)
Definition in
DataBinStream.seek(long) . |
int |
skipBytes(int n)
Definition in
DataBinStream.skipBytes(int) . |
java.lang.String |
toString() |
java.lang.String |
toStringShort() |
getClassIdentifier, isComplete, isHeldByCurrentThread, isLocked, lock, unlock
private long inClassIdentifier
JPIPMessageHeader.inClassIdentifier
private DataBinStream dataStream
private java.util.ArrayList<java.lang.Integer> numCompletedPackets
dataBin
array list. A value of 0 indicates
that either there is not data saved for this precinct or the server does
not signal the layer which data belongs (i.e. Aux parameter in jpip
message header has not been used).
Definition in JPIPMessageHeader.Aux
private java.util.ArrayList<java.lang.Integer> lengths
public PrecinctDataBin(long inClassIdentifier)
inClassIdentifier
- definition in inClassIdentifier
.public PrecinctDataBin(long inClassIdentifier, int numLayers)
Passing the number of layers allows a capacity initialization of the stream used to store precinct data bin. Then, performance is improved.
inClassIdentifier
- definition in inClassIdentifier
.numLayers
- public long getInClasIdentifier()
inClassIdentifier
attribute.inClassIdentifier
attribute.public void addStream(byte[] data, long offset, boolean complete, int numCompletedPackets)
This method can only be used when there were no gaps between consecutive message data. Otherwise, and exception is thrown.
data
- definition in JPIPMessage.messageBody
offset
- definition in JPIPMessageHeader.msgOffsetcomplete
- definition in JPIPMessageHeader.isLastBytenumCompletedPackets
- the last full layer (if this information is provived). Otherwise, it is 0.public int getNumCompletePackets()
Returned value could not be the actual number of completed packets because it is updated using the JPIP message's auxiliary information. Then, only when the server sends this information is this value updated correctly.
public boolean isPacketCompleted(int layer)
true
if the packet layer
is enterely in
the cache. layer
values are from 1 to max. number of layers.layer
- number of the packet/layer.true
if it is cached. Otherwise, returns false
public int getLastCompleteLayer(long dataBinLength)
dataBinLength
.
dataBinLength
- public int getLastCompleteLayerNew(long dataBinLength)
public int getPacketLength(int layer)
layer
. layer
values are from 1 to max. number of layers.layer
- is the packet/layer in the precinct stream.public int getPacketOffset(int layer)
layer
.
layer
values are from 1 to max. number of layers.layer
- is the packet/layer in the precinct stream.public long getLength()
DataBinStream.getLength()
.public void seek(long offset)
DataBinStream.seek(long)
.offset
- public int skipBytes(int n)
DataBinStream.skipBytes(int)
.n
- public long getPos()
DataBinStream.getPos()
.public long getNumBytesLeft()
DataBinStream.getNumBytesLeft()
.public long available()
public byte readByte() throws java.io.EOFException
DataBinStream.readByte()
.java.io.EOFException
public void readFully(byte[] b)
DataBinStream.readFully(byte[])
.b
- public void readFully(byte[] b, int off, int len) throws java.io.EOFException
DataBinStream.readFully(byte[], int, int)
.b
- off
- len
- java.io.EOFException
public java.lang.String toStringShort()
public void list(java.io.PrintStream out)
public void listData(java.io.PrintStream out)
out
- an output stream.private void saveCompletedPacketsAndLengths(int completedPacket, int length)
numPackets
- length
-
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)