Previous Next Contents Index


IBuffer interface (deprecated)

The IBuffer interface is deprecated and is provided for backward compatibility only. New applications developed according to the servlet-JSP programming model do not need the functionality provided by IBuffer.

The IBuffer interface represents a block of memory. Input arguments and output value(s) of methods are sometimes stored in IBuffer objects. For example, the get**( ) methods in the IQuery interface return values in an IBuffer object.

IBuffer provides methods for specifying and obtaining the size of the memory block, obtaining its starting address, and copying data to it.

To create an instance of the IBuffer interface, use the GX.CreateBuffer( ) method. To create and initialize an IBuffer object with string contents, use GX.CreateBufferFromString( ).

Package
com.kivasoft

Methods
Method
Description
alloc( )
Specifies the size of the memory block, in bytes.
getAddress( )
Returns a copy of the buffer contents.
getSize( )
Returns the size of the memory block, in bytes.
setData( )
Copies data to a memory block.

alloc( )
Specifies the size of the memory block, in bytes.

Syntax
public int alloc(
	int nSize)

nSize. Size of the memory block, in bytes.

Usage
After creating a memory buffer with the GX.CreateBuffer( ) function, use alloc( ) to specify its size.

Subsequent calls to getSize( ) return the size that AppLogic specified when it called alloc( ).

Rules
Return Value
GXE.SUCCESS if the method succeeds.

Example
String str = "Hello World";

byte tmp[] = new byte[12];
str.getBytes(0, 11, tmp, 0);

IBuffer buff;

buff = GX.CreateBuffer();
buff.alloc(128);
buff.setData(tmp, 12);

// The following example is an alternate to the
// previous one. It uses GX.CreateBufferFromString()
// instead of GX.CreateBuffer().

IBuffer buff;
buff = GX.CreateBufferFromString("Hello World");
Related Topics
getAddress( )

getAddress( )
Returns a copy of the buffer contents.

Syntax
public byte[] getAddress()
Usage
Use getAddress( ) to get a copy of the contents in a buffer.

Return Value
A copy of the buffer contents.

Related Topics
alloc( )

getSize( )
Returns the size of the memory block, in bytes.

Syntax
public int getSize()
Usage
Use getSize( ) to determine the length of the memory buffer that the AppLogic specified when it called alloc( ).

Rule
Before calling getSize( ), AppLogic must first specify the size of the memory block by calling alloc( ).

Return Value
GXE.SUCCESS if the method succeeds.

Related Topics
getAddress( )

setData( )

setData( )
Copies data to a memory block.

Syntax
public int setData(
	byte[] pData,
	int nDataLen)

pData. The data to copy to the memory buffer.

nDataLen. The length, in bytes, of the data to copy to the memory buffer.

Usage
Use setData( ) to copy data to a memory buffer. The buffer can then be passed to a method, such as the setValPieceByOrd( ) method in the ITable interface, that accepts data values in a buffer object.

Return Value
GXE.SUCCESS if the method succeeds.

Example
String str = "Hello World";

byte tmp[] = new byte[12];
str.getBytes(0, 11, tmp, 0);

IBuffer buff;

buff = GX.CreateBuffer();
buff.alloc(128);
buff.setData(tmp, 12);

table.setValPieceByOrd(1, buff, 12);
Related Topics
getAddress( )

getSize( )

 

© Copyright 1999 Netscape Communications Corp.