View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 com.eviware.soapui.model.ModelItem;
16  import com.eviware.soapui.support.action.SoapUIActionMapping;
17  import com.eviware.soapui.support.types.StringList;
18  
19  /***
20   * Default SoapUIActionGroup implementation
21   * 
22   * @author ole.matzura
23   */
24  
25  public class DefaultSoapUIActionGroup<T extends ModelItem> extends AbstractSoapUIActionGroup<T>
26  {
27  	private SoapUIActionMappingList<T> mappings = new SoapUIActionMappingList<T>();
28  	private StringList ids = new StringList();
29  
30  	public DefaultSoapUIActionGroup( String id, String name )
31  	{
32  		super( id, name );
33  	}
34  
35  	public SoapUIActionMappingList<T> getActionMappings( T modelItem )
36  	{
37  		return mappings;
38  	}
39  
40  	@Override
41  	public SoapUIActionMapping<T> addMapping( String id, int index, SoapUIActionMapping<T> mapping )
42  	{
43  		if( index == -1 || index >= mappings.size() )
44  			return addMapping( id, mapping );
45  		
46  		mappings.add( index, mapping );
47  		ids.add( index, id );
48  		return mapping;
49  	}
50  
51  	@Override
52  	public SoapUIActionMapping<T> addMapping( String id, SoapUIActionMapping<T> mapping )
53  	{
54  		mappings.add( mapping );
55  		ids.add( id );
56  		return mapping;
57  	}
58  
59  	@Override
60  	public int getMappingIndex( String positionRef )
61  	{
62  		return ids.indexOf( positionRef );
63  	}
64  }