View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.jdiagnose.remote;
17  
18  import org.jdiagnose.DefaultDiagnosticMessage;
19  import org.jdiagnose.DiagnosticMessage;
20  import org.jdiagnose.ResultInfo;
21  import org.jdiagnose.runtime.ResultState;
22  
23  /***
24   * @author jmccrindle
25   */
26  public class DefaultResultInfo implements ResultInfo {
27  
28      private String name;
29      private ResultState state;
30      private long duration;
31      private DiagnosticMessage message;
32      private long startTime;
33      private long finishTime;
34      
35      public DefaultResultInfo() {
36          
37      }
38      
39      /***
40       * Copy constructor
41       * 
42       * @param resultInfo the resultInfo to copy. should not be null
43       */
44      public DefaultResultInfo(ResultInfo resultInfo) {
45          this.name = resultInfo.getName();
46          this.state = resultInfo.getState();
47          this.duration = resultInfo.getDuration();
48          if(message != null) {
49              this.message = new DefaultDiagnosticMessage(resultInfo.getMessage());
50          }
51          this.startTime = resultInfo.getStartTime();
52          this.finishTime = resultInfo.getFinishTime();
53      }
54  
55      /***
56       * @param name
57       * @param state
58       * @param duration
59       * @param exception
60       * @param startTime
61       * @param finishTime
62       */
63      public DefaultResultInfo(String name, ResultState state, long duration,
64              DiagnosticMessage message, long startTime, long finishTime) {
65          super();
66          this.name = name;
67          this.state = state;
68          this.duration = duration;
69          this.message = message;
70          this.startTime = startTime;
71          this.finishTime = finishTime;
72      }
73  
74      /* (non-Javadoc)
75       * @see org.jdiagnose.runtime.ResultInfo#getName()
76       */
77      public String getName() {
78          return name;
79      }
80  
81      /* (non-Javadoc)
82       * @see org.jdiagnose.runtime.ResultInfo#getState()
83       */
84      public ResultState getState() {
85          return state;
86      }
87  
88      /* (non-Javadoc)
89       * @see org.jdiagnose.runtime.ResultInfo#getDuration()
90       */
91      public long getDuration() {
92          return duration;
93      }
94  
95      /* (non-Javadoc)
96       * @see org.jdiagnose.runtime.ResultInfo#getStartTime()
97       */
98      public long getStartTime() {
99          return startTime;
100     }
101 
102     /* (non-Javadoc)
103      * @see org.jdiagnose.runtime.ResultInfo#getFinishTime()
104      */
105     public long getFinishTime() {
106         return finishTime;
107     }
108     
109     /* (non-Javadoc)
110      * @see java.lang.Object#toString()
111      */
112     public String toString() {
113         return "{" + name + ", " + state + ", " + duration + ", " + message + ", " + startTime + ", " + finishTime + "}";
114     }
115 
116     /***
117      * @param duration The duration to set.
118      */
119     public void setDuration(long duration) {
120         this.duration = duration;
121     }
122     /***
123      * @param finishTime The finishTime to set.
124      */
125     public void setFinishTime(long finishTime) {
126         this.finishTime = finishTime;
127     }
128     /***
129      * @param name The name to set.
130      */
131     public void setName(String name) {
132         this.name = name;
133     }
134     /***
135      * @param startTime The startTime to set.
136      */
137     public void setStartTime(long startTime) {
138         this.startTime = startTime;
139     }
140     /***
141      * @param state The state to set.
142      */
143     public void setState(ResultState state) {
144         this.state = state;
145     }
146     public DiagnosticMessage getMessage() {
147         return message;
148     }
149     public void setMessage(DiagnosticMessage message) {
150         this.message = message;
151     }
152 }