Package org.cip4.jdflib.core
Class VString
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.String>
-
- org.cip4.jdflib.core.VString
-
- 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 VString extends java.util.Vector<java.lang.String>- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static VStringemptyVectorDeprecated.grab your own...
-
Constructor Summary
Constructors Constructor Description VString()constructorVString(java.lang.String strIn)convenience - constructs a VString by tokenizing a stringVString(java.lang.String[] a)creates a VString from an array of StringsVString(java.lang.String strIn, java.lang.String strSep)constructs a VString by tokenizing a stringVString(java.util.Enumeration<java.lang.String> a)creates a VString from an Enumeration of StringsVString(java.util.Vector<java.lang.String> m)constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(org.apache.commons.lang.enums.ValuedEnum enumType)appends enumType tothis
if enumType is a ValuedEnum, the name is appendedvoidaddAll(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(VString v)AppendUnique - append a vector but ignore multiple entriesbooleancontainsAny(VString others)checks whether at least one of a given vector of strings is contained inthisjava.lang.StringelementAt(int index)java.lang.Stringget(int index)java.lang.Stringget(java.lang.String s)get a string fromthisjava.lang.StringgetAllStrings()Deprecated.use getString(JDFConstants.BLANK,null,null)java.lang.StringgetAllStrings(java.lang.String strSep)Deprecated.use getString(strSep,null,null)VStringgetOverlapping(VString 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 VStringgetVString(java.lang.String strIn, java.lang.String strSep)simple static factory - null if strIn is null or emptystatic VStringgetVString(java.util.Collection<java.lang.String> c)simple static factory - null if strIn is null or emptybooleanhasString(java.lang.String s)Deprecated.2005-02-14 use contains ...intindex(java.lang.String s)index - get the index of s in the vectorstatic booleanisEmpty(VString v)are we null or empty or contain only an empty JDFAttributeMapjava.lang.Stringremove(int index)remove but also implementing the usual neg number syntaxvoidremoveStrings(java.lang.String s)Deprecated.use removeStrings(s, Integer.MAX_VALUE);voidremoveStrings(java.lang.String s, int nMax)removeStrings - remove nMax occurrences of a stringvoidremoveStrings(VString v)Deprecated.use removeStrings(v, Integer.MAX_VALUE);voidremoveStrings(VString v, int nMax)removeStrings - remove all occurrences of a stringvoidsetAllStrings(java.lang.String strIn, java.lang.String strSep)Method setAllStrings - put a separated string into the vString
e.g.java.lang.StringsetvString(VString v, java.lang.String sep, java.lang.String front, java.lang.String end)Deprecated.use getStringvoidsort()sortthislexicallyjava.lang.StringstringAt(int index)Deprecated.- simply use getjava.lang.StringtoString()toStringvoidunify()unify - make VString unique, retaining initial order-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elements, ensureCapacity, equals, firstElement, forEach, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Field Detail
-
emptyVector
@Deprecated public static final VString emptyVector
Deprecated.grab your own... this is a potential leak, since it can be modifiedthe empty VString
-
-
Constructor Detail
-
VString
public VString()
constructor
-
VString
public VString(java.util.Vector<java.lang.String> m)
constructor- Parameters:
m-
-
VString
public VString(java.lang.String strIn)
convenience - constructs a VString by tokenizing a string- Parameters:
strIn- the string to tokenize by blank
-
VString
public VString(java.lang.String strIn, java.lang.String strSep)constructs a VString by tokenizing a string- Parameters:
strIn- the string to tokenizestrSep- the separator character
-
VString
public VString(java.lang.String[] a)
creates a VString from an array of Strings- Parameters:
a- the array
-
VString
public VString(java.util.Enumeration<java.lang.String> a)
creates a VString from an Enumeration of Strings- Parameters:
a- the Enumeration
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(VString v)
are we null or empty or contain only an empty JDFAttributeMap- Parameters:
v-- Returns:
-
getVString
public static VString getVString(java.lang.String strIn, java.lang.String strSep)
simple static factory - null if strIn is null or empty- Parameters:
strIn-strSep-- Returns:
-
getVString
public static VString getVString(java.util.Collection<java.lang.String> c)
simple static factory - null if strIn is null or empty- Parameters:
strIn-strSep-- Returns:
-
stringAt
@Deprecated public java.lang.String stringAt(int index)
Deprecated.- simply use get- Parameters:
index- the index which may be negative to count backwards- Returns:
- the string at index
-
elementAt
public java.lang.String elementAt(int index)
- Overrides:
elementAtin classjava.util.Vector<java.lang.String>- Parameters:
index- the index which may be negative to count backwards- Returns:
- the string at index
-
get
public java.lang.String get(int index)
- Specified by:
getin interfacejava.util.List<java.lang.String>- Overrides:
getin classjava.util.Vector<java.lang.String>- Parameters:
index- the index which may be negative to count backwards- Returns:
- the string at index
-
toString
public java.lang.String toString()
toString- Overrides:
toStringin classjava.util.Vector<java.lang.String>- Returns:
- String
-
getAllStrings
@Deprecated public java.lang.String getAllStrings(java.lang.String strSep)
Deprecated.use getString(strSep,null,null)Method getAllStrings - returns all strings concatenated together- Parameters:
strSep- separation between the strings- Returns:
- String
-
getAllStrings
@Deprecated public java.lang.String getAllStrings()
Deprecated.use getString(JDFConstants.BLANK,null,null)- Returns:
- all strings separated by a blank
-
setAllStrings
public void setAllStrings(java.lang.String strIn, java.lang.String strSep)Method setAllStrings - put a separated string into the vString
e.g. "asdf asdf asdf asdf"- Parameters:
strIn- separated stringstrSep- string separator
-
index
public int index(java.lang.String s)
index - get the index of s in the vector- Parameters:
s-- Returns:
- int the index of a string
-
hasString
@Deprecated public boolean hasString(java.lang.String s)
Deprecated.2005-02-14 use contains ...hasString - is 's' a member ofthis?- Parameters:
s- string to find- Returns:
- boolean - true, if 's' is included in
this
-
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(VString v)
AppendUnique - append a vector but ignore multiple entries- Parameters:
v- the vector to append, if null nothing is added
-
removeStrings
@Deprecated public void removeStrings(VString v)
Deprecated.use removeStrings(v, Integer.MAX_VALUE);removeStrings - remove all occurrences of a string- Parameters:
v-
-
removeStrings
public void removeStrings(VString v, int nMax)
removeStrings - remove all occurrences of a string- Parameters:
v- the vector of strings to remove fromthisnMax- the max number of strings to remove
-
removeStrings
@Deprecated public void removeStrings(java.lang.String s)
Deprecated.use removeStrings(s, Integer.MAX_VALUE);removeStrings - remove all occurrences of a string- Parameters:
s-
-
removeStrings
public void removeStrings(java.lang.String s, int nMax)removeStrings - remove nMax occurrences of a string- Parameters:
s- the string to removenMax- remove s max. nMax times , 0 or negative = infinite
-
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
-
setvString
@Deprecated public java.lang.String setvString(VString v, java.lang.String sep, java.lang.String front, java.lang.String end)
Deprecated.use getStringcreate a string from a vector of tokens- Parameters:
v- vector of tokenssep- separator between tokensfront- prefix to string (before the first token)end- suffix to string (after the last token)- Returns:
- condensed string of tokens separated by sep
-
unify
public void unify()
unify - make VString unique, retaining initial order
-
get
public java.lang.String get(java.lang.String s)
get a string fromthis- Parameters:
s- the String you are looking for- Returns:
- the String if found or null if
thisdoes not contain s
-
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
-
sort
public void sort()
sortthislexically
-
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(VString 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 VString getOverlapping(VString 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
-
add
public boolean add(org.apache.commons.lang.enums.ValuedEnum enumType)
appends enumType tothis
if enumType is a ValuedEnum, the name is appended- Parameters:
enumType- the object to append- Returns:
- true if successfully added
-
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.Vector<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-
-
-