KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > wsdl > impl > NamedExtension


1 package org.jbpm.bpel.wsdl.impl;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 /**
6  * Represents extensibility elements having a qualified name.
7  * @author Alejandro Guízar
8  * @version $Revision: 1.3 $ $Date: 2005/05/31 00:49:53 $
9  */

10 public class NamedExtension extends AbstractExtension {
11   
12   private QName JavaDoc name;
13   
14   private static final long serialVersionUID = 1L;
15
16   /**
17    * Gets the name of this extension.
18    * @return the name in place
19    */

20   public QName JavaDoc getQName() {
21     return name;
22   }
23
24   /**
25    * Sets the name of this extension.
26    * @param name the new name
27    */

28   public void setQName(QName JavaDoc name) {
29     this.name = name;
30   }
31   
32   /**
33    * Tests this named extension for equality with another object. Two named
34    * extensions are considered equal if the element type and name are equal.
35    * This method uses {@link QName#equals(Object)} to check equality of the element
36    * type and name.
37    * @param obj the object to test for equality with this named extension.
38    * If it is not a {@link NamedExtension} or is <code>null</code>, then
39    * this method returns <code>false</code>
40    * @return <code>true</code> if the given object is equal to this named
41    * extension; <code>false</code> otherwise
42    */

43   public boolean equals(Object JavaDoc obj) {
44     boolean equals;
45     if (obj instanceof NamedExtension) {
46       NamedExtension extension = (NamedExtension) obj;
47       equals = getQName().equals(extension.getQName()) && getElementType().equals(extension.getElementType());
48     }
49     else {
50       equals = false;
51     }
52     return equals;
53   }
54   
55   /**
56    * Returns a hash code for this named extension. The hash code is calculated
57    * using both the element type and the name of this extension.
58    * @return a hash code for this named extension
59    */

60   public int hashCode() {
61     return getElementType().hashCode() ^ getQName().hashCode();
62   }
63   
64   public String JavaDoc toString() {
65     QName JavaDoc elementType = getElementType();
66     return "<" + elementType.getPrefix() + ":" + elementType.getLocalPart()
67         + " name='" + getQName() + "'/>";
68   }
69 }
70
Popular Tags