Class OrderedTableNameMap

java.lang.Object
org.dbunit.dataset.OrderedTableNameMap

public class OrderedTableNameMap extends Object
Associates a table name with an arbitrary object. Moreover the order of the added table names is maintained and the ordered table names can be retrieved via getTableNames().

The map ensures that one table name can only be added once.

TODO In the future it might be discussed if a ListOrderedMap (apache-commons-collections) can/should be used.
Since:
2.4.0
Version:
$Revision$
Author:
gommma, Last changed by: $Author$
  • Constructor Details

    • OrderedTableNameMap

      public OrderedTableNameMap(boolean caseSensitiveTableNames)
      Creates a new map which does strictly force that one table can only occur once.
      Parameters:
      caseSensitiveTableNames - Whether or not table names should be case sensitive
  • Method Details

    • get

      public Object get(String tableName)
      Returns the object associated with the given table name
      Parameters:
      tableName - The table name for which the associated object is retrieved
      Returns:
      The object that has been associated with the given table name
    • getTableNames

      public String[] getTableNames()
      Provides the ordered table names having the same order in which the table names have been added via add(String, Object).
      Returns:
      The list of table names ordered in the sequence as they have been added to this map
    • containsTable

      public boolean containsTable(String tableName)
      Checks if this map contains the given table name
      Parameters:
      tableName -
      Returns:
      Returns true if the map of tables contains the given table name
    • isLastTable

      public boolean isLastTable(String tableName)
      Parameters:
      tableName - The table name to check
      Returns:
      true if the given tableName matches the last table that has been added to this map.
    • getLastTableName

      public String getLastTableName()
      Returns:
      The name of the last table that has been added to this map. Returns null if no table has been added yet.
    • setLastTable

      public void setLastTable(String tableName) throws NoSuchTableException
      Throws:
      NoSuchTableException
    • add

      public void add(String tableName, Object object) throws AmbiguousTableNameException
      Adds the given table name to the map of table names, associating it with the given object.
      Parameters:
      tableName - The table name to be added
      object - Object to be associated with the given table name. Can be null
      Throws:
      AmbiguousTableNameException - If the given table name already exists
    • orderedValues

      public Collection orderedValues()
      Returns:
      The values of this map ordered in the sequence they have been added
    • update

      public void update(String tableName, Object object)
      Updates the value associated with the given table name. Must be invoked if the table name has already been added before.
      Parameters:
      tableName - The table name for which the association should be updated
      object - The new object to be associated with the given table name
    • getTableName

      public String getTableName(String tableName)
      Returns the table name in the correct case (for example as upper case string)
      Parameters:
      tableName - The input table name to be resolved
      Returns:
      The table name for the given string in the correct case.
    • toString

      public String toString()
      Overrides:
      toString in class Object