Holger's Java API

## com.antelmann.image
Class ImageURLEntryMapper<T extends ImageURLEntry>

    java.lang.Object
      com.antelmann.sql.BaseRowMapper<T>
          com.antelmann.image.ImageURLEntryMapper<T>

All Implemented Interfaces:
  TransactionRequired, MappingInfo, ObjectRowMapper<T>, Converter<RowItem,T>

    public class ImageURLEntryMapper<T extends ImageURLEntry>

extends BaseRowMapper<T>

an abstract base implementation of a mapper to be used with an ImageHolderSQLStore. This implementation disregards the actual original image completely and simply relies on `ImageURLEntry.retrieveImage()` to do its job. Also, if the image is ever altered by `ImageURLEntry.setImageReference(Image)`, this change is ignored when saving the image, unless subclasses take care of it.

Author:
  Holger Antelmann
See Also:
  `ImageURLEntrySQLStore`

Nested Class Summary
`static class` `ImageURLEntryMapper.ColumnKey` provide keys for accessing the column names via `MappingInfo` interface

Nested classes/interfaces inherited from interface com.antelmann.util.Converter
`Converter.Adapter<T1,T2>`

Field Summary
`protected String` `altitudeColumn` number field; null by default
`protected String` `descriptionColumn` longvarchar field
`protected String` `latitudeColumn` number field
`protected String` `longitudeColumn` number field
`protected String` `thumbnailColumn` blob field
`protected String` `timeColumn` timestamp field
`protected String` `urlColumn` string field

Fields inherited from class com.antelmann.sql.BaseRowMapper
`db, helper`

Constructor Summary
`ImageURLEntryMapper(Database<Connection> db, String tableName, String idColumn, String displayColumn, Class<T> type)` uses `BaseRowMapper.getNextIntID()` as id-factory
`ImageURLEntryMapper(Database<Connection> db, String tableName, String idColumn, String displayColumn, IDFactory idFactory, Class<T> type)`

Method Summary
`protected Map<String,Object>` `generateRowProperties(T entry)` generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row.
`String` `getMappingForTopic(Object topic)` If the topic does not exist but is a String that is an existing column, it is returned as such.
`T` `instantiate(RowItem row)` instantiates the DBEntry based on the properties in the given row.
`protected T` `makeNewInstance(Object id)` creates the instance based on the type through reflection; uses a constructor that solely takes an Object as the id
`protected InputStream` `storeThumbnail(Image image)` simply uses a jpg serialized ByteArrayInputStream

Methods inherited from class com.antelmann.sql.BaseRowMapper

`addColumnsForTopic, applyFromMapping, checkExistence, convert, convertBack, convertTopicFilter, emptyStringsToNull, extractReference, extractStub, extractStub, generateNewID, getAll, getColumnDisplayMapping, getColumnNames, getColumnsForTopic, getColumnSize, getConnection, getConnectionHelper, getDisplayColumn, getDisplayNameForColumn, getEntryClass, getEntryClassMapper, getIDColumn, getIDFactory, getMappedValue, getNextIntID, getNextIntIDFactory, getNextIntIDFactory, getPreStoreFilter, getReadOnlyColumns, getRestrictMappedColumns, getResultSet, getSQLTypeforColumn, getStubColumns, getStubQuery, getStubResultSet, getSupportedTopicColumns, getTableColumnNames, getTableName, getTableQuery, getTableQueryForComboFilter, getTransactionCounter, getUniqueRandomString, handleAfterStore, initMapping, isMappedTopic, isTranslate, javaToSql, javaToSql, lockTable, mapReference, mapReference, mapToRow, removeColumnTopic, setColumnsForTopic, setDisplayColumn, setEntryClass, setEntryClassMapper, setIDFactory, setMappedValue, setNextIntIdAsFactory, setPreStoreFilter, setReadOnlyColumns, setRestrictedMappedColumns, setStubQuery, setTableQuery, setTableQuery, setTopic, setTranslate, sqlToJava, toSQLMap, verifyBeforeDelete, verifyBeforeStore`

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

Field Detail

### timeColumn

    protected String timeColumn

  timestamp field

### thumbnailColumn

    protected String thumbnailColumn

  blob field

### descriptionColumn

    protected String descriptionColumn

  longvarchar field

### urlColumn

    protected String urlColumn

  string field

### latitudeColumn

    protected String latitudeColumn

  number field

### longitudeColumn

    protected String longitudeColumn

  number field

### altitudeColumn

    protected String altitudeColumn

  number field; null by default

Constructor Detail

### ImageURLEntryMapper

    public ImageURLEntryMapper(Database<Connection> db,
                               String tableName,
                               String idColumn,
                               String displayColumn,
                               IDFactory idFactory,
                               Class<T> type)
                        throws DatabaseException

Parameters:
  `displayColumn` - represents the title of the image entry; see `ImageURLEntry.getTitle()`
Throws:
  `DatabaseException`

### ImageURLEntryMapper

    public ImageURLEntryMapper(Database<Connection> db,
                               String tableName,
                               String idColumn,
                               String displayColumn,
                               Class<T> type)
                        throws DatabaseException

  uses `BaseRowMapper.getNextIntID()` as id-factory

  Throws:
    `DatabaseException`

Method Detail

### getMappingForTopic

    public String getMappingForTopic(Object topic)

  Description copied from class: `BaseRowMapper`
  If the topic does not exist but is a String that is an existing column, it is returned as such.

  Specified by:
    `getMappingForTopic` in interface `MappingInfo`
  Overrides:
    `getMappingForTopic` in class `BaseRowMapper<T extends ImageURLEntry>`
  Returns:
    either a table name, a column name, a query string or null - depending on the given topic
  See Also:
    `BaseRowMapper.setTopic(Object, String)`

### generateRowProperties

    protected Map<String,Object> generateRowProperties(T entry)
                                                throws WrongDataException

  Description copied from class: `BaseRowMapper`
  generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row. The ID column and the corresponding ID should not be put in there, as this will happen automatically later.

  Specified by:
    `generateRowProperties` in class `BaseRowMapper<T extends ImageURLEntry>`
  Throws:
    `WrongDataException`

### storeThumbnail

    protected InputStream storeThumbnail(Image image)
                                  throws IOException

  simply uses a jpg serialized ByteArrayInputStream

  Throws:
    `IOException`

### makeNewInstance

    protected T makeNewInstance(Object id)
                                               throws Exception

  creates the instance based on the type through reflection; uses a constructor that solely takes an Object as the id

  Throws:
    `Exception`

### instantiate

    public T instantiate(RowItem row)
                                        throws Exception

  Description copied from interface: `ObjectRowMapper`
  instantiates the DBEntry based on the properties in the given row. The given row contains all the columns of the queried ResultSet unless the columns to be retrieved are restricted by `ObjectRowMapper.getRestrictMappedColumns()`.

  Throws:
    `Exception`

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