Facet.java
3.19 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
/*
* 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.FacetValue;
import com.day.cq.searchpromote.xml.result.ResultParser;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Facet
extends AbstractResultEntity {
private static final Logger LOG = LoggerFactory.getLogger(Facet.class);
private static final String SELECTED_NODE = "selected";
private static final String TITLE_NODE = "facet-title";
private static final String UNDO_LINK_NODE = "undo-link";
private static final String ITEM_NODE = "facet-value";
private static final String BEHAVIOR_NODE = "behavior";
private boolean selected;
private String title;
private String undoQueryString;
private List<FacetValue> items = new ArrayList<FacetValue>();
private String behavior;
@Override
public void parse(XMLEventReader reader) throws Exception {
XMLEvent event;
LOG.debug("Parsing facet...");
while (reader.hasNext() && !(event = ResultParser.getNextEvent(reader)).isEndElement()) {
StartElement startElement = event.asStartElement();
String localPart = startElement.getName().getLocalPart();
LOG.debug("Parsing node {}", (Object)localPart);
if (localPart.equals("selected")) {
this.selected = ResultParser.strToBool(this.readData(reader));
ResultParser.getNextEvent(reader);
} else if (localPart.equals("facet-title")) {
this.title = this.readData(reader);
LOG.debug("Facet title is {}", (Object)this.title);
ResultParser.getNextEvent(reader);
} else if (localPart.equals("behavior")) {
this.behavior = this.readData(reader);
ResultParser.getNextEvent(reader);
} else if (localPart.equals("undo-link")) {
this.undoQueryString = this.readData(reader);
ResultParser.getNextEvent(reader);
} else if (localPart.equals("facet-value")) {
FacetValue item = new FacetValue();
item.parse(reader);
this.items.add(item);
} else {
ResultParser.parseUnknownTag(reader);
}
LOG.debug("Done parsing facet {}", (Object)this.title);
}
}
public boolean isSelected() {
return this.selected;
}
public String getTitle() {
return this.title;
}
public String getUndoQueryString() {
return this.undoQueryString;
}
public Boolean hasUndoQueryString() {
return this.undoQueryString != null && !"".equals(this.undoQueryString);
}
public List<FacetValue> getItems() {
return this.items;
}
public String getBehavior() {
return this.behavior;
}
}