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