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