KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > ltl > graph > ITypeNeighbor


1
2 //
3
// Copyright (C) 2005 United States Government as represented by the
4
// Administrator of the National Aeronautics and Space Administration
5
// (NASA). All Rights Reserved.
6
//
7
// This software is distributed under the NASA Open Source Agreement
8
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
9
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
10
// directory tree for the complete NOSA document.
11
//
12
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
13
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
14
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
15
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
16
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
17
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
18
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
19
//
20
package gov.nasa.ltl.graph;
21
22 /**
23  * DOCUMENT ME!
24  */

25 public class ITypeNeighbor extends Pair implements Comparable JavaDoc {
26   public ITypeNeighbor (int colorIn, String JavaDoc transitionIn) {
27     super(colorIn, transitionIn);
28   }
29
30   public void setColor (int colorIn) {
31     super.setValue(colorIn);
32   }
33
34   public int getColor () {
35     return super.getValue();
36   }
37
38   public void setTransition (String JavaDoc transitionIn) {
39     super.setElement(transitionIn);
40   }
41
42   public String JavaDoc getTransition () {
43     return (String JavaDoc) super.getElement();
44   }
45
46   // Priority of comparison is made on the string
47
public int compareTo (Object JavaDoc o) {
48     ITypeNeighbor other = (ITypeNeighbor) o;
49     int comparison = getTransition().compareTo(other.getTransition());
50
51     if (comparison == 0) {
52       if (getColor() < other.getColor()) {
53         return -1;
54       }
55
56       if (getColor() == other.getColor()) {
57         return 0;
58       }
59
60       if (getColor() > other.getColor()) {
61         return 1;
62       }
63     }
64
65     return comparison;
66   }
67 }
Popular Tags