1 |
/* BasicAttributes.java -- |
/* BasicAttributes.java -- |
2 |
Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc. |
Copyright (C) 2000, 2001, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
83 |
return ba; |
return ba; |
84 |
} |
} |
85 |
|
|
86 |
|
/** |
87 |
|
* Returns true if and only if the given Object is an instance of |
88 |
|
* Attributes, the given attributes both do or don't ignore case for |
89 |
|
* IDs and the collection of attributes is the same. |
90 |
|
*/ |
91 |
public boolean equals (Object obj) |
public boolean equals (Object obj) |
92 |
{ |
{ |
93 |
if (! (obj instanceof BasicAttributes)) |
if (! (obj instanceof Attributes)) |
94 |
return false; |
return false; |
95 |
BasicAttributes b = (BasicAttributes) obj; |
|
96 |
if (ignoreCase != b.ignoreCase |
Attributes bs = (Attributes) obj; |
97 |
|| attributes.size () != b.attributes.size ()) |
if (ignoreCase != bs.isCaseIgnored() |
98 |
|
|| attributes.size () != bs.size ()) |
99 |
return false; |
return false; |
100 |
|
|
101 |
// Does order matter? |
NamingEnumeration bas = bs.getAll(); |
102 |
for (int i = 0; i < attributes.size (); ++i) |
while (bas.hasMoreElements()) |
103 |
{ |
{ |
104 |
if (! attributes.get (i).equals (b.attributes.get (i))) |
Attribute a = (Attribute) bas.nextElement(); |
105 |
|
Attribute b = get(a.getID ()); |
106 |
|
if (! a.equals(b)) |
107 |
return false; |
return false; |
108 |
} |
} |
109 |
|
|
199 |
// Used when enumerating. |
// Used when enumerating. |
200 |
private class BasicAttributesEnumeration implements NamingEnumeration |
private class BasicAttributesEnumeration implements NamingEnumeration |
201 |
{ |
{ |
202 |
int where = -1; |
int where = 0; |
203 |
boolean id; |
boolean id; |
204 |
|
|
205 |
public BasicAttributesEnumeration (boolean id) |
public BasicAttributesEnumeration (boolean id) |
228 |
|
|
229 |
public Object nextElement () throws NoSuchElementException |
public Object nextElement () throws NoSuchElementException |
230 |
{ |
{ |
231 |
if (where + 1 >= attributes.size ()) |
if (where >= attributes.size ()) |
232 |
throw new NoSuchElementException ("no more elements"); |
throw new NoSuchElementException ("no more elements"); |
|
++where; |
|
233 |
Attribute at = (Attribute) attributes.get (where); |
Attribute at = (Attribute) attributes.get (where); |
234 |
|
++where; |
235 |
return id ? (Object) at.getID () : (Object) at; |
return id ? (Object) at.getID () : (Object) at; |
236 |
} |
} |
237 |
} |
} |