Está en: | Home >> ISDirValidator >> ISDirValidator Presentation | Jueves 3 de Abril de 2025 |
![]() | ![]() |
|
ISDirValidatorIsDirValidator is an utility and Ant´s task to validate directory structures. It permit to define directorys and what files can exist. The situation that this utility whan to handle is the fullfil of the requeriments about the structure of the folders in computers that provide hosting of applications. An example:<taskdef name="isdirectory" classname="com.inigoserrano.isdirvalidator.ISDirectory"/> <taskdef name="isfile" classname="com.inigoserrano.isdirvalidator.ISFile"/> <taskdef name="isfilepatterm" classname="com.inigoserrano.isdirvalidator.ISFilePatterm"/> <taskdef name="issubdirectorypatterm" classname="com.inigoserrano.isdirvalidator.ISSubDirectoryPatterm"/> <isdirectory dir="folder" /> <isdirectory dir="..\ISDirCheck\" recursive="yes" > <isfile file="build.xml" required="yes" /> <isfile file="Definition.txt" required="no" /> <isfilePatterm filePatterm="^[a-z]+\.txt$" /> <isfilePatterm filePatterm=".*\.xml$" /> <issubdirectoryPatterm directoryPatterm="^[a-zA-Z]+$" /> </isdirectory> The frist task is the simplest form and checks that the directory "folder" exist. It takes the basedir of the Ant's project as the path The second task chack that the directory "ISDirCheck" exist. It takes the parent of the ant´s basedir as the path. It also check that some conditions are fullfill:
If exist one file that dosen´t fullfill at least one of this conditions then it is an error If the attribute recursive is on the all the subdirectories must fill all the conditions of the parent. For example if exist the files:
If the file "build.xml" dosen´t exist it is also an error. The use of regular expressions is provided by the RegExp packaque of http://jakarta.apache.org in the version 1.2. You can obtain more information about this package in the web Another example of use coud be the definition of the structure of a Servlet's WAR folder (This example is not complet) <isdirectory dir="${path}"> <isfilePatterm filePatterm="^[a-zA-Z]+\.jsp$" /> <isfilePatterm filePatterm="^[a-zA-Z]+\.html$" /> </isdirectory> <isdirectory dir="${path}/META-INF"> <isfile file="MANIFEST.MF" required="yes" /> </isdirectory> <isdirectory dir="${path}/WEB-INF"> <isfile file="web.xml" required="yes" /> <isfilePatterm filePatterm="^[a-zA-Z-]+\.tld$" /> </isdirectory> <isdirectory dir="${path}/WEB-INF/classes" recursive="yes" > <isfilePatterm filePatterm="^[:alnum:]+\.properties$" /> <isfilePatterm filePatterm="^[:alnum:]+\.class$" /> <issubdirectoryPatterm directoryPatterm="^[a-zA-Z]+$" /> </isdirectory> Version 2Version 2 of this packaqe adds the support of subdirectorypatter and the recursive attribute and some minors changes to fix bugs. The recursive and required attributes have been changed to support the conventions of Ant (yes, true or no) to activate it. InstalationTo install this package you must put the ISDirValitator and the regExp in the CLASSPATH DownloadYou can download IsDirValidator in the general download page |
|