Package org.cip4.jdflib.core
Class StringArray
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<java.lang.String>
-
- org.cip4.jdflib.core.StringArray
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.String>,java.util.Collection<java.lang.String>,java.util.List<java.lang.String>,java.util.RandomAccess
public class StringArray extends java.util.ArrayList<java.lang.String>- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringArray()constructorStringArray(java.lang.String strIn)convenience - constructs a VString by tokenizing a stringStringArray(java.lang.String[] a)creates a VString from an array of StringsStringArray(java.lang.String strIn, java.lang.String strSep)constructs a VString by tokenizing a stringStringArray(java.util.Collection<java.lang.String> m)constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(java.lang.String[] strings)appends all strings of an array tothisvoidaddNonEmpty(java.lang.String text)add a string if it is not emptyvoidappendUnique(java.lang.String string)AppendUnique - append a string but ignore multiple entriesvoidappendUnique(java.util.Collection<java.lang.String> v)AppendUnique - append a vector but ignore multiple entriesbooleancontainsAny(java.util.Collection<java.lang.String> others)checks whether at least one of a given vector of strings is contained inthisjava.lang.Stringget(int index)StringArraygetOverlapping(java.util.Collection<java.lang.String> others)vector of strings that is contained inthisjava.util.Set<java.lang.String>getSet()gets a set with all entries of the VString
note that the set retains ordering (LinkedHashSet)java.lang.StringgetString()serialize to a stringjava.lang.StringgetString(java.lang.String sep, java.lang.String front, java.lang.String back)serialize to a stringstatic StringArraygetVString(java.lang.String strIn, java.lang.String strSep)simple static factory - null if strIn is null or emptystatic booleanisEmpty(java.util.Collection<java.lang.String> v)are we null or empty or contain only an empty JDFAttributeMapjava.lang.Stringremove(int index)remove but also implementing the usual neg number syntaxvoidunify()unify - make VString unique, retaining initial order-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
StringArray
public StringArray()
constructor
-
StringArray
public StringArray(java.util.Collection<java.lang.String> m)
constructor- Parameters:
m-
-
StringArray
public StringArray(java.lang.String strIn)
convenience - constructs a VString by tokenizing a string- Parameters:
strIn- the string to tokenize by blank
-
StringArray
public StringArray(java.lang.String strIn, java.lang.String strSep)constructs a VString by tokenizing a string- Parameters:
strIn- the string to tokenizestrSep- the separator character
-
StringArray
public StringArray(java.lang.String[] a)
creates a VString from an array of Strings- Parameters:
a- the array
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(java.util.Collection<java.lang.String> v)
are we null or empty or contain only an empty JDFAttributeMap- Parameters:
v-- Returns:
-
getVString
public static StringArray getVString(java.lang.String strIn, java.lang.String strSep)
simple static factory - null if strIn is null or empty- Parameters:
strIn-strSep-- Returns:
-
get
public java.lang.String get(int index)
- Specified by:
getin interfacejava.util.List<java.lang.String>- Overrides:
getin classjava.util.ArrayList<java.lang.String>- Parameters:
index- the index which may be negative to count backwards- Returns:
- the string at index
-
appendUnique
public void appendUnique(java.lang.String string)
AppendUnique - append a string but ignore multiple entries- Parameters:
string- the string to append, if null nothing is added
-
appendUnique
public void appendUnique(java.util.Collection<java.lang.String> v)
AppendUnique - append a vector but ignore multiple entries- Parameters:
v- the vector to append, if null nothing is added
-
getString
public java.lang.String getString(java.lang.String sep, java.lang.String front, java.lang.String back)serialize to a string- Parameters:
sep- separator between stringsfront- string before the first entryback- string after the last entry- Returns:
- a tokenized string
-
getString
public java.lang.String getString()
serialize to a string- Parameters:
sep- separator between stringsfront- string before the first entryback- string after the last entry- Returns:
- a tokenized string
-
unify
public void unify()
unify - make VString unique, retaining initial order
-
getSet
public java.util.Set<java.lang.String> getSet()
gets a set with all entries of the VString
note that the set retains ordering (LinkedHashSet)- Returns:
- the set corresponding to this
-
addAll
public void addAll(java.lang.String[] strings)
appends all strings of an array tothis- Parameters:
strings- the array of strings to append tothis
-
containsAny
public boolean containsAny(java.util.Collection<java.lang.String> others)
checks whether at least one of a given vector of strings is contained inthis- Parameters:
others- the VSTring of values to test- Returns:
- true if at least one String in other is in
this
-
getOverlapping
public StringArray getOverlapping(java.util.Collection<java.lang.String> others)
vector of strings that is contained inthis- Parameters:
others- the VString of values to test- Returns:
- true if at least one String in other is in
this
-
remove
public java.lang.String remove(int index)
remove but also implementing the usual neg number syntax- Specified by:
removein interfacejava.util.List<java.lang.String>- Overrides:
removein classjava.util.ArrayList<java.lang.String>- Parameters:
index- if 0, or positive count from front, else if negative from back- See Also:
Vector.remove(int)
-
addNonEmpty
public void addNonEmpty(java.lang.String text)
add a string if it is not empty- Parameters:
text-
-
-