pl.edu.agh.cast.rawdata.stat
Class BrokenDataInfo

java.lang.Object
  extended by pl.edu.agh.cast.rawdata.stat.BrokenDataInfo
All Implemented Interfaces:
IRawDataMonitorable

public class BrokenDataInfo
extends Object
implements IRawDataMonitorable

Class which represents information about broken data in TabularData object. It contains list of DataRow objects mapped to corresponding BrokenRowInfo objects. It contains statistics after data validation: all rows number, errors number, error rows number, etc. It is returned as a result of DataLoaderWithStatistics.validate() method.

Author:
AGH CAST Team TODO: add handling broken cell list

Constructor Summary
BrokenDataInfo(TabularData inputData)
          Default constructor.
 
Method Summary
 void addBrokenRowInfo(BrokenRowInfo brokenRowInfo)
          Adds information about broken row in TabularData.
 List<BrokenCellInfo> getBrokenCells()
          Returns list of all broken cells.
 List<BrokenCellInfo> getBrokenCellsByType(ErrorType errorType)
          Returns list of BrokenCellInfo objects which are not removed.
 List<BrokenCellInfo> getBrokenCellsRelatedTo(DataRow row)
          Returns list of BrokenCellInfo related to input row.
 BrokenRowInfo getBrokenRowInfo(DataRow row)
          Returns broken row info associated with the specified row.
 int getBrokenRowsCount()
           
 int getErrorsCount()
           
 Map<ErrorType,Integer> getErrorTypesWithOccurrences()
          Gets returns type mapped to number of occurrences in associated TabularData object.
 int getRowsCount()
           
 int getWarningsCount()
           
 void registerObserver(IRawDataObserver observer)
          Registers a new observer.
 void removeBrokenRowInfo(BrokenRowInfo brokenRowInfo)
          Removes row specified by specified BrokenRowInfo object.
 BrokenRowInfo removeDataRow(DataRow row)
          Removed the specified row.
 void replaceBrokenRowInfo(DataRow row, BrokenRowInfo newValue)
          Replaces information about data row which is in newValue object.
 BrokenRowInfo restoreDataRow(int rowNumber)
          Restores row with specified row number.
 void unregisterObserver(IRawDataObserver observer)
          Unregisters an existing observer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokenDataInfo

public BrokenDataInfo(TabularData inputData)
Default constructor. Creates an instance associated with specified TabularData object.

Parameters:
inputData - TabularData which will be described by created object.
Method Detail

addBrokenRowInfo

public void addBrokenRowInfo(BrokenRowInfo brokenRowInfo)
Adds information about broken row in TabularData. Updates cache information about cell which contains errors or warnings & registers observer on source row.

Parameters:
brokenRowInfo - information about broken row to be added to data info object

removeDataRow

public BrokenRowInfo removeDataRow(DataRow row)
Removed the specified row. If row has associated BrokenRowInfo object, method removeBrokenRowInfo is called, otherwise row is removed straightforward from data. The deleted row is cached and can be restored using method restoreDataRow

Parameters:
row - row to be deleted
Returns:
broken row info associated with row or null if no such object

getBrokenCellsRelatedTo

public List<BrokenCellInfo> getBrokenCellsRelatedTo(DataRow row)
Returns list of BrokenCellInfo related to input row.

Parameters:
row - data row
Returns:
list of BrokenCellInfo objects related to the specified row.

removeBrokenRowInfo

public void removeBrokenRowInfo(BrokenRowInfo brokenRowInfo)
Removes row specified by specified BrokenRowInfo object. The source object is deleted from TabularData. The broken row info object is cached for undo action.

Parameters:
brokenRowInfo - broken row info object which indicated which row should be deleted.

restoreDataRow

public BrokenRowInfo restoreDataRow(int rowNumber)
Restores row with specified row number. The restored row is placed at the beginning of rows in tabular data.

Parameters:
rowNumber - row number to be restored
Returns:
restored broken row info, null if no row has been restored or if restored row was without broken row info.

replaceBrokenRowInfo

public void replaceBrokenRowInfo(DataRow row,
                                 BrokenRowInfo newValue)
Replaces information about data row which is in newValue object. Updates statistics.

Parameters:
row - row with errors or warnings which broken info will be replaced
newValue - value new broken row info; if null the method is equal to removeBrokenRowInfo(_brokenRows.get(row))

getBrokenCells

public List<BrokenCellInfo> getBrokenCells()
Returns list of all broken cells. Doesn't omit cells which row is marked as deleted.

Returns:
unmodifiable list of broken cells

getBrokenRowInfo

public BrokenRowInfo getBrokenRowInfo(DataRow row)
Returns broken row info associated with the specified row.

Parameters:
row - data row object
Returns:
broken row info associated with the specified row

getErrorTypesWithOccurrences

public Map<ErrorType,Integer> getErrorTypesWithOccurrences()
Gets returns type mapped to number of occurrences in associated TabularData object.

Returns:
map which contains error types with number of occurrences

getBrokenCellsByType

public List<BrokenCellInfo> getBrokenCellsByType(ErrorType errorType)
Returns list of BrokenCellInfo objects which are not removed.

Parameters:
errorType - type of error
Returns:
list of broken cell info objects

getErrorsCount

public int getErrorsCount()

getWarningsCount

public int getWarningsCount()

getBrokenRowsCount

public int getBrokenRowsCount()

getRowsCount

public int getRowsCount()

registerObserver

public void registerObserver(IRawDataObserver observer)
Registers a new observer. If the specified observer is already registered it is not added the second time

Specified by:
registerObserver in interface IRawDataMonitorable
Parameters:
observer - an observer to register; it cannot be null
See Also:
registerObserver(pl.edu.agh.cast.rawdata.logging.IRawDataObserver)

unregisterObserver

public void unregisterObserver(IRawDataObserver observer)
Unregisters an existing observer. The method ignores unregistered observers.

Specified by:
unregisterObserver in interface IRawDataMonitorable
Parameters:
observer - an observer to unregister
See Also:
unregisterObserver(pl.edu.agh.cast.rawdata.logging.IRawDataObserver)


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.