Bridges > Java Export Bridge > Stock Java Wrapper Methods

# Stock Java Wrapper Methods

This section describes the stock methods in the Java wrapper objects created by the Export Bridge Assistant:

- abort
- createObject
- destroyObject
- executeString
- getIDLObjectClassName
- getIDLObjectVariableName
- getIDLVariable
- getProcessName
- isObjectCreated
- setIDLVariable
- setProcessName

Every Java connector object and custom Java wrapper object has these methods in addition to those defined by the wrapped IDL object.

## abort

The abort method requests that the IDL process containing the underlying IDL object abort its current activity. This method is useful if a given IDL method call is busy for a very long time (e.g., a very long image processing command).

Note: The request is only that, a request, and IDL might take a long time before it actually stops or might completely finish its current activity. Such a wait is an effect of the IDL interpreter.

Note that the client can only call abort from a different thread than the one currently executing because the method executing is, by its nature, blocked. The caller cannot abort IDL activity that is occurring from an execution call in another wrapper object. The client can only abort the current IDL activity if that wrapper object is the current owner of the underlying IDL process. For more information on error return code relating to aborting, see Error Handling.

### Syntax

public void abort()

### Arguments

None

## createObject

The createObject method creates the actual underlying IDL object. The argc, argv, and argpal arguments are used to supply parameters to the underlying IDL object’s Init method. If the Init method does not have any parameters, the caller sets argc, argv, and argpal to 0, null, and null, respectively. The initializer argument is used to specify IDL process initialization parameters (notably the IDL licensing mode).

The createObject method does the following:

1. It calls the Init method for the IDL object.
2. It calls the superclass initListeners method (either JIDLCanvas::initListeners or JIDLObject::initListeners) to initialize any event handlers.

The initListeners method has default behavior, which is different for drawable and nondrawable objects (see Event Handling for more information). If the default behavior is not desired, a subclass to modify the listener initialization can override the initListeners method.

Note: Registering or unregistering listeners for events should happen in the initListeners method or AFTER the createObject method.

### Syntax

public void createObject( )

public void createObject(int argc, Object[] argv, int[] argpal)

public void createObject(int argc, Object[] argv, int[] argpal, JIDLProcessInitializer initializer)

public void createObject(JIDLProcessInitializer initializer)

### Arguments

argc

The number of parameters to be passed to Init.

argv

The array of objects to be passed to IDL. This array should be of length argc and should contain objects of type JIDLNumber, JIDLObjectI, JIDLString, or JIDLArray.

argpal

An array of argc flags denoting whether each argv parameter that is of type array should be convolved or not. For parameters that are not arrays, the value within the array will always be 0.

initializer

A JIDLProcessInitializer object that encapsulates the IDL process initialization parameters. (Process initialization parameters allow the Java programmer to control the licensing mode of the IDL process. See “IDL Licensing Modes” on page 136 for details on the default licensing mechanism.)

### Example

The Init method of the IDL object being wrapped has the following signature:

PRO IDLexFoo::INIT, rect, filename

where rect is an array of four integers and filename is a string.

The following is an example of Java client code that creates an instance of the wrapper object and calls the createObject method with the rect and filename parameters:

// These are the Java types we want to pass to the ::Init method

int[] rect = {0, 0, 5, 10};

String file = "someFilename.txt";

// Wrap the Java types using Export Bridge data types

JIDLArray bRect = new JIDLArray(rect);

JIDLString bFile = new JIDLString(file);

// Create the wrapper object

MyWrapper wrapper = new MyWrapper();

// Set up parameters to pass to createObject

final int ARGC = 2;

Object[] argv = new Object[ARGC];

int[] argp = new int[ARGC];

argv[0] = bRect;

argp[0] = JIDLConst.PARMFLAG_CONST; // "in-only" parameter argv[1] = bFile;

argp[1] = JIDLConst.PARMFLAG_CONST; // "in-only" parameter

// Create the underlying IDL object and call

// its ::Init method with parameters and default IDL

// process initialization settings

wrapper.createObject(ARGC, argv, argp);

Note: See Java Object Creation for additional examples of creating Java wrapper objects with and without parameters.

## destroyObject

The destroyObject method destroys the underlying IDL object associated with the wrapper. If the object being destroyed is the last object within a process, the process is also destroyed.

Note that this method does not destroy the actual wrapper object. Because the wrapper object is a Java object, it follows all the Java reference-counting and garbage-collection schemes. Once all references to the wrapper object are released from Java code and once the JVM calls the garbage collector, the wrapper object may be deleted from memory.

Note: Trying to re-create an object after it has been destroyed it is not supported. You must re-define the variable and then re-create the object.

### Syntax

public void destroyObject()

### Arguments

None

## executeString

The executeString method executes the specified command in the IDL process containing the underlying IDL object

Note: This method is disabled for applications running in the IDL Virtual Machine.

### Syntax

public void executeString(String sCmd)

### Arguments

sCmd

The command to be executed.

### Examples

See IDL Command Line with Java Connector Object for an example that executes an IDL command entered into one textbox and writes IDL output or error information to a second textbox.

## getIDLObjectClassName

The getIDLObjectClassName method returns the IDL object class name of the underlying IDL object.

### Syntax

public String getIDLObjectClassName()

### Arguments

None

## getIDLObjectVariableName

When the underlying IDL object was created in the IDL process, it was assigned a variable name. The getIDLObjectVariableName method returns that name.

### Syntax

public String getIDLObjectVariableName()

### Arguments

None

## getIDLVariable

The getIDLVariable method retrieves the named variable from the IDL process associated with the underlying IDL object.

Note: This method is disabled for applications running in the IDL Virtual Machine.

### Syntax

public Object getIDLVariable(String sVar)

### Arguments

sVar

The named variable to be retrieved. The returned object is of type JIDLNumber, JIDLString, JIDLObjectI, or JIDLArray.

If the variable is an array, the array is always converted from IDL majority to the standard Java array majority. (For more information on implications of array majority, see Multidimensional Array Storage and Access.)

### Examples

See Data Manipulation with a Java Connector Object for an array manipulation example that uses the getIDLVariable, setIDLVariable and executeString methods.

## getProcessName

The getProcessName method returns the name of the process associated with the underlying IDL object.

### Syntax

public String getProcessName()

### Arguments

None

## isObjectCreated

The isObjectCreated method returns True if the object has been created successfully and returns False if the object has not yet been created or if the object creation was unsuccessful. This call is often useful in a multi-threaded environment to check that an object is created before making a method call on that object.

### Syntax

public boolean isObjectCreated()

### Arguments

None

## setIDLVariable

The setIDLVariable method sets the specified variable name to the specified value in the IDL process containing the underlying IDL object. If the type is JIDLArray, it is always converted to IDL majority.

Note: This method is disabled for applications running in the IDL Virtual Machine.

### Syntax

public void setIDLVariable(String sVar, Object value)

### Arguments

sVar

A string identifying the variable in the IDL process to be set to value.

value

The value for sVar. The value should be an object of type JIDLNumber, JIDLString, JIDLObjectI, or JIDLArray. If the variable does not exist, it is created.

### Examples

See Data Manipulation with a Java Connector Object for an array manipulation example that uses the getIDLVariable, setIDLVariable and executeString methods.

## setProcessName

The setProcessName method sets the name of the process that will contain the IDL object. This can only be called before making the createObject call. Once the object is created, the process name cannot be reset and calling this method after createObject has no effect.

### Syntax

public void setProcessName(String sProcess)

### Arguments

sProcess

A string containing the name of the process that will contain the IDL object.