## org.w3c.cvs
Class CvsDirectory

    java.lang.Object
      |
      +--org.w3c.cvs.CvsDirectory

public class CvsDirectory
extends java.lang.Object
implements LRUAble, CVS

Field Summary
`protected static java.util.Hashtable` | `cache` Our cache of existing CVS managers.
`protected static int` | `cachesize` Our recommended cache size.
`protected boolean` | `clean` Has this directory manager been cleaned up (removed from cache).
`protected long` | `cvscheck_stamp` The time at which we last checked the cvs status of that directory.
`static java.lang.String` | `cvspath_def` The default CVS path.
`static java.lang.String` | `CVSPATH_P` Property giving the path of the cvs binary.
`protected long` | `cvsrep_stamp` The time at which we last examined the repository for this directory.
`static java.lang.String` | `cvsroot_def` The default CVS root path.
`static java.lang.String` | `CVSROOT_P` Property giving your CVS repository.
`static java.lang.String` | `cvswrap_def` The default CVS wrapper path.
`static java.lang.String` | `CVSWRAP_P` Property giving the path of the cvswrapper.
`static java.util.Properties` | `defprops`
`protected java.io.File` | `directory` The directory we manage.
`protected java.util.Hashtable` | `entries` Known CVS entries (files)
`protected static LRUList` | `lru` All CVS entries are LRU maintained too.
`protected LRUAble` | `next` LRU management - next entry.
`protected LRUAble` | `prev` LRU management - previous entry.
`java.util.Properties` | `props` The properties we use for initialization.
`protected java.io.File` | `repdir` The corresponding repository directory (when available).
`protected org.w3c.cvs.CvsRunner` | `runner` Our associated CvsRunner.

Constructor Summary
`protected` | `CvsDirectory(java.io.File directory, java.util.Properties props, java.lang.String cvspath, java.lang.String cvsroot, java.lang.String[] cvswrap)` Create a new CVS manager for the given directory.

Method Summary
`void` | `add(java.lang.String[] names)` Add the given file to the CVS repository.
`void` | `add(java.lang.String[] names, java.lang.String[] env)` Add the given file to the CVS repository.
`void` | `addRegexp(java.lang.String regexp, java.lang.String[] env)` Add the file matching the given regular expression to the CVS repository.
`void` | `admin(java.lang.String[] command)` Perform a RCS request.
`protected void` | `cacheLoaded()` This directory manager is being fetched from the cache.
`protected static void` | `cacheUnload()` Remove a directory manager from the cache.
`protected void` | `checkDirectoryUse()` This directory manager is about to be used for sub-directories.
`protected void` | `checkDirectoryUse(java.lang.String subdir)` This directory manager is about to be used for the given sub-directory.
`protected void` | `checkUse()` This directory manager is about to be used, check it.
`protected void` | `checkUse(java.lang.String filename)` That file in the directory is about to be used, check its status.
`void` | `commit(java.lang.String msg)` Commit pending actions to all that directory content.
`void` | `commit(java.lang.String[] names, java.lang.String msg)` Commit pending actions on given file.
`void` | `commit(java.lang.String[] names, java.lang.String msg, java.lang.String[] env)` Commit pending actions on given file.
`void` | `commit(java.lang.String file, java.lang.String msg)` Commit pending actions on given file.
`void` | `commit(java.lang.String msg, java.lang.String[] env)` Commit pending actions to all that directory content.
`void` | `commit(java.lang.String file, java.lang.String msg, java.lang.String[] env)` Commit pending actions on given file.
`void` | `commitRegexp(java.lang.String regexp, java.lang.String comment, java.lang.String[] env)` Commit pending actions on files matching the given regular expression.
`protected void` | `createDirectoryEntry(long timestamp, java.lang.String name, int status)`
`protected void` | `createFileEntry(long timestamp, java.lang.String name, int status)`
`java.lang.String` | `diff(java.lang.String filename)` Get the diff of given file against repository.
`void` | `display(java.io.PrintStream prt)` Display the status of the entries in that directory.
`void` | `get(java.lang.String path)` Perform a cvs get
`protected java.lang.String[]` | `getCvsDefaults()`
`protected java.lang.String[]` | `getCvsWrapper()`
`java.io.File` | `getDirectory()` Get the directory controlled by this manager.
`protected org.w3c.cvs.CvsEntry` | `getDirectoryEntry(java.lang.String filename)` Look for a sub-directory entry.
`int` | `getDirectoryStatus(java.lang.String subdir)` Get a sub-directory status.
`int` | `getDirectoryStatus(java.lang.String subdir, boolean update)` Get a sub-directory status.
`protected org.w3c.cvs.CvsEntry` | `getFileEntry(java.lang.String filename)` Look for a file entry.
`protected static CvsDirectory` | `getManager(CvsDirectory father, java.io.File dir)`
`static CvsDirectory` | `getManager(java.io.File directory)` Get a CvsDirectory.
`static CvsDirectory` | `getManager(java.io.File directory, java.util.Properties props)`
`static CvsDirectory` | `getManager(java.io.File directory, java.util.Properties props, java.lang.String cvspath, java.lang.String cvsroot, java.lang.String[] cvswrap)` Get a CvsDirectory.
`LRUAble` | `getNext()` LRU management - Get next node.
`LRUAble` | `getPrev()` LRU management - Get previous node.
`java.util.Enumeration` | `listDirectories()` List available sub-directories of that directory.
`java.util.Enumeration` | `listFiles()` List all available file entries in that directory.
`java.lang.String` | `log(java.lang.String filename)` Get the log associated to the given file.
`static void` | `main(java.lang.String[] args)`
`protected boolean` | `needsUpdate()` Does this directory needs some CVS update ?
`void` | `refresh()` Refresh the file entries for that directory.
`protected void` | `refresh(java.lang.String filename)` Refresh the file entries for that filename.
`protected void` | `refreshRevision(java.lang.String filename)` Refresh the file entry revision number for that filename.
`protected void` | `refreshStatus(java.lang.String filename)` Refresh the file entry status for that filename.
`void` | `remove(java.lang.String[] names, java.lang.String msg, java.lang.String[] env)` Remove the given file from the repository.
`protected void` | `removeFileEntry(java.lang.String filename)`
`void` | `revert(java.lang.String filename, java.io.OutputStream out, java.lang.String revision, java.lang.String[] env)` Revert the file, make the given revision the current one.
`void` | `revert(java.lang.String filename, java.lang.String revision, java.lang.String msg, java.lang.String[] env)` Revert the file, make the given revision the current one.
`java.lang.String` | `revision(java.lang.String filename)` Get the revision number of the given file.
`void` | `setNext(LRUAble next)` LRU management - Set next node.
`void` | `setPrev(LRUAble prev)` LRU management - Set previous node.
`int` | `status(java.lang.String filename)` Get the status of a file entry.
`int` | `status(java.lang.String filename, boolean refresh)` Get the status of a file entry.
`static java.lang.String` | `statusToString(int st)`
`void` | `update()` Update all that directory's content.
`void` | `update(java.lang.String file)` Update this file from the repository.
`void` | `update(java.lang.String[] files)` Update these files from the repository.
`void` | `updateDirectory(java.lang.String subdir)` Check out, or update a sub-directory.
`void` | `updateRegexp(java.lang.String regexp)` Update thes files matching the given regular expression from the repository.
`static void` | `usage()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CVSPATH_P

    public static final java.lang.String CVSPATH_P

  Property giving the path of the cvs binary. This property should be set to the absolute path to the cvs command in your local environment.

  This property defaults to `/usr/local/bin/cvs`.

### CVSROOT_P

    public static final java.lang.String CVSROOT_P

  Property giving your CVS repository. This property should be set to the absolute path of your repository.

  This property defaults to `/afs/w3.org/pub/WWW`.

### CVSWRAP_P

    public static final java.lang.String CVSWRAP_P

  Property giving the path of the cvswrapper. Because CVS can't run without being in the right directory, this classes use a shell script wrapper to issue cvs commands, that will change directory appropriately.

  You should have gotten this wrapper in the distribution `bin` directory.

  This property defaults to `/afs/w3.org/usr/abaird/Jigsaw/bin/cvs_wrapper`.

### cvspath_def

    public static final java.lang.String cvspath_def

  The default CVS path.

### cvsroot_def

    public static final java.lang.String cvsroot_def

  The default CVS root path.

### cvswrap_def

    public static final java.lang.String cvswrap_def

  The default CVS wrapper path.

### cache

    protected static java.util.Hashtable cache

  Our cache of existing CVS managers. Maps absolute directory names to appropriate CvsDirectory instance.

### lru

    protected static LRUList lru

  All CVS entries are LRU maintained too.

### cachesize

    protected static int cachesize

  Our recommended cache size.

### prev

    protected LRUAble prev

  LRU management - previous entry.

### next

    protected LRUAble next

  LRU management - next entry.

### cvscheck_stamp

    protected long cvscheck_stamp

  The time at which we last checked the cvs status of that directory.

### cvsrep_stamp

    protected long cvsrep_stamp

  The time at which we last examined the repository for this directory.

### clean

    protected boolean clean

  Has this directory manager been cleaned up (removed from cache).

### directory

    protected java.io.File directory

  The directory we manage.

### repdir

    protected java.io.File repdir

  The corresponding repository directory (when available).

### entries

    protected java.util.Hashtable entries

  Known CVS entries (files)

### runner

    protected org.w3c.cvs.CvsRunner runner

  Our associated CvsRunner.

### props

    public java.util.Properties props

  The properties we use for initialization.

### defprops

    public static java.util.Properties defprops

Constructor Detail

### CvsDirectory

    protected CvsDirectory(java.io.File directory,
                           java.util.Properties props,
                           java.lang.String cvspath,
                           java.lang.String cvsroot,
                           java.lang.String[] cvswrap)
                    throws CvsException

  Create a new CVS manager for the given directory.
  Parameters:
    `directory` - The directory for which a manager is to be created.
    `props` - The cvs properties.
    `cvspath` - The absolute path of the cvs program.
    `cvsroot` - The absolute path of the CVS repository.
    `cvswrap` - The absolute path of the cvs wrapper program
  Throws:
    CvsException - If some initialisation failed

Method Detail

### getCvsWrapper

    protected java.lang.String[] getCvsWrapper()

### getCvsDefaults

    protected java.lang.String[] getCvsDefaults()

### createFileEntry

    protected void createFileEntry(long timestamp,
                                   java.lang.String name,
                                   int status)

### createDirectoryEntry

    protected void createDirectoryEntry(long timestamp,
                                        java.lang.String name,
                                        int status)

### getManager

    public static CvsDirectory getManager(java.io.File directory,
                                          java.util.Properties props,
                                          java.lang.String cvspath,
                                          java.lang.String cvsroot,
                                          java.lang.String[] cvswrap)
                                   throws CvsException

  Get a CvsDirectory.
  Parameters:
    `directory` - The CVS directory.
    `props` - The cvs properties.
    `cvspath` - The absolute path of the cvs program.
    `cvsroot` - The absolute path of the CVS repository.
    `cvswrap` - The absolute path of the cvs wrapper program
  Returns:
    A CvsDirectory instance.
  Throws:
    CvsException - If some initialisation failed

### getManager

    public static CvsDirectory getManager(java.io.File directory)
                                   throws CvsException

  Get a CvsDirectory.
  Parameters:
    `directory` - The CVS directory
  Returns:
    A CvsDirectory instance.
  Throws:
    CvsException - If some initialisation failed

### getManager

    public static CvsDirectory getManager(java.io.File directory,
                                          java.util.Properties props)
                                   throws CvsException

  Parameters:
    `directory` - The CVS directory.
    `props` - The cvs properties.
  Returns:
    A CvsDirectory instance.
  Throws:
    CvsException - If some initialisation failed

### getManager

    protected static CvsDirectory getManager(CvsDirectory father,
                                             java.io.File dir)
                                      throws CvsException

  Parameters:
    `father` - The father CvsDirectory.
    `directory` - The CVS directory.
  Returns:
    A CvsDirectory instance.
  Throws:
    CvsException - If some initialisation failed

### getNext

    public LRUAble getNext()

  LRU management - Get next node.
  Specified by:
    getNext in interface LRUAble
  Returns:
    A CvsDirectory instance.

### getPrev

    public LRUAble getPrev()

  LRU management - Get previous node.
  Specified by:
    getPrev in interface LRUAble
  Returns:
    A CvsDirectory instance.

### setNext

    public void setNext(LRUAble next)

  LRU management - Set next node.
  Specified by:
    setNext in interface LRUAble
  Returns:
    A CvsDirectory instance.

### setPrev

    public void setPrev(LRUAble prev)

  LRU management - Set previous node.
  Specified by:
    setPrev in interface LRUAble
  Returns:
    A CvsDirectory instance.

### statusToString

    public static java.lang.String statusToString(int st)

### cacheLoaded

    protected void cacheLoaded()
                        throws CvsException

  This directory manager is being fetched from the cache. Perform any action before we return it back to the user.
  Throws:
    CvsException - If some CVS action fails during reinitialization.

### cacheUnload

    protected static void cacheUnload()

  Remove a directory manager from the cache. Clear al references to other objects in order to free up memory even if the caller maintains a pointer to the manager.

### getFileEntry

    protected org.w3c.cvs.CvsEntry getFileEntry(java.lang.String filename)

  Look for a file entry.
  Parameters:
    `filename` - The name of the entry to look for.

### removeFileEntry

    protected void removeFileEntry(java.lang.String filename)

### getDirectoryEntry

    protected org.w3c.cvs.CvsEntry getDirectoryEntry(java.lang.String filename)

  Look for a sub-directory entry.
  Parameters:
    `filename` - The name of the entry to look for.

### refresh

    public void refresh()
                 throws CvsException

  Refresh the file entries for that directory.
  Throws:
    CvsException - If the underlying CVS command failed.

### refresh

    protected void refresh(java.lang.String filename)
                    throws CvsException

  Refresh the file entries for that filename.
  Throws:
    CvsException - If the underlying CVS command failed.

### refreshStatus

    protected void refreshStatus(java.lang.String filename)
                          throws CvsException

  Refresh the file entry status for that filename.
  Throws:
    CvsException - If the underlying CVS command failed.

### refreshRevision

    protected void refreshRevision(java.lang.String filename)
                            throws CvsException

  Refresh the file entry revision number for that filename.
  Throws:
    CvsException - If the underlying CVS command failed.

### checkUse

    protected void checkUse()
                     throws CvsException

  This directory manager is about to be used, check it.
  Throws:
    CvsException - If some CVS error occurs in that process.

### checkUse

    protected void checkUse(java.lang.String filename)
                     throws CvsException

  That file in the directory is about to be used, check its status.
  Parameters:
    `filename` - The name of the entry that is about to be used.
  Throws:
    CvsException - If a CVS error occurs.

### checkDirectoryUse

    protected void checkDirectoryUse()
                              throws CvsException

  This directory manager is about to be used for sub-directories.
  Throws:
    CvsException - If a CVS error occurs.

### checkDirectoryUse

    protected void checkDirectoryUse(java.lang.String subdir)
                              throws CvsException

  This directory manager is about to be used for the given sub-directory. (Really really faster than checkDirectoryUse())
  Throws:
    CvsException - If a CVS error occurs.

### needsUpdate

    protected boolean needsUpdate()

  Does this directory needs some CVS update ?

### listFiles

    public java.util.Enumeration listFiles()
                                    throws CvsException

  List all available file entries in that directory. This method will list all possible files:
  - The ones that exist but are not in the repository.
  - The ones that are in the repository but not in local space.
  - All the other ones.
  Returns:
    An enumeration listing zero or more String instances.
  Throws:
    CvsException - If some CVS error occured while examining the cvs status of entries.

### listDirectories

    public java.util.Enumeration listDirectories()
                                          throws CvsException

  List available sub-directories of that directory. This method will list of possible directories. If access to the repository is permitted, it will look into that to get a list of unchecked out directories, otherwise, it will just list the checked out ones.
  Returns:
    An enumeration listing zero or more File instances.
  Throws:
    CvsException - If some CVS error occured while examining the cvs status of entries.

### status

    public int status(java.lang.String filename,
                      boolean refresh)
               throws CvsException

  Get the status of a file entry.
  Parameters:
    `filename` - The file whose status is to be fetched.
    `refresh` - Should we refresh the status?
  Returns:
    A integer status indicating the CVS status of that file within the repository.
  Throws:
    CvsException - If some CVS error occured while examining the cvs status of entries.

### status

    public int status(java.lang.String filename)
               throws CvsException

  Get the status of a file entry.
  Parameters:
    `filename` - The file whose status is to be fetched.
  Returns:
    A integer status indicating the CVS status of that file within the repository.
  Throws:
    CvsException - If some CVS error occured while examining the cvs status of entries.

### revision

    public java.lang.String revision(java.lang.String filename)
                              throws CvsException

  Get the revision number of the given file.
  Parameters:
    `filename` - The File name
  Returns:
    A String instance
  Throws:
    CvsException - if some CVS errors occurs

### update

    public void update(java.lang.String[] files)
                throws CvsException

  Update these files from the repository.
  Parameters:
    `files` - The name of the files to update (as a String array).
  Throws:
    CvsException - If CVS process failed.

### update

    public void update(java.lang.String file)
                throws CvsException

  Update this file from the repository.
  Parameters:
    `file` - The name of the file to update (as a String).
  Throws:
    CvsException - If CVS process failed.

### update

    public void update()
                throws CvsException

  Update all that directory's content. (not recursivly).
  Throws:
    CvsException - If some CVS error occured during update.

### updateRegexp

    public void updateRegexp(java.lang.String regexp)
                      throws CvsException

  Update thes files matching the given regular expression from the repository.
  Parameters:
    `files` - The name of the files to update (as a String array).
  Throws:
    CvsException - If CVS process failed.

### get

    public void get(java.lang.String path)
             throws CvsException

  Perform a cvs get
  Parameters:
    `path` - the file (or directory) path
  Throws:
    CvsException - If CVS process failed.

### commit

    public void commit(java.lang.String[] names,
                       java.lang.String msg,
                       java.lang.String[] env)
                throws CvsException

  Commit pending actions on given file.
  Parameters:
    `names` - The name of the files to commit.
    `msg` - The associated message.
    `env` - The extra env to use during commit.
  Throws:
    CvsException - If some error occured during the CVS process.

### commit

    public void commit(java.lang.String file,
                       java.lang.String msg,
                       java.lang.String[] env)
                throws CvsException

  Commit pending actions on given file.
  Parameters:
    `file` - The file to commit.
    `msg` - The associated message.
    `env` - The extra env to use during commit.
  Throws:
    CvsException - If some error occured during the CVS process.

### commit

    public void commit(java.lang.String[] names,
                       java.lang.String msg)
                throws CvsException

  Commit pending actions on given file.
  Parameters:
    `names` - The name of the files to commit.
    `msg` - The associated message.
  Throws:
    CvsException - If some error occured during the CVS process.

### commit

    public void commit(java.lang.String file,
                       java.lang.String msg)
                throws CvsException

  Commit pending actions on given file.
  Parameters:
    `file` - The file to commit.
    `msg` - The associated message.
  Throws:
    CvsException - If some error occured during the CVS process.

### commit

    public void commit(java.lang.String msg)
                throws CvsException

  Commit pending actions to all that directory content.
  Parameters:
    `msg` - The associated message.
  Throws:
    CvsException - If some CVS error occurs during the CVS process.

### commit

    public void commit(java.lang.String msg,
                       java.lang.String[] env)
                throws CvsException

  Commit pending actions to all that directory content.
  Parameters:
    `msg` - The associated message.
    `env` - The extra environment.
  Throws:
    CvsException - If some CVS error occurs during the CVS process.

### commitRegexp

    public void commitRegexp(java.lang.String regexp,
                             java.lang.String comment,
                             java.lang.String[] env)
                      throws CvsException

  Commit pending actions on files matching the given regular expression.
  Parameters:
    `regexp` - The regular expresion.
    `msg` - The associated message.
    `env` - The extra env to use during commit.
  Throws:
    CvsException - If some error occured during the CVS process.

### revert

    public void revert(java.lang.String filename,
                       java.lang.String revision,
                       java.lang.String msg,
                       java.lang.String[] env)
                throws CvsException

  Revert the file, make the given revision the current one.
  - First remove the file
  - perform a cvs update -p -r <revision>
  Parameters:
    `filename` - The name of the file to revert.
    `revision` - The revision number to get.
    `msg` - The associated message.
    `env` - The extra environment.
  Throws:
    CvsException - If some CVS error occurs during the CVS process.

### revert

    public void revert(java.lang.String filename,
                       java.io.OutputStream out,
                       java.lang.String revision,
                       java.lang.String[] env)
                throws CvsException

  Revert the file, make the given revision the current one.
  - First remove the file
  - perform a cvs update -p -r <revision>
  Parameters:
    `filename` - The name of the file to revert.
    `revision` - The revision number to get.
    `out` - The output stream. (reverted file will be written in)
    `env` - The extra environment.
  Throws:
    CvsException - If some CVS error occurs during the CVS process.

### log

    public java.lang.String log(java.lang.String filename)
                         throws CvsException

  Get the log associated to the given file.
  Parameters:
    `filename` - The name of the file whose log is to be fetched.
  Throws:
    CvsException - If some CVS error occurs in the process.

### diff

    public java.lang.String diff(java.lang.String filename)
                          throws CvsException

  Get the diff of given file against repository.
  Parameters:
    `filename` - The name of the file to diff.
  Returns:
    The diffs has a String, or null if the file is in sync with the repository.
  Throws:
    CvsException - If some CVS exception occurs within the process.

### add

    public void add(java.lang.String[] names)
             throws CvsException

  Add the given file to the CVS repository. The addition will have to be commited through a commit of the same file before taking effect.
  Parameters:
    `names` - The name of the files to add.
  Throws:
    CvsException - If some CVS error occurs during the process.

### add

    public void add(java.lang.String[] names,
                    java.lang.String[] env)
             throws CvsException

  Add the given file to the CVS repository. The addition will have to be commited through a commit of the same file before taking effect.
  Parameters:
    `names` - The name of the files to add.
    `env` - The extra env to use during the process.
  Throws:
    CvsException - If some CVS error occurs during the process.

### addRegexp

    public void addRegexp(java.lang.String regexp,
                          java.lang.String[] env)
                   throws CvsException

  Add the file matching the given regular expression to the CVS repository. The addition will have to be commited through a commit of the same file before taking effect.
  Parameters:
    `regexp` - The regular expression.
    `env` - The extra env to use during the process.
  Throws:
    CvsException - If some CVS error occurs during the process.

### remove

    public void remove(java.lang.String[] names,
                       java.lang.String msg,
                       java.lang.String[] env)
                throws CvsException

  Remove the given file from the repository.
  Parameters:
    `names` - The files to be removed.
  Throws:
    CvsException - If some CVS error occurs during that process.

### admin

    public void admin(java.lang.String[] command)
               throws CvsException

  Perform a RCS request.
  Parameters:
    `command` - the rcs command splitted in a string array.
  Throws:
    CvsException - If some CVS error occurs during that process.

### display

    public void display(java.io.PrintStream prt)

  Display the status of the entries in that directory.
  Parameters:
    `prt` - A print stream to print to.

### getDirectoryStatus

    public int getDirectoryStatus(java.lang.String subdir)
                           throws CvsException

  Get a sub-directory status.
  Parameters:
    `subdir` - The name of the subdirectory.
  Returns:
    An integer CVS status for the given sub-directory.
  Throws:
    CvsException - if the CVS process failed.

### getDirectoryStatus

    public int getDirectoryStatus(java.lang.String subdir,
                                  boolean update)
                           throws CvsException

  Get a sub-directory status.
  Parameters:
    `subdir` - The name of the subdirectory.
    `update` - If true update all directory entries.
  Returns:
    An integer CVS status for the given sub-directory.
  Throws:
    CvsException - if the CVS process failed.

### updateDirectory

    public void updateDirectory(java.lang.String subdir)
                         throws CvsException

  Check out, or update a sub-directory.
  Parameters:
    `subdir` - The sub directory to update.
  Throws:
    CvsException - If the CVS process failed.

### getDirectory

    public java.io.File getDirectory()

  Get the directory controlled by this manager.
  Returns:
    A File instance locating the directory.

### usage

    public static void usage()

### main

    public static void main(java.lang.String[] args)