KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > servlets > webdav > AttributeName


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.servlets.webdav;
30
31 /**
32  * Represents an attribute name.
33  */

34 public class AttributeName {
35   private String JavaDoc prefix;
36   private String JavaDoc namespace;
37   private String JavaDoc local;
38   private String JavaDoc name;
39
40   /**
41    * Creates a new attribute name.
42    *
43    * @param uri the XML namespace
44    * @param localName the XML local name
45    * @param qName the name
46    */

47   public AttributeName(String JavaDoc uri, String JavaDoc localName, String JavaDoc qName)
48   {
49     this.local = localName;
50
51     int p = qName.indexOf(':');
52     if (p < 0)
53       prefix = "";
54     else
55       prefix = qName.substring(0, p);
56
57     this.name = qName;
58     this.namespace = uri;
59   }
60
61   /**
62    * Returns the prefix:name QName.
63    */

64   public String JavaDoc getName()
65   {
66     return name;
67   }
68
69   /**
70    * Returns the local part of the name.
71    */

72   public String JavaDoc getLocal()
73   {
74     return local;
75   }
76
77   /**
78    * Returns the prefix of the name.
79    */

80   public String JavaDoc getPrefix()
81   {
82     return prefix;
83   }
84
85   /**
86    * Returns the namespace.
87    */

88   public String JavaDoc getNamespace()
89   {
90     return namespace;
91   }
92
93   public int hashCode()
94   {
95     return local.hashCode() * 65521 + namespace.hashCode();
96   }
97
98   public boolean equals(Object JavaDoc obj)
99   {
100     if (! (obj instanceof AttributeName))
101       return false;
102
103     AttributeName name = (AttributeName) obj;
104
105     return local.equals(name.local) && namespace.equals(name.namespace);
106   }
107
108   public String JavaDoc toString()
109   {
110     return "[Name " + name + "]";
111   }
112 }
113
Popular Tags