1 17 package org.apache.excalibur.source.impl.validity; 18 19 import java.io.File ; 20 21 import org.apache.excalibur.source.SourceValidity; 22 23 29 public final class FileTimeStampValidity 30 implements SourceValidity 31 { 32 private long m_timeStamp; 33 private File m_file; 34 35 public FileTimeStampValidity( final String filename ) 36 { 37 this( new File ( filename ) ); 38 } 39 40 public FileTimeStampValidity( final File file ) 41 { 42 this( file, file.lastModified() ); 43 } 44 45 public FileTimeStampValidity( final File file, 46 final long timeStamp ) 47 { 48 m_file = file; 49 m_timeStamp = timeStamp; 50 } 51 52 59 public int isValid() 60 { 61 return ( m_file.lastModified() == m_timeStamp ? 1 : -1 ); 62 } 63 64 public int isValid( final SourceValidity newValidity ) 65 { 66 if( newValidity instanceof FileTimeStampValidity ) 67 { 68 final long timeStamp = 69 ( (FileTimeStampValidity)newValidity ).getTimeStamp(); 70 return ( m_timeStamp == timeStamp ? 1 : -1); 71 } 72 return -1; 73 } 74 75 public File getFile() 76 { 77 return this.m_file; 78 } 79 80 public long getTimeStamp() 81 { 82 return this.m_timeStamp; 83 } 84 85 public String toString() 86 { 87 return "FileTimeStampValidity: " + m_file.getPath() + ": " + this.m_timeStamp; 88 } 89 } 90 | Popular Tags |