001: /*
002: * MCS Media Computer Software Copyright (c) 2005 by MCS
003: * -------------------------------------- Created on 23.04.2005 by w.klaas
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
006: * use this file except in compliance with the License. You may obtain a copy of
007: * the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014: * License for the specific language governing permissions and limitations under
015: * the License.
016: */
017: package de.mcs.jmeasurement;
018:
019: /**
020: * This is the basic interface of an monitor. The monitor will measure the time
021: * between the call of the start() Methode and the call of the stop() methode.
022: * pause() will hold the measurement, resume() will resume it.
023: *
024: * @author w.klaas
025: */
026: public interface Monitor {
027:
028: /**
029: * get the ID of this monitor.
030: *
031: * @return the id of this monitor
032: */
033: String getMonitoId();
034:
035: /**
036: * starting the measurement of this monitor.
037: *
038: * @return boolean <code>true</code> if the monitor could be startet,
039: * otherwise <code>false</code>
040: *
041: */
042: boolean start();
043:
044: /**
045: * pausing the measurement.
046: *
047: * @return boolean <code>true</code> if the monitor could be paused,
048: * otherwise <code>false</code>
049: */
050: boolean pause();
051:
052: /**
053: * resume the measurement.
054: *
055: * @return boolean <code>true</code> if the monitor could be resumed,
056: * otherwise <code>false</code>
057: */
058: boolean resume();
059:
060: /**
061: * increasing the measurement time with msec milliseconds. Works only when
062: * monitor is currently measuring.
063: *
064: * @param msec
065: * time to increase
066: */
067: void increase(long msec);
068:
069: /**
070: * decreasing the measurement time with msec milliseconds. Works only when
071: * monitor is currently measuring.
072: *
073: * @param msec
074: * time to decrease
075: */
076: void decrease(long msec);
077:
078: /**
079: * stopping the measurment.
080: *
081: * @return boolean <code>true</code> if the monitor could be stopped,
082: * otherwise <code>false</code>
083: */
084: boolean stop();
085:
086: /**
087: * resetting the measurement. If this methode is called all information
088: * about this monitor is destroyed.
089: */
090: void reset();
091:
092: /**
093: * @return long getting the measured time.
094: */
095: long getAccrued();
096:
097: /**
098: * @return boolean the monitor is actual running
099: */
100: boolean isRunning();
101:
102: /**
103: * @return boolean the monitor is actual paused
104: */
105: boolean isPaused();
106:
107: /**
108: * @return this monitor has recorded an exception.
109: * @since 0.64
110: */
111: boolean hasException();
112:
113: /**
114: * @return the text of the recorded exception or null.
115: * @since 0.64
116: */
117: String getException();
118:
119: /**
120: * setting a exception. This also stops the monitor, if it's running. The
121: * measuredata will not be accumulated.
122: *
123: * @param text
124: * the text for this exception.
125: * @since 0.64
126: */
127: void setException(String text);
128:
129: /**
130: * setting a exception. This also stops the monitor, if it's running. The
131: * measuredata will not be accumulated.
132: *
133: * @param cause
134: * the exception to store.
135: * @since 0.66
136: */
137: void setException(Throwable cause);
138: }
|