}
if (t != null) {
result = t;
if (mustBeNew && predefined) {
throw new PublisherException("duplicate type " + result.toString());
}
else if (mustBeNew) {
t.setNameObject(sqlName);
}
return result;
}
String schema = sqlName.getSchemaName();
String type = sqlName.getTypeName();
if (whatIsIt == IS_TOPLEVEL) {
return new SqlToplevelType(sqlName, parentType, signatureFilter, this);
}
else if ((whatIsIt & IS_PACKAGE) != 0) {
Iterator<ViewRow> rowIter = m_viewCache.getRows(ALL_OBJECTS,
new String[]{"'PACKAGE' AS TYPECODE"}, new String[]{OWNER, OBJECT_NAME,
"OBJECT_TYPE", "STATUS"}, new Object[]{schema, type, "PACKAGE", "VALID"},
new String[0]);
if (rowIter.hasNext()) {
m_viewCache.fetch(type, signatureFilter);
result = new SqlPackageType(sqlName, parentType, signatureFilter, this);
}
if (result != null) {
return result;
}
if (whatIsIt == IS_PACKAGE) {
throw new PublisherException("package not found " + sqlName.toString());
}
}
/* determine whether this is an opaque type */
Iterator<ViewRow> iter = m_viewCache.getRows(ALL_TYPES, new String[0], new String[]{
OWNER, TYPE_NAME, "PREDEFINED"}, new Object[]{schema, type, "NO"},
new String[0]);
if (iter.hasNext()) {
AllTypes allTypes = (AllTypes)iter.next();
String typeCode = allTypes.typeCode;
byte[] typeOID = allTypes.typeOid;
int dbTypeCode = 0;
int kind = 0;
if (!m_getTypeCodeWarning) {
try {
Object[] outParams = m_viewCache.getOutParameters(
"BEGIN sys.sqljutl.get_typecode(:1, :2, :3, :4); END;",
new Object[]{typeOID}, new int[]{OracleTypes.INTEGER,
OracleTypes.VARCHAR, OracleTypes.INTEGER});
if (outParams == null) {
throw new SQLException("no data from sqljutl.get_typecode call");
}
dbTypeCode = ((Integer)outParams[0]).intValue();
kind = ((Integer)outParams[2]).intValue();
}
catch (SQLException exn) {
String msg = exn.getMessage();
if (isPre920()) {
// an older database version will not have GET_TYPECODE
msg = null;
m_getTypeCodeWarning = true;
}
else if (msg.indexOf("PLS-00201") > 0) {
msg = "cannot determine type " + type;
m_getTypeCodeWarning = true;
}
else {
msg = "error determining type " + type;
}
if (msg != null) {
throw new PublisherException(msg);
}
}
}
if (dbTypeCode == SqlType.CODE_OPAQUE) {
result = new SqlObjectType(sqlName, OracleTypes.OPAQUE, generateMe, parentType,
this);
}
else if (dbTypeCode == SqlType.CODE_SQLJTYPE && kind != 0) {
result = new SqlSqljType(sqlName, kind, parentType, this);
}
else if (typeCode.equals("OBJECT")) {
result = new SqlObjectType(sqlName, generateMe, parentType, this);
if (SqlName.langIsOtt()) {
/*
* For C only. Maura - I'm not sure about this, but
* it seems that a ref typedef has to be generated
* for every struct. That's the purpose of the
* following SqlRefType
*/
new SqlRefType(sqlName, result, parentType, generateMe, this);
}
if (PublisherModifier.isIncomplete(result.getModifiers())) {
/*
* give warning
* about incomplete
* type and
* continue
*/
int line = sqlName.getLine();
int column = sqlName.getColumn();
String mesg = "incomplete type " + sqlName.toString();
if (line > 0 || column > 0) {
mesg = "" + line + "." + column + ": " + mesg;
}
System.err.println(mesg);
}
}
else if (typeCode.equals("COLLECTION")) {
if ((whatIsIt & IS_COLLECTION) == 0) {
throw new PublisherException("collection found " + sqlName.toString());
}
Iterator<ViewRow> iter3 = m_viewCache.getRows(ALL_COLL_TYPES, new String[0],
new String[]{OWNER, TYPE_NAME}, new Object[]{schema, type},
new String[0]);
if (iter3.hasNext()) {
AllCollTypes act = (AllCollTypes)iter3.next();
String collTypeCode = act.collType;
if (collTypeCode.equals("TABLE")) {
result = new SqlTableType(sqlName, generateMe, parentType, this);
}
else {
// "VARYING ARRAY"
result = new SqlArrayType(sqlName, generateMe, parentType, this);
}
}
}
}
if (result != null) {
return result;
}
if (result != null) {
return result;
}
else {
// Note that this type is not supported, so we will not look
// it up again.
result = addPredefType(sqlName, OracleTypes.UNSUPPORTED);
// Now add an error message
if ((whatIsIt & IS_PACKAGE) != 0) {
throw new PublisherException("type not found " + sqlName.toString());
}
}
}
catch (SQLException e) {
System.err.println(e.getMessage());