--- /dev/null
+// CvsEntry.java\r
+// $Id: CvsEntry.java,v 1.1 2010/06/15 12:28:47 smhuang Exp $ \r
+// (c) COPYRIGHT MIT and INRIA, 1997.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.cvs2;\r
+\r
+import java.io.File;\r
+\r
+class CvsEntry {\r
+ /**\r
+ * Is that entry a directory ?\r
+ */\r
+ boolean isdir = false;\r
+ /**\r
+ * The file or directory this entry describes.\r
+ */\r
+ protected String name = null;\r
+\r
+ protected String revision = null;\r
+ /**\r
+ * the sticy options\r
+ */\r
+ protected String sticky_options = null;\r
+ /**\r
+ * The most recent CVS status obtained for this entry.\r
+ */\r
+ protected int status = -1;\r
+ /**\r
+ * The time at which we last updated the status.\r
+ */\r
+ protected long timestamp = -1;\r
+ /**\r
+ * Our CVS directory manager.\r
+ */\r
+ protected CvsDirectory cvs = null;\r
+ /**\r
+ * Our underlying file.\r
+ */\r
+ protected File file = null;\r
+\r
+ /**\r
+ * Set this entry current status.\r
+ * @param timestamp Date at which the CVS command was initiated.\r
+ * @param status The new status for this entry.\r
+ */\r
+\r
+ protected synchronized void setStatus(long timestamp, int status) {\r
+ this.timestamp = Math.min(file.lastModified(), timestamp);\r
+ this.status = status;\r
+ }\r
+\r
+ /**\r
+ * Get this entry status.\r
+ * @return An integer describing the CVS status of that entry.\r
+ */\r
+\r
+ protected synchronized int getStatus() {\r
+ return status;\r
+ }\r
+\r
+ protected synchronized void setRevision(String revision) {\r
+ this.revision = revision;\r
+ }\r
+\r
+ protected synchronized String getRevision() {\r
+ return revision;\r
+ } \r
+\r
+ protected synchronized String getStickyOptions() {\r
+ return sticky_options;\r
+ }\r
+\r
+ protected synchronized void setStickyOptions(String st_opt) {\r
+ sticky_options = st_opt;\r
+ }\r
+\r
+ /**\r
+ * Does this entry needs updating ?\r
+ * This method checks the current timestamp for that entry against the\r
+ * last modified date of the file to check if it needs a status update.\r
+ * It also check the repository file stamp.\r
+ * @return A boolean, <strong>true</strong> if the some cvs command \r
+ * required.\r
+ */\r
+\r
+ protected synchronized boolean needsUpdate() {\r
+ File dirrep = cvs.computeRepositoryDirectory(cvs.getDirectory());\r
+ if (dirrep == null)\r
+ return (timestamp < file.lastModified());\r
+\r
+ File filrep = new File(dirrep, file.getName()+",v");\r
+ return (((filrep != null) && filrep.exists())\r
+ ? ((timestamp < filrep.lastModified()) \r
+ || (timestamp < file.lastModified()))\r
+ : (timestamp < file.lastModified()));\r
+ }\r
+\r
+ CvsEntry(CvsDirectory cvs\r
+ , long timestamp\r
+ , String name\r
+ , boolean isdir\r
+ , int status) {\r
+ this.cvs = cvs;\r
+ this.timestamp = timestamp;\r
+ this.file = new File(cvs.getDirectory(), name);\r
+ this.name = name;\r
+ this.isdir = isdir;\r
+ this.status = status;\r
+ }\r
+\r
+ \r
+}\r