KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > ActiveAssistanceManager


1 /*
2  * ActiveAssistant.java
3  *
4  * Created on December 25, 2003, 11:39 AM
5  */

6
7 package com.sun.enterprise.config.backup;
8 import com.sun.enterprise.config.backup.status.Status;
9 import com.sun.enterprise.config.backup.utils.FactoryHelper;
10
11
12 /**
13  * Actively adds assistance information into the status
14  *
15  * @author sridatta
16  */

17 public class ActiveAssistanceManager {
18     
19     /** Creates a new instance of ActiveAssistant */
20     public ActiveAssistanceManager() {
21     }
22     
23     public void assist(Status s) {
24         //get status
25
if(s == null) {
26             //nothing to assist
27
return;
28         }
29         
30         if(s.isSuccess()) {
31             addDidYouKnow(s);
32         } else {
33             addDiagnosabilityInfo(s);
34         }
35     }
36     
37     private void addDidYouKnow(Status s) {
38         s.setExtraInfo(getDidYouKnow(s));
39     }
40     
41     private String JavaDoc getDidYouKnow(Status s) {
42         String JavaDoc text = getDidYouKnowText(s);
43         if (text == null || "".equals(text)) return null;
44         return "Did You Know? \n" + text;
45     }
46     
47     private void addDiagnosabilityInfo(Status s) {
48         if(s == null) return;
49         
50         String JavaDoc info = getDiagInfo(s);
51         if (info == null || "".equals(info)) return;
52
53         s.setExtraInfo(info);
54     }
55     private String JavaDoc getDiagInfo(Status s) {
56         String JavaDoc info = getDiagText(s);
57         if(info == null) return null;
58         return "Hints: \n" + info;
59     }
60     
61     private String JavaDoc getDidYouKnowText(Status status) {
62         return FactoryHelper.getAssistance().getDidYouKnow(status);
63     }
64      
65     private String JavaDoc getDiagText(Status s) {
66         return FactoryHelper.getAssistance().getDiagnosabilityInfo(s);
67     }
68 }
69
Popular Tags