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

java.lang.Object
  extended by org.apache.maven.plugin.war.util.PathSet

public class PathSet
extends Object

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.java 791368 2009-07-06 04:08:27Z snicoll $
Author:
Piotr Tabor

Constructor Summary
PathSet()
          Creates an empty paths set
PathSet(Collection 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 paths)
          Normalizes and adds given paths (collection of strings) to the set.
 void addAll(Collection 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 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.
 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 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 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 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 iterator()
Returns iterator of normalized paths (strings)

Returns:
iterator of normalized paths (strings)

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-2012 The Apache Software Foundation. All Rights Reserved.