FacetValue.java
4.13 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.searchpromote.xml.result;
import com.day.cq.searchpromote.xml.result.AbstractResultEntity;
import com.day.cq.searchpromote.xml.result.FacetValueChildList;
import com.day.cq.searchpromote.xml.result.ResultParser;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FacetValue
extends AbstractResultEntity {
private static final Logger LOG = LoggerFactory.getLogger(FacetValue.class);
private static final String LABEL_NODE = "label";
private static final String COUNT_NODE = "count";
private static final String LINK_NODE = "link";
private static final String UNDO_LINK_NODE = "undolink";
private static final String SELECTED_NODE = "selected";
private static final String HAS_CHILDREN_NODE = "facet-has-children";
private static final String CHILDREN_NODE = "children";
private String label;
private String undoQueryString;
private String queryString;
private Long count;
private boolean selected;
private boolean hasChildren;
private FacetValueChildList childList;
@Override
public void parse(XMLEventReader reader) throws Exception {
XMLEvent nextEvent;
LOG.debug("Parsing facet value");
while (reader.hasNext() && !(nextEvent = ResultParser.getNextEvent(reader)).isEndElement()) {
String data;
StartElement element = nextEvent.asStartElement();
String localPart = element.getName().getLocalPart();
LOG.debug("Parsing node {}", (Object)localPart);
if ("label".equals(localPart)) {
this.label = data = this.readData(reader);
ResultParser.getNextEvent(reader);
continue;
}
if ("count".equals(localPart)) {
data = this.readData(reader);
this.count = ResultParser.strToLong(data);
ResultParser.getNextEvent(reader);
continue;
}
if ("link".equals(localPart)) {
this.queryString = data = this.readData(reader);
ResultParser.getNextEvent(reader);
continue;
}
if ("undolink".equals(localPart)) {
this.undoQueryString = data = this.readData(reader);
ResultParser.getNextEvent(reader);
continue;
}
if ("selected".equals(localPart)) {
data = this.readData(reader);
this.selected = ResultParser.strToBool(data);
ResultParser.getNextEvent(reader);
continue;
}
if ("facet-has-children".equals(localPart)) {
data = this.readData(reader);
this.hasChildren = ResultParser.strToBool(data);
ResultParser.getNextEvent(reader);
continue;
}
if (element.getName().getLocalPart().equals("children")) {
this.childList = new FacetValueChildList();
this.childList.parse(reader);
continue;
}
ResultParser.parseUnknownTag(reader);
}
}
public String getLabel() {
return this.label;
}
public String getUndoQueryString() {
return this.undoQueryString;
}
public Boolean hasUndoQueryString() {
return this.undoQueryString != null && !"".equals(this.undoQueryString);
}
public String getQueryString() {
return this.queryString;
}
public Boolean hasQueryString() {
return this.queryString != null && !"".equals(this.queryString);
}
public Long getCount() {
return this.count;
}
public boolean isSelected() {
return this.selected;
}
public boolean hasChildren() {
return this.hasChildren;
}
public FacetValueChildList getChildList() {
return this.childList;
}
}