KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > node > integrity > IntegrityRecord


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.node.integrity;
18
19 import java.util.List JavaDoc;
20
21 /**
22  * Represents an integrity violation
23  *
24  * @author Derek Hulley
25  */

26 public class IntegrityRecord
27 {
28     private String JavaDoc msg;
29     private List JavaDoc<StackTraceElement JavaDoc[]> traces;
30     
31     /**
32      * @param msg the violation message
33      */

34     public IntegrityRecord(String JavaDoc msg)
35     {
36         this.msg = msg;
37         this.traces = null;
38     }
39     
40     /**
41      * Add a stack trace to the list of traces associated with this failure
42      *
43      * @param trace a stack trace
44      */

45     public void setTraces(List JavaDoc<StackTraceElement JavaDoc[]> traces)
46     {
47         this.traces = traces;
48     }
49     
50     public String JavaDoc getMessage()
51     {
52         return msg;
53     }
54     
55     /**
56      * Dumps the integrity message and, if present, the stack trace
57      */

58     public String JavaDoc toString()
59     {
60         StringBuilder JavaDoc sb = new StringBuilder JavaDoc(msg.length() * 2);
61         if (traces == null)
62         {
63             sb.append(msg);
64         }
65         else
66         {
67             sb.append(msg);
68             for (StackTraceElement JavaDoc[] trace : traces)
69             {
70                 sb.append("\n Trace of possible cause:");
71                 for (int i = 0; i < trace.length; i++)
72                 {
73                     sb.append("\n ").append(trace[i]);
74                 }
75             }
76         }
77         return sb.toString();
78     }
79 }
80
Popular Tags