org.apache.maven.plugin.war.util
Class PathSet

java.lang.Object
  extended by org.apache.maven.plugin.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 /.

Version:
$Id: PathSet.html 868453 2013-07-05 11:25:41Z olamy $
Author:
Piotr Tabor

Constructor Summary
PathSet()
          Creates an empty paths set
PathSet(Collection<String> paths)
          Creates paths set and normalizate and adds all 'paths'.
PathSet(String[] paths)
          Creates paths set and normalizate and adds all 'paths'.
 
Method Summary
 void add(String path)
          Normalizes and adds given path to the set.
 void addAll(Collection<String> paths)
          Normalizes and adds given paths (collection of strings) to the set.
 void addAll(Collection<String> paths, String prefix)
          Normalizes and adds given paths (collection of strings) to the set.
 void addAll(PathSet paths)
          Adds given paths to the set.
 void addAll(PathSet paths, String prefix)
          Adds given paths to the set.
 void addAll(String[] paths)
          Normalizes and adds given paths to the set.
 void addAll(String[] paths, String prefix)
          Normalizes and adds given paths to the set.
 void addAllFilesInDirectory(File directory, String prefix)
          Adds to the set all files in the given directory
 void addPrefix(String prefix)
          Adds given prefix to all paths in the set.
 boolean contains(String path)
          Checks if the set constains given path.
 Iterator<String> iterator()
          Returns iterator of normalized paths (strings)
protected  String normalizeFilePath(String path)
          The method normalizes the path.
static String normalizeFilePathStatic(String path)
          The method normalizes the path.
 Collection<String> paths()
           
 int size()
          Returns count of the paths in the set
static String trimTrailingSlashes(String str)
          The method deletes all trailing slashes from the given string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

normalizeFilePath

protected String normalizeFilePath(String path)
The method normalizes the path.

Parameters:
path - to normalization
Returns:
normalized 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.

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()

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

normalizeFilePathStatic

public static String normalizeFilePathStatic(String path)
The method normalizes the path.

Parameters:
path - to normalization
Returns:
normalized path

trimTrailingSlashes

public static String trimTrailingSlashes(String str)
The method deletes all trailing slashes from the given string

Parameters:
str - a string
Returns:
trimed string


Copyright © 2002–2013 The Apache Software Foundation. All rights reserved.