001: // CvsEntry.java
002: // $Id: CvsEntry.java,v 1.26 2003/06/06 14:21:11 ylafon Exp $
003: // (c) COPYRIGHT MIT and INRIA, 1997.
004: // Please first read the full copyright statement in file COPYRIGHT.html
005:
006: package org.w3c.cvs;
007:
008: import java.io.File;
009:
010: class CvsEntry {
011: /**
012: * Is that entry a directory ?
013: */
014: boolean isdir = false;
015: /**
016: * The file or directory this entry describes.
017: */
018: protected String name = null;
019:
020: protected String revision = null;
021: /**
022: * the sticy options
023: */
024: protected String sticky_options = null;
025: /**
026: * The most recent CVS status obtained for this entry.
027: */
028: protected int status = -1;
029: /**
030: * The time at which we last updated the status.
031: */
032: protected long timestamp = -1;
033: /**
034: * Our CVS directory manager.
035: */
036: protected CvsDirectory cvs = null;
037: /**
038: * Our underlying file.
039: */
040: protected File file = null;
041:
042: /**
043: * Set this entry current status.
044: * @param timestamp Date at which the CVS command was initiated.
045: * @param status The new status for this entry.
046: */
047:
048: protected synchronized void setStatus(long timestamp, int status) {
049: this .timestamp = Math.min(file.lastModified(), timestamp);
050: this .status = status;
051: }
052:
053: /**
054: * Get this entry status.
055: * @return An integer describing the CVS status of that entry.
056: */
057:
058: protected synchronized int getStatus() {
059: return status;
060: }
061:
062: protected synchronized void setRevision(String revision) {
063: this .revision = revision;
064: }
065:
066: protected synchronized String getRevision() {
067: return revision;
068: }
069:
070: protected synchronized String getStickyOptions() {
071: return sticky_options;
072: }
073:
074: protected synchronized void setStickyOptions(String st_opt) {
075: sticky_options = st_opt;
076: }
077:
078: /**
079: * Does this entry needs updating ?
080: * This method checks the current timestamp for that entry against the
081: * last modified date of the file to check if it needs a status update.
082: * It also check the repository file stamp.
083: * @return A boolean, <strong>true</strong> if the some cvs command
084: * required.
085: */
086:
087: protected synchronized boolean needsUpdate() {
088: File dirrep = cvs
089: .computeRepositoryDirectory(cvs.getDirectory());
090: if (dirrep == null)
091: return (timestamp < file.lastModified());
092:
093: File filrep = new File(dirrep, file.getName() + ",v");
094: return (((filrep != null) && filrep.exists()) ? ((timestamp < filrep
095: .lastModified()) || (timestamp < file.lastModified()))
096: : (timestamp < file.lastModified()));
097: }
098:
099: CvsEntry(CvsDirectory cvs, long timestamp, String name,
100: boolean isdir, int status) {
101: this .cvs = cvs;
102: this .timestamp = timestamp;
103: this .file = new File(cvs.getDirectory(), name);
104: this.name = name;
105: this.isdir = isdir;
106: this.status = status;
107: }
108:
109: }
|