View Javadoc

1   package org.csc.phynixx.watchdog;
2   
3   /*
4    * #%L
5    * phynixx-watchdog
6    * %%
7    * Copyright (C) 2014 csc
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  
24  import java.io.Serializable;
25  
26  
27  public class WatchdogInfo implements Serializable {
28  
29  
30      /**
31       *
32       */
33      private static final long serialVersionUID = -4208724399286983526L;
34  
35      private String info = null;
36  
37      private String[] conditions;
38  
39      public WatchdogInfo(IWatchdog wd) {
40          this.setConditions(wd);
41          this.setInfo(wd);
42      }
43  
44  
45      private void setInfo(IWatchdog wd) {
46  
47          this.info = wd.getWatchdogInfo();
48  
49      }
50  
51      private void setConditions(IWatchdog wd) {
52          this.conditions = wd.getConditionInfos();
53  
54      }
55  
56  
57      public String getWatchdogInfo() {
58          return info;
59      }
60  
61  
62      public String[] getConditions() {
63          return conditions;
64      }
65  
66  
67      public String[] getWatchdogInfos() {
68          String[] conds = this.getConditions();
69          String[] infos = new String[conds.length + 1];
70  
71          infos[0] = this.getWatchdogInfo();
72  
73          for (int i = 0; i < conds.length; i++) {
74              infos[i + 1] = "     " + conds[i];
75          }
76          return infos;
77  
78      }
79  
80      public String toString() {
81          StringBuffer buffer = new StringBuffer();
82          buffer.append("Watchdog - executing Thread=" + this.getWatchdogInfo()).append("\n");
83          String[] conds = this.getConditions();
84          for (int i = 0; i < conds.length; i++) {
85              buffer.append("     ").append(conds[i]).append("\n");
86          }
87          return buffer.toString();
88      }
89  
90  
91  }