1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.tonicsystems.jarjar;
18
19 import com.tonicsystems.jarjar.util.*;
20 import java.io.*;
21 import java.util.*;
22
23 abstract public class AbstractDepHandler implements DepHandler
24 {
25 protected final int level;
26 private final Set<List<Object>> seenIt = new HashSet<List<Object>>();
27
28 protected AbstractDepHandler(int level) {
29 this.level = level;
30 }
31
32 public void handle(PathClass from, PathClass to) throws IOException {
33 List<Object> pair;
34 if (level == LEVEL_JAR) {
35 pair = createPair(from.getClassPath(), to.getClassPath());
36 } else {
37 pair = createPair(from.getClassName(), to.getClassName());
38 }
39 if (!seenIt.contains(pair)) {
40 seenIt.add(pair);
41 handle(pair.get(0).toString(), pair.get(1).toString());
42 }
43 }
44
45 abstract protected void handle(String from, String to) throws IOException;
46
47 public void handleStart() throws IOException { }
48 public void handleEnd() throws IOException { }
49
50 private static List<Object> createPair(Object o1, Object o2) {
51 List<Object> list = new ArrayList<Object>(2);
52 list.add(o1);
53 list.add(o2);
54 return list;
55 }
56 }