📄 typeid.java
字号:
return ((formatId == StoredFormatIds.LONGVARCHAR_TYPE_ID) || (formatId == StoredFormatIds.NATIONAL_LONGVARCHAR_TYPE_ID)); } /** * Is this DATE/TIME or TIMESTAMP? * * @return true if this DATE/TIME or TIMESTAMP */ public boolean isDateTimeTimeStampTypeID() { return ((formatId == StoredFormatIds.DATE_TYPE_ID) || (formatId == StoredFormatIds.TIME_TYPE_ID) || (formatId == StoredFormatIds.TIMESTAMP_TYPE_ID)); } /** Does this type id represent a national character string. If this returns true then isStringTypeId will also return true. */ public boolean isNationalStringTypeId() { switch (formatId) { default: return false; case StoredFormatIds.NATIONAL_CHAR_TYPE_ID: case StoredFormatIds.NATIONAL_LONGVARCHAR_TYPE_ID: case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID: case StoredFormatIds.NCLOB_TYPE_ID: return true; } } /** *Is this an XML doc? * @return true if this is XML */ public boolean isXMLTypeId() { return (formatId == StoredFormatIds.XML_TYPE_ID); } /** * Tell whether this is a built-in type. * NOTE: There are 3 "classes" of types: * built-in - system provided types which are implemented internally * (int, smallint, etc.) * system built-in - system provided types, independent of implementation * (date, time, etc.) * user types - types implemented outside of the system * (java.lang.Integer, asdf.asdf.asdf, etc.) * * @return true for built-in types, false for user-defined types. */ public boolean builtIn() { return isBuiltIn; } /** * Tell whether this type is orderable, that is, can participate * in comparisons. * * @param cf A ClassFactory * * @return true for orderable types, false for non-orderable types. */ public boolean orderable(ClassFactory cf) { boolean orderable; switch (formatId) { // cmp not allowed, indexing not allowed case StoredFormatIds.BLOB_TYPE_ID: case StoredFormatIds.CLOB_TYPE_ID: case StoredFormatIds.NCLOB_TYPE_ID: case StoredFormatIds.NATIONAL_LONGVARCHAR_TYPE_ID: case StoredFormatIds.LONGVARCHAR_TYPE_ID: case StoredFormatIds.XML_TYPE_ID: case StoredFormatIds.LONGVARBIT_TYPE_ID: return false; case StoredFormatIds.USERDEFINED_TYPE_ID_V3: /* Is this type orderable? */ // For user java classes we are orderable if we // implement java.lang.Orderable (JDK1.2) or // have a int compareTo(Object) method (JDK1.1 or JDK1.2) UserDefinedTypeIdImpl baseUserTypeId = (UserDefinedTypeIdImpl) baseTypeId; String className = baseUserTypeId.getClassName(); try { Class c = cf.getClassInspector().getClass(className); orderable = java.lang.Comparable.class.isAssignableFrom(c); } catch (ClassNotFoundException cnfe) { orderable = false; } break; default: orderable = true; } return orderable; } /** * Each built-in type in JSQL has a precedence. This precedence determines * how to do type promotion when using binary operators. For example, float * has a higher precedence than int, so when adding an int to a float, the * result type is float. * * The precedence for some types is arbitrary. For example, it doesn't * matter what the precedence of the boolean type is, since it can't be * mixed with other types. But the precedence for the number types is * critical. The SQL standard requires that exact numeric types be * promoted to approximate numeric when one operator uses both. Also, * the precedence is arranged so that one will not lose precision when * promoting a type. * NOTE: char, varchar, and longvarchar must appear at the bottom of * the hierarchy, but above USER_PRECEDENCE, since we allow the implicit * conversion of those types to any other built-in system type. * * @return The precedence of this type. */ public int typePrecedence() { return typePrecedence; } /** * Get the name of the corresponding Java type. * * Each SQL type has a corresponding Java type. When a SQL value is * passed to a Java method, it is translated to its corresponding Java * type. For example, when a SQL date column is passed to a method, * it is translated to a java.sql.Date. * * @return The name of the corresponding Java type. */ public String getCorrespondingJavaTypeName() { if (SanityManager.DEBUG) { if (formatId == StoredFormatIds.REF_TYPE_ID) { SanityManager.THROWASSERT("getCorrespondingJavaTypeName not implemented for StoredFormatIds.REF_TYPE_ID"); } SanityManager.ASSERT(javaTypeName != null, "javaTypeName expected to be non-null"); } return javaTypeName; } /** * Get the name of the corresponding Java type. * * This method is used directly from EmbedResultSetMetaData (jdbc) * to return the corresponding type (as choosen by getObject). * It solves a specific problem for BLOB types where the * getCorrespondingJavaTypeName() is used internall for casting * which doesn't work if changed from byte[] to java.sql.Blob. * So we do it here instread, to avoid unexpected sideeffects. * * @return The name of the corresponding Java type. */ public String getResultSetMetaDataTypeName() { if ((BLOB_ID != null) && BLOB_ID.equals(this)) return "java.sql.Blob"; if ((CLOB_ID != null) && CLOB_ID.equals(this)) return "java.sql.Clob"; if ((NCLOB_ID != null) && NCLOB_ID.equals(this)) return "java.sql.Clob"; return getCorrespondingJavaTypeName(); } /** * Get the maximum maximum width of the type (that's not a typo). For * types with variable length, this is the absolute maximum for the type. * * @return The maximum maximum width of the type */ public int getMaximumMaximumWidth() { return maxMaxWidth; } /** * Converts this TypeId, given a data type descriptor (including length/precision), * to a string. E.g. * * VARCHAR(30) * * * For most data types, we just return the SQL type name. * * @param dts Data type descriptor that holds the length/precision etc. as necessary * * @return String version of datatype, suitable for running through * the Parser. */ public String toParsableString(DataTypeDescriptor dts) { return baseTypeId.toParsableString(dts); } /** * Is this a type id for a numeric type? * * @return Whether or not this a type id for a numeric type. */ public boolean isNumericTypeId() { return isNumericTypeId; } /** * Is this a type id for a decimal type? * * @return Whether or not this a type id for a decimal type. */ public boolean isDecimalTypeId() { return isDecimalTypeId; } /** * Is this a type id for a boolean type? * * @return Whether or not this a type id for a boolean type. */ public boolean isBooleanTypeId() { return isBooleanTypeId; } /** * Is this a type id for a ref type? * * @return Whether or not this a type id for a ref type. */ public boolean isRefTypeId() { return isRefTypeId; } /** * Is this a type id for a concatable type? * * @return Whether or not this a type id for a concatable type. */ public boolean isConcatableTypeId() { return isConcatableTypeId; } /** * Is this a type id for a bit type? * * @return Whether or not this a type id for a bit type. */ public boolean isBitTypeId() { return isBitTypeId; } /** * Is this a type id for a LOB type? * * @return Whether or not this a type id for a LOB type. */ public boolean isLOBTypeId() { return isLOBTypeId; } /** * Is this a type id for a long concatable type?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -