KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > xml > Attribute


1 package org.sapia.util.xml;
2
3
4 // Import of Sun's JDK classes
5
// ---------------------------
6
import java.io.Serializable JavaDoc;
7
8
9 /**
10  * The <CODE>Attribute</CODE> class is a simple object representation of an XML attribute.
11  * It contains three attributes: a name, a value and a namespace prefix.
12  *
13  * @author Jean-Cedric Desrochers
14  * <dl>
15  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class Attribute implements Serializable JavaDoc {
21   /////////////////////////////////////////////////////////////////////////////////////////
22
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
23
/////////////////////////////////////////////////////////////////////////////////////////
24

25   /** The namespace prefix of this attribute. */
26   private String JavaDoc _theNamespacePrefix;
27
28   /** The name of this attribute. */
29   private String JavaDoc _theName;
30
31   /** The value of this attribute. */
32   private String JavaDoc _theValue;
33
34   /////////////////////////////////////////////////////////////////////////////////////////
35
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
36
/////////////////////////////////////////////////////////////////////////////////////////
37

38   /**
39    * Creates a new Attribute instance.
40    */

41   public Attribute() {
42   }
43
44   /**
45    * Creates a new Attribute instance.
46    */

47   public Attribute(String JavaDoc aName, String JavaDoc aValue) {
48     _theName = aName;
49     _theValue = aValue;
50   }
51
52   /**
53    * Creates a new Attribute instance.
54    */

55   public Attribute(String JavaDoc aNamespacePrefix, String JavaDoc aName, String JavaDoc aValue) {
56     _theNamespacePrefix = aNamespacePrefix;
57     _theName = aName;
58     _theValue = aValue;
59   }
60
61   /////////////////////////////////////////////////////////////////////////////////////////
62
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
63
/////////////////////////////////////////////////////////////////////////////////////////
64

65   /**
66    * Returns the namespace prefix of this attribute.
67    *
68    * @return The namespace prefix of this attribute.
69    */

70   public String JavaDoc getNamespacePrefix() {
71     return _theNamespacePrefix;
72   }
73
74   /**
75    * Returns the name of this attribute.
76    *
77    * @return The name of this attribute.
78    */

79   public String JavaDoc getName() {
80     return _theName;
81   }
82
83   /**
84    * Returns the value of this attribute.
85    *
86    * @return The value of this attribute.
87    */

88   public String JavaDoc getValue() {
89     return _theValue;
90   }
91
92   /////////////////////////////////////////////////////////////////////////////////////////
93
/////////////////////////////////// MUTATOR METHODS ///////////////////////////////////
94
/////////////////////////////////////////////////////////////////////////////////////////
95

96   /**
97    * Changes the namespace prefix of this attribute.
98    *
99    * @param aNamespacePrefix The new namespace prefix.
100    */

101   public void setNamespacePrefix(String JavaDoc aNamespacePrefix) {
102     _theNamespacePrefix = aNamespacePrefix;
103   }
104
105   /**
106    * Changes the name of this attribute.
107    *
108    * @param aName The new name.
109    */

110   public void setName(String JavaDoc aName) {
111     _theName = aName;
112   }
113
114   /**
115    * Changes the value of this attribute.
116    *
117    * @param aValue The new value.
118    */

119   public void setValue(String JavaDoc aValue) {
120     _theValue = aValue;
121   }
122
123   /////////////////////////////////////////////////////////////////////////////////////////
124
////////////////////////////////// OVERRIDEN METHODS //////////////////////////////////
125
/////////////////////////////////////////////////////////////////////////////////////////
126

127   /**
128    * Returns a string representation of this attribute.
129    *
130    * @return A string representation of this attribute.
131    */

132   public String JavaDoc toString() {
133     StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc(super.toString());
134     aBuffer.append("[namespacePrefix=").append(_theNamespacePrefix)
135            .append(" name=").append(_theName).append(" value=").append(_theValue)
136            .append("]");
137
138     return aBuffer.toString();
139   }
140 }
141
Popular Tags