directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r472583 - in /directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name: LdapDN.java Rdn.java
Date Wed, 08 Nov 2006 18:46:24 GMT
Author: elecharny
Date: Wed Nov  8 10:46:24 2006
New Revision: 472583

URL: http://svn.apache.org/viewvc?view=rev&rev=472583
Log:
Migrate the code to Java 5, using generic

Modified:
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java?view=diff&rev=472583&r1=472582&r2=472583
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDN.java
Wed Nov  8 10:46:24 2006
@@ -58,7 +58,7 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapDN /* extends LdapString */implements Name
+public class LdapDN implements Name
 {
    /** The LoggerFactory used by this class */
    private static Logger log = LoggerFactory.getLogger( LdapDN.class );
@@ -81,7 +81,7 @@
    // ~ Static fields/initializers
    // -----------------------------------------------------------------
    /** The RDNs that are elements of the DN */
-   private List rdns = new ArrayList( 5 );
+   private List<Rdn> rdns = new ArrayList<Rdn>( 5 );
 
    /** The user provided name */
    private String upName;
@@ -133,16 +133,13 @@
     *
     * @param list of String name components.
     */
-   LdapDN( List list ) throws InvalidNameException
+   LdapDN( List<String> list ) throws InvalidNameException
    {
        if ( ( list != null ) && ( list.size() != 0 ) )
        {
-           Iterator nameComponents = list.iterator();
-
-           while ( nameComponents.hasNext() )
+           for ( String rdn:list )
            {
-               String nameComponent = ( String ) nameComponents.next();
-               add( 0, nameComponent );
+               add( 0, rdn );
            }
        }
    }
@@ -154,14 +151,13 @@
     * @param nameComponents
     *            List of String name components.
     */
-   LdapDN( Iterator nameComponents ) throws InvalidNameException
+   LdapDN( Iterator<String> nameComponents ) throws InvalidNameException
    {
        if ( nameComponents != null )
        {
            while ( nameComponents.hasNext() )
            {
-               String nameComponent = ( String ) nameComponents.next();
-               add( 0, nameComponent );
+               add( 0, nameComponents.next() );
            }
        }
    }
@@ -255,7 +251,7 @@
            StringBuffer sb = new StringBuffer();
            boolean isFirst = true;
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
                if ( isFirst )
                {
@@ -266,7 +262,7 @@
                    sb.append( ',' );
                }
 
-               sb.append( ( ( Rdn ) rdns.get( i ) ) );
+               sb.append( rdn );
            }
 
            String newNormName = sb.toString();
@@ -310,7 +306,7 @@
            StringBuffer sb = new StringBuffer();
            boolean isFirst = true;
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
                if ( isFirst )
                {
@@ -321,7 +317,7 @@
                    sb.append( ',' );
                }
 
-               sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+               sb.append( rdn.getUpName() );
            }
 
            upName = sb.toString();
@@ -379,7 +375,7 @@
                sb.append( ',' );
            }
 
-           sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+           sb.append( rdns.get( i ).getUpName() );
        }
 
        return sb.toString();
@@ -425,7 +421,7 @@
                sb.append( ',' );
            }
 
-           sb.append( ( ( Rdn ) rdns.get( i ) ).getUpName() );
+           sb.append( rdns.get( i ).getUpName() );
        }
 
        return sb.toString();
@@ -443,10 +439,10 @@
 
        if ( ( rdns != null ) || ( rdns.size() == 0 ) )
        {
-               for ( Iterator rdnsIter = rdns.iterator(); rdnsIter.hasNext(); )
-               {
-                       result = result * 37 + rdnsIter.next().hashCode();
-               }
+           for ( Rdn rdn:rdns )
+           {
+               result = result * 37 + rdn.hashCode();
+           }
        }
 
        return result;
@@ -544,8 +540,8 @@
 
            for ( int i = nameDN.size() - 1; i >= 0; i-- )
            {
-               Rdn nameRdn = ( Rdn ) ( nameDN.rdns.get( nameDN.rdns.size() - i - 1 ) );
-               Rdn ldapRdn = ( Rdn ) rdns.get( rdns.size() - i - 1 );
+               Rdn nameRdn = nameDN.rdns.get( nameDN.rdns.size() - i - 1 );
+               Rdn ldapRdn = rdns.get( rdns.size() - i - 1 );
 
                if ( nameRdn.compareTo( ldapRdn ) != 0 )
                {
@@ -573,11 +569,12 @@
 
            for ( int i = name.size() - 1; i >= 0; i-- )
            {
-               Rdn ldapRdn = ( Rdn ) rdns.get( rdns.size() - i - 1 );
+               Rdn ldapRdn = rdns.get( rdns.size() - i - 1 );
                Rdn nameRdn = null;
+               
                try
                {
-                   nameRdn = new Rdn( ( String ) name.get( name.size() - i - 1 ) );
+                   nameRdn = new Rdn( name.get( name.size() - i - 1 ) );
                }
                catch ( InvalidNameException e )
                {
@@ -634,8 +631,8 @@
            // Ok, iterate through all the RDN of the name
            for ( int i = 0; i < nameDN.size(); i++ )
            {
-               Rdn nameRdn = ( Rdn ) ( nameDN.rdns.get( i ) );
-               Rdn ldapRdn = ( Rdn ) rdns.get( i );
+               Rdn nameRdn = nameDN.rdns.get( i );
+               Rdn ldapRdn = rdns.get( i );
 
                if ( nameRdn.compareTo( ldapRdn ) != 0 )
                {
@@ -683,7 +680,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( rdns.size() - posn - 1 );
+           Rdn rdn = rdns.get( rdns.size() - posn - 1 );
 
            return rdn.toString();
        }
@@ -708,7 +705,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( rdns.size() - posn - 1 );
+           Rdn rdn = rdns.get( rdns.size() - posn - 1 );
 
            return rdn;
        }
@@ -727,7 +724,7 @@
        }
        else
        {
-           Rdn rdn = ( Rdn ) rdns.get( 0 );
+           Rdn rdn = rdns.get( 0 );
 
            return rdn;
        }
@@ -741,12 +738,12 @@
     */
    public List getRdns()
    {
-       List newRdns = new ArrayList();
+       List<Rdn> newRdns = new ArrayList<Rdn>();
 
        // We will clone the list, to avoid user modifications
-       for ( int i = 0; i < rdns.size(); i++ )
+       for ( Rdn rdn:rdns )
        {
-           newRdns.add( i, ( ( Rdn ) rdns.get( i ) ).clone() );
+           newRdns.add( (Rdn)rdn.clone() );
        }
 
        return newRdns;
@@ -760,7 +757,7 @@
     *
     * @return an enumeration of the components of this name, each as string
     */
-   public Enumeration getAll()
+   public Enumeration<String> getAll()
    {
        /*
         * Note that by accessing the name component using the get() method on
@@ -768,7 +765,7 @@
         * right to left with increasing index values. LdapName.get() does the
         * index translation on m_list for us.
         */
-       return new Enumeration()
+       return new Enumeration<String>()
        {
            private int pos;
 
@@ -779,7 +776,7 @@
            }
 
 
-           public Object nextElement()
+           public String nextElement()
            {
                if ( pos >= rdns.size() )
                {
@@ -787,7 +784,7 @@
                    throw new NoSuchElementException();
                }
 
-               Object obj = rdns.get( rdns.size() - pos - 1 );
+               Rdn obj = rdns.get( rdns.size() - pos - 1 );
                pos++;
                return obj.toString();
            }
@@ -796,13 +793,13 @@
 
 
    /**
-    * Retrieves the components of this name as an enumeration of strings. The
+    * Retrieves the components of this name as an enumeration of RDNs. The
     * effect on the enumeration of updates to this name is undefined. If the
     * name has zero components, an empty (non-null) enumeration is returned.
     *
     * @return an enumeration of the components of this name, as Rdn
     */
-   public Enumeration getAllRdn()
+   public Enumeration<Rdn> getAllRdn()
    {
        /*
         * Note that by accessing the name component using the get() method on
@@ -810,7 +807,7 @@
         * right to left with increasing index values. LdapName.get() does the
         * index translation on m_list for us.
         */
-       return new Enumeration()
+       return new Enumeration<Rdn>()
        {
            private int pos;
 
@@ -821,7 +818,7 @@
            }
 
 
-           public Object nextElement()
+           public Rdn nextElement()
            {
                if ( pos >= rdns.size() )
                {
@@ -829,7 +826,7 @@
                    throw new NoSuchElementException();
                }
 
-               Object obj = rdns.get( rdns.size() - pos - 1 );
+               Rdn obj = rdns.get( rdns.size() - pos - 1 );
                pos++;
                return obj;
            }
@@ -869,7 +866,7 @@
        for ( int i = rdns.size() - posn; i < rdns.size(); i++ )
        {
            // Don't forget to clone the rdns !
-           newLdapDN.rdns.add( ( ( Rdn ) rdns.get( i ) ).clone() );
+           newLdapDN.rdns.add( (Rdn)rdns.get( i ).clone() );
        }
 
        newLdapDN.normName = newLdapDN.toNormName();
@@ -912,7 +909,7 @@
        for ( int i = 0; i < size() - posn; i++ )
        {
            // Don't forget to clone the rdns !
-           newLdapDN.rdns.add( ( ( Rdn ) rdns.get( i ) ).clone() );
+           newLdapDN.rdns.add( ( Rdn ) rdns.get( i ).clone() );
        }
 
        newLdapDN.normName = newLdapDN.toNormName();
@@ -988,9 +985,11 @@
                Rdn rdn = new Rdn( name.get( ii ) );
                rdns.add( size() - posn, rdn );
            }
+           
            normalizeInternal();
            toUpName();
        }
+       
        return this;
    }
 
@@ -1105,7 +1104,7 @@
        }
 
        int realPos = size() - posn - 1;
-       Rdn rdn = ( Rdn ) rdns.remove( realPos );
+       Rdn rdn = rdns.remove( realPos );
 
        normalizeInternal();
        toUpName();
@@ -1126,11 +1125,11 @@
        try
        {
            LdapDN dn = ( LdapDN ) super.clone();
-           dn.rdns = new ArrayList();
+           dn.rdns = new ArrayList<Rdn>();
 
-           for ( int i = 0; i < rdns.size(); i++ )
+           for ( Rdn rdn:rdns )
            {
-               dn.rdns.add( i, ( ( Rdn ) rdns.get( i ) ).clone() );
+               dn.rdns.add( ( Rdn ) rdn.clone() );
            }
 
            return dn;
@@ -1163,7 +1162,7 @@
 
            for ( int i = 0; i < size(); i++ )
            {
-               if ( ( ( Rdn ) name.rdns.get( i ) ).compareTo( rdns.get( i ) ) != 0 )
+               if ( name.rdns.get( i ).compareTo( rdns.get( i ) ) != 0 )
                {
                    return false;
                }
@@ -1213,8 +1212,8 @@
 
            for ( int i = rdns.size(); i > 0; i-- )
            {
-               Rdn rdn1 = ( Rdn ) rdns.get( i - 1 );
-               Rdn rdn2 = ( Rdn ) ldapDN.rdns.get( i - 1 );
+               Rdn rdn1 = rdns.get( i - 1 );
+               Rdn rdn2 = ldapDN.rdns.get( i - 1 );
                int res = rdn1.compareTo( rdn2 );
 
                if ( res != 0 )
@@ -1232,7 +1231,7 @@
    }
 
 
-   private static AttributeTypeAndValue atavOidToName( AttributeTypeAndValue atav, Map oidsMap
)
+   private static AttributeTypeAndValue atavOidToName( AttributeTypeAndValue atav, Map<String,
OidNormalizer> oidsMap )
        throws InvalidNameException, NamingException
    {
        String type = StringTools.trim( atav.getType() );
@@ -1250,11 +1249,11 @@
            }
            else
            {
-               OidNormalizer oidNormalizer = ( OidNormalizer ) oidsMap.get( type );
+               OidNormalizer oidNormalizer = oidsMap.get( type );
 
                if ( oidNormalizer != null )
                {
-                   return new AttributeTypeAndValue( oidNormalizer.getAttributeTypeOid(),
( String ) oidNormalizer.getNormalizer()
+                   return new AttributeTypeAndValue( oidNormalizer.getAttributeTypeOid(),
oidNormalizer.getNormalizer()
                        .normalize( atav.getValue() ) );
 
                }
@@ -1287,7 +1286,7 @@
     *             If
     * @throws NamingException
     */
-   private static void rdnOidToName( Rdn rdn, Map oidsMap ) throws InvalidNameException,
NamingException
+   private static void rdnOidToName( Rdn rdn, Map<String, OidNormalizer> oidsMap )
throws InvalidNameException, NamingException
    {
        if ( rdn.getNbAtavs() > 1 )
        {
@@ -1296,12 +1295,12 @@
            Rdn rdnCopy = ( Rdn ) rdn.clone();
            rdn.clear();
 
-           Iterator atavs = rdnCopy.iterator();
+           Iterator<AttributeTypeAndValue> atavs = rdnCopy.iterator();
 
            while ( atavs.hasNext() )
            {
-               Object val = atavs.next();
-               AttributeTypeAndValue newAtav = atavOidToName( ( AttributeTypeAndValue ) val,
oidsMap );
+        	   AttributeTypeAndValue val = atavs.next();
+               AttributeTypeAndValue newAtav = atavOidToName( val, oidsMap );
                rdn.addAttributeTypeAndValue( newAtav.getType(), newAtav.getValue() );
            }
 
@@ -1323,7 +1322,7 @@
                }
                else
                {
-                   OidNormalizer oidNormalizer = ( OidNormalizer ) oidsMap.get( type );
+                   OidNormalizer oidNormalizer = oidsMap.get( type );
 
                    if ( oidNormalizer != null )
                    {
@@ -1334,8 +1333,7 @@
                        value = DefaultStringNormalizer.normalizeString( ( String ) value
);
 
                        rdn.addAttributeTypeAndValue( oidNormalizer.getAttributeTypeOid(),
-                           ( String ) oidNormalizer.getNormalizer()
-                           .normalize( value ) );
+                           oidNormalizer.getNormalizer().normalize( value ) );
 
                    }
                    else
@@ -1374,7 +1372,7 @@
     * @throws InvalidNameException
     *             If the DN is invalid
     */
-   public static LdapDN normalize( LdapDN dn, Map oidsMap ) throws InvalidNameException,
NamingException
+   public static LdapDN normalize( LdapDN dn, Map<String, OidNormalizer> oidsMap )
throws InvalidNameException, NamingException
    {
        if ( ( dn == null ) || ( dn.size() == 0 ) || ( oidsMap == null ) || ( oidsMap.size()
== 0 ) )
        {
@@ -1383,12 +1381,12 @@
 
        LdapDN newDn = ( LdapDN ) dn.clone();
 
-       Enumeration rdns = newDn.getAllRdn();
+       Enumeration<Rdn> rdns = newDn.getAllRdn();
 
        // Loop on all RDNs
        while ( rdns.hasMoreElements() )
        {
-           Rdn rdn = ( Rdn ) rdns.nextElement();
+           Rdn rdn = rdns.nextElement();
            String upName = rdn.getUpName();
            rdnOidToName( rdn, oidsMap );
            rdn.normalizeString();
@@ -1415,19 +1413,19 @@
     * @throws InvalidNameException
     *             If the DN is invalid
     */
-   public void normalize( Map oidsMap ) throws InvalidNameException, NamingException
+   public void normalize( Map<String, OidNormalizer> oidsMap ) throws InvalidNameException,
NamingException
    {
        if ( ( oidsMap == null ) || ( oidsMap.size() == 0 ) )
        {
            return;
        }
 
-       Enumeration rdns = getAllRdn();
+       Enumeration<Rdn> rdns = getAllRdn();
 
        // Loop on all RDNs
        while ( rdns.hasMoreElements() )
        {
-           Rdn rdn = ( Rdn ) rdns.nextElement();
+           Rdn rdn = rdns.nextElement();
            String upName = rdn.getUpName();
            rdnOidToName( rdn, oidsMap );
            rdn.normalizeString();

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?view=diff&rev=472583&r1=472582&r2=472583
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
Wed Nov  8 10:46:24 2006
@@ -130,13 +130,13 @@
     * because we want the ATAVs to be sorted. An atav may contain more than one
     * value. In this case, the values are String stored in a List.
     */
-   private TreeSet atavs = null;
+   private TreeSet<AttributeTypeAndValue> atavs = null;
 
    /**
     * We also keep a set of types, in order to use manipulations. A type is
     * connected with the atav it represents.
     */
-   private Map atavTypes = new MultiHashMap();
+   private Map<String, AttributeTypeAndValue> atavTypes = new MultiHashMap();
 
    /**
     * We keep the type for a single valued RDN, to avoid the creation of an HashMap
@@ -265,16 +265,13 @@
 
            default:
                // We must duplicate the treeSet and the hashMap
-               Iterator iter = rdn.atavs.iterator();
-
-               atavs = new TreeSet();
+               atavs = new TreeSet<AttributeTypeAndValue>();
                atavTypes = new MultiHashMap();
 
-               while ( iter.hasNext() )
+               for ( AttributeTypeAndValue atv:rdn.atavs )
                {
-                   AttributeTypeAndValue currentAtav = ( AttributeTypeAndValue ) iter.next();
-                   atavs.add( currentAtav.clone() );
-                   atavTypes.put( currentAtav.getType(), currentAtav );
+                   atavs.add( (AttributeTypeAndValue)atv.clone() );
+                   atavTypes.put( atv.getType(), atv );
                }
        }
    }
@@ -315,13 +312,10 @@
                // We have more than one AttributeTypeAndValue
                StringBuffer sb = new StringBuffer();
 
-               Iterator elems = atavs.iterator();
                boolean isFirst = true;
 
-               while ( elems.hasNext() )
+               for ( AttributeTypeAndValue atv:atavs )
                {
-                   AttributeTypeAndValue ata = ( AttributeTypeAndValue ) elems.next();
-
                    if ( isFirst )
                    {
                        isFirst = false;
@@ -331,7 +325,7 @@
                        sb.append( '+' );
                    }
 
-                   sb.append( ata.normalize() );
+                   sb.append( atv.normalize() );
                }
 
                string = sb.toString();
@@ -372,7 +366,7 @@
                // We already have an atav. We have to put it in the HashMap
                // before adding a new one.
                // First, create the HashMap,
-               atavs = new TreeSet();
+               atavs = new TreeSet<AttributeTypeAndValue>();
 
                // and store the existing AttributeTypeAndValue into it.
                atavs.add( atav );
@@ -519,7 +513,7 @@
            default:
                if ( atavTypes.containsKey( normalizedType ) )
                {
-                   return ( AttributeTypeAndValue ) atavTypes.get( normalizedType );
+                   return atavTypes.get( normalizedType );
                }
                else
                {
@@ -536,11 +530,11 @@
     *
     * @return an enumeration of the components of this name, each a string
     */
-   public Iterator iterator()
+   public Iterator<AttributeTypeAndValue> iterator()
    {
        if ( nbAtavs == 1 )
        {
-           return new Iterator()
+           return new Iterator<AttributeTypeAndValue>()
            {
                private boolean hasMoreElement = true;
 
@@ -551,11 +545,10 @@
                }
 
 
-               public Object next()
+               public AttributeTypeAndValue next()
                {
-                   Object obj = atav;
                    hasMoreElement = false;
-                   return obj;
+                   return atav;
                }
 
 
@@ -596,15 +589,12 @@
                default:
                    // We must duplicate the treeSet and the hashMap
                    rdn.atavTypes = new MultiHashMap();
-                   rdn.atavs = new TreeSet();
+                   rdn.atavs = new TreeSet<AttributeTypeAndValue>();
 
-                   Iterator iter = this.atavs.iterator();
-
-                   while ( iter.hasNext() )
+                   for ( AttributeTypeAndValue atv:this.atavs )
                    {
-                       AttributeTypeAndValue currentAtav = ( AttributeTypeAndValue ) iter.next();
-                       rdn.atavs.add( currentAtav.clone() );
-                       rdn.atavTypes.put( currentAtav.getType(), currentAtav );
+                       rdn.atavs.add( (AttributeTypeAndValue)atv.clone() );
+                       rdn.atavTypes.put( atv.getType(), atv );
                    }
 
                    break;
@@ -660,23 +650,20 @@
                default:
                    // We have more than one value. We will
                    // go through all of them.
-                   Iterator keys = atavs.iterator();
-
-                   while ( keys.hasNext() )
+                   for ( AttributeTypeAndValue atv:atavs )
                    {
-                       AttributeTypeAndValue current = ( AttributeTypeAndValue ) keys.next();
-                       String type = current.getType();
+                       String type = atv.getType();
 
                        if ( rdn.atavTypes.containsKey( type ) )
                        {
-                           List atavLocalList = ( List ) atavTypes.get( type );
-                           List atavParamList = ( List ) rdn.atavTypes.get( type );
+                           List<AttributeTypeAndValue> atavLocalList = (List<AttributeTypeAndValue>)atavTypes.get(
type );
+                           List<AttributeTypeAndValue> atavParamList = (List<AttributeTypeAndValue>)
rdn.atavTypes.get( type );
 
                            if ( atavLocalList.size() == 1 )
                            {
                                // We have only one ATAV
-                               AttributeTypeAndValue atavLocal = ( AttributeTypeAndValue
) atavLocalList.get( 0 );
-                               AttributeTypeAndValue atavParam = ( AttributeTypeAndValue
) atavParamList.get( 0 );
+                               AttributeTypeAndValue atavLocal = atavLocalList.get( 0 );
+                               AttributeTypeAndValue atavParam = atavParamList.get( 0 );
 
                                return atavLocal.compareTo( atavParam );
                            }
@@ -685,19 +672,12 @@
                                // We have to verify that each value of the
                                // first list are present in
                                // the second list
-                               Iterator atavLocals = atavLocalList.iterator();
-
-                               while ( atavLocals.hasNext() )
+                               for ( AttributeTypeAndValue atavLocal:atavLocalList )
                                {
-                                   AttributeTypeAndValue atavLocal = ( AttributeTypeAndValue
) atavLocals.next();
-
-                                   Iterator atavParams = atavParamList.iterator();
                                    boolean found = false;
 
-                                   while ( atavParams.hasNext() )
+                                   for ( AttributeTypeAndValue atavParam:atavParamList )
                                    {
-                                       AttributeTypeAndValue atavParam = ( AttributeTypeAndValue
) atavParams.next();
-
                                        if ( atavLocal.compareTo( atavParam ) == EQUALS )
                                        {
                                            found = true;
@@ -787,7 +767,7 @@
                return atav;
 
            default:
-               return ( AttributeTypeAndValue ) atavs.first();
+               return atavs.first();
        }
    }
 
@@ -808,7 +788,7 @@
                return atav.getType();
 
            default:
-               return ( ( AttributeTypeAndValue ) atavs.first() ).getType();
+               return atavs.first().getType();
        }
    }
 
@@ -829,7 +809,7 @@
                return atav.getValue();
 
            default:
-               return ( ( AttributeTypeAndValue ) atavs.first() ).getValue();
+               return atavs.first().getValue();
        }
    }
 
@@ -898,16 +878,12 @@
                while ( types.hasNext() )
                {
                    String type = ( String ) types.next();
-                   List values = ( List ) atavTypes.get( type );
+                   List<AttributeTypeAndValue> values = ( List<AttributeTypeAndValue>
) atavTypes.get( type );
 
                    attribute = new BasicAttribute( type, true );
 
-                   Iterator iterValues = values.iterator();
-
-                   while ( iterValues.hasNext() )
+                   for ( AttributeTypeAndValue value:values )
                    {
-                       AttributeTypeAndValue value = ( AttributeTypeAndValue ) iterValues.next();
-
                        attribute.add( value.getValue() );
                    }
 
@@ -1183,9 +1159,8 @@
            default:
                // We have more than one AttributeTypeAndValue
 
-               for ( Iterator elems = atavs.iterator();elems.hasNext(); )
+               for ( AttributeTypeAndValue ata:atavs )
                {
-                   AttributeTypeAndValue ata = ( AttributeTypeAndValue ) elems.next();
                    result = result * 37 + ata.hashCode();
                }
        }



Mime
View raw message