avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test EntryDescriptorTestCase.java
Date Mon, 14 Jul 2003 04:31:59 GMT
mcconnell    2003/07/13 21:31:58

  Modified:    meta/api/src/java/org/apache/avalon/meta/info
                        ContextDescriptor.java EntryDescriptor.java
               meta/api/src/test/org/apache/avalon/meta/info/test
                        EntryDescriptorTestCase.java
  Log:
  Improvement in the utility of the ContextDescriptor.getEntry( key ) operation - now returnes
a context entry descriptor by alias or by key.  Test-cases updated to reflect enhancment.
  
  Revision  Changes    Path
  1.6       +15 -8     avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java
  
  Index: ContextDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/ContextDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContextDescriptor.java	12 Jul 2003 13:34:27 -0000	1.5
  +++ ContextDescriptor.java	14 Jul 2003 04:31:58 -0000	1.6
  @@ -142,26 +142,33 @@
       }
   
       /**
  -     * Return the entry with specified key.
  +     * Return the entry with specified alias.  If the entry
  +     * does not declare an alias the method will return an 
  +     * entry with the matching key.
        *
  -     * @param key the context entry key to lookup
  +     * @param alias the context entry key to lookup
        * @return the entry with specified key.
        */
  -    public EntryDescriptor getEntry( final String key )
  +    public EntryDescriptor getEntry( final String alias )
       {
  -        if ( null == key )
  +        if ( null == alias )
           {
  -            throw new NullPointerException( "key" );
  +            throw new NullPointerException( "alias" );
           }
   
           for ( int i = 0; i < m_entries.length; i++ )
           {
               final EntryDescriptor entry = m_entries[i];
  -            if ( ( entry.getAlias() != null ) && entry.getAlias().equals( key )
)
  +            if( entry.getAlias().equals( alias ) )
               {
                   return entry;
               }
  -            if ( entry.getKey().equals( key ) )
  +        }
  +
  +        for ( int i = 0; i < m_entries.length; i++ )
  +        {
  +            final EntryDescriptor entry = m_entries[i];
  +            if( entry.getKey().equals( alias ) )
               {
                   return entry;
               }
  
  
  
  1.6       +11 -2     avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/EntryDescriptor.java
  
  Index: EntryDescriptor.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/java/org/apache/avalon/meta/info/EntryDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EntryDescriptor.java	12 Jul 2003 13:34:27 -0000	1.5
  +++ EntryDescriptor.java	14 Jul 2003 04:31:58 -0000	1.6
  @@ -177,12 +177,21 @@
   
       /**
        * Return the alias that Component uses to lookup the entry.
  +     * If no alias is declared, the standard lookup key will be 
  +     * returned.
        *
        * @return the alias to the key.
        */
       public String getAlias()
       {
  -        return m_alias;
  +        if( m_alias != null )
  +        {
  +            return m_alias;
  +        }
  +        else
  +        {
  +            return m_key;
  +        }
       }
   
       /**
  
  
  
  1.4       +8 -1      avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/EntryDescriptorTestCase.java
  
  Index: EntryDescriptorTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/EntryDescriptorTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EntryDescriptorTestCase.java	11 Jul 2003 21:36:28 -0000	1.3
  +++ EntryDescriptorTestCase.java	14 Jul 2003 04:31:58 -0000	1.4
  @@ -112,7 +112,14 @@
       {
           assertNotNull( desc );
           assertEquals( key, desc.getKey() );
  -        assertEquals( alias, desc.getAlias() );
  +        if( alias == null )
  +        {
  +            assertEquals( key, desc.getAlias() );
  +        }
  +        else
  +        {
  +            assertEquals( alias, desc.getAlias() );
  +        }
           assertEquals( type, desc.getClassname() );
           assertEquals( isOptional, desc.isOptional() );
           assertEquals( ! isOptional, desc.isRequired() );
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message