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.system;
17  
18  import java.util.ArrayList;
19  import java.util.Iterator;
20  import java.util.LinkedList;
21  import java.util.List;
22  
23  import org.jdiagnose.RemoteResult;
24  import org.jdiagnose.runtime.ResultState;
25  
26  /***
27   * @author jmccrindle
28   */
29  public class DefaultRemoteDiagnostic implements RemoteDiagnostic {
30  
31      private String name;
32      private List remoteResultList = new LinkedList();
33  
34      public DefaultRemoteDiagnostic(String name) {
35          this.name = name;
36      }
37      
38      /* (non-Javadoc)
39       * @see org.jdiagnose.remote.RemoteDiagnostic#getName()
40       */
41      public String getName() {
42          return name;
43      }
44  
45      /* (non-Javadoc)
46       * @see org.jdiagnose.remote.RemoteDiagnostic#getRemoteResults()
47       */
48      public Iterator getRemoteResults() {
49          return new ArrayList(remoteResultList).iterator();
50      }
51  
52      /***
53       * @return
54       */
55      public List getRemoteResultList() {
56          return remoteResultList;
57      }
58  
59      /* (non-Javadoc)
60       * @see org.jdiagnose.remote.Monitorable#isUp()
61       */
62      public boolean isUp() {
63          if(remoteResultList != null && remoteResultList.size() > 0) {
64              RemoteResult result = (RemoteResult) remoteResultList.get(0);
65              return result.getResultInfo().getState() != ResultState.FAILED;
66          } else {
67              return true;
68          }
69      }
70      
71      /* (non-Javadoc)
72       * @see java.lang.Object#toString()
73       */
74      public String toString() {
75          return "{" + name + ", " + remoteResultList.toString() + "}";
76      }
77  
78  }