--- /dev/null
+/*******************************************************************************
+ * Copyright
+ * 2013 axYus - www.axyus.com
+ * 2013 P.Renier - paul.renier@axyus.com
+ *
+ * This file is part of XEMELIOS.
+ *
+ * XEMELIOS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * XEMELIOS 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XEMELIOS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *******************************************************************************/
+package fr.gouv.finances.dgfip.xemelios.importers;
+
+import java.io.File;
+
+import org.apache.commons.io.FilenameUtils;
+
+public class Volume implements Comparable<Volume> {
+ private int number;
+ private String name;
+ private File folder;
+ private String collectivite;
+ private String exercice;
+
+ public Volume(final int number, final File folder, final String name, final String collectivite, final String exercice) {
+ super();
+ this.number = number;
+ this.folder = folder;
+ this.name = name;
+ this.collectivite = collectivite;
+ this.exercice = exercice;
+ }
+
+ public String getCollectivite() {
+ return this.collectivite;
+ }
+
+ public String getExercice() {
+ return this.exercice;
+ }
+
+ public int getNumber() {
+ return this.number;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public File getFolder() {
+ return this.folder;
+ }
+
+ public File getPath() {
+ return new File(this.folder, this.name);
+ }
+
+ public boolean exists() {
+ return new File(this.folder, this.name).exists();
+ }
+
+ @Override
+ public int compareTo(final Volume v) {
+ return this.number > v.number ? +1 : this.number < v.number ? -1 : 0;
+ }
+
+ public String getImportArchiveName() {
+ final String fileName = this.getName();
+ final String extension = FilenameUtils.getExtension(fileName);
+ final String baseName = FilenameUtils.getBaseName(fileName);
+ final String shortName = baseName.replaceFirst("_[0-9]*$", "");
+ return shortName + "." + extension;
+ }
+
+ public static String getFirstVolumeFromArchiveName(final String archiveName) {
+ return FilenameUtils.getBaseName(archiveName) + "_1." + FilenameUtils.getExtension(archiveName);
+ }
+}
\ No newline at end of file