001: /*
002: * Gruntspud
003: *
004: * Copyright (C) 2002 Brett Smith.
005: *
006: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public License
010: * as published by the Free Software Foundation; either version 2 of
011: * the License, or (at your option) any later version.
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Library General Public License for more details.
016: *
017: * You should have received a copy of the GNU Library General Public
018: * License along with this program; if not, write to the Free Software
019: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020: */
021:
022: package gruntspud.file;
023:
024: import gruntspud.CVSChangeStatus;
025:
026: import java.util.Iterator;
027:
028: /**
029: * Description of the Class
030: *
031: *@author magicthize
032: *@created 26 May 2002
033: */
034: public class DirectoryStatus implements Comparable {
035: private final static java.util.List allTypes = new java.util.ArrayList();
036:
037: public final static String PROJECT_NAME = "Project";
038: public final static String MODULE_NAME = "Module";
039: public final static String PLAIN_NAME = "Plain";
040: public final static String ATTENTION_NAME = "Attention";
041: public final static String UP_TO_DATE_NAME = "Up-to-date";
042:
043: public final static DirectoryStatus PROJECT = new DirectoryStatus(
044: PROJECT_NAME);
045: public final static DirectoryStatus MODULE = new DirectoryStatus(
046: MODULE_NAME);
047: public final static DirectoryStatus PLAIN = new DirectoryStatus(
048: PLAIN_NAME);
049: public final static DirectoryStatus ATTENTION = new DirectoryStatus(
050: ATTENTION_NAME);
051: public final static DirectoryStatus UP_TO_DATE = new DirectoryStatus(
052: UP_TO_DATE_NAME);
053:
054: private String name;
055:
056: /**
057: * Constructor for the CVSSubstType object
058: *
059: *@param name Description of the Parameter
060: *@param icon Description of the Parameter
061: */
062: protected DirectoryStatus(String name) {
063: this .name = name;
064: allTypes.add(this );
065: }
066:
067: /**
068: * Gets the name attribute of the CVSChangeStatus
069: *
070: *@return The name value
071: */
072: public String getName() {
073: return name;
074: }
075:
076: public java.util.List getDirectoryStatusList() {
077: return allTypes;
078: }
079:
080: /**
081: * Description of the Method
082: *
083: *@return Description of the Return Value
084: */
085: public String toString() {
086: return getName();
087: }
088:
089: /**
090: * DOCUMENT ME!
091: *
092: * @param code DOCUMENT ME!
093: *
094: * @return DOCUMENT ME!
095: */
096: public static DirectoryStatus getStatusForName(String name) {
097: for (Iterator i = allTypes.iterator(); i.hasNext();) {
098: DirectoryStatus s = (DirectoryStatus) i.next();
099: if (s.getName().equals(name)) {
100: return s;
101: }
102: }
103: return null;
104: }
105:
106: public static Iterator changeStatus() {
107: return allTypes.iterator();
108: }
109:
110: /**
111: * DOCUMENT ME!
112: *
113: * @param o DOCUMENT ME!
114: *
115: * @return DOCUMENT ME!
116: */
117: public int compareTo(Object o) {
118: /** @todo make this better */
119: return name.compareTo(((CVSChangeStatus) o).getName());
120: }
121: }
|