📄 platforminfo.java
字号:
return _delimiterToken;
}
/**
* Sets the text that is used to delimit identifiers (eg. table names).
*
* @param delimiterToken The delimiter text
*/
public void setDelimiterToken(String delimiterToken)
{
_delimiterToken = delimiterToken;
}
/**
* Returns the text that is used for for quoting values (e.g. text) when
* printing default values and in generates insert/update/delete statements.
* Per default, this is a single quotation character (').
*
* @return The quote text
*/
public String getValueQuoteToken()
{
return _valueQuoteToken;
}
/**
* Sets the text that is used for for quoting values (e.g. text) when
* printing default values and in generates insert/update/delete statements.
*
* @param valueQuoteChar The new quote text
*/
public void setValueQuoteToken(String valueQuoteChar)
{
_valueQuoteToken = valueQuoteChar;
}
/**
* Returns the string that denotes the beginning of a comment.
*
* @return The comment prefix
*/
public String getCommentPrefix()
{
return _commentPrefix;
}
/**
* Sets the text that starts a comment.
*
* @param commentPrefix The new comment prefix
*/
public void setCommentPrefix(String commentPrefix)
{
_commentPrefix = (commentPrefix == null ? "" : commentPrefix);
}
/**
* Returns the string that denotes the end of a comment. Note that comments will
* be always on their own line.
*
* @return The comment suffix
*/
public String getCommentSuffix()
{
return _commentSuffix;
}
/**
* Sets the text that ends a comment.
*
* @param commentSuffix The new comment suffix
*/
public void setCommentSuffix(String commentSuffix)
{
_commentSuffix = (commentSuffix == null ? "" : commentSuffix);
}
/**
* Returns the text separating individual sql commands.
*
* @return The delimiter text
*/
public String getSqlCommandDelimiter()
{
return _sqlCommandDelimiter;
}
/**
* Sets the text separating individual sql commands.
*
* @param sqlCommandDelimiter The delimiter text
*/
public void setSqlCommandDelimiter(String sqlCommandDelimiter)
{
_sqlCommandDelimiter = sqlCommandDelimiter;
}
/**
* Returns the database-native type for the given type code.
*
* @param typeCode The {@link java.sql.Types} type code
* @return The native type or <code>null</code> if there isn't one defined
*/
public String getNativeType(int typeCode)
{
return (String)_nativeTypes.get(new Integer(typeCode));
}
/**
* Returns the jdbc type corresponding to the native type that is used for the given
* jdbc type. This is most often the same jdbc type, but can also be a different one.
* For application. if a database has no native boolean type, then the source jdbc type
* would be <code>BIT</code> or <code>BOOLEAN</code>, and the target jdbc type might
* be <code>TINYINT</code> or <code>SMALLINT</code>.
*
* @param typeCode The {@link java.sql.Types} type code
* @return The target jdbc type
*/
public int getTargetJdbcType(int typeCode)
{
Integer targetJdbcType = (Integer)_targetJdbcTypes.get(new Integer(typeCode));
return targetJdbcType == null ? typeCode : targetJdbcType.intValue();
}
/**
* Adds a mapping from jdbc type to database-native type.
*
* @param jdbcTypeCode The jdbc type code as defined by {@link java.sql.Types}
* @param nativeType The native type
*/
public void addNativeTypeMapping(int jdbcTypeCode, String nativeType)
{
_nativeTypes.put(new Integer(jdbcTypeCode), nativeType);
}
/**
* Adds a mapping from jdbc type to database-native type.
*
* @param jdbcTypeCode The jdbc type code as defined by {@link java.sql.Types}
* @param nativeType The native type
* @param targetJdbcTypeCode The jdbc type code corresponding to the native type
* (e.g. when reading the model from the database)
*/
public void addNativeTypeMapping(int jdbcTypeCode, String nativeType, int targetJdbcTypeCode)
{
addNativeTypeMapping(jdbcTypeCode, nativeType);
_targetJdbcTypes.put(new Integer(jdbcTypeCode), new Integer(targetJdbcTypeCode));
}
/**
* Adds a mapping from jdbc type to database-native type. Note that this
* method accesses the named constant in {@link java.sql.Types} via reflection
* and is thus safe to use under JDK 1.2/1.3 even with constants defined
* only in later Java versions - for these, the method simply will not add
* a mapping.
*
* @param jdbcTypeName The jdbc type name, one of the constants defined in
* {@link java.sql.Types}
* @param nativeType The native type
*/
public void addNativeTypeMapping(String jdbcTypeName, String nativeType)
{
try
{
Field constant = Types.class.getField(jdbcTypeName);
if (constant != null)
{
addNativeTypeMapping(constant.getInt(null), nativeType);
}
}
catch (Exception ex)
{
// ignore -> won't be defined
_log.warn("Cannot add native type mapping for undefined jdbc type "+jdbcTypeName, ex);
}
}
/**
* Adds a mapping from jdbc type to database-native type. Note that this
* method accesses the named constant in {@link java.sql.Types} via reflection
* and is thus safe to use under JDK 1.2/1.3 even with constants defined
* only in later Java versions - for these, the method simply will not add
* a mapping.
*
* @param jdbcTypeName The jdbc type name, one of the constants defined
* in {@link java.sql.Types}
* @param nativeType The native type
* @param targetJdbcTypeName The jdbc type corresponding to the native type
* (e.g. when reading the model from the database)
*/
public void addNativeTypeMapping(String jdbcTypeName, String nativeType, String targetJdbcTypeName)
{
try
{
Field sourceType = Types.class.getField(jdbcTypeName);
Field targetType = Types.class.getField(targetJdbcTypeName);
if ((sourceType != null) && (targetType != null))
{
addNativeTypeMapping(sourceType.getInt(null), nativeType, targetType.getInt(null));
}
}
catch (Exception ex)
{
// ignore -> won't be defined
_log.warn("Cannot add native type mapping for undefined jdbc type "+jdbcTypeName+", target jdbc type "+targetJdbcTypeName, ex);
}
}
/**
* Determines whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has a null default value on this platform.
*
* @param sqlTypeCode The sql type code
* @return <code>true</code> if the native type has a null default value
*/
public boolean hasNullDefault(int sqlTypeCode)
{
return _typesWithNullDefault.contains(new Integer(sqlTypeCode));
}
/**
* Specifies whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has a null default value on this platform.
*
* @param sqlTypeCode The sql type code
* @param hasNullDefault <code>true</code> if the native type has a null default value
*/
public void setHasNullDefault(int sqlTypeCode, boolean hasNullDefault)
{
if (hasNullDefault)
{
_typesWithNullDefault.add(new Integer(sqlTypeCode));
}
else
{
_typesWithNullDefault.remove(new Integer(sqlTypeCode));
}
}
/**
* Determines whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has a size specification on this platform.
*
* @param sqlTypeCode The sql type code
* @return <code>true</code> if the native type has a size specification
*/
public boolean hasSize(int sqlTypeCode)
{
return _typesWithSize.contains(new Integer(sqlTypeCode));
}
/**
* Specifies whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has a size specification on this platform.
*
* @param sqlTypeCode The sql type code
* @param hasSize <code>true</code> if the native type has a size specification
*/
public void setHasSize(int sqlTypeCode, boolean hasSize)
{
if (hasSize)
{
_typesWithSize.add(new Integer(sqlTypeCode));
}
else
{
_typesWithSize.remove(new Integer(sqlTypeCode));
}
}
/**
* Returns the default size value for the given type, if any.
*
* @param jdbcTypeCode The jdbc type code
* @return The default size or <code>null</code> if none is defined
*/
public Integer getDefaultSize(int jdbcTypeCode)
{
return (Integer)_typesDefaultSizes.get(new Integer(jdbcTypeCode));
}
/**
* Adds a default size for the given jdbc type.
*
* @param jdbcTypeCode The jdbc type code
* @param defaultSize The default size
*/
public void setDefaultSize(int jdbcTypeCode, int defaultSize)
{
_typesDefaultSizes.put(new Integer(jdbcTypeCode), new Integer(defaultSize));
}
/**
* Adds a default size for the given jdbc type.
*
* @param jdbcTypeName The name of the jdbc type, one of the {@link Types} constants
* @param defaultSize The default size
*/
public void setDefaultSize(String jdbcTypeName, int defaultSize)
{
try
{
Field constant = Types.class.getField(jdbcTypeName);
if (constant != null)
{
setDefaultSize(constant.getInt(null), defaultSize);
}
}
catch (Exception ex)
{
// ignore -> won't be defined
_log.warn("Cannot add default size for undefined jdbc type "+jdbcTypeName, ex);
}
}
/**
* Determines whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has precision and scale specifications on
* this platform.
*
* @param sqlTypeCode The sql type code
* @return <code>true</code> if the native type has precision and scale specifications
*/
public boolean hasPrecisionAndScale(int sqlTypeCode)
{
return _typesWithPrecisionAndScale.contains(new Integer(sqlTypeCode));
}
/**
* Specifies whether the native type for the given sql type code (one of the
* {@link java.sql.Types} constants) has precision and scale specifications on
* this platform.
*
* @param sqlTypeCode The sql type code
* @param hasPrecisionAndScale <code>true</code> if the native type has precision and scale specifications
*/
public void setHasPrecisionAndScale(int sqlTypeCode, boolean hasPrecisionAndScale)
{
if (hasPrecisionAndScale)
{
_typesWithPrecisionAndScale.add(new Integer(sqlTypeCode));
}
else
{
_typesWithPrecisionAndScale.remove(new Integer(sqlTypeCode));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -