1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
package tim.prune.function.filesleuth.data;
import java.io.File;
import tim.prune.function.filesleuth.SearchResult;
/** Represents a single track file which may or may not have been read yet */
public class TrackFile
{
private final File _file;
private final String _pathString;
private TrackFileStatus _status;
private TrackContents _contents = null;
private int _index = 0;
public TrackFile(File inFile)
{
_file = inFile;
_pathString = inFile.getAbsolutePath().toLowerCase().trim();
_status = TrackFileStatus.FOUND;
}
public File getFile() {
return _file;
}
public TrackFileStatus getStatus() {
return _status;
}
public void setStatus(TrackFileStatus inStatus) {
_status = inStatus;
}
public void setContents(TrackContents inContents) {
_contents = inContents;
}
public boolean hasContents() {
return _contents != null;
}
public String getNameOrDescription() {
return hasContents() ? _contents.getNameOrDescription() : "";
}
public boolean matchesFilename(String inFilter)
{
if (inFilter == null || inFilter.equals("")) {
return true;
}
return _pathString.contains(inFilter);
}
public boolean matchesStringFilter(String inFilter, SearchResult inResult)
{
inResult.setContents(_contents == null ? "" : _contents.getNameOrDescription());
if (inFilter == null || inFilter.equals("")) {
return true;
}
if (_contents != null && _contents.getNumStrings() > 0)
{
for (String s : _contents.getStrings())
{
if (s.contains(inFilter))
{
inResult.setIsMatch(true);
inResult.setContents(s);
return true;
}
}
}
return false;
}
public boolean matchesDateFilter(DateRange inRange) {
return _contents == null || _contents.matchesDateFilter(inRange);
}
public void setIndex(int inIndex) {
_index = inIndex;
}
public int getIndex() {
return _index;
}
public boolean matchesLocationFilter(LocationFilter inFilter) {
return _contents == null || _contents.matchesLocationFilter(inFilter);
}
}
|