Add computation of deltas (differences between Analysis runs).
[cfb.git] / prod / net / jaekl / cfb / xml / LocalVariable.java
1 package net.jaekl.cfb.xml;
2
3 import java.io.PrintWriter;
4
5 import org.xml.sax.Attributes;
6
7 import net.jaekl.cfb.util.Util;
8 import net.jaekl.qd.xml.MissingAttributeException;
9 import net.jaekl.qd.xml.ParseResult;
10 import net.jaekl.qd.xml.XmlParseException;
11
12 public class LocalVariable extends ParseResult {
13
14         static final String TAG = "LocalVariable";
15         static final String[] INTERNAL = { };
16         static final Object[][] EXTERNAL = { };
17
18         static final String NAME = "name";
19         static final String ROLE = "role";
20         
21         String m_name;
22         String m_role;
23         
24         public LocalVariable() {
25                 super(TAG, INTERNAL, EXTERNAL);
26                 
27                 m_name = m_role = null;
28         }
29         
30         public String getName() { return m_name; }
31         public String getRole() { return m_role; }
32         
33         @Override
34         public void handleMainAttributes(Attributes attr)
35                 throws MissingAttributeException
36         {
37                 m_name = getRequiredAttr(TAG, attr, NAME);
38                 m_role = getRequiredAttr(TAG, attr, ROLE);
39         }
40         
41         @Override
42         public void endContents(String uri, String localName, String qName, String chars) 
43                 throws XmlParseException 
44         {
45         }
46
47         @Override
48         public void endExternal(String uri, String localName, String qName)
49                 throws XmlParseException 
50         {
51                 // no-op
52         }
53         
54         @Override
55         public void dump(PrintWriter pw, int indent) 
56         {
57                 super.dump(pw, indent);
58                 String tab = String.format("%" + (indent + 2) + "s", "");
59                 
60                 pw.println(tab + NAME + "=" + m_name);
61                 pw.println(tab + ROLE + "=" + m_role);
62         }
63         
64         @Override
65         public boolean equals(Object obj) 
66         {
67                 if (null == obj) {
68                         return false;
69                 }
70                 if (obj instanceof LocalVariable) {
71                         LocalVariable that = (LocalVariable)obj;
72                         return (   Util.objsAreEqual(this.m_name, that.m_name) 
73                                     && Util.objsAreEqual(this.m_role, that.m_role) );
74                 }
75                 return false;
76         }
77         
78         @Override
79         public int hashCode()
80         {
81                 return ( (1 + Util.objHashCode(m_name)) * (1 + Util.objHashCode(m_role)) );
82         }
83 }