本文整理汇总了Java中com.sun.tools.javac.file.RelativePath.RelativeFile类的典型用法代码示例。如果您正苦于以下问题:Java RelativeFile类的具体用法?Java RelativeFile怎么用?Java RelativeFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RelativeFile类属于com.sun.tools.javac.file.RelativePath包,在下文中一共展示了RelativeFile类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: length
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
public synchronized int length(RelativeFile path) throws IOException {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException();
if (entry.isDir) {
return 0;
}
byte[] header = getHeader(entry);
// entry is not compressed?
if (get2ByteLittleEndian(header, 8) == 0) {
return entry.compressedSize;
} else {
return entry.size;
}
}
示例2: getFileForInput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
private JavaFileObject getFileForInput(Location location, RelativeFile name) throws IOException {
Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
for (File dir : path) {
Archive a = archives.get(dir);
if (a == null) {
if (fsInfo.isDirectory(dir)) {
File f = name.getFile(dir);
if (f.exists())
return new RegularFileObject(this, f);
continue;
}
// Not a directory, create the archive
a = openArchive(dir);
}
// Process the archive
if (a.contains(name)) {
return a.getFileObject(name.dirname(), name.basename());
}
}
return null;
}
示例3: getFileForInput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
private JavaFileObject getFileForInput(Location location, RelativeFile name) throws IOException {
Iterable<? extends File> path = getLocation(location);
if (path == null)
return null;
for (File dir: path) {
Archive a = archives.get(dir);
if (a == null) {
if (fsInfo.isDirectory(dir)) {
File f = name.getFile(dir);
if (f.exists())
return new RegularFileObject(this, f);
continue;
}
// Not a directory, create the archive
a = openArchive(dir);
}
// Process the archive
if (a.contains(name)) {
return a.getFileObject(name.dirname(), name.basename());
}
}
return null;
}
示例4: getFileForOutput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
public FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling)
throws IOException
{
nullCheck(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForOutput(location, name, sibling);
}
示例5: getFileForInput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public FileObject getFileForInput(Location location,
String packageName,
String relativeName)
throws IOException
{
checkNotModuleOrientedLocation(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForInput(location, name);
}
示例6: getFileForOutput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling)
throws IOException
{
checkOutputLocation(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForOutput(location, name, sibling);
}
示例7: run
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
void run() throws Exception {
RelativeFile TEST_ENTRY_NAME = new RelativeFile("java/lang/String.class");
File testJar = createJar("test.jar", "java.lang.*");
try (JarFile j = new JarFile(testJar)) {
JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath());
long jarEntryTime = je.getTime();
Context context = new Context();
JavacFileManager fm = new JavacFileManager(context, false, null);
fm.setLocation(StandardLocation.CLASS_PATH, Collections.singletonList(testJar));
FileObject fo =
fm.getFileForInput(StandardLocation.CLASS_PATH, "", TEST_ENTRY_NAME.getPath());
long jfoTime = fo.getLastModified();
check(je, jarEntryTime, fo, jfoTime);
if (errors > 0)
throw new Exception(errors + " occurred");
}
}
示例8: getFileForInput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public FileObject getFileForInput(Location location,
String packageName,
String relativeName)
throws IOException
{
nullCheck(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForInput(location, name);
}
示例9: getFileForOutput
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling)
throws IOException
{
nullCheck(location);
// validatePackageName(packageName);
nullCheck(packageName);
if (!isRelativeUri(relativeName))
throw new IllegalArgumentException("Invalid relative name: " + relativeName);
RelativeFile name = packageName.length() == 0
? new RelativeFile(relativeName)
: new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
return getFileForOutput(location, name, sibling);
}
示例10: length
import com.sun.tools.javac.file.RelativePath.RelativeFile; //导入依赖的package包/类
public int length(RelativeFile path) throws IOException {
lock.lock();
try {
Entry entry = getZipIndexEntry(path);
if (entry == null)
throw new FileNotFoundException();
if (entry.isDir) {
return 0;
}
byte[] header = getHeader(entry);
// entry is not compressed?
if (get2ByteLittleEndian(header, 8) == 0) {
return entry.compressedSize;
} else {
return entry.size;
}
}
finally {
lock.unlock();
}
}