View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.support.action.support;
14  
15  import java.util.List;
16  
17  import com.eviware.soapui.model.ModelItem;
18  import com.eviware.soapui.support.action.SoapUIActionMapping;
19  import com.eviware.soapui.support.types.StringList;
20  
21  /***
22   * Default SoapUIActionGroup implementation
23   * 
24   * @author ole.matzura
25   */
26  
27  public class DefaultSoapUIActionGroup<T extends ModelItem> extends AbstractSoapUIActionGroup<T>
28  {
29  	private SoapUIActionMappingList<T> mappings = new SoapUIActionMappingList<T>();
30  	private StringList ids = new StringList();
31  
32  	public DefaultSoapUIActionGroup( String id, String name )
33  	{
34  		super( id, name );
35  	}
36  
37  	public List<SoapUIActionMapping<T>> getActionMappings( T modelItem )
38  	{
39  		return mappings;
40  	}
41  
42  	@Override
43  	public SoapUIActionMapping<T> addMapping( String id, int index, SoapUIActionMapping<T> mapping )
44  	{
45  		if( index == -1 || index >= mappings.size() )
46  			return addMapping( id, mapping );
47  		
48  		mappings.add( index, mapping );
49  		ids.add( index, id );
50  		return mapping;
51  	}
52  
53  	@Override
54  	public SoapUIActionMapping<T> addMapping( String id, SoapUIActionMapping<T> mapping )
55  	{
56  		mappings.add( mapping );
57  		ids.add( id );
58  		return mapping;
59  	}
60  
61  	@Override
62  	public int getMappingIndex( String positionRef )
63  	{
64  		return ids.indexOf( positionRef );
65  	}
66  }