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 Field extends ParseResult implements Variable {
13 static final String TAG = "Field";
14 static final String[] INTERNAL = { };
15 static final Object[][] EXTERNAL = { };
17 static final String CLASSNAME = "classname";
18 static final String FIELD = "FIELD";
19 static final String IS_STATIC = "isStatic";
20 static final String NAME = "name";
21 static final String SIGNATURE = "signature";
29 super(TAG, INTERNAL, EXTERNAL);
31 m_className = m_name = m_signature = null;
35 public String getClassName() { return m_className; }
36 public String getSignature() { return m_signature; }
37 public boolean isStatic() { return m_isStatic; }
40 public String getDescription()
46 if (null != getClassName()) {
47 result += getClassName() + ".";
54 public String getName() { return m_name; }
57 public String getRole() { return FIELD; }
60 public void handleMainAttributes(Attributes attr)
61 throws MissingAttributeException
63 m_className = getRequiredAttr(TAG, attr, CLASSNAME);
65 String isStaticStr = getRequiredAttr(TAG, attr, CLASSNAME);
66 m_isStatic = "true".equals(isStaticStr);
68 m_name = getRequiredAttr(TAG, attr, NAME);
70 m_signature = getRequiredAttr(TAG, attr, SIGNATURE);
74 public void endContents(String uri, String localName, String qName, String chars)
75 throws XmlParseException
80 public void endExternal(String uri, String localName, String qName)
81 throws XmlParseException
87 public void dump(PrintWriter pw, int indent)
89 super.dump(pw, indent);
90 String tab = String.format("%" + (indent + 2) + "s", "");
92 pw.println(tab + CLASSNAME + "=" + m_className);
93 pw.println(tab + IS_STATIC + "=" + (m_isStatic ? "true" : "false"));
94 pw.println(tab + NAME + "=" + m_name);
95 pw.println(tab + SIGNATURE + "=" + m_signature);
99 public boolean equals(Object obj)
104 if (obj instanceof Field) {
105 Field that = (Field)obj;
106 return ( Util.objsAreEqual(this.m_className, that.m_className)
107 && (this.m_isStatic == that.m_isStatic)
108 && Util.objsAreEqual(this.m_name, that.m_name)
109 && Util.objsAreEqual(this.m_signature, that.m_signature) );
115 public int hashCode()
117 return ( (Util.objHashCode(m_className))
118 ^ (Boolean.valueOf(m_isStatic).hashCode())
119 ^ (Util.objHashCode(m_name))
120 ^ (Util.objHashCode(m_signature)) );