Java Doc for DirectoryScanner.java in  » XML-UI » XUI » net » xoetrope » builder » editor » ant » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » XUI » net.xoetrope.builder.editor.ant 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.xoetrope.builder.editor.ant.DirectoryScanner

DirectoryScanner
public class DirectoryScanner (Code)
Class for scanning a directory for files/directories that match a certain criteria.

These criteria consist of a set of include and exclude patterns. With these patterns, you can select which files you want to have included, and which files you want to have excluded.

The idea is simple. A given directory is recursively scanned for all files and directories. Each file/directory is matched against a set of include and exclude patterns. Only files/directories that match at least one pattern of the include pattern list, and don't match a pattern of the exclude pattern list will be placed in the list of files/directories found.

When no list of include patterns is supplied, "**" will be used, which means that everything will be matched. When no list of exclude patterns is supplied, an empty list is used, such that nothing will be excluded.

The pattern matching is done as follows: The name to be matched is split up in path segments. A path segment is the name of a directory or file, which is bounded by File.separator ('/' under UNIX, '\' under Windows). E.g. "abc/def/ghi/xyz.java" is split up in the segments "abc", "def", "ghi" and "xyz.java". The same is done for the pattern against which should be matched.

Then the segments of the name and the pattern will be matched against each other. When '**' is used for a path segment in the pattern, then it matches zero or more path segments of the name.

There are special case regarding the use of File.separators at the beginningof the pattern and the string to match:
When a pattern starts with a File.separator, the string to match must also start with a File.separator. When a pattern does not start with a File.separator, the string to match may not start with a File.separator. When one of these rules is not obeyed, the string will not match.

When a name path segment is matched against a pattern path segment, the following special characters can be used: '*' matches zero or more characters, '?' matches one character.

Examples:

"**\*.class" matches all .class files/dirs in a directory tree.

"test\a??.java" matches all files/dirs which start with an 'a', then two more characters and then ".java", in a directory called test.

"**" matches everything in a directory tree.

"**\test\**\XYZ*" matches all files/dirs that start with "XYZ" and where there is a parent directory called test (e.g. "abc\test\def\ghi\XYZ123").

Example of usage:

 String[] includes = {"**\\*.class"};
 String[] excludes = {"modules\\*\\**"};
 ds.setIncludes(includes);
 ds.setExcludes(excludes);
 ds.setBasedir(new File("test"));
 ds.scan();
 System.out.println("FILES:");
 String[] files = ds.getIncludedFiles();
 for (int i = 0; i < files.length;i++) {
 System.out.println(files[i]);
 }
 
This will scan a directory called test for .class files, but excludes all .class files in all directories under a directory called "modules"
author:
   Arnout J. Kuiper ajkuiper@wxs.nl



Constructor Summary
public  DirectoryScanner()
     Constructor.

Method Summary
public  voidaddDefaultExcludes()
     Adds the array with default exclusions to the current exclusions set.
public  FilegetBasedir()
     Gets the basedir that is used for scanning.
public  String[]getExcludedDirectories()
     Get the names of the directories that matched at least one of the include patterns, an matched also at least one of the exclude patterns.
public  String[]getExcludedFiles()
     Get the names of the files that matched at least one of the include patterns, an matched also at least one of the exclude patterns.
public  String[]getIncludedDirectories()
     Get the names of the directories that matched at least one of the include patterns, an matched none of the exclude patterns.
public  String[]getIncludedFiles()
     Get the names of the files that matched at least one of the include patterns, an matched none of the exclude patterns.
public  String[]getNotIncludedDirectories()
     Get the names of the directories that matched at none of the include patterns.
public  String[]getNotIncludedFiles()
     Get the names of the files that matched at none of the include patterns.
public  voidscan()
     Scans the base directory for files that match at least one include pattern, and don't match any exclude patterns.
public  voidsetBasedir(String basedir)
     Sets the basedir for scanning.
public  voidsetBasedir(File basedir)
     Sets the basedir for scanning.
public  voidsetExcludes(String[] excludes)
     Sets the set of exclude patterns to use.
public  voidsetIncludes(String[] includes)
     Sets the set of include patterns to use.


Constructor Detail
DirectoryScanner
public DirectoryScanner()(Code)
Constructor.




Method Detail
addDefaultExcludes
public void addDefaultExcludes()(Code)
Adds the array with default exclusions to the current exclusions set.
See Also:   DirectoryScanner.DEFAULTEXCLUDES



getBasedir
public File getBasedir()(Code)
Gets the basedir that is used for scanning. This is the directory that is scanned recursively. the basedir that is used for scanning



getExcludedDirectories
public String[] getExcludedDirectories()(Code)
Get the names of the directories that matched at least one of the include patterns, an matched also at least one of the exclude patterns. The names are relative to the basedir. the names of the directories



getExcludedFiles
public String[] getExcludedFiles()(Code)
Get the names of the files that matched at least one of the include patterns, an matched also at least one of the exclude patterns. The names are relative to the basedir. the names of the files



getIncludedDirectories
public String[] getIncludedDirectories()(Code)
Get the names of the directories that matched at least one of the include patterns, an matched none of the exclude patterns. The names are relative to the basedir. the names of the directories



getIncludedFiles
public String[] getIncludedFiles()(Code)
Get the names of the files that matched at least one of the include patterns, an matched none of the exclude patterns. The names are relative to the basedir. the names of the files



getNotIncludedDirectories
public String[] getNotIncludedDirectories()(Code)
Get the names of the directories that matched at none of the include patterns. The names are relative to the basedir. the names of the directories



getNotIncludedFiles
public String[] getNotIncludedFiles()(Code)
Get the names of the files that matched at none of the include patterns. The names are relative to the basedir. the names of the files



scan
public void scan()(Code)
Scans the base directory for files that match at least one include pattern, and don't match any exclude patterns.
exception:
  IllegalStateException - when basedir was set incorrecly



setBasedir
public void setBasedir(String basedir)(Code)
Sets the basedir for scanning. This is the directory that is scanned recursively. All '/' and '\' characters are replaced by File.separatorChar. So the separator used need not match File.separatorChar.
Parameters:
  basedir - the (non-null) basedir for scanning



setBasedir
public void setBasedir(File basedir)(Code)
Sets the basedir for scanning. This is the directory that is scanned recursively.
Parameters:
  basedir - the basedir for scanning



setExcludes
public void setExcludes(String[] excludes)(Code)
Sets the set of exclude patterns to use. All '/' and '\' characters are replaced by File.separatorChar. So the separator used need not match File.separatorChar.

When a pattern ends with a '/' or '\', "**" is appended.
Parameters:
  excludes - list of exclude patterns




setIncludes
public void setIncludes(String[] includes)(Code)
Sets the set of include patterns to use. All '/' and '\' characters are replaced by File.separatorChar. So the separator used need not match File.separatorChar.

When a pattern ends with a '/' or '\', "**" is appended.
Parameters:
  includes - list of include patterns




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.