本文整理汇总了Java中javax.tools.JavaFileObject.Kind方法的典型用法代码示例。如果您正苦于以下问题:Java JavaFileObject.Kind方法的具体用法?Java JavaFileObject.Kind怎么用?Java JavaFileObject.Kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.tools.JavaFileObject
的用法示例。
在下文中一共展示了JavaFileObject.Kind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listModuleContent
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@NonNull
private Iterable<JavaFileObject> listModuleContent(
@NonNull final ModLoc modLoc,
@NonNull final String packageName,
@NonNull final Set<JavaFileObject.Kind> kinds) throws IOException {
final CachingArchiveProvider cap = CachingArchiveProvider.getDefault();
final Collection<JavaFileObject> res = new ArrayList<>();
if (javaBaseModInfo != null && "java.base".equals(modLoc.getModuleName()) && packageName.isEmpty()) {
final JavaFileObject jfo = new MemJFO("module-info");
try(OutputStream out = jfo.openOutputStream()) {
final byte[] data = javaBaseModInfo.get();
out.write(data, 0, data.length);
}
res.add(jfo);
}
for (URL url : modLoc.getRoots()) {
final Archive ca = cap.getArchive(url, false);
if (ca != null) {
StreamSupport.stream(
ca.getFiles(FileObjects.convertPackage2Folder(packageName), null, kinds, null, false).spliterator(),
false)
.forEach(res::add);
}
}
return res;
}
示例2: getJavaFileForInput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
*/
public JavaFileObject getJavaFileForInput( Location location,
String className,
JavaFileObject.Kind kind )
throws IOException
{
return fileManager.getJavaFileForInput( location, className, kind );
}
示例3: getJavaFileForInput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public JavaFileObject getJavaFileForInput(Location location,
String className,
JavaFileObject.Kind kind)
throws IOException {
nullCheck(location);
// validateClassName(className);
nullCheck(className);
nullCheck(kind);
if (!sourceOrClass.contains(kind))
throw new IllegalArgumentException("Invalid kind: " + kind);
return getFileForInput(location, RelativeFile.forClass(className, kind));
}
示例4: getFileForOutput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
public JavaFileObject getFileForOutput(String classname,
JavaFileObject.Kind kind,
JavaFileObject sibling)
throws IOException
{
return getJavaFileForOutput(CLASS_OUTPUT, classname, kind, sibling);
}
示例5: listDirectory
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
* Insert all files in subdirectory subdirectory of directory directory
* which match fileKinds into resultList
*/
private void listDirectory(File directory,
RelativeDirectory subdirectory,
Set<JavaFileObject.Kind> fileKinds,
boolean recurse,
ListBuffer<JavaFileObject> resultList) {
File d = subdirectory.getFile(directory);
if (!caseMapCheck(d, subdirectory))
return;
File[] files = d.listFiles();
if (files == null)
return;
if (sortFiles != null)
Arrays.sort(files, sortFiles);
for (File f : files) {
String fname = f.getName();
if (f.isDirectory()) {
if (recurse && SourceVersion.isIdentifier(fname)) {
listDirectory(directory,
new RelativeDirectory(subdirectory, fname),
fileKinds,
recurse,
resultList);
}
} else {
if (isValidFile(fname, fileKinds)) {
JavaFileObject fe =
new RegularFileObject(this, fname, new File(d, fname));
resultList.append(fe);
}
}
}
}
示例6: list
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
* Insert all files in a subdirectory of the platform image
* which match fileKinds into resultList.
*/
@Override
public void list(Path userPath,
RelativeDirectory subdirectory,
Set<JavaFileObject.Kind> fileKinds,
boolean recurse,
ListBuffer<JavaFileObject> resultList) throws IOException {
try {
JRTIndex.Entry e = getJRTIndex().getEntry(subdirectory);
if (symbolFileEnabled && e.ctSym.hidden)
return;
for (Path file: e.files.values()) {
if (fileKinds.contains(getKind(file))) {
JavaFileObject fe
= PathFileObject.forJRTPath(JavacFileManager.this, file);
resultList.append(fe);
}
}
if (recurse) {
for (RelativeDirectory rd: e.subdirs) {
list(userPath, rd, fileKinds, recurse, resultList);
}
}
} catch (IOException ex) {
ex.printStackTrace(System.err);
log.error(Errors.ErrorReadingFile(userPath, getMessage(ex)));
}
}
示例7: getJavaFileForOutput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput (Location l, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling)
throws IOException, UnsupportedOperationException, IllegalArgumentException {
URL aptRoot = getAptRoot(sibling);
if (ModuleLocation.isInstance(l)) {
ModuleLocation mloc = ModuleLocation.cast(l);
l = mloc.getBaseLocation();
if (aptRoot == null) {
final Iterator<? extends URL> it = mloc.getModuleRoots().iterator();
aptRoot = it.hasNext() ? it.next() : null;
} else if (!mloc.getModuleRoots().contains(aptRoot)) {
throw new UnsupportedOperationException("ModuleLocation's APT root differs from the sibling's APT root");
}
}
final Location location = l;
if (StandardLocation.SOURCE_OUTPUT != location) {
throw new UnsupportedOperationException("Only apt output is supported."); // NOI18N
}
if (aptRoot == null) {
throw new UnsupportedOperationException(noAptRootDebug(sibling));
}
final String nameStr = className.replace('.', File.separatorChar) + kind.extension; //NOI18N
//Always on master fs -> file is save.
return Optional.ofNullable(URLMapper.findFileObject(aptRoot))
.map(fo -> {
File f = FileUtil.toFile(fo);
return fileTx.createFileObject(location, new File(f, nameStr), f, null, null);
}).get();
}
示例8: getJavaFileForOutput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, javax.tools.FileObject sibling) throws IOException {
assertLocation(location, true);
final String[] ncs = FileObjects.getPackageAndName(className);
return new MemOutFileObject(
ncs[0],
String.format("%s%s", ncs[1], kind.extension));
}
示例9: isNameCompatible
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
cn.getClass();
// null check
if (kind == Kind.OTHER && getKind() != kind) {
return false;
}
String n = cn + kind.extension;
if (name.equals(n)) {
return true;
}
if (isMacOS && Normalizer.isNormalized(name, Normalizer.Form.NFD)
&& Normalizer.isNormalized(n, Normalizer.Form.NFC)) {
// On Mac OS X it is quite possible to file name and class
// name normalized in a different way - in that case we have to normalize file name
// to the Normal Form Compised (NFC)
String normName = Normalizer.normalize(name, Normalizer.Form.NFC);
if (normName.equals(n)) {
this.name = normName;
return true;
}
}
if (name.equalsIgnoreCase(n)) {
try {
// allow for Windows
return file.getCanonicalFile().getName().equals(n);
} catch (IOException e) {
}
}
return false;
}
示例10: getJavaFileForOutput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public JavaFileObject getJavaFileForOutput(Location location,
String className,
JavaFileObject.Kind kind,
FileObject sibling)
throws IOException
{
checkOutputLocation(location);
// validateClassName(className);
nullCheck(className);
nullCheck(kind);
if (!sourceOrClass.contains(kind))
throw new IllegalArgumentException("Invalid kind: " + kind);
return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling);
}
示例11: getJavaFileForInput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location location,
String className,
JavaFileObject.Kind kind)
throws IOException {
if (location == StandardLocation.SOURCE_PATH &&
kind == JavaFileObject.Kind.SOURCE &&
TEST_CLASS_NAME.equals(className)) {
return new SourceFileObject(className, testSource);
}
return super.getJavaFileForInput(location, className, kind);
}
示例12: getJavaFileForInput
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind) throws IOException {
assertLocation(location, false);
return readDelegate.getJavaFileForInput(location, className, kind);
}
示例13: getKind
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
@Override
public JavaFileObject.Kind getKind() {
return this.kind;
}
示例14: getPackageFileKinds
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
/**
* specifies types of files to be read when filling in a package symbol
*/
protected EnumSet<JavaFileObject.Kind> getPackageFileKinds() {
return EnumSet.of(JavaFileObject.Kind.CLASS, JavaFileObject.Kind.SOURCE);
}
示例15: isPkgInfo
import javax.tools.JavaFileObject; //导入方法依赖的package包/类
private boolean isPkgInfo(JavaFileObject fo, JavaFileObject.Kind kind) {
return fo.isNameCompatible("package-info", kind);
}