Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.inigoserrano.isdirvalidator
Class Directory  view Directory download Directory.java

java.lang.Object
  extended bycom.inigoserrano.isdirvalidator.Directory

public class Directory
extends java.lang.Object

This class check the structure of the disk. It check that the fisical disk hasnīt files that dosenīt fit any conditions (file and filePatterm conditions). It also check that the files that are required exisit in the ficial disk. And also check... that the directory exisits :-) If no file and filePatterm conditions are provided then it only check that the directory exisit.

Esta utilidad comprueba que en el disco no exista más ficheros que los que se declaran como parametros a la clase, pero puede que en los parámetros se indiquen más ficheros que los que existen en el disco y esto no se consiera un error. Se puede indicar que un determinado fichero es obligatorio y si ese fichero no existe se considerara como un error.
This program is license under the terms of the GNU GPL v 2.0 License

Version:
2.0.1

Field Summary
private  java.lang.String directory
          The directory to check
private  boolean directoryError
          Boolean to indicate that the error is because a directory dosnīt exist in the fisical directory
private  boolean extraFileError
          Boolean to indicate that the error is because in the fisical directory exist one file that dosenīt match any condition
private  boolean extraSubDirectoryError
          Boolean to indicate that the error is because in the fisical directory exist one subdirectory that dosnīt match any condition
private  java.util.Hashtable filesStore
          Hashtable to store all the names of file that are permited
private  java.lang.String invalidFile
          The name of the file in the directory that dosenīt fit the conditions
private  java.lang.String invalidSubDirectory
          The name of the subDirectory in the directory that dosnīt fit the conditions
private  boolean obligatoryFileError
          Boolean to indicate that the error is because a file that is indicated to be required dosenīt exisit in the fisical directory
private  java.util.Vector pattermStore
          Vector to store all the patterms that are permited the diferents files
private  java.util.Vector subDirectoryPattermStore
          Vector to store all the patterms that are permited the diferents subDirectories
 
Constructor Summary
Directory()
           
 
Method Summary
 void addFile(java.lang.String newFile)
          Add a new file name in the conditions

Aņade un nuevo nombre de fichero al almacen
 void addFile(java.lang.String newFile, boolean mustExist)
          Add a new file name in the conditions
 void addFilePatterm(java.lang.String newPatterm)
          Add a new file patterm in the conditions

Aqui le voy aņadiendo los patrones a cumplir
 void addSubDirectoryPatterm(java.lang.String newPatterm)
          Add a new subDirectory patterm in the conditions

Aqui le voy aņadiendo los patrones a cumplir
private  boolean checkAllTheFileConditions()
          Check all the files in the directory.
private  boolean checkAllTheSubDirectoriesConditions()
          Check all the subdirectories in the directory.
private  boolean checkOneFile(java.lang.String newFile)
          Check that the file passed as argument exist in the fisical disk and match at least one condition.
private  boolean checkOneFileByPatterm(java.lang.String oneFile)
          Check one file with all the patterm conditions.
private  boolean checkOneSubDirectory(java.lang.String oneSubDirectory)
          Check one subDirectory with all the patterm conditions.
private  boolean existDirectory()
          Check that the directory exist in the fisical disk (and is a directory).
private  boolean existFile(java.lang.String oneFile)
          It check that the file match at least one file condition (addFile())
 java.lang.String getDirectory()
          Gets the fisical directory, with its path
 java.lang.String getInvalidFile()
          To indicate what is the name of the file that dosenīt match any condition
 java.lang.String getInvalidSubDirectory()
          To indicate what is the name of the subDirectory that dosenīt match any condition
 boolean isDirectoryError()
          To indicate that the error is because in the fisical directory dosnīt exist the directory
 boolean isExtraFileError()
          To indicate that the error is because in the fisical directory exist one file that dosenīt match any condition
 boolean isExtraSubDirectoryError()
          To indicate that the error is because in the fisical directory exist one subDirectory that dosnīt match any condition
 boolean isObligatoryFileError()
          To indicate that the error is because in the fisical directory dosnīt exist one file that is required
 boolean isValid()
          Check if the directory is valid or not.
 void setDirectory(java.lang.String newDirectory)
          Set the directory , with its path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

directory

private java.lang.String directory
The directory to check


pattermStore

private java.util.Vector pattermStore
Vector to store all the patterms that are permited the diferents files


subDirectoryPattermStore

private java.util.Vector subDirectoryPattermStore
Vector to store all the patterms that are permited the diferents subDirectories


filesStore

private java.util.Hashtable filesStore
Hashtable to store all the names of file that are permited


invalidFile

private java.lang.String invalidFile
The name of the file in the directory that dosenīt fit the conditions


invalidSubDirectory

private java.lang.String invalidSubDirectory
The name of the subDirectory in the directory that dosnīt fit the conditions


extraSubDirectoryError

private boolean extraSubDirectoryError
Boolean to indicate that the error is because in the fisical directory exist one subdirectory that dosnīt match any condition


extraFileError

private boolean extraFileError
Boolean to indicate that the error is because in the fisical directory exist one file that dosenīt match any condition


obligatoryFileError

private boolean obligatoryFileError
Boolean to indicate that the error is because a file that is indicated to be required dosenīt exisit in the fisical directory


directoryError

private boolean directoryError
Boolean to indicate that the error is because a directory dosnīt exist in the fisical directory

Constructor Detail

Directory

public Directory()
Method Detail

isValid

public boolean isValid()
Check if the directory is valid or not. The conditions to be valid is:
  • The directory must exist in the fisical disk
  • Each file in the fisical disk must mach at least one condition indicated in the file or filePatterm
  • The files indicated to be required must exist in the fisical disk
  • Each subDirectory in the fisical disk must mach at least one condition indicated in the subDirectoryPatterm

isExtraFileError

public boolean isExtraFileError()
To indicate that the error is because in the fisical directory exist one file that dosenīt match any condition


isExtraSubDirectoryError

public boolean isExtraSubDirectoryError()
To indicate that the error is because in the fisical directory exist one subDirectory that dosnīt match any condition


isDirectoryError

public boolean isDirectoryError()
To indicate that the error is because in the fisical directory dosnīt exist the directory


isObligatoryFileError

public boolean isObligatoryFileError()
To indicate that the error is because in the fisical directory dosnīt exist one file that is required


getInvalidFile

public java.lang.String getInvalidFile()
To indicate what is the name of the file that dosenīt match any condition


getInvalidSubDirectory

public java.lang.String getInvalidSubDirectory()
To indicate what is the name of the subDirectory that dosenīt match any condition


checkAllTheFileConditions

private boolean checkAllTheFileConditions()
Check all the files in the directory. If no file conditions or filePatterm conditions is provided then return true, because it asumes that the user only want to check that the directory exist.

Compruebo todos los ficheros del directorio, tanto que encajen en un fichero o que encajen en un patron. Si no se expecifica ni ficheros ni patrones se devuelve true, porque se considera que solo se quiere comprobar que exista el directorio.


checkAllTheSubDirectoriesConditions

private boolean checkAllTheSubDirectoriesConditions()
Check all the subdirectories in the directory. If no subDirectoryPatterm conditions is provided then return true, because it asumes that the user dosnīt want to use this function.

Compruebo todos los subdirectorios del directorio, que encajen en un patron. Si no se expecifican patrones se devuelve true, porque se considera que no se quiere utilizar esta caracteristica.


checkOneFile

private boolean checkOneFile(java.lang.String newFile)
Check that the file passed as argument exist in the fisical disk and match at least one condition.

Compruebo un fichero del directorio. Si ese fichero no está en la lista de ficheros a comprobar ni encaja con ningun patron entonces es un error


existFile

private boolean existFile(java.lang.String oneFile)
It check that the file match at least one file condition (addFile())


checkOneFileByPatterm

private boolean checkOneFileByPatterm(java.lang.String oneFile)
Check one file with all the patterm conditions. If the file match at least one then return true, else return false

Compruebo un fichero con todos los patrones, si no encaja en ninguno entonces es un fallo y devuelvo false


checkOneSubDirectory

private boolean checkOneSubDirectory(java.lang.String oneSubDirectory)
Check one subDirectory with all the patterm conditions. If the subDirectory match at least one then return true, else return false

Compruebo un subDirectorio con todos los patrones, si no encaja en ninguno entonces es un fallo y devuelvo false


existDirectory

private boolean existDirectory()
Check that the directory exist in the fisical disk (and is a directory).

Comprueba si existe el directorio (existe y es directorio)


addFile

public void addFile(java.lang.String newFile,
                    boolean mustExist)
Add a new file name in the conditions


addFile

public void addFile(java.lang.String newFile)
Add a new file name in the conditions

Aņade un nuevo nombre de fichero al almacen


addFilePatterm

public void addFilePatterm(java.lang.String newPatterm)
                    throws org.apache.regexp.RESyntaxException
Add a new file patterm in the conditions

Aqui le voy aņadiendo los patrones a cumplir


addSubDirectoryPatterm

public void addSubDirectoryPatterm(java.lang.String newPatterm)
                            throws org.apache.regexp.RESyntaxException
Add a new subDirectory patterm in the conditions

Aqui le voy aņadiendo los patrones a cumplir


getDirectory

public java.lang.String getDirectory()
Gets the fisical directory, with its path


setDirectory

public void setDirectory(java.lang.String newDirectory)
Set the directory , with its path