public class TextHistogram extends Reportable implements java.util.Observer
TextHistogram
class is providing a statistic analysis about
text values. Given Strings are counted and the report will show the amount of
every given text.
If the given parameter is a null pointer it will not be counted.Histogram
and ValueStatistics
from Soenke Claassen, based on DESMO-C from Thomas Schniewind, 1998
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You
may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing
permissions and limitations under the License.Constructor and Description |
---|
TextHistogram(Model ownerModel,
java.lang.String name,
boolean showInReport,
boolean showInTrace)
Constructor for a TextHistogram object that will NOT be connected to a
TextSupplier . |
TextHistogram(Model ownerModel,
java.lang.String name,
TextSupplier textSup,
boolean showInReport,
boolean showInTrace)
Constructor for a TextHistogram object that will be connected to a
TextSupplier . |
Modifier and Type | Method and Description |
---|---|
Reporter |
createDefaultReporter()
Returns a Reporter to produce a report about this TextHistogram.
|
java.lang.String |
getLastString()
Returns the last observed String of this TextHistogram object.
|
java.lang.String |
getLeastFrequentedString()
Returns the String with the least number of entries.
|
java.lang.String |
getMostFrequentedString()
Returns the String with the largest number of entries.
|
int |
getNumberOfStringsObserved()
Returns the number of Strings observed.
|
long |
getObservationsOfString(java.lang.String obsStr)
Returns the number of observations for the given String.
|
java.lang.String[] |
getStringsObserved()
Returns an array of Strings observed.
|
void |
reset()
Resets this TextHistogram object by deleting all observed Strings.
|
void |
update()
Updates this
TextHistogram object by fetching the actual
value of the TextSupplier and processing it. |
void |
update(java.util.Observable o,
java.lang.Object arg)
Implementation of the virtual
update(Observable, Object)
method of the Observer interface. |
void |
update(java.lang.String updateStr)
Updates this
TextHistogram object with the String value
given as parameter. |
getCorrespondingSchedulable, getDescription, getObservations, getReporter, incrementObservations, incrementObservations, reportIsOn, reportOff, reportOn, resetAt, setCorrespondingSchedulable, setDescription, setReporter
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public TextHistogram(Model ownerModel, java.lang.String name, boolean showInReport, boolean showInTrace)
TextSupplier
.ownerModel
- Model : The model this TextHistogram is associated to.name
- java.lang.String : The name of this TextHistogram object.showInReport
- boolean : Flag for showing the report about this Histogram.showInTrace
- boolean : Flag for showing the trace output of this Histogram.public TextHistogram(Model ownerModel, java.lang.String name, TextSupplier textSup, boolean showInReport, boolean showInTrace)
TextSupplier
.ownerModel
- Model : The model this TextHistogram is associated to.name
- java.lang.String : The name of this TextHistogram object.textValSup
- TextSupplier : The TextSupplier providing the String for this
TextHistogram. The given TextValueSupplier will be observed by
this TextHistogram object.showInReport
- boolean : Flag for showing the report about this TextHistogram.showInTrace
- boolean : Flag for showing the trace output of this TextHistogram.public Reporter createDefaultReporter()
public java.lang.String getLastString()
public java.lang.String getLeastFrequentedString()
public java.lang.String getMostFrequentedString()
public int getNumberOfStringsObserved()
public long getObservationsOfString(java.lang.String obsStr)
obsStr
- java.lang.String: The String of which want to get the number of
observations made for.public java.lang.String[] getStringsObserved()
public void reset()
reset
in class Reportable
public void update()
TextHistogram
object by fetching the actual
value of the TextSupplier
and processing it.
If the actual value is a null
pointer it will not be counted and an
error is given out in the error report.
The TextSupplier
is passed in the constructor of this
TextHistogram
object. This update()
method
complies with the one described in DESMO, see [Page91].public void update(java.lang.String updateStr)
TextHistogram
object with the String value
given as parameter.
If the parameter is a null
pointer it will not be counted and an
error is given out in the error report.
In some cases it might be more convenient to pass the String value this TextHistogram
will be updated with directly
within the update(String updateStr)
method instead of going via
the TextSupplier
.updateStr
- String : The String with which this TextHistogram
will be updated.public void update(java.util.Observable o, java.lang.Object arg)
update(Observable, Object)
method of the Observer
interface. This method will be called
automatically from an Observable
object within its
notifyObservers()
method. null
value) is passed as arg, the actual
value of the TextSupplier will be fetched with the text()
method of the TextSupplier. Otherwise it is expected that the actual
text is passed in the Object arg.
If the the actual value is a null
pointer it will not be counted and an
error is given out in the error report.update
in interface java.util.Observer
o
- java.util.Observable : The Observable calling this method
within its own notifyObservers()
method.arg
- Object : The Object with which this
Statistic Object
is updated. Normally a String
which is added to the statistics or null
when
there is an actual text to be given with the text()
method.