1 19 20 package org.netbeans.modules.apisupport.project.universe; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.HashSet ; 25 import java.util.Set ; 26 import java.util.TreeSet ; 27 import org.netbeans.modules.apisupport.project.ManifestManager; 28 import org.netbeans.modules.apisupport.project.Util; 29 import org.openide.modules.Dependency; 30 31 final class BinaryEntry extends AbstractEntry { 32 33 private final String cnb; 34 private final File jar; 35 private final String cpext; 36 private final File nbdestdir; 37 private final File clusterDir; 38 private final String releaseVersion; 39 private final String specVersion; 40 private final String [] providedTokens; 41 private LocalizedBundleInfo bundleInfo; 42 private final ManifestManager.PackageExport[] publicPackages; 43 private final String [] friends; 44 private final boolean deprecated; 45 private final String [] runDependencies; 46 private Set <String > allPackageNames; 47 48 public BinaryEntry(String cnb, File jar, File [] exts, File nbdestdir, File clusterDir, 49 String releaseVersion, String specVersion, String [] providedTokens, 50 ManifestManager.PackageExport[] publicPackages, String [] friends, 51 boolean deprecated, Set <Dependency> moduleDependencies) { 52 this.cnb = cnb; 53 this.jar = jar; 54 this.nbdestdir = nbdestdir; 55 this.clusterDir = clusterDir; 56 StringBuffer _cpext = new StringBuffer (); 57 for (int i = 0; i < exts.length; i++) { 58 _cpext.append(':'); 59 _cpext.append(exts[i].getAbsolutePath()); 60 } 61 cpext = _cpext.toString(); 62 this.releaseVersion = releaseVersion; 63 this.specVersion = specVersion; 64 this.providedTokens = providedTokens; 65 this.publicPackages = publicPackages; 66 this.friends = friends; 67 this.deprecated = deprecated; 68 Set <String > deps = new TreeSet <String >(); 69 for (Dependency d : moduleDependencies) { 70 String codename = d.getName(); 71 int slash = codename.lastIndexOf('/'); 72 if (slash == -1) { 73 deps.add(codename); 74 } else { 75 deps.add(codename.substring(0, slash)); 76 } 77 } 78 runDependencies = deps.toArray(new String [deps.size()]); 79 } 80 81 public File getSourceLocation() { 83 NbPlatform platform = NbPlatform.getPlatformByDestDir(getDestDir()); 84 89 return platform.getSourceLocationOfModule(getJarLocation()); 90 95 } 96 97 public String getNetBeansOrgPath() { 98 return null; 99 } 100 101 public File getJarLocation() { 102 return jar; 103 } 104 105 public File getDestDir() { 106 return nbdestdir; 107 } 108 109 public String getCodeNameBase() { 110 return cnb; 111 } 112 113 public File getClusterDirectory() { 114 return clusterDir; 115 } 116 117 public String getClassPathExtensions() { 118 return cpext; 119 } 120 121 public String getReleaseVersion() { 122 return releaseVersion; 123 } 124 125 public String getSpecificationVersion() { 126 return specVersion; 127 } 128 129 public String [] getProvidedTokens() { 130 return providedTokens; 131 } 132 133 protected LocalizedBundleInfo getBundleInfo() { 134 if (bundleInfo == null) { 135 bundleInfo = Util.findLocalizedBundleInfoFromJAR(getJarLocation()); 136 if (bundleInfo == null) { 137 bundleInfo = LocalizedBundleInfo.EMPTY; 138 } 139 } 140 return bundleInfo; 141 } 142 143 public ManifestManager.PackageExport[] getPublicPackages() { 144 return publicPackages; 145 } 146 147 public synchronized Set <String > getAllPackageNames() { 148 if (allPackageNames == null) { 149 allPackageNames = new TreeSet <String >(); 150 Util.scanJarForPackageNames(allPackageNames, getJarLocation()); 151 } 152 return allPackageNames; 153 } 154 155 public boolean isDeclaredAsFriend(String cnb) { 156 return isDeclaredAsFriend(friends, cnb); 157 } 158 159 public boolean isDeprecated() { 160 return deprecated; 161 } 162 163 public String toString() { 164 File source = getSourceLocation(); 165 return "BinaryEntry[" + getJarLocation() + (source != null ? "," + source : "") + "]"; } 167 168 protected Set <String > computePublicClassNamesInMainModule() throws IOException { 169 Set <String > result = new HashSet <String >(); 170 scanJarForPublicClassNames(result, jar); 171 return result; 172 } 173 174 public String [] getRunDependencies() { 175 return runDependencies; 176 } 177 178 } 179 | Popular Tags |