From a54ef6ee1c86fa3cd6a3bb53a869e404517697a6 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 20 Nov 2006 13:28:34 +0000 Subject: [PATCH] Fix filtering files if start date is before any existing record date --- .../impl/history/HistoryReaderImpl.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java index c81208482..0ab2f44b4 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java @@ -731,14 +731,25 @@ else if(endDate == null) { // end date is null get all the inclusive the one record before the startdate Long startLong = new Long(startDate.getTime()); - files.add(startLong); - resultAsLong.addAll(files.subSet(startLong, files.last())); - resultAsLong.add(files.last()); + if(files.size() > 0 && + (startLong.longValue() < ((Long)files.first()).longValue())) + { + // if the start date is before any existing file date + // then return all the files + resultAsLong = files; + } + else + { + files.add(startLong); - // here we must get and the element before startLong - resultAsLong.add(files.subSet(files.first(), startLong).last()); - resultAsLong.remove(startLong); + resultAsLong.addAll(files.subSet(startLong, files.last())); + resultAsLong.add(files.last()); + + // here we must get and the element before startLong + resultAsLong.add(files.subSet(files.first(), startLong).last()); + resultAsLong.remove(startLong); + } } else {