ru.onego.industrial.catalog.meta
Class CatalogImpl

java.lang.Object
  extended by ru.onego.industrial.catalog.meta.CatalogImpl
All Implemented Interfaces:
Catalog

public class CatalogImpl
extends java.lang.Object
implements Catalog

Default implementation of the Catalog interface.

Version:
1.0
Author:
Lev Levin

Constructor Summary
CatalogImpl()
          Constructor for the object.
 
Method Summary
 void add(Catalog catalog)
          Adds data from another catalog.
 void add(java.lang.String identificator, CatalogLine catalogLine)
          Adds given line to the catalog.
 CatalogLine createCatalogLine(java.lang.String identificator)
          Creates new catalog line with the given identificator.
 void deleteLine(CatalogLine line)
          Removes given line from the catalog.
 CatalogLine get(int line)
          Returns catalog line with the given index.
 CatalogLine get(java.lang.String identificator)
          Returns catalog line with the given identificator.
 java.util.List<java.lang.String> getColumns()
          Returns column names of this catalog.
 java.lang.String getIdentificator(int index)
          Returns identificator of the line with the given index.
 java.util.List<CatalogLine> getLines()
          Returns list of all line in the catalog.
 int size()
          Returns number of lines in this catalog.
 void updateLine(java.lang.String identificator, CatalogLine catalogLine)
          Updates line with the given identificator with data stored in the given catalog line.
static java.lang.String valueHash(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CatalogImpl

public CatalogImpl()
            throws MetaException
Constructor for the object.

Throws:
MetaException - Thrown if error occur while reading init parameters from parser.ini
Method Detail

add

public void add(java.lang.String identificator,
                CatalogLine catalogLine)
         throws MetaException
Adds given line to the catalog.

Parameters:
identificator - Identificator of the line
catalogLine - Line to be added
Throws:
MetaException - Thrown if any error occur while adding

add

public void add(Catalog catalog)
         throws MetaException
Description copied from interface: Catalog
Adds data from another catalog. Catalogs should have the same structure (the same number of columns of the same type). Existing data is not removed. If two lines in both catalogs have the same identifier, data from the adding catalog is added to the data of this catalog according to data types rules for adding. If no value was specified for this catalog and adding catalog has value - new value is set.

Specified by:
add in interface Catalog
Parameters:
catalog - Source catalog
Throws:
MetaException - Should be thrown if catalogs have different metadata

createCatalogLine

public CatalogLine createCatalogLine(java.lang.String identificator)
                              throws MetaException
Description copied from interface: Catalog
Creates new catalog line with the given identificator. Identificator should not point to existing line.

Specified by:
createCatalogLine in interface Catalog
Parameters:
identificator - Unique identificator of the line
Returns:
Object implemented CatalogLine interface
Throws:
MetaException - Thrown if any error occurs while creating the line

size

public int size()
Description copied from interface: Catalog
Returns number of lines in this catalog.

Specified by:
size in interface Catalog
Returns:
Number of lines

updateLine

public void updateLine(java.lang.String identificator,
                       CatalogLine catalogLine)
                throws MetaException
Description copied from interface: Catalog
Updates line with the given identificator with data stored in the given catalog line. Catalog lines should have the same structure. Existing data is not removed. Data from the given catalog line is added to the data of this catalog line according to data types rules for adding. If no value was specified for this catalog line and adding catalog line has value - new value is set.

Specified by:
updateLine in interface Catalog
Parameters:
identificator - Identificator of the line
catalogLine - Source catalog line
Throws:
MetaException - Thrown if metadata differs or error occur while setting values

deleteLine

public void deleteLine(CatalogLine line)
                throws MetaException
Description copied from interface: Catalog
Removes given line from the catalog.

Specified by:
deleteLine in interface Catalog
Parameters:
line - Line to be removed
Throws:
MetaException - Thrown if line is not part of this catalog

get

public CatalogLine get(int line)
                throws MetaException
Description copied from interface: Catalog
Returns catalog line with the given index. Index should not be less than 0 or bigger than size of the catalog.

Specified by:
get in interface Catalog
Parameters:
line - Index of the line
Returns:
CatalogLine object
Throws:
MetaException - Thrown if index is out of bounds

get

public CatalogLine get(java.lang.String identificator)
                throws MetaException
Description copied from interface: Catalog
Returns catalog line with the given identificator. Identificator should point to existing line.

Specified by:
get in interface Catalog
Parameters:
identificator - Identificator of the line
Returns:
CatalogLine object
Throws:
MetaException - Thrown if line with the given identificator is not found

getIdentificator

public java.lang.String getIdentificator(int index)
                                  throws MetaException
Description copied from interface: Catalog
Returns identificator of the line with the given index. Index should not be less than 0 or bigger than size of the catalog.

Specified by:
getIdentificator in interface Catalog
Parameters:
index - Index of the line
Returns:
String holding the identificator
Throws:
MetaException - Thrown if index is out of bounds

getColumns

public java.util.List<java.lang.String> getColumns()
Description copied from interface: Catalog
Returns column names of this catalog.

Specified by:
getColumns in interface Catalog
Returns:
List of columns names

getLines

public java.util.List<CatalogLine> getLines()
Description copied from interface: Catalog
Returns list of all line in the catalog. Lines are sorted by key fields.

Specified by:
getLines in interface Catalog
Returns:
List of lines.

valueHash

public static java.lang.String valueHash(java.lang.String value)