The preceding pages describe methods you use to create a new opaque type without an existing Java class. When you create an opaque type from existing Java code, you specify the SQL name, JAR file SQL name, support UDRs (if any), and any additional nonsupport UDRs that are included in the opaque type. (For an explanation of SQL names, see SQL Names.) You can also specify the length, alignment, and implicit and explicit casts.
To create an opaque type from existing code, use the following methods:
Support UDRs are input/output, send/receive, and so forth.
In addition, the setXXXCast(), setSupportUDR(), and setUDR() methods are used only for creating an opaque type from existing code:
public void setImplicitCast(int ifxtype, String methodsqlname) throws SQLException public void setExplicitCast(int ifxtype, String methodsqlname) throws SQLException public void setSupportUDR(Method method, String sqlname, int type) throws SQLException public void setUDR(Method method, String sqlname) throws SQLException
The setXXXCast() methods specify the implicit or explicit cast to convert data from an opaque type to the data type specified.
The ifxtype parameter is a type code from the class com.informix.lang.IfxTypes. Data type mapping between the ifxtype parameter and the SQL type in the database server is detailed in Mapping for Casts. The methodsqlname parameter is the SQL name of the Java method that implements the cast.
The following example sets an implicit cast implemented by a Java method with the SQL name circle2_input:
setImplicitCast(com.informix.lang.IfxTypes.IFX_TYPE_LVARCHAR, "circle2_input");
The following example sets an explicit cast implemented by a Java method with the SQL name circle_output:
setExplicitCast(com.informix.lang.IfxTypes.IFX_TYPE_LVARCHAR, "circle2_output");
The following example sets an explicit cast for converting a circle2 opaque type to an integer:
setExplicitCast(com.informix.lang.IfxTypes.IFX_TYPE_INT, "circle2_to_int");
The setSupportUDR() method specifies a Java method in an existing Java class that will be registered as a support UDR for the opaque type.
The method parameter specifies an object from java.lang.reflect.Method to be registered as a Java support UDR for the opaque type in the database server. Support UDRs are Input, Output, Send, Receive, and so forth (for more information, see IBM Informix: User-Defined Routines and Data Types Developer's Guide.)
The sqlname parameter specifies the SQL name of the method. For more information, see SQL Names.
The type parameter specifies the kind of support UDR, as follows:
UDTMetaData.INPUT UDTMetaData.OUTPUT UDTMetaData.SEND UDTMetaData.RECEIVE UDTMetaData.IMPORT UDTMetaData.EXPORT UDTMetaData.BINARYIMPORT UDTMetaData.BINARYEXPORT
For step-by-step information on creating an opaque type from existing code, see ***.
To specify other UDRs, use setUDR() as described in Creating UDRs.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]