1 11 package org.eclipse.jdt.launching; 12 13 import java.net.URL ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.jdt.internal.launching.LaunchingMessages; 17 18 19 25 public final class LibraryLocation { 26 private IPath fSystemLibrary; 27 private IPath fSystemLibrarySource; 28 private IPath fPackageRootPath; 29 private URL fJavadocLocation; 30 31 45 public LibraryLocation(IPath libraryPath, IPath sourcePath, IPath packageRoot) { 46 this(libraryPath, sourcePath, packageRoot, null); 47 } 48 49 65 public LibraryLocation(IPath libraryPath, IPath sourcePath, IPath packageRoot, URL javadocLocation) { 66 if (libraryPath == null) 67 throw new IllegalArgumentException (LaunchingMessages.libraryLocation_assert_libraryNotNull); 68 69 fSystemLibrary= libraryPath; 70 fSystemLibrarySource= sourcePath; 71 fPackageRootPath= packageRoot; 72 fJavadocLocation= javadocLocation; 73 } 74 75 80 public IPath getSystemLibraryPath() { 81 return fSystemLibrary; 82 } 83 84 89 public IPath getSystemLibrarySourcePath() { 90 return fSystemLibrarySource; 91 } 92 93 98 public IPath getPackageRootPath() { 99 return fPackageRootPath; 100 } 101 104 public boolean equals(Object obj) { 105 if (obj instanceof LibraryLocation) { 106 LibraryLocation lib = (LibraryLocation)obj; 107 return getSystemLibraryPath().equals(lib.getSystemLibraryPath()) 108 && equals(getSystemLibrarySourcePath(), lib.getSystemLibrarySourcePath()) 109 && equals(getPackageRootPath(), lib.getPackageRootPath()) 110 && equalsOrNull(getJavadocLocation(), lib.getJavadocLocation()); 111 } 112 return false; 113 } 114 115 118 public int hashCode() { 119 return getSystemLibraryPath().hashCode(); 120 } 121 122 128 protected boolean equals(IPath path1, IPath path2) { 129 return equalsOrNull(path1, path2); 130 } 131 132 139 private boolean equalsOrNull(Object o1, Object o2) { 140 if (o1 == null) { 141 return o2 == null; 142 } 143 if (o2 == null) { 144 return false; 145 } 146 return o1.equals(o2); 147 } 148 149 156 public URL getJavadocLocation() { 157 return fJavadocLocation; 158 } 159 160 } 161 | Popular Tags |