Holger's Java API

## com.antelmann.sql
Class DefaultMappingInfo

    java.lang.Object
      com.antelmann.sql.DefaultMappingInfo

All Implemented Interfaces:
  XMLSerializable, ForeignKeyMappingInfo, MappingInfo, DetailedString, Forgeable<DefaultMappingInfo>, Serializable

    public class DefaultMappingInfo

extends Object
implements MappingInfo, ForeignKeyMappingInfo, Forgeable<DefaultMappingInfo>, Serializable, DetailedString, XMLSerializable

provides a default implementation for the `MappingInfo` interface, making it easy to allow other objects to delegate the interface methods to an instance of this class.

Since:
  12.02.2009, 11:22:21
Author:
  Holger Antelmann
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface com.antelmann.sql.ForeignKeyMappingInfo
`ForeignKeyMappingInfo.Analyzer`

Constructor Summary
`DefaultMappingInfo()` for use as a bean
`DefaultMappingInfo(DBClassStore<?> store)`
`DefaultMappingInfo(DefaultMappingInfo mi)`
`DefaultMappingInfo(MappingInfo mi, Object... topics)`
`DefaultMappingInfo(String tableName, String idColumn)`
`DefaultMappingInfo(String tableName, String idColumn, String displayColumn)`
`DefaultMappingInfo(String tableName, String idColumn, String displayColumn, String tableQuery, Connection con)`

Method Summary
`void` `exportXML(OutputStream out)` exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with `importXML(InputSource)`.
`String[]` `getBooleanColumns()`
`String[]` `getChoosableColumns()`
`static String` `getColumnForForeignKey(ForeignKeyMappingInfo fmi, Class<?> type)` returns the first available column (if any) that maps to the given type
`String[]` `getColumnNames()` returns all the columns that are retrieved by the mapper when querying the database); the column names for the ID column and display column are included in the returned array.
`String[]` `getColumnsForTopic(Object topic)` allows to determine whether there are any columns that are applicable for the given topic
`int` `getColumnSize(String column)` allows to determine the size of the given column name.
`String[]` `getDateRangeColumns()`
`String` `getDisplayColumn()` for use in stubs (in case a single column is used as a display value)
`String` `getDisplayNameForColumn(String column)` returns a name suitable for display in a GUI if different from the column name used in the database
`Filter<? super Stub<?>>` `getForeignKeyFilter(String column)` returns a filter that limits the allowed choices for the foreign key column; may be null
`Map<String,Class<? extends DBEntry>>` `getForeignKeys()` returns all columns denoting a foreign key mapped to their respective class representation, so that a component can allow to select from the respective values accordingly.
`String` `getIDColumn()` specifies the column where the ID of the entry is mapped to
`String` `getMappingForTopic(Object topic)` allows to determine whether a specific given topic maps to a distinct table, query or column name.
`static String` `getNameForType(int type)` a utility method that provides a String representation for an SQL-type
`String[]` `getNumberRangeColumns()`
`String[]` `getReadOnlyColumns()`
`String[]` `getRequiredColumns()`
`String[]` `getSelectedTextSearchColumns()`
`int` `getSQLTypeforColumn(String column)` allows to determine the SQL-type for a given column name
`String` `getTableName()` provides the name of the table that stores the data for the store
`String` `getTableQuery()` if querying involves something different than just selecting all columns of the table, this method returns the string used to replace the table name in a query.
`String[]` `getTextSearchColumns()`
`HashSet<Object>` `getTopics()` creates and returns a newly created set containing topics for both: `getMappingForTopic(Object)` and `getColumnsForTopic(Object)`
`void` `importXML(InputStream source)` The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.
`void` `setAllFrom(DefaultMappingInfo mi)` copies the properties of the given object and applies them to this instance, so that its behavior in regards to the given object can be matched to the extend that the implementing class supports that behavior.
`void` `setAllFrom(ForeignKeyMappingInfo fmi)`
`DefaultMappingInfo` `setAllTopics(Map<?,String> map)`
`void` `setBooleanColumns(String[] booleanColumns)`
`void` `setChoosableColumns(String[] chooseableColumns)`
`void` `setColumnNames(String[] columnNames)`
`void` `setColumnsForTopic(Object topic, String... columns)`
`void` `setColumnSize(String column, int size)`
`void` `setDateRangeColumns(String[] dateRangeColumns)`
`void` `setDisplayColumn(String column)`
`void` `setDisplayNameForColumn(String column, String display)`
`void` `setForeignKey(String column, Class<? extends DBEntry> c)`
`Filter<? super Stub<?>>` `setForeinKeyFilter(String column, Filter<? super Stub<?>> filter)`
`void` `setIDColumn(String column)`
`void` `setMappingForTopic(Object topic, String mapping)`
`void` `setNumberRangeColumns(String[] numberRangeColumns)`
`void` `setReadOnlyColumns(String... readOnlyColumns)`
`void` `setRequiredColumns(String[] requiredColumns)`
`void` `setSelectedTextSearchColumns(String[] selectedTextSearchColumns)`
`void` `setSQLTypeForColumn(String column, int type)`
`void` `setTableName(String tableName)`
`void` `setTableQuery(String query)`
`void` `setTextSearchColumns(String[] textSearchColumns)`
`String` `toDetailedString()` provides full details of this instance in a String.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultMappingInfo

    public DefaultMappingInfo()

  for use as a bean

### DefaultMappingInfo

    public DefaultMappingInfo(String tableName,
                              String idColumn)

### DefaultMappingInfo

    public DefaultMappingInfo(String tableName,
                              String idColumn,
                              String displayColumn)

### DefaultMappingInfo

    public DefaultMappingInfo(String tableName,
                              String idColumn,
                              String displayColumn,
                              String tableQuery,
                              Connection con)
                       throws SQLException

Throws:
  `SQLException`

### DefaultMappingInfo

    public DefaultMappingInfo(DBClassStore<?> store)

### DefaultMappingInfo

    public DefaultMappingInfo(DefaultMappingInfo mi)

### DefaultMappingInfo

    public DefaultMappingInfo(MappingInfo mi,
                              Object... topics)

Method Detail

### setAllFrom

    public void setAllFrom(ForeignKeyMappingInfo fmi)

### setAllFrom

    public void setAllFrom(DefaultMappingInfo mi)

  Description copied from interface: `Forgeable`
  copies the properties of the given object and applies them to this instance, so that its behavior in regards to the given object can be matched to the extend that the implementing class supports that behavior.

  Specified by:
    `setAllFrom` in interface `Forgeable<DefaultMappingInfo>`
  Parameters:
    `mi` - the object whose behavior is to be copied to this instance

### getNameForType

    public static String getNameForType(int type)

  a utility method that provides a String representation for an SQL-type

  See Also:
    `Types`

### getColumnNames

    public String[] getColumnNames()

  Description copied from interface: `MappingInfo`
  returns all the columns that are retrieved by the mapper when querying the database); the column names for the ID column and display column are included in the returned array. Note that the return value refers to the columns in the table query; only if the query is null, the return value refers to the columns in the table itself.

  Specified by:
    `getColumnNames` in interface `MappingInfo`
  Returns:
    all columns that are retrieved by the mapper or null if this doesn't apply for this instance.
  See Also:
    `MappingInfo.getTableName()`, `MappingInfo.getTableQuery()`, `MappingInfo.getIDColumn()`, `MappingInfo.getDisplayColumn()`

### setColumnNames

    public void setColumnNames(String[] columnNames)

### getDisplayColumn

    public String getDisplayColumn()

  Description copied from interface: `MappingInfo`
  for use in stubs (in case a single column is used as a display value)

  Specified by:
    `getDisplayColumn` in interface `MappingInfo`

### setDisplayColumn

    public void setDisplayColumn(String column)

### getDisplayNameForColumn

    public String getDisplayNameForColumn(String column)

  Description copied from interface: `MappingInfo`
  returns a name suitable for display in a GUI if different from the column name used in the database

  Specified by:
    `getDisplayNameForColumn` in interface `MappingInfo`
  Returns:
    a suitable display value for the given column or the given column itself if no better display name exists

### setDisplayNameForColumn

    public void setDisplayNameForColumn(String column,
                                        String display)

### getIDColumn

    public String getIDColumn()

  Description copied from interface: `MappingInfo`
  specifies the column where the ID of the entry is mapped to

  Specified by:
    `getIDColumn` in interface `MappingInfo`

### setIDColumn

    public void setIDColumn(String column)

### getTopics

    public HashSet<Object> getTopics()

  creates and returns a newly created set containing topics for both: `getMappingForTopic(Object)` and `getColumnsForTopic(Object)`

### getMappingForTopic

    public String getMappingForTopic(Object topic)

  Description copied from interface: `MappingInfo`
  allows to determine whether a specific given topic maps to a distinct table, query or column name.

  Specified by:
    `getMappingForTopic` in interface `MappingInfo`
  Returns:
    either a table name, a column name, a query string or null - depending on the given topic

### setMappingForTopic

    public void setMappingForTopic(Object topic,
                                   String mapping)

### setAllTopics

    public DefaultMappingInfo setAllTopics(Map<?,String> map)

### getColumnsForTopic

    public String[] getColumnsForTopic(Object topic)

  Description copied from interface: `MappingInfo`
  allows to determine whether there are any columns that are applicable for the given topic

  Specified by:
    `getColumnsForTopic` in interface `MappingInfo`
  Returns:
    an array of column names that apply to the given topic; the array may be empty but never null

### setColumnsForTopic

    public void setColumnsForTopic(Object topic,
                                   String... columns)

### getSQLTypeforColumn

    public int getSQLTypeforColumn(String column)
                            throws IllegalArgumentException

  Description copied from interface: `MappingInfo`
  allows to determine the SQL-type for a given column name

  Specified by:
    `getSQLTypeforColumn` in interface `MappingInfo`
  Returns:
    the SQL-type for the given column
  Throws:
    `IllegalArgumentException` - if the given column is not known
  See Also:
    `Types`

### setSQLTypeForColumn

    public void setSQLTypeForColumn(String column,
                                    int type)
                             throws IllegalArgumentException

  Throws:
    `IllegalArgumentException`

### getColumnSize

    public int getColumnSize(String column)
                      throws IllegalArgumentException

  Description copied from interface: `MappingInfo`
  allows to determine the size of the given column name. For a text column, this is the maximum number of characters; for a number column, this specifies the precision.

  Specified by:
    `getColumnSize` in interface `MappingInfo`
  Throws:
    `IllegalArgumentException` - if the given column is not known

### setColumnSize

    public void setColumnSize(String column,
                              int size)
                       throws IllegalArgumentException

  Throws:
    `IllegalArgumentException`

### getTableName

    public String getTableName()

  Description copied from interface: `MappingInfo`
  provides the name of the table that stores the data for the store

  Specified by:
    `getTableName` in interface `MappingInfo`
  See Also:
    `MappingInfo.getTableQuery()`

### setTableName

    public void setTableName(String tableName)

### getTableQuery

    public String getTableQuery()

  Description copied from interface: `MappingInfo`
  if querying involves something different than just selecting all columns of the table, this method returns the string used to replace the table name in a query. The return value - if non-null - is used to create ResultSet objects, so that other columns than those merely present in the original table can be retrieved (e.g. through a join). If this value is null, the value from `MappingInfo.getTableName()` is used in all cases. If non-null, this variable would have a value like '(select a.field1, b.* from a, b where a.id=b.id) as t1'.

  Specified by:
    `getTableQuery` in interface `MappingInfo`
  See Also:
    `MappingInfo.getTableName()`

### setTableQuery

    public void setTableQuery(String query)

### getReadOnlyColumns

    public String[] getReadOnlyColumns()

### setReadOnlyColumns

    public void setReadOnlyColumns(String... readOnlyColumns)

### getBooleanColumns

    public String[] getBooleanColumns()

### setBooleanColumns

    public void setBooleanColumns(String[] booleanColumns)

### getChoosableColumns

    public String[] getChoosableColumns()

### setChoosableColumns

    public void setChoosableColumns(String[] chooseableColumns)

### getDateRangeColumns

    public String[] getDateRangeColumns()

### setDateRangeColumns

    public void setDateRangeColumns(String[] dateRangeColumns)

### getForeignKeyFilter

    public Filter<? super Stub<?>> getForeignKeyFilter(String column)

  Description copied from interface: `ForeignKeyMappingInfo`
  returns a filter that limits the allowed choices for the foreign key column; may be null

  Specified by:
    `getForeignKeyFilter` in interface `ForeignKeyMappingInfo`
  See Also:
    `ForeignKeyMappingInfo.getForeignKeys()`

### setForeinKeyFilter

    public Filter<? super Stub<?>> setForeinKeyFilter(String column,
                                                      Filter<? super Stub<?>> filter)

### getForeignKeys

    public Map<String,Class<? extends DBEntry>> getForeignKeys()

  Description copied from interface: `ForeignKeyMappingInfo`
  returns all columns denoting a foreign key mapped to their respective class representation, so that a component can allow to select from the respective values accordingly.

  Specified by:
    `getForeignKeys` in interface `ForeignKeyMappingInfo`
  See Also:
    `ForeignKeyMappingInfo.getForeignKeyFilter(String)`

### setForeignKey

    public void setForeignKey(String column,
                              Class<? extends DBEntry> c)

### getNumberRangeColumns

    public String[] getNumberRangeColumns()

### setNumberRangeColumns

    public void setNumberRangeColumns(String[] numberRangeColumns)

### getRequiredColumns

    public String[] getRequiredColumns()

### setRequiredColumns

    public void setRequiredColumns(String[] requiredColumns)

### getSelectedTextSearchColumns

    public String[] getSelectedTextSearchColumns()

### setSelectedTextSearchColumns

    public void setSelectedTextSearchColumns(String[] selectedTextSearchColumns)

### getTextSearchColumns

    public String[] getTextSearchColumns()

### setTextSearchColumns

    public void setTextSearchColumns(String[] textSearchColumns)

### getColumnForForeignKey

    public static String getColumnForForeignKey(ForeignKeyMappingInfo fmi,
                                                Class<?> type)

  returns the first available column (if any) that maps to the given type

### toDetailedString

    public String toDetailedString()

  Description copied from interface: `DetailedString`
  provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

  Specified by:
    `toDetailedString` in interface `DetailedString`
  Returns:
    a (potentially multi-line) String providing full details on this object instance

### exportXML

    public void exportXML(OutputStream out)
                   throws IOException

  Description copied from interface: `XMLSerializable`
  exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with `importXML(InputSource)`. The given stream is neither flushed nor closed, so that other data may be effectively written to the InputSource after the method returned.

  Specified by:
    `exportXML` in interface `XMLSerializable`
  Throws:
    `IOException`
  See Also:
    `XMLSerializable.importXML(InputStream)`

### importXML

    public void importXML(InputStream source)
                   throws SAXException,
                          IOException,
                          ClassCastException

  Description copied from interface: `XMLSerializable`
  The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.

  Specified by:
    `importXML` in interface `XMLSerializable`
  Throws:
    `SAXException`
    `IOException`
    `ClassCastException`
  See Also:
    `XMLSerializable.exportXML(OutputStream)`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads