001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Antoine Taillefer 018 */ 019package org.nuxeo.ecm.core.convert.plugins.text.extractors.presentation; 020 021import java.io.Serializable; 022 023/** 024 * Representation of a presentation document slide with its string content and its order. 025 */ 026public class PresentationSlide implements Serializable, Comparable<PresentationSlide> { 027 028 private static final long serialVersionUID = 1534438297504069864L; 029 030 protected String content; 031 032 protected int order; 033 034 public PresentationSlide(String content, int order) { 035 this.content = content; 036 this.order = order; 037 } 038 039 public String getContent() { 040 return content; 041 } 042 043 public void setContent(String content) { 044 this.content = content; 045 } 046 047 public int getOrder() { 048 return order; 049 } 050 051 public void setOrder(int order) { 052 this.order = order; 053 } 054 055 @Override 056 public boolean equals(Object other) { 057 058 if (this == other) { 059 return true; 060 } 061 if (other == null || !(other instanceof PresentationSlide)) { 062 return false; 063 } 064 065 String otherContent = ((PresentationSlide) other).getContent(); 066 int otherOrder = ((PresentationSlide) other).getOrder(); 067 if (order != otherOrder) { 068 return false; 069 } 070 return content == null && otherContent == null || content != null && content.equals(otherContent); 071 } 072 073 @Override 074 public String toString() { 075 076 StringBuilder sb = new StringBuilder(); 077 sb.append(content); 078 sb.append(" ("); 079 sb.append(order); 080 sb.append(")"); 081 return sb.toString(); 082 } 083 084 @Override 085 public int compareTo(PresentationSlide other) { 086 return Integer.valueOf(order).compareTo(Integer.valueOf(other.getOrder())); 087 } 088}