public abstract class AbstractDataSegment extends Object implements IDataSegment
This class represents a basic interface for a data segment contained in a ProtocolDataUnit
object.
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
dataBuffer
The buffer of this data segment.
|
protected int |
length
The number of bytes actually used by the
dataBuffer. |
| Constructor and Description |
|---|
AbstractDataSegment(int initMaxChunkSize)
Constructor to create a new, empty
DataSegment object with
the given chunk size. |
| Modifier and Type | Method and Description |
|---|---|
protected static int |
calcPadding(int len)
This methods calculates the number of padding bytes of the given length.
|
void |
clear()
Clears all made settings of this object.
|
boolean |
equals(Object anObject)
Compares this object with another object for equality.
|
int |
getLength()
Returns the length, which is really used by the
dataBuffer. |
SettingsMap |
getSettings()
Returns a
SettingsMap instance of this IDataSegment instance. |
static int |
getTotalLength(int len)
Returns the total length (with padding), which is needed for the given
length
len. |
int |
hashCode() |
org.jscsi.parser.datasegment.AbstractDataSegment.DataSegmentIterator |
iterator()
Returns an iterator over the chunks of this data segment in proper
sequence.
|
protected void |
resizeBuffer(int additionalLength,
boolean copyData)
This method resizes the data buffer, if necessary.
|
int |
serialize(ByteBuffer dst,
int off)
This method exports the data buffer to the given
ByteBuffer object, which is padded to a
integer number of 4 byte words. |
int |
setDataBuffer(ByteBuffer src,
int off,
int len)
Sets the data buffer to the given buffer
src. |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitappend, deserializeprotected ByteBuffer dataBuffer
protected int length
dataBuffer.public AbstractDataSegment(int initMaxChunkSize)
DataSegment object with
the given chunk size.initMaxChunkSize - The maximum size (in bytes) of one chunk, which represents the
MaxRecvDataSegmentLength.public int serialize(ByteBuffer dst, int off)
ByteBuffer object, which is padded to a
integer number of 4 byte words.serialize in interface IDataSegmentdst - Destination ByteBuffer object.off - Start position in dst, where to serialize.public SettingsMap getSettings() throws InternetSCSIException
SettingsMap instance of this IDataSegment instance. This is only
useful with a TextParameterDataSegment instance.getSettings in interface IDataSegmentTextParameterDataSegment instance.InternetSCSIException - if any violation of the iSCSI Standard occurs.public static final int getTotalLength(int len)
len.len - The length of the DataSegment, which want to be
stored.protected void resizeBuffer(int additionalLength,
boolean copyData)
neededLength is greater than the capacity
of allocated data buffer. The flag copyData indicates, if
the old buffer has to be copied into the new bigger data buffer.additionalLength - The length, which is now needed to store all informations in
the data buffer.copyData - true, if old buffer has to be copied into the new
buffer. false indicates, that the new buffer is
initialized with zeros.public void clear()
clear in interface IDataSegmentpublic final int getLength()
dataBuffer.getLength in interface IDataSegmentpublic boolean equals(Object anObject)
public final int setDataBuffer(ByteBuffer src, int off, int len)
src. Starting from
the position offset with length of len.setDataBuffer in interface IDataSegmentsrc - The buffer to read from.off - The start offset to read from.len - The number of bytes to read.public final org.jscsi.parser.datasegment.AbstractDataSegment.DataSegmentIterator iterator()
iterator in interface IDataSegmentprotected static final int calcPadding(int len)
0, ..., BYTES_PER_INT.len - The length for which the padding bytes are calculated.Copyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.