01: package org.libresource.kernel.comparator.util;
02:
03: import java.io.IOException;
04: import java.io.Writer;
05:
06: import org.libresource.LibresourceResourceValue;
07: import org.libresource.kernel.filter.DateFilter;
08:
09: public abstract class ListStructure {
10: private static final String CREATION = "creation";
11: private static final String OWNER = "owner";
12: private static final String UPDATE = "update";
13: private static final String TYPE = "type";
14: private static final String URI = "uri";
15: private int limit;
16: private String groupBy;
17: private String sort;
18:
19: abstract public void addItem(LibresourceResourceValue item);
20:
21: abstract public void print(Writer writer) throws IOException;
22:
23: public String getGroupBy() {
24: return groupBy;
25: }
26:
27: public void setGroupBy(String groupBy) {
28: this .groupBy = groupBy;
29: }
30:
31: public int getLimit() {
32: return limit;
33: }
34:
35: public void setLimit(int limit) {
36: this .limit = limit;
37: }
38:
39: public String getSort() {
40: return sort;
41: }
42:
43: public void setSort(String sort) {
44: this .sort = sort;
45: }
46:
47: public static String getInfo(LibresourceResourceValue lsv,
48: String param) {
49: if (TYPE.equals(param)) {
50: if (lsv.getLibresourceResourceIdentifier() != null)
51: return lsv.getLibresourceResourceIdentifier()
52: .getResourceType();
53: return "No type";
54: }
55: if (OWNER.equals(param)) {
56: if (lsv.getOwner() != null)
57: return lsv.getOwner().toString();
58: return "No owner";
59: }
60: if (CREATION.equals(param)) {
61: return DateFilter.DATE_FORMAT.format(lsv.getCreationDate());
62: }
63: if (UPDATE.equals(param)) {
64: return DateFilter.DATE_FORMAT.format(lsv.getUpdateDate());
65: }
66:
67: if (URI.equals(param)) {
68: return lsv.getUri().toString();
69: }
70: return "Invalid param";
71: }
72: }
|