Partial implementation of XML parse for FindBugs output
[cfb.git] / prod / net / jaekl / qd / xml / MissingInfoException.java
1 // Copyright (C) 2004, 2014 Christian Jaekl
2
3 package net.jaekl.qd.xml;
4
5 import java.util.ArrayList;
6
7 public class MissingInfoException extends XmlParseException
8 {
9         private static final long serialVersionUID = 1L;
10
11         String m_tagName;
12         ArrayList<String> m_missingAttributes;
13         ArrayList<String> m_missingChildTags;
14
15         public MissingInfoException(String tagName) {
16                 super();
17                 m_tagName = tagName;
18                 m_missingAttributes = new ArrayList<String>();
19                 m_missingChildTags = new ArrayList<String>();
20         }
21
22         public void addMissingAttribute(String name) {
23                 m_missingAttributes.add(name);
24         }
25
26         public void addMissingChild(String name) {
27                 m_missingChildTags.add(name);
28         }
29
30         public String getTagName() { return m_tagName; }
31         
32         @Override
33         public String getMessage() {
34                 StringBuilder sb = new StringBuilder();
35                 
36                 sb.append("Tag:  \"" + getTagName() + "\"");
37                 
38                 for (String attr : m_missingAttributes) {
39                         sb.append("\n  Attribute:  \"" + attr + "\"");
40                 }
41                 
42                 for (String child : m_missingChildTags) {
43                         sb.append("\n  Child tag:  \"" + child + "\"");
44                 }
45                 return sb.toString();
46         }
47 }