org.sejda.model.input.FileIndexAndPage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sejda-model Show documentation
Show all versions of sejda-model Show documentation
Package containing reusable model for Sejda.
/*
* Copyright 2015 by Edi Weissmann ([email protected])
*
* This file is part of the Sejda source code
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License
* along with this program. If not, see .
*/
package org.sejda.model.input;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.sejda.model.rotation.Rotation;
/**
* A page and the associated file, referenced by its index in the sources list.
* Supports specifying a page rotation.
*/
public class FileIndexAndPage {
private int fileIndex;
private int page;
private Rotation rotation;
public FileIndexAndPage(int fileIndex, int page) {
this(fileIndex, page, Rotation.DEGREES_0);
}
public FileIndexAndPage(int fileIndex, int page, Rotation rotation) {
this.fileIndex = fileIndex;
this.page = page;
this.rotation = rotation;
}
public int getFileIndex() {
return fileIndex;
}
public int getPage() {
return page;
}
public Rotation getRotation() {
return rotation;
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(this.fileIndex).append(this.page).append(rotation).toHashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final FileIndexAndPage other = (FileIndexAndPage) obj;
return new EqualsBuilder().append(this.fileIndex, other.fileIndex).append(this.page, other.page)
.append(this.rotation, other.rotation)
.isEquals();
}
@Override
public String toString() {
return String.format("%d:%d:%d", fileIndex, page, rotation.getDegrees());
}
public boolean isAddBlankPage() {
return page < 0 || fileIndex < 0;
}
}