Class EbicsDataBuffer
public class EbicsDataBuffer
- Inheritance
-
EbicsDataBuffer
- Inherited Members
Constructors
EbicsDataBuffer()
Creates a completely empty byte buffer that can be subsequently filled with byte data.
public EbicsDataBuffer()
EbicsDataBuffer(byte[])
Create a byte buffer with an initial content.
public EbicsDataBuffer(byte[] vbBytes)
Parameters
vbBytes
byte[]Byte array that holds the initial content.
Remarks
The EbicsDataBuffer only holds a reference to the given byte array and does not create a copy, yet. Thus any changes to the content of the provided byte array will be seen by the EbicsDataBuffer.
EbicsDataBuffer(byte[], int, int)
Create a byte buffer with an initial content.
public EbicsDataBuffer(byte[] vbBytes, int nOffset, int nLength)
Parameters
vbBytes
byte[]Byte array that holds the initial content.
nOffset
intStarting offset into the byte array where the content begins.
nLength
intLength of the content.
Remarks
The EbicsDataBuffer only holds a reference to the given byte array and does not create a copy, yet. Thus any changes to the content of the provided byte array will be seen by the EbicsDataBuffer.
EbicsDataBuffer(int)
Creates a completely empty byte buffer with a given initial capacity.
public EbicsDataBuffer(int nInitialCapacity)
Parameters
nInitialCapacity
intThe initial capacity that shall be allocated for the new byte buffer. If this is zero, then nothing will be allocated now.
EbicsDataBuffer(string)
Create a data buffer that contains the base 64 encoded data.
public EbicsDataBuffer(string sBase64)
Parameters
sBase64
string
Fields
DEFAULTORDERDATABUFFERSIZE
The default capacity allocated for EBICS order data (=262144 bytes).
public const int DEFAULTORDERDATABUFFERSIZE = 262144
Field Value
MAXSEGMENTLENGTH
Maximum length of a data segment before base 64 encoding (=786432 bytes).
public const int MAXSEGMENTLENGTH = 786432
Field Value
Properties
Bytes
Provides the byte array that is managed by this data buffer.
public byte[] Bytes { get; }
Property Value
- byte[]
Remarks
The actual significant data is just a portion of this array. The significant range of this array is defined through the Offset and Length properties.
Capacity
The current maximum capacity of this byte buffer that is available without causing a reallocation of the byte array.
public int Capacity { get; set; }
Property Value
Remarks
Reducing the capacity by setting this property is not possible and any attempt to do so will be ignored. Increasing the capacity will cause a reallocation any copy of the buffer byte array.
this[int]
Indexed access to the buffer bytes. The index always zero based, regardless of the actual Offset.
public byte this[int i] { get; set; }
Parameters
i
int
Property Value
Length
Provides or sets the count of significant bytes in this buffer.
public int Length { get; set; }
Property Value
- int
The length may be zero but is never negative.
Remarks
It is possible to set the length in order to increase or decrease the amount of significant bytes in this buffer. Increasing the length will append zero bytes to the buffer.
Offset
Byte offset of the first significant byte in this buffer.
public int Offset { get; }
Property Value
Reserve
The amount of additional reserve capacity that allocated whenever the byte array has to be reallocated.
public int Reserve { get; set; }
Property Value
SegmentCount
The number of data segments that are needed to transfer this buffer.
public int SegmentCount { get; }
Property Value
Methods
AppendByte(byte)
public void AppendByte(byte b)
Parameters
b
byte
AppendByteArray(byte[])
Appends a sequence of bytes from a byte array to this byte buffer.
public void AppendByteArray(byte[] vbBytes)
Parameters
vbBytes
byte[]Byte array that holds the sequence of bytes to be appended to this byte buffer.
AppendByteArray(byte[], int, int)
Appends a sequence of bytes from a byte array to this byte buffer.
public void AppendByteArray(byte[] vbBytes, int nOffset, int nLength)
Parameters
vbBytes
byte[]Byte array that holds the sequence of bytes to be appended to this byte buffer.
nOffset
intStart offset of the sequence of bytes to be appened.
nLength
intLength of the sequence of bytes to be appened.
AppendByteStream(Stream, int)
Appends byte data from a byte stream to this byte buffer.
public int AppendByteStream(Stream aStream, int nLength)
Parameters
aStream
StreamStream that provides the byte data to be appended to this byte buffer.
nLength
intMaximum number of bytes to read from the stream and append to this byte buffer. The byte buffer will be reallocated to have a capacity large enough to hold this amount. Thus it is not at all useful to pass Int32.MaxValue here. If this is zero, then the entire stream is read into this buffer.
Returns
- int
Returns the actual number of bytes that have been read from the stream and appended to this byte buffer. This may be less than the requested nLength, if the stream was exhausted before nLength bytes could have been read. It may even be zero if the stream was exhausted from the very beginning.
AppendBytes(byte, int)
public void AppendBytes(byte b, int nCount)
Parameters
AppendDataBuffer(EbicsDataBuffer)
Appends another byte buffer to this byte buffer.
public void AppendDataBuffer(EbicsDataBuffer aByteBuffer)
Parameters
aByteBuffer
EbicsDataBufferThe byte buffer to be appended. If this is
null
, then nothing will be appended.
AppendInteger(int, int)
Appends the binary representation of an integer.
public void AppendInteger(int i, int nLength)
Parameters
i
intThe integer value to be appended.
nLength
intThe number of bytes that shall be appended. This must be zero or a positove value.
Remarks
The bytes are always appended in little endian order, regardless of the plattform.
AppendString(string)
Appends the given string to this byte buffer, using UTF-8 encoding.
public void AppendString(string s)
Parameters
s
stringThe string to be appended. Must not be
null
.
Exceptions
- ArgumentNullException
The parameter was
null
.
AppendString(string, Encoding)
public void AppendString(string s, Encoding aEncoding)
Parameters
Clone()
Create a complete copy of this byte buffer.
public EbicsDataBuffer Clone()
Returns
- EbicsDataBuffer
A new EbicsDataBuffer instance that is a complete copy of this buffer.
Compare(EbicsDataBuffer)
public bool Compare(EbicsDataBuffer dBuffer)
Parameters
dBuffer
EbicsDataBuffer
Returns
Compare(byte[])
public bool Compare(byte[] vbBytes)
Parameters
vbBytes
byte[]
Returns
Compare(byte[], int, int)
public bool Compare(byte[] vbBytes, int nOffset, int nLength)
Parameters
Returns
ComputeAdler32()
Compute the Adler 32 checksum.
public int ComputeAdler32()
Returns
ComputeDigest(CryDigest)
Computes the cryptographic digest over the content of this buffer.
public EbicsDataBuffer ComputeDigest(CryDigest aDigest)
Parameters
aDigest
CryDigestThe cryptographic algorithm that shall be used.
Returns
- EbicsDataBuffer
The digest value is wrapped in a new EbicsDataBuffer instance.
GetSegment(int)
public EbicsDataBuffer GetSegment(int nSegmentNumber)
Parameters
nSegmentNumber
intThe segment number of the segment to return. Must be one or higher.
Returns
- EbicsDataBuffer
Returns a data buffer that contains the data of the indicated segment. If the requested segment is beyond the buffers content, then
null
is returned.
Remarks
This method assumes that leading segments always contain a full MAXSEGMENTLENGTH bytes, and only the last segment contains less or equal to that size bytes.
OpenRead()
public Stream OpenRead()
Returns
Peek(int)
Returns the first nCount
bytes from this buffer.
public byte[] Peek(int nCount)
Parameters
nCount
intThe number of loading bytes to return from this buffer. Must not be zero or negative.
Returns
- byte[]
Always returns a byte array with exactly
nCount
bytes. If the actual buffer content is less thannCount
bytes, then the unused bytes are filled with zeroes.
ToArray()
Creates a new byte array with a copy of the content of this byte buffer.
public byte[] ToArray()
Returns
- byte[]
A newly allocated byte array with a copy of the content of this byte buffer. If this byte buffer is empty, then a zero sized byte array is returned.
ToBase64()
Converts this buffer's content to a base 64 encoded string.
public string ToBase64()
Returns
ToHex()
Converts this buffer's content to a string of hex digits.
public string ToHex()
Returns
ToString()
Converts this buffer's content to a string using UTF-8 encoding.
public override string ToString()
Returns
ToString(Encoding)
Converts this buffer's content to a string using the given encoding.
public string ToString(Encoding aEncoding)
Parameters
aEncoding
Encoding
Returns
ToXml()
If the content starts with "<?xml", then an attempt is made to convert it to a XML document.
public XmlDocument ToXml()
Returns
- XmlDocument
If the content could be converted to XML, then a XmlDocument is returned. Otherwise
null
is returned.
TrimLeadingNullBytes()
Advances the Offset until the first byte that is not a NULL byte.
public void TrimLeadingNullBytes()