/** * License Agreement for OpenSearchServer * * Copyright (C) 2014 Emmanuel Keller / Jaeksoft * * http://www.open-search-server.com * * This file is part of OpenSearchServer. * * OpenSearchServer is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenSearchServer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenSearchServer. * If not, see <http://www.gnu.org/licenses/>. **/ package com.jaeksoft.searchlib.renderer; import javax.xml.xpath.XPathExpressionException; import org.w3c.dom.Node; import org.xml.sax.SAXException; import com.jaeksoft.searchlib.util.DomUtils; import com.jaeksoft.searchlib.util.StringUtils; import com.jaeksoft.searchlib.util.XPathParser; import com.jaeksoft.searchlib.util.XmlWriter; public class RendererSort { private String label; private String sort; private final static String RENDERER_FIELD_ATTR_LABEL = "label"; public RendererSort() { label = StringUtils.EMPTY; sort = "-score"; } public RendererSort(XPathParser xpp, Node node) throws XPathExpressionException { label = DomUtils.getAttributeText(node, RENDERER_FIELD_ATTR_LABEL); sort = DomUtils.getText(node); } public RendererSort(RendererSort field) { field.copyTo(this); } public void copyTo(RendererSort target) { target.label = label; target.sort = sort; } /** * @return the label */ public String getLabel() { return label; } /** * @param label * the label to set */ public void setLabel(String label) { this.label = label; } public String getSort() { return sort; } public void setSort(String sort) { this.sort = sort; } public void writeXml(XmlWriter xmlWriter, String nodeName) throws SAXException { xmlWriter.startElement(nodeName, RENDERER_FIELD_ATTR_LABEL, label); xmlWriter.textNode(sort); xmlWriter.endElement(); } }