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