src/share/classes/com/sun/tools/jdeps/Archive.java

Print this page

        

*** 23,57 **** * questions. */ package com.sun.tools.jdeps; import com.sun.tools.classfile.Dependency.Location; ! import java.io.File; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * Represents the source of the class files. */ public class Archive { ! private final File file; private final String filename; private final ClassFileReader reader; ! private final Map<Location, Set<Location>> deps ! = new HashMap<Location, Set<Location>>(); public Archive(String name) { ! this.file = null; this.filename = name; this.reader = null; } ! public Archive(File f, ClassFileReader reader) { ! this.file = f; ! this.filename = f.getName(); this.reader = reader; } public ClassFileReader reader() { return reader; --- 23,56 ---- * questions. */ package com.sun.tools.jdeps; import com.sun.tools.classfile.Dependency.Location; ! import java.nio.file.Path; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * Represents the source of the class files. */ public class Archive { ! private final Path path; private final String filename; private final ClassFileReader reader; ! private final Map<Location, Set<Location>> deps = new HashMap<>(); public Archive(String name) { ! this.path = null; this.filename = name; this.reader = null; } ! public Archive(Path p, ClassFileReader reader) { ! this.path = p; ! this.filename = path.getFileName().toString(); this.reader = reader; } public ClassFileReader reader() { return reader;
*** 62,79 **** } public void addClass(Location origin) { Set<Location> set = deps.get(origin); if (set == null) { ! set = new HashSet<Location>(); deps.put(origin, set); } } public void addClass(Location origin, Location target) { Set<Location> set = deps.get(origin); if (set == null) { ! set = new HashSet<Location>(); deps.put(origin, set); } set.add(target); } --- 61,78 ---- } public void addClass(Location origin) { Set<Location> set = deps.get(origin); if (set == null) { ! set = new HashSet<>(); deps.put(origin, set); } } public void addClass(Location origin, Location target) { Set<Location> set = deps.get(origin); if (set == null) { ! set = new HashSet<>(); deps.put(origin, set); } set.add(target); }
*** 85,95 **** } } } public String toString() { ! return file != null ? file.getPath() : filename; } interface Visitor { void visit(Location loc); void visit(Location origin, Location target); --- 84,94 ---- } } } public String toString() { ! return path != null ? path.toString() : filename; } interface Visitor { void visit(Location loc); void visit(Location origin, Location target);