Package adams.db.types
Class AbstractTypes
- java.lang.Object
-
- adams.db.types.AbstractTypes
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
TypesH2,TypesMSSQL,TypesMySQL,TypesPostgreSQL,TypesSQLite
public abstract class AbstractTypes extends Object implements Serializable
Ancestor for SQL types classes.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Map<String,AbstractTypes>m_Cachefor caching types on URLs.protected static List<AbstractTypes>m_Typesthe available types.static intMAX_MEDIUMTEXTmax size of MEDIUMTEXT.static intMAX_TEXTmax size of TEXT.static intMAX_VARCHARmax size of varchar.
-
Constructor Summary
Constructors Constructor Description AbstractTypes()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intactualSize(int type, int size)Get the actual size of type.abstract StringgetAutoIncrementCreateType(int type)Returns the type definition for auto increment types.static AbstractTypesgetHandler(String url)Returns the handler for the JDBC url.abstract StringgetTimestampDefault()Returns the default used for timestamps.abstract booleanhandles(String url)Checks whether this URL is handled.abstract StringtoTypeString(int type, int size, boolean compare)Get a string representation of this type for comparison or create purposes.abstract booleanusesTimestampDefault()Whether a default is used for timestamps.
-
-
-
Field Detail
-
MAX_VARCHAR
public static final int MAX_VARCHAR
max size of varchar.- See Also:
- Constant Field Values
-
MAX_TEXT
public static final int MAX_TEXT
max size of TEXT.- See Also:
- Constant Field Values
-
MAX_MEDIUMTEXT
public static final int MAX_MEDIUMTEXT
max size of MEDIUMTEXT.- See Also:
- Constant Field Values
-
m_Cache
protected static Map<String,AbstractTypes> m_Cache
for caching types on URLs.
-
m_Types
protected static List<AbstractTypes> m_Types
the available types.
-
-
Method Detail
-
toTypeString
public abstract String toTypeString(int type, int size, boolean compare)
Get a string representation of this type for comparison or create purposes.- Parameters:
type- the typesize- the sizecompare- if true then a string for comparison is returned, otherwise for creation- Returns:
- string representation of this type
-
actualSize
public int actualSize(int type, int size)Get the actual size of type.- Returns:
- size
-
getAutoIncrementCreateType
public abstract String getAutoIncrementCreateType(int type)
Returns the type definition for auto increment types.- Parameters:
type- the preferred type- Returns:
- the definition for creating the column
-
usesTimestampDefault
public abstract boolean usesTimestampDefault()
Whether a default is used for timestamps.- Returns:
- true if a default is used
-
getTimestampDefault
public abstract String getTimestampDefault()
Returns the default used for timestamps.- Returns:
- the default, null if none used
-
handles
public abstract boolean handles(String url)
Checks whether this URL is handled.- Parameters:
url- the URL to check- Returns:
- true if handled by this type class
-
getHandler
public static AbstractTypes getHandler(String url)
Returns the handler for the JDBC url.- Parameters:
url- the URL- Returns:
- the handler
- Throws:
IllegalArgumentException- if JDBC connection type not supported
-
-