private static void attribute2resultSet(
final OCMetadataAttributeCollection attributeCollection,
LocalResultSet lrs, String schema, String tableName)
throws SQLException, JIException {
OCAttributeMetadataObject amo = null;
OCTypeDescription typeDescription = null;
int attrSZ = attributeCollection.size();
for (int z = 0; z < attrSZ; z++) {
amo = attributeCollection.get(z);
typeDescription = amo.getTypeDescription();
OCType ot = typeDescription.getType();
int innerType = ot.getTypeCode();
// determinate column size
Integer columnSize = null;
Integer decimalDigits = null;
if (!(typeDescription.isMultiType())) {
switch (innerType) {
case OCType.OCT_STRING: {
columnSize = typeDescription.getStringQualifiers()
.getLength();
break;
}
case OCType.OCT_NUMBER: {
OCNumberQualifiers qualifiers = typeDescription
.getNumberQualifiers();
columnSize = qualifiers.getDigits();
decimalDigits = qualifiers.getFractionDigits();
break;
}
default: {
columnSize = null;
decimalDigits = null;
}
}
}
// determinate char_octet_length
Integer charOctetLength = null;
if (columnSize != null && innerType == OCType.OCT_STRING) {
charOctetLength = columnSize;
}
OCType[] dataType = typeDescription.getNotNullTypes();
lrs.createRowAndSetValues(new Object[] {
null, // TABLE_CAT
schema, // TABLE_SCHEM
tableName, // TABLE_NAME
amo.getName(), // COLUMN_NAME
Integer.valueOf(OCType.typesToSQLType(dataType)), // DATA_TYPE
OCType.typesToSQLTypeName(dataType), // typeDescription.isMultiType()?"MultiType":typeDescription.getType().getSynonym(),
// // TYPE_NAME
columnSize, // COLUMN_SIZE
null, // BUFFER_LENGTH
decimalDigits, // DECIMAL_DIGITS
Integer.valueOf(10), // NUM_PREC_RADIX
Integer.valueOf(columnNullableUnknown), // NULLABLE
amo.getComment(), // REMARKS
null, // COLUMN_DEF
null, // SQL_DATA_TYPE - unused
null, // SQL_DATETIME_SUB - unused
charOctetLength, // CHAR_OCTET_LENGTH
Integer.valueOf(z + 1), // ORDINAL_POSITION
"", // IS_NULLABLE empty string --- if it cannot be
// determined, else YES\NO
// JDBC 3.0
null, // SCOPE_CATLOG
innerType > 100 ? typeDescription.getType().getLinkType()
: null, // SCOPE_SCHEMA
null, // SCOPE_TABLE
null, // SOURCE_DATA_TYPE
"" // IS_AUTOINCREMENT empty string --- if it cannot be
// determined, else YES\NO