View Javadoc
1   /*
2    * Copyright 2007 Edward Kuns
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   * $Id: Attribute.java 0000 2007-01-11 00:00:00Z ekuns $
17   */
18  package org.castor.xmlctf.xmldiff.xml.nodes;
19  
20  
21  /**
22   * A class representing an Attribute XML node.
23   *
24   * @author <a href="mailto:edward.kuns@aspect.com">Edward Kuns</a>
25   * @version $Revision: 0000 $ $Date: 2007-01-11 00:00:00 -0600 (Thu, 11 Jan 2007) $
26   * @since Castor 1.1
27   */
28  public class Attribute extends XMLNode {
29  
30      /** Serial Version UID. */
31      private static final long serialVersionUID = 2499101510478363466L;
32      /** Attribute value. */
33      private final String      _value;
34  
35      /**
36       * Creates a new Attribute.
37       *
38       * @param namespace the namespace URI for this node. (May be null.)
39       * @param localName the localname of this node. (Cannot be null.)
40       * @param value the String value of this attribute. (Cannot be null.)
41       */
42      public Attribute(String namespace, String localName, String value) {
43          super(namespace, localName, XMLNode.ATTRIBUTE);
44          if (localName == null || localName.length() == 0) {
45              throw new IllegalArgumentException("An Attribute localname must be non-null "
46                                                 + "and must have a non-zero length");
47          }
48          this._value = value;
49      } // -- Attribute
50  
51      /**
52       * Returns the string value of this attribute.
53       * @return The string value of this attribute.
54       */
55      public String getStringValue() {
56          return _value;
57      }
58  
59  }