aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/history
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2014-03-10 11:31:19 +0200
committerDamian Minkov <damencho@jitsi.org>2014-03-10 11:32:13 +0200
commit8a8b05170cb8c3e5feb10d2b52be45a0782c26e2 (patch)
treec0c6d228bc44b24846758cf004f4d17ee69c8b52 /src/net/java/sip/communicator/impl/history
parent220bcbf20bf84c9e7ad2dc2d06ef19fe93a394b8 (diff)
downloadjitsi-8a8b05170cb8c3e5feb10d2b52be45a0782c26e2.zip
jitsi-8a8b05170cb8c3e5feb10d2b52be45a0782c26e2.tar.gz
jitsi-8a8b05170cb8c3e5feb10d2b52be45a0782c26e2.tar.bz2
Adds possible subtype of stored messages, and option to filter them by this subtype.
Diffstat (limited to 'src/net/java/sip/communicator/impl/history')
-rw-r--r--src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java
index f1159e53..3c872e7 100644
--- a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java
+++ b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java
@@ -165,6 +165,27 @@ public class HistoryReaderImpl
public synchronized QueryResultSet<HistoryRecord> findLast(int count)
throws RuntimeException
{
+ return findLast(count, null, null, false);
+ }
+
+ /**
+ * Returns the supplied number of recent messages
+ * containing all <tt>keywords</tt>.
+ *
+ * @param count messages count
+ * @param keywords array of keywords we search for
+ * @param field the field where to look for the keyword
+ * @param caseSensitive is keywords search case sensitive
+ * @return the found records
+ * @throws RuntimeException
+ */
+ public synchronized QueryResultSet<HistoryRecord> findLast(
+ int count,
+ String[] keywords,
+ String field,
+ boolean caseSensitive)
+ throws RuntimeException
+ {
// the files are supposed to be ordered from oldest to newest
Vector<String> filelist =
filterFilesByDate(this.historyImpl.getFileList(), null, null);
@@ -227,37 +248,14 @@ public class HistoryReaderImpl
timestamp = new Date(Long.parseLong(ts));
}
- ArrayList<String> nameVals = new ArrayList<String>();
+ HistoryRecord record =
+ filterByKeyword(propertyNodes, timestamp,
+ keywords, field, caseSensitive);
- int len = propertyNodes.getLength();
- for (int j = 0; j < len; j++)
+ if(record != null)
{
- Node propertyNode = propertyNodes.item(j);
- if (propertyNode.getNodeType() == Node.ELEMENT_NODE)
- {
- // Get nested TEXT node's value
- Node nodeValue = propertyNode.getFirstChild();
-
- if(nodeValue == null)
- continue;
-
- nameVals.add(propertyNode.getNodeName());
- nameVals.add(nodeValue.getNodeValue());
- }
- }
-
- String[] propertyNames = new String[nameVals.size() / 2];
- String[] propertyValues = new String[propertyNames.length];
- for (int j = 0; j < propertyNames.length; j++)
- {
- propertyNames[j] = nameVals.get(j * 2);
- propertyValues[j] = nameVals.get(j * 2 + 1);
+ result.add(record);
}
-
- HistoryRecord record = new HistoryRecord(propertyNames,
- propertyValues, timestamp);
-
- result.add(record);
}
currentFile--;