View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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.impl.wsdl.panels.request.components.editor.inspectors.registry;
14  
15  import java.util.ArrayList;
16  import java.util.Arrays;
17  import java.util.List;
18  
19  public class XmlInspectorRegistry
20  {
21  	private static XmlInspectorRegistry instance;
22  	private List<XmlInspectorFactory> factories = new ArrayList<XmlInspectorFactory>();
23  	
24  	public XmlInspectorRegistry()
25  	{
26  	}
27  	
28  	public void addFactory( XmlInspectorFactory factory )
29  	{
30  		factories.add( factory );
31  	}
32  
33  	public static final XmlInspectorRegistry getInstance()
34  	{
35  		if( instance == null )
36  			instance = new XmlInspectorRegistry();
37  		
38  		return instance;
39  	}
40  	
41  	public XmlInspectorFactory [] getFactories()
42  	{
43  		return factories.toArray( new XmlInspectorFactory[factories.size()] );
44  	}
45  	
46  	public XmlInspectorFactory [] getFactoriesOfType( Class type )
47  	{
48  		List<XmlInspectorFactory> result = new ArrayList<XmlInspectorFactory>();
49  		for( XmlInspectorFactory factory : factories )
50  		{
51  			if( Arrays.asList( factory.getClass().getInterfaces() ).contains( type )) 
52  				result.add( factory );
53  		}
54  		
55  		return result.toArray( new XmlInspectorFactory[result.size()] );
56  	}
57  }