1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.contract.writer.search;
17
18 import org.kuali.student.contract.model.SearchResult;
19 import org.kuali.student.contract.model.SearchResultColumn;
20 import org.kuali.student.contract.writer.XmlWriter;
21
22 import java.io.PrintStream;
23
24
25
26
27
28 public class SearchResultWriter extends XmlWriter {
29
30 private SearchResult searchResult;
31
32 public SearchResultWriter(PrintStream out, int indent,
33 SearchResult searchResult) {
34 super(out, indent);
35 this.searchResult = searchResult;
36 }
37
38 public void write() {
39
40 println("");
41 indentPrint("<search:searchResultTypeInfo");
42
43 writeAttribute("id", searchResult.getKey());
44 println(">");
45 incrementIndent();
46
47 writeComment(searchResult.getComments());
48
49 writeTag("search:name", searchResult.getName());
50 writeTag("search:desc", searchResult.getDescription());
51 indentPrintln("<search:resultColumns>");
52 incrementIndent();
53 for (SearchResultColumn col : searchResult.getResultColumns()) {
54 indentPrintln(calcRefBean(col.getKey()));
55 }
56 decrementIndent();
57 indentPrintln("</search:resultColumns>");
58 indentPrintln("</search:searchResultTypeInfo>");
59 decrementIndent();
60 }
61
62 private String calcRefBean(String id) {
63 return "<ref bean=\"" + id + "\" />";
64 }
65 }