comparison visualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java @ 4512:015fb895586b

Moved visualizer to new directory.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 07 Feb 2012 22:41:09 +0100
parents
children
comparison
equal deleted inserted replaced
4511:6cb549627941 4512:015fb895586b
1 /*
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 package com.sun.hotspot.igv.data;
25
26 import java.util.Comparator;
27
28 /**
29 *
30 * @author Thomas Wuerthinger
31 */
32 public class InputEdge {
33
34 public enum State {
35
36 SAME,
37 NEW,
38 DELETED
39 }
40
41 public static final Comparator<InputEdge> OUTGOING_COMPARATOR = new Comparator<InputEdge>(){
42
43 @Override
44 public int compare(InputEdge o1, InputEdge o2) {
45 if(o1.getFromIndex() == o2.getFromIndex()) {
46 return o1.getTo() - o2.getTo();
47 }
48 return o1.getFromIndex() - o2.getFromIndex();
49 }
50 };
51
52
53 public static final Comparator<InputEdge> INGOING_COMPARATOR = new Comparator<InputEdge>(){
54
55 @Override
56 public int compare(InputEdge o1, InputEdge o2) {
57 if(o1.getToIndex() == o2.getToIndex()) {
58 return o1.getFrom() - o2.getFrom();
59 }
60 return o1.getToIndex() - o2.getToIndex();
61 }
62 };
63
64 private char toIndex;
65 private char fromIndex;
66 private int from;
67 private int to;
68 private State state;
69 private String label;
70
71 public InputEdge(char toIndex, int from, int to) {
72 this((char) 0, toIndex, from, to, null);
73 }
74
75 public InputEdge(char fromIndex, char toIndex, int from, int to) {
76 this(fromIndex, toIndex, from, to, null);
77 }
78
79 public InputEdge(char fromIndex, char toIndex, int from, int to, String label) {
80 this.toIndex = toIndex;
81 this.fromIndex = fromIndex;
82 this.from = from;
83 this.to = to;
84 this.state = State.SAME;
85 this.label = label;
86 }
87
88 public State getState() {
89 return state;
90 }
91
92 public void setState(State x) {
93 this.state = x;
94 }
95
96 public char getToIndex() {
97 return toIndex;
98 }
99
100 public char getFromIndex() {
101 return fromIndex;
102 }
103
104 public String getName() {
105 return "in" + toIndex;
106 }
107
108 public int getFrom() {
109 return from;
110 }
111
112 public int getTo() {
113 return to;
114 }
115
116 public String getLabel() {
117 return label;
118 }
119
120 @Override
121 public boolean equals(Object o) {
122 if (o == null || !(o instanceof InputEdge)) {
123 return false;
124 }
125 InputEdge conn2 = (InputEdge) o;
126 return conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to;
127 }
128
129 @Override
130 public String toString() {
131 return "Edge from " + from + " to " + to + "(" + (int) fromIndex + ", " + (int) toIndex + ") ";
132 }
133
134 @Override
135 public int hashCode() {
136 return (from << 20 | to << 8 | toIndex << 4 | fromIndex);
137 }
138 }