001package org.kuali.ole.docstore.common.search;
002
003
004import org.apache.log4j.Logger;
005
006import javax.xml.bind.JAXBContext;
007import javax.xml.bind.JAXBElement;
008import javax.xml.bind.Marshaller;
009import javax.xml.bind.Unmarshaller;
010import javax.xml.bind.annotation.XmlAccessType;
011import javax.xml.bind.annotation.XmlAccessorType;
012import javax.xml.bind.annotation.XmlRootElement;
013import javax.xml.bind.annotation.XmlType;
014import javax.xml.transform.stream.StreamSource;
015import java.io.ByteArrayInputStream;
016import java.io.StringWriter;
017
018
019/**
020 * <p>Java class for browseParams complex type.
021 *
022 * <p>The following schema fragment specifies the expected content contained within this class.
023 *
024 * <pre>
025 * &lt;complexType name="browseParams">
026 *   &lt;complexContent>
027 *     &lt;extension base="{}searchParams">
028 *       &lt;sequence>
029 *         &lt;element name="totalCount" type="{http://www.w3.org/2001/XMLSchema}long"/>
030 *       &lt;/sequence>
031 *     &lt;/extension>
032 *   &lt;/complexContent>
033 * &lt;/complexType>
034 * </pre>
035 *
036 *
037 */
038@XmlAccessorType(XmlAccessType.FIELD)
039@XmlType(name = "browseParams", propOrder = {
040        "totalCount"
041})
042@XmlRootElement
043public class BrowseParams
044        extends SearchParams
045{
046    private static final Logger LOG = Logger.getLogger(BrowseParams.class);
047    protected long totalCount;
048
049    /**
050     * Gets the value of the totalCount property.
051     *
052     */
053    public long getTotalCount() {
054        return totalCount;
055    }
056
057    /**
058     * Sets the value of the totalCount property.
059     *
060     */
061    public void setTotalCount(long value) {
062        this.totalCount = value;
063    }
064
065   @Override
066    public String serialize(Object object) {
067        String result = null;
068        StringWriter sw = new StringWriter();
069        BrowseParams browseParams = (BrowseParams) object;
070        try {
071            JAXBContext jaxbContext = JAXBContext.newInstance(BrowseParams.class);
072            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
073            jaxbMarshaller.marshal(browseParams, sw);
074            result = sw.toString();
075        } catch (Exception e) {
076            LOG.error("Exception ", e);
077        }
078        return result;
079    }
080
081    @Override
082    public Object deserialize(String content) {
083
084        JAXBElement<BrowseParams> browseParamsElement = null;
085        try {
086            JAXBContext jaxbContext = JAXBContext.newInstance(BrowseParams.class);
087            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
088            ByteArrayInputStream input = new ByteArrayInputStream(content.getBytes("UTF-8"));
089            browseParamsElement = jaxbUnmarshaller.unmarshal(new StreamSource(input),BrowseParams.class);
090        } catch (Exception e) {
091            LOG.error("Exception ", e);
092        }
093        return browseParamsElement.getValue();
094    }
095
096}