Class PathSet

java.lang.Object
org.apache.maven.plugins.war.util.PathSet
All Implemented Interfaces:
Iterable<String>

public class PathSet extends Object implements Iterable<String>
Set of file's paths. The class extends functionality of a "normal" set of strings by a process of the paths normalization. All paths are converted to unix form (slashes) and they don't start with starting /.
  • Field Details

    • SEPARATOR

      private static final String SEPARATOR
      See Also:
    • SEPARATOR_CHAR

      private static final char SEPARATOR_CHAR
    • pathsSet

      private Set<String> pathsSet
      Set of normalized paths
  • Constructor Details

    • PathSet

      public PathSet()
      Creates an empty paths set
    • PathSet

      public PathSet(Collection<String> paths)
      Creates paths set and normalizate and adds all 'paths'. The source 'paths' will not be changed
      Parameters:
      paths - to be added
    • PathSet

      public PathSet(String[] paths)
      Creates paths set and normalizate and adds all 'paths'. The source 'paths' will not be changed
      Parameters:
      paths - to be added
  • Method Details

    • normalizeSubPath

      static String normalizeSubPath(String path)
    • add

      public void add(String path)
      Normalizes and adds given path to the set.
      Parameters:
      path - to be added
    • addAll

      public void addAll(Collection<String> paths, String prefix)
      Normalizes and adds given paths (collection of strings) to the set. The source collection will not be changed
      Parameters:
      paths - - collection of strings to be added
      prefix - added to all given paths
    • addAll

      public void addAll(String[] paths, String prefix)
      Normalizes and adds given paths to the set. The source collection will not be changed
      Parameters:
      paths - to be added
      prefix - added to all given paths
    • addAll

      public void addAll(PathSet paths, String prefix)
      Adds given paths to the set. The source collection will not be changed
      Parameters:
      paths - to be added
      prefix - added to all given paths
    • addAll

      public void addAll(Collection<String> paths)
      Normalizes and adds given paths (collection of strings) to the set. The source collection will not be changed
      Parameters:
      paths - - collection of strings to be added
    • addAll

      public void addAll(String[] paths)
      Normalizes and adds given paths to the set. The source collection will not be changed
      Parameters:
      paths - to be added
    • addAll

      public void addAll(PathSet paths)
      Adds given paths to the set. The source collection will not be changed
      Parameters:
      paths - to be added
    • contains

      public boolean contains(String path)
      Checks if the set constains given path. The path is normalized before check.
      Parameters:
      path - we are looking for in the set.
      Returns:
      information if the set constains the path.
    • remove

      boolean remove(String path)
      Removes the specified path if it exists.
      Parameters:
      path - the path to remove
      Returns:
      true if the path was removed, false if it did not existed
    • iterator

      public Iterator<String> iterator()
      Returns iterator of normalized paths (strings)
      Specified by:
      iterator in interface Iterable<String>
      Returns:
      iterator of normalized paths (strings)
    • paths

      public Collection<String> paths()
      Returns:
      pathsSet
    • addPrefix

      public void addPrefix(String prefix)
      Adds given prefix to all paths in the set. The prefix should be ended by '/'. The generated paths are normalized.
      Parameters:
      prefix - to be added to all items
    • size

      public int size()
      Returns count of the paths in the set
      Returns:
      count of the paths in the set
    • addAllFilesInDirectory

      public void addAllFilesInDirectory(File directory, String prefix)
      Adds to the set all files in the given directory
      Parameters:
      directory - that will be searched for file's paths to add
      prefix - to be added to all found files