Top Description Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv final Class DRDAString

extends Object
Class Inheritance

This class provides functionality for reusing buffers and strings when parsing DRDA packets. A byte array representing a string is stored internally. When the string is requested as a String object, the byte array is converted to a string, and the string is cached to avoid unnecessary conversion later.

Field Summary

Modifier and TypeField and Description
private byte[]
buffer

Buffer representing the string.

private String
cachedString

The previously generated string.

private boolean
modified

True if the contents were modified in the previous call to setBytes.

private final DDMWriter
writer

Keep the DDMWriter as it contains the current CCSID manager being used

Constructor Summary

AccessConstructor and Description
pack-priv
DRDAString(DDMWriter
a DDMWriter which holds current CCSidManager and which encoding is used
w
)

Create a new DRDAString instance.

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true if the internal buffer contains the same data as the specified byte array
equalTo
(byte[]
a byte array
buf
,
int
start position in the byte array
offset
,
int
how many bytes to read from the byte array
size
)

Check whether the internal buffer contains the same data as another byte buffer.

public byte[]

Returns:

internal buffer
getBytes
()

Return the internal byte array.

public int

Returns:

length of internal representation
length
()

Return the length in bytes of the internal string representation.

public void
setBytes(byte[]
the new bytes
src
,
int
start offset
offset
,
int
number of bytes to use
size
)

Modify the internal byte buffer.

public String

Returns:

a String value
toString
()

Overrides java.lang.Object.toString.

Convert the internal byte array to a string.
public boolean

Returns:

true if the contents were modified
wasModified
()

Check whether the contents of the DRDAString were modified in the previous call to setBytes().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufferback to summary
private byte[] buffer

Buffer representing the string.

cachedStringback to summary
private String cachedString

The previously generated string.

modifiedback to summary
private boolean modified

True if the contents were modified in the previous call to setBytes.

writerback to summary
private final DDMWriter writer

Keep the DDMWriter as it contains the current CCSID manager being used

Constructor Detail

DRDAStringback to summary
pack-priv DRDAString(DDMWriter w)

Create a new DRDAString instance.

Parameters
w:DDMWriter

a DDMWriter which holds current CCSidManager and which encoding is used

Method Detail

equalToback to summary
private boolean equalTo(byte[] buf, int offset, int size)

Check whether the internal buffer contains the same data as another byte buffer.

Parameters
buf:byte[]

a byte array

offset:int

start position in the byte array

size:int

how many bytes to read from the byte array

Returns:boolean

true if the internal buffer contains the same data as the specified byte array

getBytesback to summary
public byte[] getBytes()

Return the internal byte array. The returned array should not be modified, as it is used internally in DRDAString. The value of the array might be modified by subsequent calls to DRDAString.setBytes().

Returns:byte[]

internal buffer

lengthback to summary
public int length()

Return the length in bytes of the internal string representation.

Returns:int

length of internal representation

setBytesback to summary
public void setBytes(byte[] src, int offset, int size)

Modify the internal byte buffer. If the new data is equal to the old data, the cached values are not cleared.

Parameters
src:byte[]

the new bytes

offset:int

start offset

size:int

number of bytes to use

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Convert the internal byte array to a string. The string value is cached.

Returns:String

a String value

wasModifiedback to summary
public boolean wasModified()

Check whether the contents of the DRDAString were modified in the previous call to setBytes().

Returns:boolean

true if the contents were modified