1 11 package org.eclipse.jdt.internal.compiler.batch; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.util.zip.ZipEntry ; 16 17 import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; 18 import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; 19 import org.eclipse.jdt.internal.compiler.util.Util; 20 21 public class ClasspathSourceJar extends ClasspathJar { 22 private String encoding; 23 24 public ClasspathSourceJar(File file, boolean closeZipFileAtEnd, 25 AccessRuleSet accessRuleSet, String encoding, 26 String destinationPath) { 27 super(file, closeZipFileAtEnd, accessRuleSet, destinationPath); 28 this.encoding = encoding; 29 } 30 31 public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName, boolean asBinaryOnly) { 32 if (!isPackage(qualifiedPackageName)) 33 return null; 35 ZipEntry sourceEntry = this.zipFile.getEntry(qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java); 36 if (sourceEntry != null) { 37 try { 38 return new NameEnvironmentAnswer( 39 new CompilationUnit( 40 Util.getInputStreamAsCharArray(this.zipFile.getInputStream(sourceEntry), 41 -1, this.encoding), 42 qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java, 43 this.encoding, this.destinationPath), 44 fetchAccessRestriction(qualifiedBinaryFileName)); 45 } catch (IOException e) { 46 } 48 } 49 return null; 50 } 51 public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { 52 return findClass(typeName, qualifiedPackageName, qualifiedBinaryFileName, false); 53 } 54 } 55 | Popular Tags |