Class EbicsDataBuffer
Inheritance
Inherited Members
Namespace: Subsembly.EBICS
Assembly: Subsembly.EBICS.Core.dll
Syntax
public class EbicsDataBuffer
Constructors
EbicsDataBuffer()
Creates a completely empty byte buffer that can be subsequently filled with byte data.
Declaration
public EbicsDataBuffer()
EbicsDataBuffer(Byte[])
Create a byte buffer with an initial content.
Declaration
public EbicsDataBuffer(byte[] vbBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes | 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[], Int32, Int32)
Create a byte buffer with an initial content.
Declaration
public EbicsDataBuffer(byte[] vbBytes, int nOffset, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes | Byte array that holds the initial content. |
System.Int32 | nOffset | Starting offset into the byte array where the content begins. |
System.Int32 | nLength | Length 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(Int32)
Creates a completely empty byte buffer with a given initial capacity.
Declaration
public EbicsDataBuffer(int nInitialCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nInitialCapacity | The 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.
Declaration
public EbicsDataBuffer(string sBase64)
Parameters
Type | Name | Description |
---|---|---|
System.String | sBase64 |
Fields
DEFAULTORDERDATABUFFERSIZE
The default capacity allocated for EBICS order data (=262144 bytes).
Declaration
public const int DEFAULTORDERDATABUFFERSIZE = 262144
Field Value
Type | Description |
---|---|
System.Int32 |
MAXSEGMENTLENGTH
Maximum length of a data segment before base 64 encoding (=786432 bytes).
Declaration
public const int MAXSEGMENTLENGTH = 786432
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
Bytes
Provides the byte array that is managed by this data buffer.
Declaration
public byte[] Bytes { get; }
Property Value
Type | Description |
---|---|
System.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.
Declaration
public int Capacity { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
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.
Item[Int32]
Indexed access to the buffer bytes. The index always zero based, regardless of the actual Offset.
Declaration
public byte this[int i] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i |
Property Value
Type | Description |
---|---|
System.Byte |
Length
Provides or sets the count of significant bytes in this buffer.
Declaration
public int Length { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | 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.
Declaration
public int Offset { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Reserve
The amount of additional reserve capacity that allocated whenever the byte array has to be reallocated.
Declaration
public int Reserve { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SegmentCount
The number of data segments that are needed to transfer this buffer.
Declaration
public int SegmentCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AppendByte(Byte)
Declaration
public void AppendByte(byte b)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | b |
AppendByteArray(Byte[])
Appends a sequence of bytes from a byte array to this byte buffer.
Declaration
public void AppendByteArray(byte[] vbBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes | Byte array that holds the sequence of bytes to be appended to this byte buffer. |
AppendByteArray(Byte[], Int32, Int32)
Appends a sequence of bytes from a byte array to this byte buffer.
Declaration
public void AppendByteArray(byte[] vbBytes, int nOffset, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes | Byte array that holds the sequence of bytes to be appended to this byte buffer. |
System.Int32 | nOffset | Start offset of the sequence of bytes to be appened. |
System.Int32 | nLength | Length of the sequence of bytes to be appened. |
AppendBytes(Byte, Int32)
Declaration
public void AppendBytes(byte b, int nCount)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | b | |
System.Int32 | nCount |
AppendByteStream(Stream, Int32)
Appends byte data from a byte stream to this byte buffer.
Declaration
public int AppendByteStream(Stream aStream, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | aStream | Stream that provides the byte data to be appended to this byte buffer. |
System.Int32 | nLength | Maximum 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
Type | Description |
---|---|
System.Int32 | 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. |
AppendDataBuffer(EbicsDataBuffer)
Appends another byte buffer to this byte buffer.
Declaration
public void AppendDataBuffer(EbicsDataBuffer aByteBuffer)
Parameters
Type | Name | Description |
---|---|---|
EbicsDataBuffer | aByteBuffer | The byte buffer to be appended. If this is |
AppendInteger(Int32, Int32)
Appends the binary representation of an integer.
Declaration
public void AppendInteger(int i, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | The integer value to be appended. |
System.Int32 | nLength | The 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.
Declaration
public void AppendString(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to be appended. Must not be |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter was |
AppendString(String, Encoding)
Declaration
public void AppendString(string s, Encoding aEncoding)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | |
System.Text.Encoding | aEncoding |
Clone()
Create a complete copy of this byte buffer.
Declaration
public EbicsDataBuffer Clone()
Returns
Type | Description |
---|---|
EbicsDataBuffer | A new EbicsDataBuffer instance that is a complete copy of this buffer. |
Compare(EbicsDataBuffer)
Declaration
public bool Compare(EbicsDataBuffer dBuffer)
Parameters
Type | Name | Description |
---|---|---|
EbicsDataBuffer | dBuffer |
Returns
Type | Description |
---|---|
System.Boolean |
Compare(Byte[])
Declaration
public bool Compare(byte[] vbBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes |
Returns
Type | Description |
---|---|
System.Boolean |
Compare(Byte[], Int32, Int32)
Declaration
public bool Compare(byte[] vbBytes, int nOffset, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vbBytes | |
System.Int32 | nOffset | |
System.Int32 | nLength |
Returns
Type | Description |
---|---|
System.Boolean |
ComputeAdler32()
Compute the Adler 32 checksum.
Declaration
public int ComputeAdler32()
Returns
Type | Description |
---|---|
System.Int32 |
ComputeDigest(CryDigest)
Computes the cryptographic digest over the content of this buffer.
Declaration
public EbicsDataBuffer ComputeDigest(CryDigest aDigest)
Parameters
Type | Name | Description |
---|---|---|
Subsembly.Crypto.CryDigest | aDigest | The cryptographic algorithm that shall be used. |
Returns
Type | Description |
---|---|
EbicsDataBuffer | The digest value is wrapped in a new EbicsDataBuffer instance. |
GetSegment(Int32)
Declaration
public EbicsDataBuffer GetSegment(int nSegmentNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nSegmentNumber | The segment number of the segment to return. Must be one or higher. |
Returns
Type | Description |
---|---|
EbicsDataBuffer | Returns a data buffer that contains the data of the indicated segment. If the
requested segment is beyond the buffers content, then |
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()
Declaration
public Stream OpenRead()
Returns
Type | Description |
---|---|
System.IO.Stream |
Peek(Int32)
Returns the first nCount
bytes from this buffer.
Declaration
public byte[] Peek(int nCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | nCount | The number of loading bytes to return from this buffer. Must not be zero or negative. |
Returns
Type | Description |
---|---|
System.Byte[] | Always returns a byte array with exactly |
ToArray()
Creates a new byte array with a copy of the content of this byte buffer.
Declaration
public byte[] ToArray()
Returns
Type | Description |
---|---|
System.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.
Declaration
public string ToBase64()
Returns
Type | Description |
---|---|
System.String |
ToHex()
Converts this buffer's content to a string of hex digits.
Declaration
public string ToHex()
Returns
Type | Description |
---|---|
System.String |
ToString()
Converts this buffer's content to a string using UTF-8 encoding.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
ToString(Encoding)
Converts this buffer's content to a string using the given encoding.
Declaration
public string ToString(Encoding aEncoding)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | aEncoding |
Returns
Type | Description |
---|---|
System.String |
ToXml()
If the content starts with "<?xml", then an attempt is made to convert it to a XML document.
Declaration
public XmlDocument ToXml()
Returns
Type | Description |
---|---|
System.Xml.XmlDocument | If the content could be converted to XML, then a XmlDocument is returned.
Otherwise |
TrimLeadingNullBytes()
Advances the Offset until the first byte that is not a NULL byte.
Declaration
public void TrimLeadingNullBytes()