Holger's
Java API

com.antelmann.sql
Class WrappedDBClassStoreMapping<T extends DBEntry>

java.lang.Object
  extended by com.antelmann.db.WrappedDBClassStore<T>
      extended by com.antelmann.sql.WrappedDBClassStoreMapping<T>
All Implemented Interfaces:
DBClassStore<T>, ProcessedFilterOption<T>, TransactionRequired, MappingInfo, ProcessorHook<T,DatabaseException>, Wrapped<DBClassStore<T>>
Direct Known Subclasses:
CategoryStore, PropertyEntryHeaderStore, PropertyEntryTableStore, TaggableHeaderStore, TaggableSQLStore, UnionSqlStore

public class WrappedDBClassStoreMapping<T extends DBEntry>
extends WrappedDBClassStore<T>
implements MappingInfo

eases the wrapping of stores that need to override certain mapping infos

Since:
11.12.2009, 02:23:03
Author:
Holger Antelmann
See Also:
DefaultMappingInfo

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore
DBClassStore.DBMethod
 
Field Summary
protected  MappingInfo mi
           
 
Fields inherited from class com.antelmann.db.WrappedDBClassStore
store
 
Constructor Summary
WrappedDBClassStoreMapping(DBClassStore<T> store)
          the given store must directly support or wrap the MappingInfo interface
WrappedDBClassStoreMapping(DBClassStore<T> store, MappingInfo mi)
           
 
Method Summary
 void addColumnsForTopic(Object topic, String... columns)
          adds all given columns as applicable for the given topic
 String addTopicMapping(Object topic, String mapping)
          allows to define information for getMappingForTopic(Object)
 Hashtable<String,String> getColumnDisplayMapping()
          provides direct access to the underlying data to individualize the column display information
 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 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
 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.
 int getSQLTypeforColumn(String column)
          allows to determine the SQL-type for a given column name
 String[] getSupportedTopicColumns()
          returns all topics supported by getColumnsForTopic(Object)
 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.
 ArrayList<String> removeColumnTopics(Object topic)
          removes all columns from the mapping for the given topic
 String removeTopicMapping(Object topic)
           
 void setColumnsForTopic(Object topic, String... columns)
           
 
Methods inherited from class com.antelmann.db.WrappedDBClassStore
add, checkReadAccess, checkWriteAccess, containsID, deleteEntries, deleteEntriesIndividually, deleteEntry, exposesInterfaces, fetch, fetchStubs, generateNewID, getAccessFilter, getAccessStubFilter, getDatabase, getEntry, getEntryClass, getFetchProcessor, getPreStoreHandler, getStoreHandler, getStub, getStubProcessor, insert, insertAsNew, isApplyFilterProcessingRecursively, isDeleteEntriesIndividually, isEnsureTransactionsOnFetch, isProcessBeforeFiltering, queryForInterface, remove, setAccessFilter, setAccessStubFilter, setApplyFilterProcessingRecursively, setDeleteEntriesIndividually, setEnsureTransactionsOnFetch, setExposesInterfaces, setFetchProcessor, setPreStoreHandler, setProcessBeforeFiltering, setProcessBeforeFiltering, setStoreHandler, setStubProcessor, size, unwrap, update, wrapFilterForProcessing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mi

protected final MappingInfo mi
Constructor Detail

WrappedDBClassStoreMapping

public WrappedDBClassStoreMapping(DBClassStore<T> store)
the given store must directly support or wrap the MappingInfo interface


WrappedDBClassStoreMapping

public WrappedDBClassStoreMapping(DBClassStore<T> store,
                                  MappingInfo mi)
Method Detail

addTopicMapping

public String addTopicMapping(Object topic,
                              String mapping)
allows to define information for getMappingForTopic(Object)

Parameters:
mapping - if null, the given topic is removed from the map
Returns:
the last mapping for the given topic
See Also:
getMappingForTopic(Object)

removeTopicMapping

public String removeTopicMapping(Object topic)

removeColumnTopics

public ArrayList<String> removeColumnTopics(Object topic)
removes all columns from the mapping for the given topic

Returns:
a list of previously defined columns for the given topic or null
See Also:
getColumnsForTopic(Object)

setColumnsForTopic

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

addColumnsForTopic

public void addColumnsForTopic(Object topic,
                               String... columns)
adds all given columns as applicable for the given topic

See Also:
getColumnsForTopic(Object)

getColumnDisplayMapping

public Hashtable<String,String> getColumnDisplayMapping()
provides direct access to the underlying data to individualize the column display information

See Also:
getDisplayNameForColumn(String)

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()

getSupportedTopicColumns

public String[] getSupportedTopicColumns()
returns all topics supported by getColumnsForTopic(Object)


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

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

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

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

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

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

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

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()

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()


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