Suggestions.java
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.searchpromote.xml.result;
import com.day.cq.searchpromote.xml.result.AbstractResultEntity;
import com.day.cq.searchpromote.xml.result.ResultParser;
import com.day.cq.searchpromote.xml.result.Suggestion;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
public class Suggestions
extends AbstractResultEntity {
private static final String AUTO_SEARCH_NODE = "auto-searched";
private static final String SUGGESTION_LOW_RESULT_NODE = "suggestions-low-results";
private static final String ORIG_QUERY_NODE = "orig-query";
private static final String ITEM_NODE = "suggestion-item";
private boolean autoSearched;
private boolean suggestionLowResult;
private String origQuery;
private List<Suggestion> items = new ArrayList<Suggestion>();
@Override
public void parse(XMLEventReader reader) throws Exception {
XMLEvent event;
while (reader.hasNext() && !(event = ResultParser.getNextEvent(reader)).isEndElement()) {
String data;
StartElement startElement = event.asStartElement();
String localPart = startElement.getName().getLocalPart();
if ("auto-searched".equals(localPart)) {
data = this.readData(reader);
this.autoSearched = ResultParser.strToBool(data);
ResultParser.getNextEvent(reader);
continue;
}
if ("suggestions-low-results".equals(localPart)) {
data = this.readData(reader);
this.suggestionLowResult = ResultParser.strToBool(data);
ResultParser.getNextEvent(reader);
continue;
}
if ("orig-query".equals(localPart)) {
this.origQuery = data = this.readData(reader);
ResultParser.getNextEvent(reader);
continue;
}
if ("suggestion-item".equals(localPart)) {
Suggestion item = new Suggestion();
item.parse(reader);
this.items.add(item);
continue;
}
ResultParser.parseUnknownTag(reader);
}
}
public boolean isAutoSearched() {
return this.autoSearched;
}
public boolean isSuggestionLowResult() {
return this.suggestionLowResult;
}
public String getOrigQuery() {
return this.origQuery;
}
public List<Suggestion> getItems() {
return this.items;
}
}