assert(endDate != null); // because the condition list is nonempty
ProvenanceCondition versions = new ProvenanceCondition();
for (int iVersion = 0; iVersion < versionIndex.size(); iVersion++) {
Version version = versionIndex.get(iVersion);
boolean matches = true;
if (dateOp != null) {
if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordAfter)) {
matches = version.time() > startDate.getTime();
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordBefore)) {
matches = version.time() < endDate.getTime();
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordSince)) {
matches = version.time() >= startDate.getTime();
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordUntil)) {
matches = version.time() <= endDate.getTime();
} else if (dateOp.equalsIgnoreCase(XAQLSyntaxParser.KeywordBetween)) {
matches = ((version.time() >= startDate.getTime()) && (version.time() <= endDate.getTime()));
}
}
if ((matches) && (username != null) ) {
if (version.provenance().user() != null) {
matches = version.provenance().user().login().equals(username);
} else { // unknown user differs from any specific user name
matches = false;
}
}
if ((matches) && (provenanceType != Provenance.ProvenanceTypeUnknown)) {
matches = (version.provenance().type() == provenanceType);
}
if (matches) {
versions.add(version);
}
}