KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > log > FrameworkLogEntry


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.framework.log;
13
14 /**
15  * A framework log entry used to log information to a FrameworkLog
16  * @since 3.1
17  */

18 public class FrameworkLogEntry {
19     /**
20      * Severity constant (value 0) indicating this log entry represents the nominal case.
21      * @see #getSeverity()
22      * @since 3.2
23      */

24     public static final int OK = 0;
25
26     /**
27      * Severity constant (bit mask, value 1) indicating this log entry is informational only.
28      * @see #getSeverity()
29      * @since 3.2
30      */

31     public static final int INFO = 0x01;
32
33     /**
34      * Severity constant (bit mask, value 2) indicating this log entry represents a warning.
35      * @see #getSeverity()
36      * @since 3.2
37      */

38     public static final int WARNING = 0x02;
39
40     /**
41      * Severity constant (bit mask, value 4) indicating this log entry represents an error.
42      * @see #getSeverity()
43      * @since 3.2
44      */

45     public static final int ERROR = 0x04;
46
47     /**
48      * Status type severity (bit mask, value 8) indicating this log entry represents a cancelation.
49      * @see #getSeverity()
50      * @since 3.2
51      */

52     public static final int CANCEL = 0x08;
53
54
55     // It would be nice to rename some of these fields but we cannot change the getter method
56
// names without breaking clients. Changing only the field names would be confusing.
57
//TODO "entry" has another meaning here - title, summary, tag are better names
58
private String JavaDoc entry;
59     private String JavaDoc message;
60     //TODO get rid of this
61
private int stackCode;
62     //TODO: use "reason" or "cause" instead
63
private Throwable JavaDoc throwable;
64     private FrameworkLogEntry[] children;
65     private int severity = 0;
66     private int bundleCode = 0;
67
68     /**
69      * Constructs a new FrameworkLogEntry
70      * @param entry the entry
71      * @param message the message
72      * @param stackCode the stack code
73      * @param throwable the throwable
74      * @param children the children
75      */

76     public FrameworkLogEntry(String JavaDoc entry, String JavaDoc message, int stackCode, Throwable JavaDoc throwable, FrameworkLogEntry[] children) {
77         this.entry = entry;
78         this.message = message;
79         this.stackCode = stackCode;
80         this.throwable = throwable;
81         this.children = children;
82     }
83
84     /**
85      * Constructs a new FrameworkLogEntry
86      * @param entry the entry
87      * @param severity the severity
88      * @param bundleCode the bundle code
89      * @param message the message
90      * @param stackCode the stack code
91      * @param throwable the throwable
92      * @param children the children
93      * @since 3.2
94      */

95     public FrameworkLogEntry(String JavaDoc entry, int severity, int bundleCode, String JavaDoc message, int stackCode, Throwable JavaDoc throwable, FrameworkLogEntry[] children) {
96         this.entry = entry;
97         this.message = message;
98         this.stackCode = stackCode;
99         this.throwable = throwable;
100         this.children = children;
101         this.severity = severity;
102         this.bundleCode = bundleCode;
103     }
104
105     /**
106      *
107      * @return Returns the children.
108      */

109     public FrameworkLogEntry[] getChildren() {
110         return children;
111     }
112
113     /**
114      * @return Returns the entry.
115      */

116     public String JavaDoc getEntry() {
117         return entry;
118     }
119
120     /**
121      * @return Returns the message.
122      */

123     public String JavaDoc getMessage() {
124         return message;
125     }
126
127     /**
128      * @return Returns the stackCode.
129      */

130     public int getStackCode() {
131         return stackCode;
132     }
133
134     /**
135      * @return Returns the throwable.
136      */

137     public Throwable JavaDoc getThrowable() {
138         return throwable;
139     }
140
141     /**
142      * Returns the severity. The severities are as follows (in descending order):
143      * <ul>
144      * <li><code>CANCEL</code> - cancelation occurred</li>
145      * <li><code>ERROR</code> - a serious error (most severe)</li>
146      * <li><code>WARNING</code> - a warning (less severe)</li>
147      * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
148      * <li><code>OK</code> - everything is just fine</li>
149      * </ul>
150      * <p>
151      * The severity of a multi-entry log is defined to be the maximum
152      * severity of any of its children, or <code>OK</code> if it has
153      * no children.
154      * </p>
155      *
156      * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
157      * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
158      * @since 3.2
159      */

160     public int getSeverity() {
161         return severity;
162     }
163
164     /**
165      * Returns the bundle-specific code describing the outcome.
166      *
167      * @return bundle-specific code
168      * @since 3.2
169      */

170     public int getBundleCode() {
171         return bundleCode;
172     }
173
174 }
175
Popular Tags