|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javasimon.AbstractSimon
abstract class AbstractSimon
AbstractSimon implements basic enable/disable and hierarchy functionality. All Simon implementations extend this class.
| Field Summary | |
|---|---|
private AttributesSupport |
attributesSupport
|
protected boolean |
enabled
Simon's effective state. |
protected long |
firstUsage
Timestamp of the first usage. |
private List<Simon> |
children
|
protected long |
lastUsage
Timestamp of the last usage. |
protected Manager |
manager
Owning manager of this Simon. |
private String |
name
|
private String |
note
|
private Simon |
parent
|
private long |
resetTimestamp
|
private SimonState |
state
|
| Constructor Summary | |
|---|---|
AbstractSimon(String name,
Manager manager)
Constructor of the abstract Simon is used internally by subclasses. |
|
| Method Summary | ||
|---|---|---|
(package private) void |
addChild(AbstractSimon simon)
Adds child to this Simon with setting the parent of the child. |
|
Object |
getAttribute(String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists. |
|
|
getAttribute(String name,
Class<T> clazz)
Returns the value of the named attribute typed to the specified class, or null if no attribute of
the given name exists. |
|
Iterator<String> |
getAttributeNames()
Returns an Iterator containing the names of the attributes available to this Simon. |
|
Map<String,Object> |
getCopyAsSortedMap()
Returns copy of attributes as a sorted map, this can be used further for operations like toString. |
|
long |
getFirstUsage()
Returns ms timestamp of the first usage of this Simon. |
|
List<Simon> |
getChildren()
Returns list of children - direct sub-simons. |
|
long |
getLastReset()
Returns ms timestamp of the last recent usage of the Simon.reset() method on the Simon. |
|
long |
getLastUsage()
Returns ms timestamp of the last usage of this Simon. |
|
String |
getName()
Returns Simon name. |
|
String |
getNote()
Returns note for the Simon. |
|
Simon |
getParent()
Returns parent Simon. |
|
SimonState |
getState()
Returns state of the Simon that can be enabled, disabled or ihnerited. |
|
private boolean |
isAnonymousOrRootSimon()
|
|
boolean |
isEnabled()
Returns true, if the Simon is enabled or if the enabled state is inherited. |
|
void |
removeAttribute(String name)
Removes an attribute from this Simon. |
|
(package private) void |
replaceChild(Simon simon,
AbstractSimon newSimon)
Replaces one of the children for a new one (unknown to concrete). |
|
protected void |
resetCommon()
Saves the timestamp when the Simon was reset and calls Callback.onSimonReset(Simon). |
|
(package private) void |
sampleCommon(Sample sample)
|
|
void |
setAttribute(String name,
Object value)
Stores an attribute in this Simon. |
|
void |
setNote(String note)
Sets note for the Simon. |
|
(package private) void |
setParent(Simon parent)
Sets parent for this Simon - used only internally. |
|
void |
setState(SimonState state,
boolean overrule)
Sets the state of the Simon. |
|
private boolean |
shouldBeEffectivlyEnabled()
|
|
String |
toString()
Returns name and state of the Simon as a human readable string. |
|
private void |
updateAndPropagateEffectiveState(boolean enabled,
boolean overrule)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.javasimon.Simon |
|---|
reset, sample, sampleAndReset |
| Field Detail |
|---|
protected Manager manager
protected volatile boolean enabled
protected long firstUsage
protected long lastUsage
private final String name
private SimonState state
private Simon parent
private final List<Simon> children
private String note
private long resetTimestamp
private AttributesSupport attributesSupport
| Constructor Detail |
|---|
AbstractSimon(String name,
Manager manager)
name - Simon's namemanager - owning Manager| Method Detail |
|---|
public final Simon getParent()
Simon
getParent in interface Simonpublic final List<Simon> getChildren()
Simon
getChildren in interface Simonfinal void setParent(Simon parent)
parent - Simon's parentfinal void addChild(AbstractSimon simon)
simon - future child of this Simonpublic final String getName()
Simonnull for anonymous Simons.
getName in interface Simon
public final void setState(SimonState state,
boolean overrule)
setState in interface Simonstate - a new state.overrule - specifies whether this change is forced to the whole subtree.
IllegalArgumentException - if state is null.private boolean isAnonymousOrRootSimon()
private boolean shouldBeEffectivlyEnabled()
private void updateAndPropagateEffectiveState(boolean enabled,
boolean overrule)
public boolean isEnabled()
Simon
isEnabled in interface Simonprotected void resetCommon()
Callback.onSimonReset(Simon).
Called only from synchronized method Simon.reset().
public long getLastReset()
SimonSimon.reset() method on the Simon.
Returns 0 if reset was not called yet. This timestamp is useful for rate measuring
when reset is called on a regular basis - likely via Simon.sampleAndReset(). While
client code could store the timestamp too it is not necessary with this method.
getLastReset in interface Simonpublic final SimonState getState()
Simon
getState in interface Simonpublic String getNote()
Simon
getNote in interface Simonpublic void setNote(String note)
Simon
setNote in interface Simonnote - note for the Simon.public long getFirstUsage()
Simon
getFirstUsage in interface Simonpublic long getLastUsage()
Simon
getLastUsage in interface Simon
void replaceChild(Simon simon,
AbstractSimon newSimon)
simon - original Simon (unknown)newSimon - new Simon
public void setAttribute(String name,
Object value)
setAttribute in interface HasAttributesname - a String specifying the name of the attributevalue - the Object to be storedpublic Object getAttribute(String name)
getAttribute in interface HasAttributesname - a String specifying the name of the attribute
public <T> T getAttribute(String name,
Class<T> clazz)
null if no attribute of
the given name exists.
getAttribute in interface HasAttributesname - a String specifying the name of the attribute
null if the attribute does not existpublic void removeAttribute(String name)
removeAttribute in interface HasAttributesname - a String specifying the name of the attribute to removepublic Iterator<String> getAttributeNames()
getAttributeNames in interface HasAttributespublic Map<String,Object> getCopyAsSortedMap()
toString.
getCopyAsSortedMap in interface HasAttributesvoid sampleCommon(Sample sample)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||