Diagnostics tutorial |
|
|
Obtaining &
using Diagnosis instances Diagnosis instances are used to format data collected in life-time of Diagnostics object. They save this data to files. Saved files are raports from work of your code, and are called diagnosis.
There are two ways of getting Diagnosis. First, recommended way is to use Diagnostics methods: getPlainTextDiagnosis(), getHtmlDiagnosis(), getXMLDiagnosis(), getLowLevelDiagnosis(). All four are overriden - they may have one String parameter which gives name to document. If you use non-parametrical method document name will be defaultly set to "Unnamed document". Second way is to pass List<Entry> instance manually to constructor. Every implementation of Diagnosis has constructor ...Diagnosis(List<Entry> l). To find out how to prepare such a list check part 3 of this page Diagnosis interface & AbstractDiagnosis class Diagnosis is interface implemented by every ...Diagnosis class, also AbstractDiagnosis. It has 3 methods: set/getDocumentName() - standard setter/getter for document name. Document name can also be given while getting Diagnosis instance from Diagnostics. It's only for your use, to get better oriented what does it means (if you test several programs or have several instances of Diagnostics its use makes more sense - to differ one diagnosis from another. saveToFile(String f) - save the diagnosis to file called f. No Diagnosis implementation adds extension to file, you have to precise it yourself. It also have static fields with time units. They are given for future, when Diagnosis can be told in what time unit should it print time. AbstractDiagnosis is abstract class implementing Diagnosis interface. It implements set/getDocumentName() and adds method saveToFile() which works as saveToFile(document_name+".txt"). In future this method will be added to interface. It does leave saveToFile() abstract, so that inheritating classes can implement it themselves. Also contains static fields BEGINTAG, ENDTAG, LOOPTAG, which are used for interpreting data. For more information of what they mean check part 3part 3 Structure of Diagnostics<->Diagnosis data This part is under construction, will tell you how diagnosis data is stored in memory, and then how is interpreted. |