Previous Next Contents Index


GX class (deprecated)

The GX class 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 the GX class.

The GX class is a utility class for general operations, such as creating a memory buffer or an IValList object. Like the Math and System classes in the Java Class Library, the GX class provides a suite of static methods that can be used anywhere regardless of whether an instance of the class exists or not.

You call the methods in the GX class by using the following convention: GX.method. The following example shows how you call CreateBuffer( ), a method in the GX class:

IBuffer buff;

buff = GX.CreateBuffer();
Package
com.kivasoft.util

Methods
Method
Description
CreateBuffer( )
Creates a new IBuffer object, which represents a block of memory.
CreateBufferFromString( )
Creates a new IBuffer object, which represents a block of memory, and assigns a string value to it.
CreateStreamBuffer( )
Creates a new IStreamBuffer object, which represents a buffer for capturing streamed output during template processing.
CreateTemplateDataBasic( )
Creates a new ITemplateData object, which represents a hierarchical source of data.
CreateTemplateMapBasic( )
Creates a new ITemplateMap object, which represents a mapping between a template field specification and dynamic data used for template processing.
CreateValList( )
Creates a new IValList object, which represents a collection of values.
ProcessOutput( )
Processes the results in an AppLogic's output IValList (vOut) and returns an ITile object from which the caller can extract data.
Release( )
Releases an object from memory.
WaitForOrder( )
Waits for asynchronous operations, such as database queries, to be completed.

CreateBuffer( )
Creates a new IBuffer object, which represents a block of memory.

Syntax
public static IBuffer CreateBuffer()
Usage
Use CreateBuffer( ) to create IBuffer objects to pass as input arguments to methods, such as put( ) in the TemplateMapBasic class. After you create the IBuffer object, use methods in the IBuffer interface to allocate the memory buffer and to assign a value to it.

Tip
If the buffer is to contain a string, use CreateBufferFromString( ) instead. This method creates the IBuffer object and assigns a string value to it.

Return Value
IBuffer object, or null for failure.

Related Topics
IBuffer interface (deprecated)

CreateBufferFromString( )
Creates a new IBuffer object, which represents a block of memory, and assigns a string value to it.

Syntax
public static IBuffer CreateBufferFromString(
	String str)

str. The string to assign to the memory buffer.

Usage
Use CreateBufferFromString( ) to create an IBuffer object that contains a string value. The put( ) method in the TemplateMapBasic class, for example, takes an IBuffer object and a string value as an input argument.

Return Value
IBuffer object, or null for failure.

Example
String str = "StateName";

IBuffer buff;
buff = GX.CreateBufferFromString(str);
...
ITemplateMap tmplmap;
tmplmap.put("$STATES", buff);
Related Topics
IBuffer interface (deprecated)

CreateStreamBuffer( )
Deprecated. This method is retained for backward compatibility only.

Creates a new IStream object, which represents a buffer for capturing streamed output during template processing.

Syntax
public IStream CreateStreamBuffer(
	IStream stream)

stream. Specify null to create a simple stream buffer. Specify another stream buffer to chain two stream buffers.

Usage
Use CreateStreamBuffer( ) to create a stream buffer to pass to evalOutput( ) or evalTemplate( ). The evalOutput( ) and evalTemplate( ) methods merge a template with data from the ITemplateData object and stream the output to the buffer. Use a stream buffer if, for example, your AppLogic needs to manipulate the data before sending it to another AppLogic.

Tip
The IStream object implements the IStreamBuffer interface. To manipulate data in a stream buffer, use the getStreamData( ) method in the IStreamBuffer interface (deprecated).

Return Value
IStream object, or null for failure.

Related Topics
evalOutput( ) and evalTemplate( ) in the AppLogic class (deprecated)

IStreamBuffer interface (deprecated)

CreateTemplateDataBasic( )
Deprecated. This method is retained for backward compatibility only.

Creates a new ITemplateData object, which represents a hierarchical source of data.

Syntax
public static ITemplateData CreateTemplateDataBasic(
	String str)

str. The name of the TemplateDataBasic object.

Usage
Use CreateTemplateDataBasic( ) to create a hierarchical source of data to pass to evalOutput( ) or evalTemplate( ). The evalOutput( ) and evalTemplate( ) methods merge a template with data from the ITemplateData object and stream an output report.

Tip
CreateTemplateDataBasic( ) returns an ITemplateData object. If the AppLogic needs to call a method in the TemplateDataBasic class, cast the ITemplateData object to the TemplateDataBasic class, as shown in the following example:

TemplateDataBasic td;

td = (TemplateDataBasic)GX.CreateTemplateDataBasic("td");
Return Value
ITemplateData object, or null for failure.

Example
In the following code snippet, two TemplateDataBasic objects are created to store the results from a query to avoid running the same query twice. The two TemplateDataBasic objects are then combined into one and passed to evalTemplate( ) for processing.

// Create the TemplateDataBasic objects.

// CreateTemplateDataBasic() returns an ITemplateData
// object, which is cast to TemplateDataBasic
TemplateDataBasic acctsTempDB = (TemplateDataBasic)GX.CreateTemplateDataBasic("CustAccts");
TemplateDataBasic acctsTempDB2 = (TemplateDataBasic)GX.CreateTemplateDataBasic("CustAccts2");

String acctDesc;
String acctNum;

// Get the indices of columns in the result set
int acctDescCol = rs.getColumnOrdinal("OBAcctType_acctDesc");
int acctNumCol = rs.getColumnOrdinal("OBAcct_acctNum");

// Loop through the result set and add rows to the
// TemplateDataBasic objects
do
{
acctDesc = rs.getValueString(acctDescCol);
acctNum = rs.getValueString(acctNumCol);

String newRowString = "acctDesc=" + acctDesc + ";" +
"acctNum=" + acctNum;

log(newRowString);
acctsTempDB.rowAppend(newRowString);
acctsTempDB2.rowAppend(newRowString);
} while (rs.fetchNext() == 0);

//Create a dummy parent to contain the two template objects
TemplateDataBasic parentTempDB = (TemplateDataBasic)GX.CreateTemplateDataBasic("Parent");
parentTempDB.rowAppend("Dummy=dummy");// one dummy row
parentTempDB.groupAppend(acctsTempDB);
parentTempDB.groupAppend(acctsTempDB2);

// Merge the template data results with a template
if (evalTemplate("GXApp/OnlineBank/templates/Transfer.html", parentTempDB, null) != 0)
{
return handleOBSystemError("Unable to handle template");
}
return (result(null));
Related Topics
evalOutput( ) and evalTemplate( ) in the AppLogic class (deprecated)

ITemplateData interface (deprecated)

TemplateDataBasic class (deprecated)

CreateTemplateMapBasic( )
Deprecated. This method is retained for backward compatibility only.

Creates a new ITemplateMap object, which represents a mapping between a template field specification and dynamic data used for template processing.

Syntax
public static ITemplateMap CreateTemplateMapBasic()
Usage
Use CreateTemplateMapBasic( ) to create a template map object to pass to evalOutput( ) or evalTemplate( ). A template map object is used to link template fields to calculated values or to source data with a non-matching field name but identically-formatted data.

Tip
CreateTemplateMapBasic( ) returns an ITemplateMap object. If the AppLogic needs to call a method in the TemplateMapBasic class, cast to TemplateMapBasic, as shown in the following example:

TemplateMapBasic tmplmap;

tmplmap = (TemplateMapBasic) GX.CreateTemplateMapBasic();
Return Value
ITemplateMap object, or null for failure.

Related Topics
evalOutput( ) and evalTemplate( ) in the AppLogic class (deprecated)

ITemplateMap interface (deprecated)

TemplateMapBasic class (deprecated)

CreateValList( )
Creates a new IValList object, which represents a collection of values.

Syntax
public static IValList CreateValList()
Usage
Use CreateValList( ) to create IValList objects to pass as input arguments to methods, such as execute( ) in the IPreparedQuery interface. After creating the IValList object, use methods in the IValList interface to set values in the IValList.

Return Value
IValList object, or null for failure.

Example
IValList params;

params = GX.CreateValList();
params.setValString(":Make", "Acura")
params.setValString(":Model", "Integra")
...
resultset = pqry.execute(0, params, null, null);
Related Topics
IValList interface

ProcessOutput( )
Deprecated. This method is retained for backward compatibility only.

Processes the results in an AppLogic's output IValList (vOut) and returns an ITile object from which the caller can extract data.

Syntax
public static ITile ProcessOutput(
	IContext context,
	int flags,
	IValList list)

context. The IContext object, which gives the AppLogic access to Netscape Application Server services. Pass in the AppLogic's context member variable.

flags. Specify 0. Internal use only.

list. The output IValList that contains the results returned by a called AppLogic.

Usage
Use ProcessOutput( ) to process non-HTML results that are returned in the following situation:

  1. A client (AppLogic or OCL client application) calls an AppLogic with newRequest( ).
  2. Through newRequest( ), the client passes input and output IValLists to the called AppLogic. If the client is an AppLogic, it should specify the value "ocl" for the gx_client_type key in the input IValList. The "ocl" value is assigned automatically for OCL clients.
  3. The called AppLogic processes the request and returns results in the output IValList.
ProcessOutput( ) returns the processed data as an ITile object. Data in the ITile object is organized like a hierarchical result set. The client can use methods in the ITile interface to loop through the result set and retrieve values.

Return Value
ITile object, or null for failure.

Example
// Call an AppLogic

hr = newRequest(guid, vIn, vOut, 0);
if (hr == GXE.SUCCESS)
{
// Get the root tile from the output vallist
ITile roottile = GX.ProcessOutput(null, 0, vOut);
if (roottile != null)
{
String sval;
ITile ptile;

//Iterate over all products and print their names
ptile = roottile.getTileChild("PRODUCTS");
hr = GXE.SUCCESS;
System.out.println("Products:");
while (ptile != null && hr != GXE.FAIL)
{
sval = ptile.getTileValue("PRODUCTS.ProdName");
System.out.println(" " + sval);

hr = ptile.moveTileNextRecord();
}
Related Topics
newRequest( ) in the AppLogic class (deprecated)

ITile interface (deprecated)

Release( )
Releases an object from memory.

Syntax
public static int Release(
	Object obj)

obj. The object to release.

Usage
Use Release( ) to free an object from memory when it is no longer needed. Although Java automatically detects and frees objects that are no longer being used, the Java garbage collector generally runs only at set garbage collection intervals; unused objects might not be freed immediately. Release( ) gives your application more control over object deallocation and system resource usage.

Return Value
GXE.SUCCESS if the method succeeds.

Example
GX.Release(resultset);
WaitForOrder( )
Deprecated. This method is retained for backward compatibility only.

Waits for asynchronous operations, such as database queries, to be completed.

Syntax
public static int WaitForOrder(
	IOrder orders[],
	IObject context,
	int timeout);

orders. An array of IOrder objects. Each element in the array corresponds to an asynchronous operation.

context. The context object, which is a member variable of the AppLogic class.

timeout. Maximum number of seconds to wait before expiring, if none of the asynchronous queries is finished. Specify 0 to wait forever.

Usage
Use WaitForOrder( ) to wait for one or more asynchronous operations, such as asynchronous database queries, to return the completed results from the database server on which they are submitted. Asynchronous queries that were started with executeQuery( ) in the IDataConn interface might return result sets that are not finished yet. An AppLogic, however, must wait for the result set to be finished before using it.

WaitForOrder( ) waits until one of the following conditions occurs:

Return Value
The index in the orders array of the IOrder that is now completed. WaitForOrder( ) returns a negative number if an error or timeout occurred.

Example
class MyAppLogic extends AppLogic

execute(){
...
IOrder orders[] = new orders[5];
// fill array with order objects

int done_index = GX.WaitForOrder(orders, this.context,
timeout);
if (done_index >= 0)
System.out.println("order finished:" +
orders[done_index]);
else
System.out.println("error or timeout occurred");
Related Topics
IOrder interface (deprecated)

 

© Copyright 1999 Netscape Communications Corp.