View Javadoc

1   /* 
2    * Copyright 2002-2004 The Apache Software Foundation
3    * Licensed  under the  Apache License,  Version 2.0  (the "License");
4    * you may not use  this file  except in  compliance with the License.
5    * You may obtain a copy of the License at 
6    * 
7    *   http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed  under the  License is distributed on an "AS IS" BASIS,
11   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
12   * implied.
13   * 
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.struts.flow.core.source.impl.validity;
18  
19  import java.util.ArrayList;
20  import java.util.Collections;
21  import java.util.Iterator;
22  import java.util.List;
23  
24  import org.apache.struts.flow.core.source.SourceValidity;
25  
26  /***
27   * The base class for the aggregation implementations
28   *
29   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
30   * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:17 $
31   */
32  public abstract class AbstractAggregatedValidity
33      implements SourceValidity
34  {
35      final ArrayList m_list = new ArrayList();
36  
37      public void add( final SourceValidity validity )
38      {
39          m_list.add( validity );
40      }
41  
42      public String toString()
43      {
44          final StringBuffer sb = new StringBuffer( "SourceValidity " );
45          for( final Iterator i = m_list.iterator(); i.hasNext(); )
46          {
47              sb.append( i.next() );
48              if( i.hasNext() ) sb.append( ':' );
49          }
50          return sb.toString();
51      }
52      
53      public List getValidities() 
54      {
55          return Collections.unmodifiableList(m_list);
56      }
57      
58      SourceValidity getValidity(final int index) 
59      {
60          return (SourceValidity) m_list.get(index);
61      }
62      
63  }