01: // AttributeDescription.java
02: // $Id: AttributeDescription.java,v 1.3 2000/08/16 21:37:54 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05: package org.w3c.tools.resources.serialization;
06:
07: import org.w3c.tools.resources.Attribute;
08:
09: /**
10: * @version $Revision: 1.3 $
11: * @author Benoît Mahé (bmahe@w3.org)
12: */
13: public class AttributeDescription {
14:
15: Attribute attribute = null;
16: String classname = null;
17: String name = null;
18: Object value = null;
19:
20: /**
21: * Get the attribute class name
22: * @return a String
23: */
24: public String getClassName() {
25: return classname;
26: }
27:
28: /**
29: * Get the attribute name.
30: * @return a String
31: */
32: public String getName() {
33: return name;
34: }
35:
36: /**
37: * Get the attribute value
38: * @return an Object
39: */
40: public Object getValue() {
41: return value;
42: }
43:
44: /**
45: * Set the attribute value.
46: * @param the new value
47: */
48: public void setValue(Object value) {
49: this .value = value;
50: }
51:
52: /**
53: * Get the attribute itself.
54: * @return an Attribute instance
55: * @see org.w3c.tools.resources.Attribute
56: */
57: public Attribute getAttribute() {
58: return attribute;
59: }
60:
61: /**
62: * Constructor.
63: * @param classname The attribute class name
64: * @param name the attribute name
65: * @param value the attribute value
66: */
67: private AttributeDescription(String classname, String name,
68: Object value) {
69: this .classname = classname;
70: this .name = name;
71: this .value = value;
72: try {
73: Class cls = Class.forName(classname);
74: this .attribute = (Attribute) cls.newInstance();
75: } catch (Exception ex) {
76: this .attribute = null;
77: }
78: }
79:
80: /**
81: * Constructor.
82: * @param attribute the attribute itself
83: * @param value the attribute value.
84: */
85: public AttributeDescription(Attribute attribute, Object value) {
86: this.name = attribute.getName();
87: this.value = value;
88: this.classname = attribute.getClass().getName();
89: this.attribute = attribute;
90: }
91:
92: }
|