public class JPIPMessageEncoder
extends java.lang.Object
JPIPMessageEncoder
is useful to encode JPIP messages. It
contains the JPIP header that provides descriptive information to identify
the JPIP message in the data-bin.
Usage example:
constructor
[setIndependentForm]
encoderHeader
Modifier and Type | Field and Description |
---|---|
private byte[] |
encodedHeader
It is an byte array where the encoded JPIP Message Header is stored.
|
private JPIPMessageHeader |
header
Contains the JPIP message header.
|
private boolean |
independentForm
Message header can take an independent form and a dependent form.
|
private int |
lastClass
Contains the last Class value.
|
private int |
lastCSn
Contains the last CSn value.
|
private int |
position
It is an index that indicates the position in jpipMessageHeader.
|
private boolean |
useExtendedHeader
Definition in
ServerControlField.useExtendedHeaders . |
Constructor and Description |
---|
JPIPMessageEncoder()
Default constructor.
|
JPIPMessageEncoder(boolean independentForm)
Constructor
|
JPIPMessageEncoder(boolean independentForm,
boolean useExtendedHeader)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private static int |
calculateNecessaryBytes(long value)
Calculate the number of bytes that are necessary to encode a value
using the VBAS.
|
private void |
encodeEOR()
ISO/IEC 15444-9 section D.3
|
private byte[] |
encoderHeader(boolean completeDataBin,
long InClassIdentifier,
int Class,
int CSn,
long MsgOffset,
long MsgLength,
int Aux)
The message header consists of a sequence of bytes, all but the
last of which has a most significant bit (bit 7) of 1.
|
byte[] |
encoderHeader(JPIPMessageHeader header)
Encodes a JPIP Message Header following a sequence of variable-length
byte-aligned segments (VBAS).
|
static int |
estimateLength(JPIPMessageHeader header)
Estimates the length of the JPIP message header.
|
void |
list(java.io.PrintStream out)
Prints this JPIP Message Encoder fields out to the specified output
stream.
|
void |
reset()
Sets the attributes to its initial vaules.
|
void |
setIndependentForm(boolean independentForm)
Sets the independent form for encoding the JPIP message header or the
dependent form.
|
void |
setUseExtendedHeaders(boolean useExtendedHeaders)
Sets the
useExtendedHeader attribute. |
java.lang.String |
toString()
Returns this JPIP Message as a String.
|
private void |
writeVBASInteger(long value)
Encodes a value with with a VBAS in a buffer.
|
private JPIPMessageHeader header
private byte[] encodedHeader
private int position
encodeHeader
and
writeVBASInteger
methods.private boolean independentForm
private boolean useExtendedHeader
ServerControlField.useExtendedHeaders
.private int lastClass
private int lastCSn
public JPIPMessageEncoder()
public JPIPMessageEncoder(boolean independentForm)
independentForm
- definition in independentForm
.public JPIPMessageEncoder(boolean independentForm, boolean useExtendedHeader)
independentForm
- definition in independentForm
.useExtendedHeader
- definition in useExtendedHeader
.public void reset()
public void setIndependentForm(boolean independentForm)
independentForm
- if true, the independent form is used. False, the
header is built using the dependent form.public void setUseExtendedHeaders(boolean useExtendedHeaders)
useExtendedHeader
attribute.useExtendedHeaders
- definition in useExtendedHeader
.public byte[] encoderHeader(JPIPMessageHeader header)
Message header format:
Bin-ID [,Class] [,CSn], Msg-Offset, Msg-Length [,Aux]
where Bin-ID = BinIDIndicator, completeDataBin InClassIdentifier
public static int estimateLength(JPIPMessageHeader header)
This methods performs a rough estimation (upper bound) of the JPIP message length.
header
- an JPIPMessageHeader
object.public java.lang.String toString()
toString
in class java.lang.Object
public void list(java.io.PrintStream out)
out
- an output stream.private void encodeEOR()
private byte[] encoderHeader(boolean completeDataBin, long InClassIdentifier, int Class, int CSn, long MsgOffset, long MsgLength, int Aux)
Message header format:
Bin-ID [,Class] [,CSn], Msg-Offset, Msg-Length [,Aux]
where Bin-ID = BinIDIndicator, completeDataBin InClassIdentifier
private void writeVBASInteger(long value)
value
- the value to be encoded.private static int calculateNecessaryBytes(long value)
value
- the value to encode
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)