/[classpath]/classpath/javax/naming/directory/BasicAttributes.java
ViewVC logotype

Diff of /classpath/javax/naming/directory/BasicAttributes.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by tromey, Sat Nov 6 23:31:50 2004 UTC revision 1.5 by mark, Thu Jan 20 10:20:33 2005 UTC
# Line 1  Line 1 
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    
# Line 83  public class BasicAttributes implements Line 83  public class BasicAttributes implements
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    
# Line 191  public class BasicAttributes implements Line 199  public class BasicAttributes implements
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)
# Line 220  public class BasicAttributes implements Line 228  public class BasicAttributes implements
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    }    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26