ddiff
Version 1.0.0

com.ehsbe.ddiff
Class Dir

java.lang.Object
  extended by com.ehsbe.ddiff.DirEntry
      extended by com.ehsbe.ddiff.Dir

public class Dir
extends DirEntry

Internal directory worker and representation.

Version:
$Revision: 393 $
Author:
Jens Elkner

Nested Class Summary
Modifier and Type Class and Description
 
Nested classes/interfaces inherited from class com.ehsbe.ddiff.DirEntry
DirEntry.Type
 
Field Summary
Modifier and Type Field and Description
 
Fields inherited from class com.ehsbe.ddiff.DirEntry
attr, opath, path
 
Constructor Summary
Modifier Constructor and Description
  Dir(java.nio.file.Path dir, boolean follow, String[] exclude_globs, Pattern[] exclude_regex, boolean hidden)
          Convinience constructor to create a new directory worker instance.
  Dir(java.nio.file.Path dir, PathFilter filter)
          Create a new directory worker instance.
protected Dir(java.nio.file.Path dir, PathFilter filter, java.nio.file.attribute.BasicFileAttributes attrs)
          Create a new directory worker instance.
 
Method Summary
Modifier and Type Method and Description
 int getCount()
          Get the number of entries for this instance.
 int getDirCount()
          Get the number of sub directories for this instance.
 TreeMap<String,Dir> getDirMap()
          Get a map of all sub directories, keyed by their basename.
 Dir[] getDirs()
          Get a copy of the list of all sub directory entries for this instance sorted by its name.
 DirEntry[] getEntries()
          Get a copy of the list of all entries for this instance grouped by sub directories and none-sub directories, sorted by its name.
 int getNoDirCount()
          Get the number of none-sub directories for this instance.
 TreeMap<String,DirEntry> getNoDirMap()
          Get a map of all none-sub directories, keyed by their basename.
 DirEntry[] getNoDirs()
          Get a copy of the list of all none-sub directory entries for this instance sorted by its name.
 boolean isEmpty()
          Check, whether this instance contains dir entries.
 void list(PrintStream out, String format, com.ehsbe.ddiff.Analyzer.Result result, StringBuilder prefix, boolean recursive)
          List all entries of this instance (directories first), ordered by its name.
 
Methods inherited from class com.ehsbe.ddiff.DirEntry
getName, getType, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dir

public Dir(java.nio.file.Path dir,
           boolean follow,
           String[] exclude_globs,
           Pattern[] exclude_regex,
           boolean hidden)
Convinience constructor to create a new directory worker instance.

Parameters:
dir - the anchor for this instance
follow - if true folow symlinks
exclude_globs - globbing patterns for pathnames to ignore. Might be null.
exclude_regex - regex patterns for pathnames to ignore. Might be null.
hidden - if true ignore hidden entries as well
Throws:
IllegalArgumentException - if the given path is null
See Also:
PathFilter, DirEntry

Dir

public Dir(java.nio.file.Path dir,
           PathFilter filter)
Create a new directory worker instance.

Parameters:
dir - the anchor for this instance
filter - exclude filter
Throws:
IllegalArgumentException - if the given path is null
See Also:
PathFilter, DirEntry

Dir

protected Dir(java.nio.file.Path dir,
              PathFilter filter,
              java.nio.file.attribute.BasicFileAttributes attrs)
Create a new directory worker instance.

Parameters:
dir - the anchor for this instance
filter - exclude filter
attrs - the file attributes associated with this instance. If null, gets determined automatically, using the LinkOption.NOFOLLOW_LINKS.
Throws:
IllegalArgumentException - if the given path is null
See Also:
DirEntry, PathFilter
Method Detail

getDirCount

public int getDirCount()
Get the number of sub directories for this instance.

Returns:
the number of sub directories.

getDirs

public Dir[] getDirs()
Get a copy of the list of all sub directory entries for this instance sorted by its name.

Returns:
a possibly empty array

getDirMap

public TreeMap<String,Dir> getDirMap()
Get a map of all sub directories, keyed by their basename.

Returns:
a possibly empty map.

getNoDirCount

public int getNoDirCount()
Get the number of none-sub directories for this instance.

Returns:
the number of none-sub directories

getNoDirs

public DirEntry[] getNoDirs()
Get a copy of the list of all none-sub directory entries for this instance sorted by its name.

Returns:
a possibly empty array

getNoDirMap

public TreeMap<String,DirEntry> getNoDirMap()
Get a map of all none-sub directories, keyed by their basename.

Returns:
a possibly empty map.

getCount

public int getCount()
Get the number of entries for this instance.

Returns:
the number of entries

getEntries

public DirEntry[] getEntries()
Get a copy of the list of all entries for this instance grouped by sub directories and none-sub directories, sorted by its name.

Returns:
a possibly empty array

isEmpty

public boolean isEmpty()
Check, whether this instance contains dir entries.

Returns:
true, if this instance contains at least on entry.

list

public void list(PrintStream out,
                 String format,
                 com.ehsbe.ddiff.Analyzer.Result result,
                 StringBuilder prefix,
                 boolean recursive)
List all entries of this instance (directories first), ordered by its name. Per contract the given prefix must have the same content on return as on enter.

Parameters:
out - where to write the list
format - format to use for printing. Must accept 4 %s. Ignored if null or result is null..
result - result to print, when printing formatted entries. Ignored if null of format is null.
prefix - prefix, which should be used for each print out.
recursive - if true, cycle through sub directoeries as well.

ddiff
Version 1.0.0

Created by Jens Elkner