Class 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 VString emptyVector
      Deprecated.
      grab your own...
      • Fields inherited from class java.util.Vector

        capacityIncrement, elementCount, elementData
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      VString()
      constructor
      VString​(java.lang.String strIn)
      convenience - constructs a VString by tokenizing a string
      VString​(java.lang.String[] a)
      creates a VString from an array of Strings
      VString​(java.lang.String strIn, java.lang.String strSep)
      constructs a VString by tokenizing a string
      VString​(java.util.Collection<java.lang.String> m)
      constructor
      VString​(java.util.Enumeration<java.lang.String> a)
      creates a VString from an Enumeration of Strings
      VString​(java.util.Vector<java.lang.String> v)
      constructor
      VString​(VString v)
      constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean add​(org.apache.commons.lang.enums.ValuedEnum enumType)
      appends enumType to this
      if enumType is a ValuedEnum, the name is appended
      void addAll​(java.lang.String[] strings)
      appends all strings of an array to this
      void addNonEmpty​(java.lang.String text)
      add a string if it is not empty
      void appendUnique​(java.lang.String string)
      AppendUnique - append a string but ignore multiple entries
      void appendUnique​(java.util.Collection<java.lang.String> v)
      AppendUnique - append a vector but ignore multiple entries
      void appendUnique​(VString v)
      AppendUnique - append a vector but ignore multiple entries
      boolean containsAny​(java.util.Collection<java.lang.String> others)
      checks whether at least one of a given vector of strings is contained in this
      boolean containsAny​(VString others)  
      java.lang.String elementAt​(int index)  
      java.lang.String get​(int index)  
      java.lang.String get​(java.lang.String s)
      get a string from this
      java.lang.String getAllStrings()
      Deprecated.
      use getString(JDFConstants.BLANK,null,null)
      java.lang.String getAllStrings​(java.lang.String strSep)
      Deprecated.
      use getString(strSep,null,null)
      VString getOverlapping​(java.util.Collection<java.lang.String> others)
      vector of strings that is contained in this
      java.util.Set<java.lang.String> getSet()
      gets a set with all entries of the VString
      note that the set retains ordering (LinkedHashSet)
      java.lang.String getString()
      serialize to a string
      java.lang.String getString​(java.lang.String sep, java.lang.String front, java.lang.String back)
      serialize to a string
      static VString getVString​(java.lang.String strIn, java.lang.String strSep)
      simple static factory - null if strIn is null or empty
      static VString getVString​(java.util.Collection<java.lang.String> c)
      simple static factory - null if strIn is null or empty
      boolean hasString​(java.lang.String s)
      Deprecated.
      2005-02-14 use contains ...
      int index​(java.lang.String s)
      index - get the index of s in the vector
      static boolean isEmpty​(java.util.Collection<java.lang.String> v)
      are we null or empty or contain only an empty JDFAttributeMap
      static boolean isEmpty​(VString v)
      are we null or empty or contain only an empty JDFAttributeMap
      java.lang.String remove​(int index)
      remove but also implementing the usual neg number syntax
      void removeStrings​(java.lang.String s)
      Deprecated.
      use removeStrings(s, Integer.MAX_VALUE);
      void removeStrings​(java.lang.String s, int nMax)
      removeStrings - remove nMax occurrences of a string
      void removeStrings​(java.util.Collection<java.lang.String> v, int nMax)
      removeStrings - remove all occurrences of a set of string
      void removeStrings​(VString v)
      Deprecated.
      use removeStrings(v, Integer.MAX_VALUE);
      void setAllStrings​(java.lang.String strIn, java.lang.String strSep)
      Method setAllStrings - put a separated string into the vString
      e.g.
      java.lang.String setvString​(VString v, java.lang.String sep, java.lang.String front, java.lang.String end)
      Deprecated.
      use getString
      void sort()
      sort this lexically
      java.lang.String stringAt​(int index)
      Deprecated.
      - simply use get
      java.lang.String toString()
      toString
      void unify()
      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
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
    • Field Detail

      • emptyVector

        @Deprecated
        public static final VString emptyVector
        Deprecated.
        grab your own... this is a potential leak, since it can be modified
        the empty VString
    • Constructor Detail

      • VString

        public VString()
        constructor
      • VString

        public VString​(java.util.Collection<java.lang.String> m)
        constructor
        Parameters:
        m -
      • VString

        public VString​(java.util.Vector<java.lang.String> v)
        constructor
        Parameters:
        m -
      • VString

        public VString​(VString v)
        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 tokenize
        strSep - 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​(java.util.Collection<java.lang.String> v)
        are we null or empty or contain only an empty JDFAttributeMap
        Parameters:
        v -
        Returns:
      • 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:
        elementAt in class java.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:
        get in interface java.util.List<java.lang.String>
        Overrides:
        get in class java.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:
        toString in class java.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 string
        strSep - 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 of this?
        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
      • 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
      • 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​(java.util.Collection<java.lang.String> v,
                                  int nMax)
        removeStrings - remove all occurrences of a set of string
        Parameters:
        v - the vector of strings to remove from this
        nMax - 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 remove
        nMax - 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 strings
        front - string before the first entry
        back - string after the last entry
        Returns:
        a tokenized string
      • getString

        public java.lang.String getString()
        serialize to a string
        Parameters:
        sep - separator between strings
        front - string before the first entry
        back - 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 getString
        create a string from a vector of tokens
        Parameters:
        v - vector of tokens
        sep - separator between tokens
        front - 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 from this
        Parameters:
        s - the String you are looking for
        Returns:
        the String if found or null if this does 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()
        sort this lexically
      • addAll

        public void addAll​(java.lang.String[] strings)
        appends all strings of an array to this
        Parameters:
        strings - the array of strings to append to this
      • containsAny

        public boolean containsAny​(java.util.Collection<java.lang.String> others)
        checks whether at least one of a given vector of strings is contained in this
        Parameters:
        others - the VSTring of values to test
        Returns:
        true if at least one String in other is in this
      • containsAny

        public boolean containsAny​(VString others)
      • getOverlapping

        public VString getOverlapping​(java.util.Collection<java.lang.String> others)
        vector of strings that is contained in this
        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 to this
        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:
        remove in interface java.util.List<java.lang.String>
        Overrides:
        remove in class java.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 -