Package overit.geocall.sql
Class DBFields
java.lang.Object
overit.geocall.sql.DBFields
- All Implemented Interfaces:
Serializable,Iterable<DBFields.Field>
This class implements an ordered collection of
DBFields.Field, accessed by name, used as a local cache
to store and retrieve the database table metadata. Every Field has a name, the name of the table which
belongs, the JDBC data type and the position in the collection.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LinkedHashMap<String, DBFields.Field> protected static ConcurrentHashMap<String, DBFields> static final DBFieldsEmpty (so invalid) DBFieldsstatic final intInt that defines the unknown type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a field to the collectionAdds a field at the end of the collection.Adds a field at the end of the collection.add(DBFields.Field field) Adds a field at the end of the collection, copying the attributes of the field passed as parameter.Adds to the DBFields passed as parameter the existing fields in this instance of DBFieldsstatic voidclear()Clears the cache collectionbooleanChecks if the field is in the collectionstatic booleanChecks the presence of a field in tha table, using the cache.static DBFieldsExtracts from the cache, or if necessary loads, the structure of the specified tables.static DBFieldsExtracts from the cache, or if necessary loads, the structure of the specified tables.static DBFieldsfetch(@NotNull PooledConnection pooledConnection, @NotNull String tables) Extracts from the cache, or if necessary loads, the structure of the specified tables.static DBFieldsExtracts from the cache, or if necessary loads, the structure of the specified tables.static DBFieldsfetchSelection(String pool, String table, String fieldList) Returns a new DBFields containing the desired fields, for the table passed as parameterRemoves from the DBFields all the fields ofTypes.BINARY,Types.LONGVARBINARY,Types.VARBINARYandTypes.BLOBtypesfilterOutFields(int... types) Filters out (removes from the DBFields) the fields which type is in the varargs list of types passed as parameterfilterOutFields(String... prefixes) Filters out (removes from the DBFields) the fields which name starts with the varargs list of prefixes passed as parameterRemoves from the DBFields all the fields ofTypes.BINARY,Types.LONGVARBINARY,Types.VARBINARY,Types.BLOB,Types.CLOB,Types.NCLOBtypesfilterOutTable(String table) Filters out (removes from the DBFields) all the fields that belongs to a specific tableReturns aDBFields.Fieldfrom the collectionDeprecated.iterator()keepInFields(int... types) Keeps in (maintains in the DBFields) only the fields which type is in the varargs list of types passed as parameterkeepInFields(String... prefixes) Keeps is out (maintains in the DBFields) only the fields which name starts with the varargs list of prefixes passed as parameterkeepInTable(String table) Keeps in (maintains in the DBFields) only the fields that belongs to a specific tablenames()Returns the names of the fields in the collectionRemoves aDBFields.Fieldfrom the collectionRemoves aDBFields.Fieldfrom the collectionintsize()Returns the size of the collectionString[]toArray()toString()protected StringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
INVALID
Empty (so invalid) DBFields -
UNKNOWN_TYPE
public static final int UNKNOWN_TYPEInt that defines the unknown type- See Also:
-
_tables
-
_map
-
-
Constructor Details
-
DBFields
public DBFields()Creates a new empty DBFields object
-
-
Method Details
-
clear
public static void clear()Clears the cache collection -
fetchSelection
Returns a new DBFields containing the desired fields, for the table passed as parameter- Parameters:
pool- The serviceConnectionPoolfrom which extract the connection to retrieve the datatable- The name of the tablefieldList- The string containing the list of fields, separated by the comma- Returns:
- The DBFields for the desired table
-
fetch
Extracts from the cache, or if necessary loads, the structure of the specified tables.- Parameters:
pool- The serviceConnectionPoolfrom which extract the connection to retrieve the datatables- The varargs list of tables. It is possible to pass a string containing the names of more tables separated by the comma (,) character- Returns:
- The structure of the union of all the desired tables
-
fetch
public static DBFields fetch(@NotNull @NotNull PooledConnection pooledConnection, @NotNull @NotNull String tables) Extracts from the cache, or if necessary loads, the structure of the specified tables.- Parameters:
pooledConnection-PooledConnectionabout the currentPoolKit.Transactionin progress.tables-Stringabout one or more comma separated tables.- Returns:
- the structure of the union of all the desired tables.
-
fetch
Extracts from the cache, or if necessary loads, the structure of the specified tables.- Parameters:
pool- The serviceConnectionPoolfrom which extract the connection to retrieve the datatables- The varargs list of tables. It is possible to pass a list of strings containing the names of more tables separated by the comma (,) character- Returns:
- The structure of the union of all the desired tables
-
fetch
public static DBFields fetch(@NotNull @NotNull PooledConnection pooledConnection, @NotNull @NotNull List<String> tables) Extracts from the cache, or if necessary loads, the structure of the specified tables.- Parameters:
pooledConnection-PooledConnectionabout the currentPoolKit.Transactionin progress.tables-List<String> about the tables for which to extract the structure.- Returns:
- the structure of the union of all the desired tables.
-
exists
Checks the presence of a field in tha table, using the cache. If the field is null, is checked the presence of the table.- Parameters:
pool- The serviceConnectionPoolfrom which extract the connection to retrieve the datatable- The name of the tablefield- The name of the field- Returns:
trueif the field is present in the DBFields cache,falseotherwise
-
contains
Checks if the field is in the collection- Parameters:
name- The name of the field- Returns:
trueif the field is in the collection,falseotherwise
-
add
Adds a field to the collection- Parameters:
name- The name of the field- Returns:
- The DBFields with the added field
-
add0
Adds to the DBFields passed as parameter the existing fields in this instance of DBFields- Parameters:
dbfs- The DBFields to add- Returns:
- The DBFields with the added fields
-
validName
-
add
Adds a field at the end of the collection. To avoid conflicts, the names in the collection are extended with a numeric progressive id; it is just a mapping, the name is not really changed- Parameters:
name- The name of the field to addtable- The name of the tabletype- The JDBC type of the field- Returns:
- The DBFields with the added field
-
add
Adds a field at the end of the collection. To avoid conflicts, the names in the collection are extended with a numeric progressive id; it is just a mapping, the name is not really changed.- Parameters:
name- The name of the field to addtable- The name of the tabletype- The JDBC type of the fieldfieldClass- The class of the field- Returns:
- The DBFields with the added field
-
add
Adds a field at the end of the collection, copying the attributes of the field passed as parameter. To avoid conflicts, the names in the collection are extended with a numeric progressive id; it is just a mapping, the name is not really changed.- Parameters:
field- The field to copy from- Returns:
- The DBFields with the added field
-
remove
Removes aDBFields.Fieldfrom the collection- Parameters:
name- The name of the field- Returns:
- The removed Field
-
rename
Removes aDBFields.Fieldfrom the collection- Parameters:
name- The name of the field to removeto- The name of the filed- Returns:
- The removed Field
-
size
public int size()Returns the size of the collection- Returns:
- The number of fields in the collection
-
getFieldMap
Deprecated.Only for backward compatibility withDBView.getFieldMap()- Returns:
- Only for backward compatibility with
DBView.getFieldMap()
-
getField
Returns aDBFields.Fieldfrom the collection- Parameters:
name- The name of the field- Returns:
- The Field
-
iterator
- Specified by:
iteratorin interfaceIterable<DBFields.Field>
-
names
Returns the names of the fields in the collection- Returns:
- The key set of the collection
-
filterOutFields
Filters out (removes from the DBFields) the fields which name starts with the varargs list of prefixes passed as parameter- Parameters:
prefixes- The string used as prefix to filter the fields of the collection- Returns:
- The filtered DBFields
-
keepInFields
Keeps is out (maintains in the DBFields) only the fields which name starts with the varargs list of prefixes passed as parameter- Parameters:
prefixes- The string used as prefix to filter the fields of the collection- Returns:
- The filtered DBFields
-
filterOutFields
Filters out (removes from the DBFields) the fields which type is in the varargs list of types passed as parameter- Parameters:
types- The list of types- Returns:
- The filtered DBFields
-
keepInFields
Keeps in (maintains in the DBFields) only the fields which type is in the varargs list of types passed as parameter- Parameters:
types- The list of types- Returns:
- The filtered DBFields
-
filterOutTable
Filters out (removes from the DBFields) all the fields that belongs to a specific table- Parameters:
table- The name of the table- Returns:
- The filtered DBFields
-
keepInTable
Keeps in (maintains in the DBFields) only the fields that belongs to a specific table- Parameters:
table- The name of the table- Returns:
- The filtered DBFields
-
filterOutBinaries
Removes from the DBFields all the fields ofTypes.BINARY,Types.LONGVARBINARY,Types.VARBINARYandTypes.BLOBtypes- Returns:
- The filtered DBFields
-
filterOutLOB
Removes from the DBFields all the fields ofTypes.BINARY,Types.LONGVARBINARY,Types.VARBINARY,Types.BLOB,Types.CLOB,Types.NCLOBtypes- Returns:
- The filtered DBFields
-
toString
-
toArray
-
DBView.getFieldMap()