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