Source code: com/fm/rss/comparator/rssTitleComparator.java
1 /****************************************************************************
2 * Copyright (c) 2003 Andrew Duka | aduka@users.sourceforge.net
3 * All right reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 ****************************************************************************/
11 package com.fm.rss.comparator;
12
13 import com.fm.rss.rssItem;
14
15 /**
16 * Compares RSS items by title
17 *
18 * @author Andrew Duka
19 */
20 public class rssTitleComparator extends RssItemComparator
21 {
22 public int compare(Object o1, Object o2) {
23 if (o1 == o2)
24 return 0;
25
26 if ((o1 == null) & (o2 != null))
27 return -1;
28
29 if ((o2 == null) & (o1 != null))
30 return 1;
31
32 if ((o1 instanceof rssItem) & !(o2 instanceof rssItem))
33 return 1;
34
35 if (!(o1 instanceof rssItem) & (o2 instanceof rssItem))
36 return -1;
37
38 return ((rssItem) o1).getTitle().compareTo(((rssItem) o2).getTitle());
39 }
40
41 public boolean equals(Object o) {
42 return false;
43 }
44 }