1 /**
2  *  ServingXML
3  *
4  *  Copyright (C) 2006  Daniel Parker
5  *    daniel.parker@servingxml.com
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  **/
20 
21 package com.servingxml.util;
22 
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.ArrayList;
26 
27 /**
28  *
29  *
30  * @author Daniel A. Parker (daniel.parker@servingxml.com)
31  */
32 
33 public class ServingXmlFaultDetail {
34 
35   private final List<Entry> detail;
36 
ServingXmlFaultDetail()37   public ServingXmlFaultDetail() {
38      this.detail = new ArrayList<Entry>();
39   }
40 
addEntry(Name name, String message)41   public void addEntry(Name name, String message) {
42     detail.add(new Entry(name,message));
43   }
44 
size()45   public int size() {
46     return detail.size();
47   }
48 
entries()49   public Iterator<Entry> entries() {
50     return detail.iterator();
51   }
52 
toString()53   public String toString() {
54     Iterator iter = entries();
55     StringBuilder buf = new StringBuilder();
56     String nl = System.getProperty("line.separator");
57     while (iter.hasNext()) {
58       Entry entry = (Entry)iter.next();
59       buf.append(entry.getMessage()+nl);
60     }
61     return buf.toString();
62   }
63 
64   public static class Entry {
65 
66     private final Name name;
67     private final String message;
68 
Entry(Name name, String message)69     public Entry(Name name, String message) {
70       this.name = name;
71       this.message = message;
72     }
73 
getMessage()74     public String getMessage() {
75       return message;
76     }
77 
getName()78     public Name getName() {
79       return name;
80     }
81   }
82 }
83 
84