mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-21 00:00:13 +02:00
5e31bad711
all unique links! This made it necessary, that a large portion of the parser and link processing classes must be adopted to carry a different type of link collection which carry a property attribute which are attached to web anchors. - introduction of a new URL class, AnchorURL - the other url classes, DigestURI and MultiProtocolURI had been renamed and refactored to fit into a new document package schema, document.id - cleanup of net.yacy.cora.document package and refactoring
35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
package net.yacy.data.ymark;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import net.yacy.cora.document.encoding.UTF8;
|
|
import net.yacy.kelondro.blob.Tables;
|
|
|
|
public class TablesRowComparator implements Comparator<Tables.Row> {
|
|
private String sortname;
|
|
private boolean desc;
|
|
|
|
public TablesRowComparator(final String sortname, final String sortorder) {
|
|
setSortName(sortname);
|
|
if(sortorder.equals("desc"))
|
|
this.desc = true;
|
|
else
|
|
this.desc = false;
|
|
}
|
|
|
|
public void setSortName(final String sortname) {
|
|
this.sortname = sortname;
|
|
}
|
|
|
|
@Override
|
|
public int compare(Tables.Row row0, Tables.Row row1) {
|
|
if(row0 != null && row1 != null) {
|
|
if(row0.containsKey(this.sortname) && row1.containsKey(this.sortname)) {
|
|
String name1 = UTF8.String(row0.get(this.sortname)).toLowerCase();
|
|
String name2 = UTF8.String(row1.get(this.sortname)).toLowerCase();
|
|
return (this.desc) ? name2.compareTo(name1) : name1.compareTo(name2);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
} |