Package adams.data.report
Class Report
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.data.report.Report
-
- All Implemented Interfaces:
CloneHandler<Report>
,LoggingSupporter
,Mergeable<Report>
,SizeOfHandler
,DatabaseIDHandler
,MutableDatabaseIDHandler
,SpreadSheetSupporter
,Serializable
,Comparable
public class Report extends LoggingObject implements Serializable, CloneHandler<Report>, Comparable, Mergeable<Report>, MutableDatabaseIDHandler, SpreadSheetSupporter
Data structure for a report.- Author:
- Dale (dale at cs dot waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DATATYPE_SUFFIX
the property suffix for the data type.static String
FIELD_DUMMYREPORT
field: Dummy report (in case there was no quantitation report and a dummy report was generated automatically).static String
FIELD_EXCLUDED
field: Excluded (= dodgy).protected int
m_DatabaseID
the database ID of the data structure this report belongs to.protected Hashtable<String,AbstractField>
m_Fields
fields.protected Hashtable<AbstractField,Object>
m_Params
Store Header parameters ( parameter:value ).static String
PROPERTY_PARENTID
the parent ID property.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description Report()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addField(AbstractField field)
Adds the given field.void
addParameter(String key, Object value)
Add parameter value to store.void
addParameter(String key, String value)
Add parameter value to store.void
assign(Report other)
Obtains all the values from the specified report.int
compareTo(Object o)
Compares this object with the specified object for order.boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.Boolean
getBooleanValue(AbstractField key)
Get parameter value, or null if not available.Boolean
getBooleanValue(String key)
Get parameter value, or null if not available.Report
getClone()
Returns a clone of itself.int
getDatabaseID()
Returns the database ID of the data container this report belongs to.Double
getDoubleValue(AbstractField key)
Get parameter value, or null if not available.Double
getDoubleValue(String key)
Get parameter value, or null if not available.List<AbstractField>
getFields()
Get all fields as vector.List<AbstractField>
getFields(PrefixOnlyField prefix)
Get all fields as vector that have the same prefix.List<AbstractField>
getFields(SuffixOnlyField suffix)
Get all fields as vector that have the same suffix.DataType
getFieldType(AbstractField field)
Returns the type for given field.LoggingLevel
getLoggingLevel()
Returns the logging level.Hashtable<AbstractField,Object>
getParams()
Get the parameters.List<PrefixOnlyField>
getPrefixFields()
Returns all distinct prefix fields.String
getStringValue(AbstractField key)
Get parameter value, or null if not available.String
getStringValue(String key)
Get parameter value, or null if not available.List<SuffixOnlyField>
getSuffixFields()
Returns all distinct suffix fields.Object
getValue(AbstractField key)
Get parameter value, or null if not available.boolean
hasField(AbstractField field)
Checks whether the field is already stored.boolean
hasField(String field)
Checks whether the field is already stored.int
hashCode()
Hashcode so can be used as hashtable key.boolean
hasValue(AbstractField key)
Returns whether a certain value is available in this report.boolean
hasValue(String key)
Returns whether a certain value is available in this report.protected boolean
hasValues(AbstractField[] fields)
Checks whether all the fields are available.boolean
hasValues(String[] fields)
Checks whether all the fields are available.protected void
initFields()
Set field types.Report
intersect(Report report)
Returns the intersection with this Quantitation Report and the provided one.boolean
isDummyReport()
Returns whether this report is a dummy report or not.void
mergeWith(Report other)
Merges its own data with the one provided by the specified object.Report
minus(Report report)
Returns the subset of values that this Quantitation Report contains, but not the provided one.static Report
newInstance(Report report)
Returns a new instance of the concrete subclass for the report.static Report
parseProperties(Properties props)
Parses the properties (generated with the toProperties() method) and generates a report object from it.static Report
parseReport(String s)
Parses the string generated by the toString() method.Object
removeValue(AbstractField key)
Removes the specified field.boolean
removeValues(BaseRegExp regExp)
Removes all fields that match the regular expression.boolean
removeValuesStartingWith(String prefix)
Removes all fields that start with the provided string.void
setBooleanValue(String key, boolean value)
Sets a boolean value.void
setDatabaseID(int value)
Sets the parent ID, i.e., the database ID of the data container this report belongs to.void
setDummyReport(boolean value)
Sets whether this report is dummy report or not.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.void
setNumericValue(String key, double value)
Sets a numeric value.void
setParams(Hashtable<AbstractField,Object> ht)
Set the parameters.void
setStringValue(String key, String value)
Sets a string value.boolean
setValue(AbstractField key, Object value)
Sets a value.Properties
toProperties()
Turns the report into a properties object.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.String
toString()
Return String representation of report.void
update()
Updates certain dependant fields.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
FIELD_DUMMYREPORT
public static final String FIELD_DUMMYREPORT
field: Dummy report (in case there was no quantitation report and a dummy report was generated automatically).- See Also:
- Constant Field Values
-
FIELD_EXCLUDED
public static final String FIELD_EXCLUDED
field: Excluded (= dodgy).- See Also:
- Constant Field Values
-
PROPERTY_PARENTID
public static final String PROPERTY_PARENTID
the parent ID property.- See Also:
- Constant Field Values
-
DATATYPE_SUFFIX
public static final String DATATYPE_SUFFIX
the property suffix for the data type.- See Also:
- Constant Field Values
-
m_Params
protected Hashtable<AbstractField,Object> m_Params
Store Header parameters ( parameter:value ).
-
m_Fields
protected Hashtable<String,AbstractField> m_Fields
fields.
-
m_DatabaseID
protected int m_DatabaseID
the database ID of the data structure this report belongs to.
-
-
Method Detail
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Parameters:
value
- the level
-
getLoggingLevel
public LoggingLevel getLoggingLevel()
Returns the logging level.- Overrides:
getLoggingLevel
in classLoggingObject
- Returns:
- the level
-
setDatabaseID
public void setDatabaseID(int value)
Sets the parent ID, i.e., the database ID of the data container this report belongs to.- Specified by:
setDatabaseID
in interfaceMutableDatabaseIDHandler
- Parameters:
value
- the database ID
-
getDatabaseID
public int getDatabaseID()
Returns the database ID of the data container this report belongs to.- Specified by:
getDatabaseID
in interfaceDatabaseIDHandler
- Returns:
- the database ID, -1 if not set
-
initFields
protected void initFields()
Set field types.
-
addField
public void addField(AbstractField field)
Adds the given field.- Parameters:
field
- the field to add
-
hasField
public boolean hasField(String field)
Checks whether the field is already stored.- Parameters:
field
- the field to check- Returns:
- true if already added
-
hasField
public boolean hasField(AbstractField field)
Checks whether the field is already stored.- Parameters:
field
- the field to check- Returns:
- true if already added
-
getFieldType
public DataType getFieldType(AbstractField field)
Returns the type for given field. Either based on the stored fields (m_Fields) orDataType.UNKNOWN
.- Parameters:
field
- the field to look for- Returns:
- the stored field type or
DataType.UNKNOWN
if field not stored - See Also:
m_Fields
-
getFields
public List<AbstractField> getFields()
Get all fields as vector.- Returns:
- the fields
-
getFields
public List<AbstractField> getFields(PrefixOnlyField prefix)
Get all fields as vector that have the same prefix.- Parameters:
prefix
- the common prefix- Returns:
- the fields that match the prefix
-
getFields
public List<AbstractField> getFields(SuffixOnlyField suffix)
Get all fields as vector that have the same suffix.- Parameters:
suffix
- the common suffix- Returns:
- the fields that match the suffix
-
getPrefixFields
public List<PrefixOnlyField> getPrefixFields()
Returns all distinct prefix fields.- Returns:
- the prefix fields
-
getSuffixFields
public List<SuffixOnlyField> getSuffixFields()
Returns all distinct suffix fields.- Returns:
- the suffix fields
-
addParameter
public void addParameter(String key, String value)
Add parameter value to store.- Parameters:
key
- the keyvalue
- the value for the key
-
addParameter
public void addParameter(String key, Object value)
Add parameter value to store.- Parameters:
key
- the keyvalue
- the value for the key
-
setParams
public void setParams(Hashtable<AbstractField,Object> ht)
Set the parameters.- Parameters:
ht
- hashtable of parameters
-
getParams
public Hashtable<AbstractField,Object> getParams()
Get the parameters.- Returns:
- hashtable of parameters
-
hasValue
public boolean hasValue(AbstractField key)
Returns whether a certain value is available in this report.- Parameters:
key
- the value to look for- Returns:
- true if the value is available
-
hasValue
public boolean hasValue(String key)
Returns whether a certain value is available in this report.- Parameters:
key
- the value to look for- Returns:
- true if the value is available
-
hasValues
protected boolean hasValues(AbstractField[] fields)
Checks whether all the fields are available.- Parameters:
fields
- the required fields- Returns:
- true if required fields available
-
hasValues
public boolean hasValues(String[] fields)
Checks whether all the fields are available.- Parameters:
fields
- the required fields- Returns:
- true if required fields available
-
setValue
public boolean setValue(AbstractField key, Object value)
Sets a value.- Parameters:
key
- the key of the valuevalue
- the new value- Returns:
- whether successfully set
-
setNumericValue
public void setNumericValue(String key, double value)
Sets a numeric value.- Parameters:
key
- the key of the valuevalue
- the new value
-
setStringValue
public void setStringValue(String key, String value)
Sets a string value.- Parameters:
key
- the key of the valuevalue
- the new value
-
setBooleanValue
public void setBooleanValue(String key, boolean value)
Sets a boolean value.- Parameters:
key
- the key of the valuevalue
- the new value
-
getValue
public Object getValue(AbstractField key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value
-
getStringValue
public String getStringValue(String key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value
-
getStringValue
public String getStringValue(AbstractField key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value, null if not present
-
getBooleanValue
public Boolean getBooleanValue(String key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value
-
getBooleanValue
public Boolean getBooleanValue(AbstractField key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value, null if not present
-
getDoubleValue
public Double getDoubleValue(String key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value
-
getDoubleValue
public Double getDoubleValue(AbstractField key)
Get parameter value, or null if not available.- Parameters:
key
- the key- Returns:
- parameter value, null if not present
-
removeValue
public Object removeValue(AbstractField key)
Removes the specified field.- Parameters:
key
- the key- Returns:
- the value previously stored in the report, can be null if the field wasn't present
-
removeValues
public boolean removeValues(BaseRegExp regExp)
Removes all fields that match the regular expression.- Parameters:
regExp
- the regular expression to match the field names against- Returns:
- true if report got modified (ie at least one field removed)
-
removeValuesStartingWith
public boolean removeValuesStartingWith(String prefix)
Removes all fields that start with the provided string.- Parameters:
prefix
- the prefix of fields to remove- Returns:
- true if report got modified (ie at least one field removed)
-
update
public void update()
Updates certain dependant fields. This method should be called before saving it to the database, after loading it from the database or when a quantitation report has been created by hand. Default implementation does nothing.
-
toString
public String toString()
Return String representation of report.
-
getClone
public Report getClone()
Returns a clone of itself.- Specified by:
getClone
in interfaceCloneHandler<Report>
- Returns:
- the clone
-
assign
public void assign(Report other)
Obtains all the values from the specified report.- Parameters:
other
- the report to obtain the values form
-
setDummyReport
public void setDummyReport(boolean value)
Sets whether this report is dummy report or not.- Parameters:
value
- if true then this report will be flagged as dummy report
-
isDummyReport
public boolean isDummyReport()
Returns whether this report is a dummy report or not.- Returns:
- true if this report is a dummy report
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
hashCode
public int hashCode()
Hashcode so can be used as hashtable key. Returns the hashcode of them_Params
hashtable.
-
intersect
public Report intersect(Report report)
Returns the intersection with this Quantitation Report and the provided one. The result contains the values of this quantitation report. No merging of values between the two is performed.- Parameters:
report
- the report to get the intersection with- Returns:
- the intersection
-
minus
public Report minus(Report report)
Returns the subset of values that this Quantitation Report contains, but not the provided one. The result contains the values of this quantitation report.- Parameters:
report
- the report to get the fields from to not include in the result- Returns:
- the new report
-
mergeWith
public void mergeWith(Report other)
Merges its own data with the one provided by the specified object. Never overwrites its own values, only adds missing ones.
-
newInstance
public static Report newInstance(Report report)
Returns a new instance of the concrete subclass for the report.- Parameters:
report
- the report class to create a new instance from- Returns:
- the new instance
-
toProperties
public Properties toProperties()
Turns the report into a properties object. Also adds the parent ID.- Returns:
- the generated
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
parseReport
public static Report parseReport(String s)
Parses the string generated by the toString() method.- Parameters:
s
- the string to parse- Returns:
- the generated report
- See Also:
toString()
-
parseProperties
public static Report parseProperties(Properties props)
Parses the properties (generated with the toProperties() method) and generates a report object from it.- Parameters:
props
- the properties to generate the report from- Returns:
- the report
- See Also:
toProperties()
-
-