001/*
002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Antoine Taillefer
016 */
017package org.nuxeo.ecm.core.convert.plugins.text.extractors.presentation;
018
019import java.io.Serializable;
020
021/**
022 * Representation of a presentation document slide with its string content and its order.
023 */
024public class PresentationSlide implements Serializable, Comparable<PresentationSlide> {
025
026    private static final long serialVersionUID = 1534438297504069864L;
027
028    protected String content;
029
030    protected int order;
031
032    public PresentationSlide(String content, int order) {
033        this.content = content;
034        this.order = order;
035    }
036
037    public String getContent() {
038        return content;
039    }
040
041    public void setContent(String content) {
042        this.content = content;
043    }
044
045    public int getOrder() {
046        return order;
047    }
048
049    public void setOrder(int order) {
050        this.order = order;
051    }
052
053    @Override
054    public boolean equals(Object other) {
055
056        if (this == other) {
057            return true;
058        }
059        if (other == null || !(other instanceof PresentationSlide)) {
060            return false;
061        }
062
063        String otherContent = ((PresentationSlide) other).getContent();
064        int otherOrder = ((PresentationSlide) other).getOrder();
065        if (order != otherOrder) {
066            return false;
067        }
068        return content == null && otherContent == null || content != null && content.equals(otherContent);
069    }
070
071    @Override
072    public String toString() {
073
074        StringBuilder sb = new StringBuilder();
075        sb.append(content);
076        sb.append(" (");
077        sb.append(order);
078        sb.append(")");
079        return sb.toString();
080    }
081
082    @Override
083    public int compareTo(PresentationSlide other) {
084        return Integer.valueOf(order).compareTo(Integer.valueOf(other.getOrder()));
085    }
086}