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 string used in enumeration of files/directories.
031 */
032class StringEnumerationUnit
033    implements Comparable<StringEnumerationUnit>
034{
035  /** index of the corresponding file/directory */
036  int index;
037
038  /** String to be used in sorting */
039  String value;
040
041
042  /**
043   * Constructor.
044   *
045   * @param index
046   *     Index of the corresponding file/directory
047   * @param val
048   *     String to be used in sorting.
049   */
050  StringEnumerationUnit(
051      int index,
052      String 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      final StringEnumerationUnit o)
063  {
064    return this.value.compareTo(o.value);
065  }
066
067
068  /** indicate if this object is equal to the specified object */
069  @Override
070  public boolean equals(
071      final Object o)
072  {
073    if (o instanceof StringEnumerationUnit)
074      return this.value.equals(((StringEnumerationUnit) o).value);
075
076    return false;
077  }
078
079
080  /** return a hash code value for this object */
081  @Override
082  public int hashCode()
083  {
084    return this.value.hashCode();
085  }
086}