1 package net.jaekl.cfb.xml;
3 import java.io.PrintWriter;
5 import org.xml.sax.Attributes;
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;
12 public class LocalVariable extends ParseResult implements Variable {
14 static final String TAG = "LocalVariable";
15 static final String[] INTERNAL = { };
16 static final Object[][] EXTERNAL = { };
18 static final String NAME = "name";
19 static final String ROLE = "role";
25 public LocalVariable() {
26 super(TAG, INTERNAL, EXTERNAL);
29 m_name = m_role = null;
32 public LocalVariable(Long id, String name, String role) {
33 super(TAG, INTERNAL, EXTERNAL);
40 public Long getId() { return m_id; }
43 public String getDescription()
45 String result = getName();
46 if (null != getRole()) {
47 result += " (" + getRole() + ")";
53 public String getName() { return m_name; }
56 public String getRole() { return m_role; }
59 public void handleMainAttributes(Attributes attr)
60 throws MissingAttributeException
62 m_name = getRequiredAttr(TAG, attr, NAME);
63 m_role = getRequiredAttr(TAG, attr, ROLE);
67 public void endContents(String uri, String localName, String qName, String chars)
68 throws XmlParseException
73 public void endExternal(String uri, String localName, String qName)
74 throws XmlParseException
80 public void dump(PrintWriter pw, int indent)
82 super.dump(pw, indent);
83 String tab = String.format("%" + (indent + 2) + "s", "");
85 pw.println(tab + NAME + "=" + m_name);
86 pw.println(tab + ROLE + "=" + m_role);
90 public boolean equals(Object obj)
95 if (obj instanceof LocalVariable) {
96 LocalVariable that = (LocalVariable)obj;
97 return ( Util.objsAreEqual(this.m_name, that.m_name)
98 && Util.objsAreEqual(this.m_role, that.m_role) );
104 public int hashCode()
106 return ( (Util.objHashCode(m_name)) ^ (Util.objHashCode(m_role)) );