KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > WildcardAttribute


1 /*
2  * Copyright 2004 The Apache Software Foundation
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  */

17 package org.apache.ws.jaxme;
18
19 import javax.xml.namespace.QName JavaDoc;
20
21 /** <p>Wildcard attributes (as specified by <code>xs:anyAttribute</code>)
22  * are stored in a set, the set elements being instances of
23  * <code>WildcardAttribute</code>.</p>
24  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
25  */

26 public class WildcardAttribute {
27     private final QName JavaDoc name;
28     private final String JavaDoc value;
29
30     /** <p>Creates a new instance of <code>WildcardAttribute</code>
31      * with the given name and value.</p>
32      * @throws NullPointerException Either of the arguments is null.
33      */

34     public WildcardAttribute(QName JavaDoc pName, String JavaDoc pValue) {
35         if (pName == null) {
36             throw new NullPointerException JavaDoc("A wildcard attributes name must not be null.");
37         }
38         if (pValue == null) {
39             throw new NullPointerException JavaDoc("A wildcard attributes value must not be null.");
40         }
41         name = pName;
42         value = pValue;
43     }
44     
45     /** <p>Returns the attributes name.</p>
46      */

47     public QName JavaDoc getName() {
48         return name;
49     }
50
51     /** <p>Returns the attributes value.</p>
52      */

53     public String JavaDoc getValue() {
54         return value;
55     }
56
57     public String JavaDoc toString() {
58         return name + "=" + value;
59     }
60
61     /** <p>Returns <code>getName().hashCode()</code>.</p>
62      */

63     public int hashCode() {
64         return name.hashCode();
65     }
66
67     /** <p>Returns true, if the object <code>pOther</code> is an instance of
68      * <code>WildcardAttribute</code> and <code>pOther.getName().equals(getName())</code>.</p>
69      */

70     public boolean equals(Object JavaDoc pOther) {
71         return pOther != null && pOther instanceof WildcardAttribute &&
72             ((WildcardAttribute) pOther).name.equals(name);
73     }
74 }
75
Popular Tags