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.types;
14  
15  import java.util.ArrayList;
16  import java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.apache.xmlbeans.XmlException;
20  
21  import com.eviware.soapui.config.StringListConfig;
22  
23  public class StringList extends ArrayList<String>
24  {
25  	public StringList()
26  	{
27  		super();
28  	}
29  
30  	public StringList(Collection<? extends String> c)
31  	{
32  		super(c);
33  	}
34  
35  	public StringList(int initialCapacity)
36  	{
37  		super(initialCapacity);
38  	}
39  
40  	public StringList( String[] strings )
41  	{
42  		super( Arrays.asList( strings ));
43  	}
44  
45  	public StringList( Object[] objects )
46  	{
47  		super();
48  		
49  		for( Object object : objects )
50  			add( object == null ? null : object.toString() );
51  	}
52  
53  	public void addAll(String[] strings)
54  	{
55  		addAll( Arrays.asList( strings ));
56  	}
57  
58  	public String[] toStringArray()
59  	{
60  		return toArray( new String[size()]);
61  	}
62  
63  	public static StringList fromXml( String value ) throws XmlException
64  	{
65  		return new StringList( StringListConfig.Factory.parse( value ).getEntryList() );
66  	}
67  
68  	public String toXml()
69  	{
70  		StringListConfig config = StringListConfig.Factory.newInstance();
71  		config.setEntryArray( toStringArray() );
72  		return config.xmlText();
73  	}
74  }