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 StringDATATYPE_SUFFIXthe property suffix for the data type.static StringFIELD_DUMMYREPORTfield: Dummy report (in case there was no quantitation report and a dummy report was generated automatically).static StringFIELD_EXCLUDEDfield: Excluded (= dodgy).protected intm_DatabaseIDthe database ID of the data structure this report belongs to.protected Hashtable<String,AbstractField>m_Fieldsfields.protected Hashtable<AbstractField,Object>m_ParamsStore Header parameters ( parameter:value ).static StringPROPERTY_PARENTIDthe 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 voidaddField(AbstractField field)Adds the given field.voidaddParameter(String key, Object value)Add parameter value to store.voidaddParameter(String key, String value)Add parameter value to store.voidassign(Report other)Obtains all the values from the specified report.intcompareTo(Object o)Compares this object with the specified object for order.booleanequals(Object obj)Indicates whether some other object is "equal to" this one.BooleangetBooleanValue(AbstractField key)Get parameter value, or null if not available.BooleangetBooleanValue(String key)Get parameter value, or null if not available.ReportgetClone()Returns a clone of itself.intgetDatabaseID()Returns the database ID of the data container this report belongs to.DoublegetDoubleValue(AbstractField key)Get parameter value, or null if not available.DoublegetDoubleValue(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.DataTypegetFieldType(AbstractField field)Returns the type for given field.LoggingLevelgetLoggingLevel()Returns the logging level.Hashtable<AbstractField,Object>getParams()Get the parameters.List<PrefixOnlyField>getPrefixFields()Returns all distinct prefix fields.StringgetStringValue(AbstractField key)Get parameter value, or null if not available.StringgetStringValue(String key)Get parameter value, or null if not available.List<SuffixOnlyField>getSuffixFields()Returns all distinct suffix fields.ObjectgetValue(AbstractField key)Get parameter value, or null if not available.booleanhasField(AbstractField field)Checks whether the field is already stored.booleanhasField(String field)Checks whether the field is already stored.inthashCode()Hashcode so can be used as hashtable key.booleanhasValue(AbstractField key)Returns whether a certain value is available in this report.booleanhasValue(String key)Returns whether a certain value is available in this report.protected booleanhasValues(AbstractField[] fields)Checks whether all the fields are available.booleanhasValues(String[] fields)Checks whether all the fields are available.protected voidinitFields()Set field types.Reportintersect(Report report)Returns the intersection with this Quantitation Report and the provided one.booleanisDummyReport()Returns whether this report is a dummy report or not.voidmergeWith(Report other)Merges its own data with the one provided by the specified object.Reportminus(Report report)Returns the subset of values that this Quantitation Report contains, but not the provided one.static ReportnewInstance(Report report)Returns a new instance of the concrete subclass for the report.static ReportparseProperties(Properties props)Parses the properties (generated with the toProperties() method) and generates a report object from it.static ReportparseReport(String s)Parses the string generated by the toString() method.ObjectremoveValue(AbstractField key)Removes the specified field.booleanremoveValues(BaseRegExp regExp)Removes all fields that match the regular expression.booleanremoveValuesStartingWith(String prefix)Removes all fields that start with the provided string.voidsetBooleanValue(String key, boolean value)Sets a boolean value.voidsetDatabaseID(int value)Sets the parent ID, i.e., the database ID of the data container this report belongs to.voidsetDummyReport(boolean value)Sets whether this report is dummy report or not.voidsetLoggingLevel(LoggingLevel value)Sets the logging level.voidsetNumericValue(String key, double value)Sets a numeric value.voidsetParams(Hashtable<AbstractField,Object> ht)Set the parameters.voidsetStringValue(String key, String value)Sets a string value.booleansetValue(AbstractField key, Object value)Sets a value.PropertiestoProperties()Turns the report into a properties object.SpreadSheettoSpreadSheet()Returns the content as spreadsheet.StringtoString()Return String representation of report.voidupdate()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:
getLoggingLevelin 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:
setDatabaseIDin interfaceMutableDatabaseIDHandler- Parameters:
value- the database ID
-
getDatabaseID
public int getDatabaseID()
Returns the database ID of the data container this report belongs to.- Specified by:
getDatabaseIDin 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.UNKNOWNif 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:
getClonein 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:
compareToin 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_Paramshashtable.
-
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:
toSpreadSheetin 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()
-
-