Class DBFields

java.lang.Object
overit.geocall.sql.DBFields
All Implemented Interfaces:
Serializable, Iterable<DBFields.Field>

public class DBFields extends Object implements 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:
  • Field Details

  • Constructor Details

    • DBFields

      public DBFields()
      Creates a new empty DBFields object
  • Method Details

    • clear

      public static void clear()
      Clears the cache collection
    • fetchSelection

      public static DBFields fetchSelection(String pool, String table, String fieldList)
      Returns a new DBFields containing the desired fields, for the table passed as parameter
      Parameters:
      pool - The service ConnectionPool from which extract the connection to retrieve the data
      table - The name of the table
      fieldList - The string containing the list of fields, separated by the comma
      Returns:
      The DBFields for the desired table
    • fetch

      public static DBFields fetch(String pool, String... tables)
      Extracts from the cache, or if necessary loads, the structure of the specified tables.
      Parameters:
      pool - The service ConnectionPool from which extract the connection to retrieve the data
      tables - 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 - PooledConnection about the current PoolKit.Transaction in progress.
      tables - String about one or more comma separated tables.
      Returns:
      the structure of the union of all the desired tables.
    • fetch

      public static DBFields fetch(String pool, List<String> tables)
      Extracts from the cache, or if necessary loads, the structure of the specified tables.
      Parameters:
      pool - The service ConnectionPool from which extract the connection to retrieve the data
      tables - 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 - PooledConnection about the current PoolKit.Transaction in 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

      public static boolean exists(String pool, String table, String field)
      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 service ConnectionPool from which extract the connection to retrieve the data
      table - The name of the table
      field - The name of the field
      Returns:
      true if the field is present in the DBFields cache, false otherwise
    • contains

      public boolean contains(String name)
      Checks if the field is in the collection
      Parameters:
      name - The name of the field
      Returns:
      true if the field is in the collection, false otherwise
    • add

      public DBFields add(String name)
      Adds a field to the collection
      Parameters:
      name - The name of the field
      Returns:
      The DBFields with the added field
    • add0

      public DBFields add0(DBFields dbfs)
      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

      protected String validName(String name)
    • add

      public DBFields add(String name, String table, int type)
      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 add
      table - The name of the table
      type - The JDBC type of the field
      Returns:
      The DBFields with the added field
    • add

      public DBFields add(String name, String table, int type, Class<?> fieldClass)
      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 add
      table - The name of the table
      type - The JDBC type of the field
      fieldClass - The class of the field
      Returns:
      The DBFields with the added field
    • add

      public DBFields add(DBFields.Field field)
      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

      public DBFields.Field remove(String name)
      Removes a DBFields.Field from the collection
      Parameters:
      name - The name of the field
      Returns:
      The removed Field
    • rename

      public DBFields.Field rename(String name, String to)
      Removes a DBFields.Field from the collection
      Parameters:
      name - The name of the field to remove
      to - 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 public HashGetter getFieldMap()
      Deprecated.
      Only for backward compatibility with DBView.getFieldMap()
      Returns:
      Only for backward compatibility with DBView.getFieldMap()
    • getField

      public DBFields.Field getField(String name)
      Returns a DBFields.Field from the collection
      Parameters:
      name - The name of the field
      Returns:
      The Field
    • iterator

      public Iterator<DBFields.Field> iterator()
      Specified by:
      iterator in interface Iterable<DBFields.Field>
    • names

      public Set<String> names()
      Returns the names of the fields in the collection
      Returns:
      The key set of the collection
    • filterOutFields

      public DBFields filterOutFields(String... prefixes)
      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

      public DBFields keepInFields(String... prefixes)
      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

      public DBFields filterOutFields(int... types)
      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

      public DBFields keepInFields(int... types)
      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

      public DBFields filterOutTable(String table)
      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

      public DBFields keepInTable(String table)
      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

      public DBFields filterOutBinaries()
      Removes from the DBFields all the fields of Types.BINARY, Types.LONGVARBINARY, Types.VARBINARY and Types.BLOB types
      Returns:
      The filtered DBFields
    • filterOutLOB

      public DBFields filterOutLOB()
      Removes from the DBFields all the fields of Types.BINARY, Types.LONGVARBINARY, Types.VARBINARY, Types.BLOB, Types.CLOB, Types.NCLOB types
      Returns:
      The filtered DBFields
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toArray

      public String[] toArray()