KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > logging > diagnostics > Diagnostics


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.server.logging.diagnostics;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 /**
28  * Diagnostics class contains list of causes, diagnostic checks and the uri
29  * to search for the latest and greatest diagnostics information based on
30  * a message id.
31  *
32  * @author Hemanth Puttaswamy
33  */

34 public class Diagnostics {
35     String JavaDoc messageId;
36     private ArrayList JavaDoc causes;
37     private ArrayList JavaDoc checks;
38     private String JavaDoc uri;
39
40     public Diagnostics( String JavaDoc messageId ) {
41         this.messageId = messageId;
42         causes = new ArrayList JavaDoc();
43         checks = new ArrayList JavaDoc();
44     }
45
46     public void addCause( String JavaDoc cause ) {
47         causes.add( cause );
48     }
49
50     public void addCheck( String JavaDoc check ) {
51         checks.add( check );
52     }
53
54     public void setPossibleCauses( ArrayList JavaDoc list ) {
55         causes = list;
56     }
57
58     public void setDiagnosticChecks( ArrayList JavaDoc list ) {
59         checks = list;
60     }
61  
62     public void setURI( String JavaDoc uri ) {
63         this.uri = uri;
64     }
65
66     public String JavaDoc getMessageId( ) {
67         return messageId;
68     }
69
70     public ArrayList JavaDoc getPossibleCauses( ) {
71         return causes;
72     }
73
74     public ArrayList JavaDoc getDiagnosticChecks( ) {
75         return checks;
76     }
77
78     public String JavaDoc getURI( ) {
79         return uri;
80     }
81
82     /**
83      * A Simple Debug print method to print the contents of this class.
84      */

85     public void print( ) {
86         System.out.println( "---------------------------------" );
87         System.out.println( "Diagnostics for MessageId = " + messageId );
88         Iterator JavaDoc iterator = null;
89         if( causes != null ) {
90             iterator = causes.iterator( );
91             System.out.println( "Causes --> " );
92             while( iterator.hasNext( ) ) {
93                 System.out.println( iterator.next( ) );
94             }
95         }
96         if( checks != null ) {
97             iterator = checks.iterator( );
98             System.out.println( "Checks --> " );
99             while( iterator.hasNext( ) ) {
100                 System.out.println( iterator.next( ) );
101             }
102         }
103         System.out.println( "URI = " + uri );
104         System.out.println( "---------------------------------" );
105     }
106 }
107
108
Popular Tags