source: branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/misc/Identifier.java @ 1579

Last change on this file since 1579 was 1579, checked in by rkrimmel, 10 years ago

Code cleanup, removed alot of unneccessary code from pal sources

File size: 2.1 KB
Line 
1// Identifier.java
2//
3// (c) 1999-2000 PAL Development Core Team
4//
5// This package may be distributed under the
6// terms of the Lesser GNU General Public License (LGPL)
7
8package de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc;
9
10import de.ugoe.cs.autoquest.tasktrees.alignment.pal.util.Comparable;
11
12/**
13 * An identifier for some sampled data. This will most often be
14 * for example, the accession number of a DNA sequence, or the
15 * taxonomic name that the sequence represents, et cetera.
16 *
17 * @version $Id: Identifier.java,v 1.6 2001/12/02 22:32:18 matt Exp $
18 *
19 * @author Alexei Drummond
20 */
21
22
23public class Identifier implements
24                                         Comparable, Nameable {
25
26        private String name = null;
27
28       
29        public static Identifier ANONYMOUS = new Identifier("");
30
31                public Identifier() {}
32
33                public Identifier(String name) {
34        setName(name);
35                }
36
37                public String toString() {
38        return getName();
39                }
40
41                // implements Comparable interface
42
43                public int compareTo(Object c) {
44
45        return getName().compareTo(((Identifier)c).getName());
46                }
47
48                public boolean equals(Object c) {
49
50        if (c instanceof Identifier) {
51                        return getName().equals(((Identifier)c).getName());
52        } else return false;
53                }
54
55                // implements Nameable interface
56
57                public String getName() {
58        return name;
59                }
60
61                public void setName(String s) {
62        name = s;
63                }
64        /**
65         * Translates an array of identifiers into an array of strings
66         */
67        public final static String[] getNames(Identifier[] ids) {
68                String[] names = new String[ids.length];
69                for(int i = 0 ; i < names.length ; i++) {
70                        names[i] = ids[i].getName();
71                }
72                return names;
73        }
74        /**
75         * Translates an array of identifiers into an array of strings, with optional removal of particular identifier
76         * @param toIgnoreIndex the index of an idetifier to ignore, if <0 no element is ignored
77         */
78        public final static String[] getNames(Identifier[] ids, int toIgnore) {
79                if(toIgnore<0||toIgnore>=ids.length) {
80                        return getNames(ids);
81                }
82                String[] names = new String[ids.length-1];
83                int index = 0;
84                for(int i = 0 ; i < names.length ; i++) {
85                        if(i!=toIgnore) {
86                                names[index] = ids[i].getName();
87                                index++;
88                        }
89                }
90                return names;
91        }
92
93}
94
Note: See TracBrowser for help on using the repository browser.