001/** 002 * RenameWand 2.2 003 * Copyright 2007 Zach Scrivena 004 * 2007-12-09 005 * zachscrivena@gmail.com 006 * http://renamewand.sourceforge.net/ 007 * 008 * RenameWand is a simple command-line utility for renaming files or 009 * directories using an intuitive but powerful syntax. 010 * 011 * TERMS AND CONDITIONS: 012 * This program is free software: you can redistribute it and/or modify 013 * it under the terms of the GNU General Public License as published by 014 * the Free Software Foundation, either version 3 of the License, or 015 * (at your option) any later version. 016 * 017 * This program is distributed in the hope that it will be useful, 018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 020 * GNU General Public License for more details. 021 * 022 * You should have received a copy of the GNU General Public License 023 * along with this program. If not, see <http://www.gnu.org/licenses/>. 024 */ 025 026package ca.bc.webarts.tools.renamewand; 027 028 029/** 030 * Represent a double value used in enumeration of files/directories. 031 */ 032class DoubleEnumerationUnit 033 implements Comparable<DoubleEnumerationUnit> 034{ 035 /** index of the corresponding file/directory */ 036 int index; 037 038 /** double value to be used in sorting */ 039 double value; 040 041 042 /** 043 * Constructor. 044 * 045 * @param index 046 * Index of the corresponding file/directory 047 * @param val 048 * Double value to be used in sorting. 049 */ 050 DoubleEnumerationUnit( 051 int index, 052 double value) 053 { 054 this.index = index; 055 this.value = value; 056 } 057 058 059 /** compare this object to the specified object */ 060 @Override 061 public int compareTo( 062 DoubleEnumerationUnit o) 063 { 064 if (this.value > o.value) 065 { 066 return 1; 067 } 068 else if (this.value < o.value) 069 { 070 return -1; 071 } 072 else 073 { 074 return 0; 075 } 076 } 077 078 079 /** indicate if this object is equal to the specified object */ 080 @Override 081 public boolean equals( 082 Object o) 083 { 084 if (o instanceof DoubleEnumerationUnit) 085 return (this.value == ((DoubleEnumerationUnit) o).value); 086 087 return false; 088 } 089 090 091 /** return a hash code value for this object */ 092 @Override 093 public int hashCode() 094 { 095 return (int) this.value; 096 } 097}