• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DocumentationTool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.tools.DocumentationTool的典型用法代码示例。如果您正苦于以下问题:Java DocumentationTool类的具体用法?Java DocumentationTool怎么用?Java DocumentationTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DocumentationTool类属于javax.tools包,在下文中一共展示了DocumentationTool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testBadFileObject

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify bad file object is handled correctly.
 */
@Test
public void testBadFileObject() throws Exception {
    File testSrc = new File(System.getProperty("test.src"));
    File srcFile = new File(testSrc, "pkg/C.class");  // unacceptable file kind
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
        try {
            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
            error("getTask succeeded, no exception thrown");
        } catch (IllegalArgumentException e) {
            System.err.println("exception caught as expected: " + e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:GetTask_FileObjectsTest.java


示例2: testNull

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify null is handled correctly.
 */
@Test
public void testNull() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList((JavaFileObject) null);
        try {
            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
            error("getTask succeeded, no exception thrown");
        } catch (NullPointerException e) {
            System.err.println("exception caught as expected: " + e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:GetTask_FileObjectsTest.java


示例3: testDirectAccess1

import javax.tools.DocumentationTool; //导入依赖的package包/类
@Test
public void testDirectAccess1() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    Context c = new Context();
    Messager.preRegister(c, "javadoc");
    try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        DocumentationTask t = new JavadocTaskImpl(c, null, null, files);
        if (t.call()) {
            System.err.println("task succeeded");
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:JavadocTaskImplTest.java


示例4: testMemoryFileObject

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that expected output files are written via the file manager,
 * for an in-memory file object.
 */
@Test
public void testMemoryFileObject() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
        if (t.call()) {
            System.err.println("task succeeded");
            checkFiles(outDir, standardExpectFiles);
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:GetTask_FileObjectsTest.java


示例5: testNull

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify null is handled correctly.
 */
@Test
public void testNull() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<String> options = Arrays.asList((String) null);
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        try {
            DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
            error("getTask succeeded, no exception thrown");
        } catch (NullPointerException e) {
            System.err.println("exception caught as expected: " + e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:GetTask_OptionsTest.java


示例6: testDoclet

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that an alternate doclet can be specified.
 *
 * There is no standard interface or superclass for a doclet;
 * the only requirement is that it provides static methods that
 * can be invoked via reflection. So, for now, the doclet is
 * specified as a class.
 * Because we cannot create and use a unique instance of the class,
 * we verify that the doclet has been called by having it record
 * (in a static field!) the comment from the last time it was invoked,
 * which is randomly generated each time the test is run.
 */
@Test
public void testDoclet() throws Exception {
    Random r = new Random();
    int key = r.nextInt();
    JavaFileObject srcFile = createSimpleJavaFileObject(
            "pkg/C",
            "package pkg; /** " + key + "*/ public class C { }");
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files);
        if (t.call()) {
            System.err.println("task succeeded");
            if (TestDoclet.lastCaller.equals(String.valueOf(key)))
                System.err.println("found expected key: " + key);
            else
                error("Expected key not found");
            checkFiles(outDir, Collections.<String>emptySet());
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:GetTask_DocletClassTest.java


示例7: testRawCall

import javax.tools.DocumentationTool; //导入依赖的package包/类
@Test
public void testRawCall() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);

        @SuppressWarnings("rawtypes")
        Callable t = tool.getTask(null, fm, null, null, null, files);

        if (t.call() == Boolean.TRUE) {
            System.err.println("task succeeded");
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:JavadocTaskImplTest.java


示例8: testDirectAccess2

import javax.tools.DocumentationTool; //导入依赖的package包/类
@Test
public void testDirectAccess2() throws Exception {
    JavaFileObject srcFile = null; // error, provokes NPE
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    Context c = new Context();
    Messager.preRegister(c, "javadoc");
    try (StandardJavaFileManager fm = new JavacFileManager(c, true, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        try {
            DocumentationTask t = new JavadocTaskImpl(c, null, null, files);;
            error("getTask succeeded, no exception thrown");
        } catch (NullPointerException e) {
            System.err.println("exception caught as expected: " + e);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:JavadocTaskImplTest.java


示例9: testStandardFileObject

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that expected output files are written via the file manager,
 * for a source file read from the file system with StandardJavaFileManager.
 */
@Test
public void testStandardFileObject() throws Exception {
    File testSrc = new File(System.getProperty("test.src"));
    File srcFile = new File(testSrc, "pkg/C.java");
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
        if (t.call()) {
            System.err.println("task succeeded");
            checkFiles(outDir, standardExpectFiles);
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:GetTask_FileObjectsTest.java


示例10: testNoIndex

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that expected output files are written for given options.
 */
@Test
public void testNoIndex() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        Iterable<String> options = Arrays.asList("-noindex");
        DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
        if (t.call()) {
            System.err.println("task succeeded");
            Set<String> expectFiles = new TreeSet<String>(noIndexFiles);
            checkFiles(outDir, expectFiles);
        } else {
            error("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:GetTask_OptionsTest.java


示例11: readPackageListFromFile

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Read the "package-list" file which is available locally.
 *
 * @param path URL or directory path to the packages.
 * @param pkgListPath Path to the local "package-list" file.
 */
private void readPackageListFromFile(String path, DocFile pkgListPath)
        throws Fault {
    DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
    if (! (file.isAbsolute() || linkoffline)){
        file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
    }
    try {
        if (file.exists() && file.canRead()) {
            boolean pathIsRelative =
                    !DocFile.createFileForInput(configuration, path).isAbsolute()
                    && !isUrl(path);
            readPackageList(file.openInputStream(), path, pathIsRelative);
        } else {
            throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
        }
    } catch (IOException exc) {
       throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:Extern.java


示例12: PathDocFileFactory

import javax.tools.DocumentationTool; //导入依赖的package包/类
public PathDocFileFactory(Configuration configuration) {
    super(configuration);
    fileManager = (PathFileManager) configuration.getFileManager();

    if (!configuration.destDirName.isEmpty()
            || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
        try {
            String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
            Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
            fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
        } catch (IOException e) {
            throw new DocletAbortException(e);
        }
    }

    destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:PathDocFileFactory.java


示例13: getDestDir

import javax.tools.DocumentationTool; //导入依赖的package包/类
private File getDestDir() {
    if (destDir == null) {
        if (!configuration.destDirName.isEmpty()
                || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
            try {
                String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
                File dir = new File(dirName);
                fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
            } catch (IOException e) {
                throw new DocletAbortException(e);
            }
        }

        destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
    }
    return destDir;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:StandardDocFileFactory.java


示例14: readPackageListFromFile

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Read the "package-list" file which is available locally.
 *
 * @param path URL or directory path to the packages.
 * @param pkgListPath Path to the local "package-list" file.
 * @throws Fault if an error occurs that can be treated as a warning
 * @throws DocFileIOException if there is a problem opening the package list file
 */
private void readPackageListFromFile(String path, DocFile pkgListPath)
        throws Fault, DocFileIOException {
    DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
    if (! (file.isAbsolute() || linkoffline)){
        file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
    }
    try {
        if (file.exists() && file.canRead()) {
            boolean pathIsRelative =
                    !isUrl(path)
                    && !DocFile.createFileForInput(configuration, path).isAbsolute();
            readPackageList(file.openInputStream(), path, pathIsRelative);
        } else {
            throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
        }
    } catch (IOException exc) {
       throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Extern.java


示例15: setDestDir

import javax.tools.DocumentationTool; //导入依赖的package包/类
@Override
public void setDestDir(String destDirName) throws SimpleDocletException {
    if (destDir != null)
        throw new AssertionError("destDir already initialized: " + destDir);

    if (!destDirName.isEmpty()
            || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
        try {
            String dirName = destDirName.isEmpty() ? "." : destDirName;
            Path dir = Paths.get(dirName);
            fileManager.setLocationFromPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
        } catch (IOException e) {
            // generic IOException from file manager, setting location, e.g. file not a directory
            String message = configuration.getResources().getText("doclet.error.initializing.dest.dir", e);
            throw new SimpleDocletException(message, e);
        }
    }

    destDir = fileManager.getLocationAsPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:StandardDocFileFactory.java


示例16: getAndRunTask

import javax.tools.DocumentationTool; //导入依赖的package包/类
private DocumentationTask getAndRunTask() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
        if (t.call()) {
            System.err.println("task succeeded");
            return t;
        } else {
            throw new Exception("task failed");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Task_reuseTest.java


示例17: testBadDoclet

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that exceptions from a doclet are thrown as expected.
 */
@Test
public void testBadDoclet() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
        try {
            t.call();
            error("call completed without exception");
        } catch (RuntimeException e) {
            e.printStackTrace();
            Throwable c = e.getCause();
            if (c.getClass() == UnexpectedError.class)
                System.err.println("exception caught as expected: " + c);
            else
                throw e;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:GetTask_DocletClassTest.java


示例18: testFileManager

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that an alternate file manager can be specified:
 * in this case, a TestFileManager.
 */
@Test
public void testFileManager() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    StandardJavaFileManager fm = new TestFileManager();
    File outDir = getOutDir();
    fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
    Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
    DocumentationTask t = tool.getTask(null, fm, null, null, Arrays.asList("-verbose"), files);
    if (t.call()) {
        System.err.println("task succeeded");
        checkFiles(outDir, standardExpectFiles);
    } else {
        throw new Exception("task failed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:GetTask_FileManagerTest.java


示例19: testBadDoclet

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Verify that exceptions from a doclet are thrown as expected.
 */
@Test
public void testBadDoclet() throws Exception {
    JavaFileObject srcFile = createSimpleJavaFileObject();
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File outDir = getOutDir();
        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
        DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
        try {
            t.call();
            error("call completed without exception");
        } catch (RuntimeException e) {
            Throwable c = e.getCause();
            if (c.getClass() == UnexpectedError.class)
                System.err.println("exception caught as expected: " + c);
            else
                throw e;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:GetTask_DocletClassTest.java


示例20: readPackageListFromFile

import javax.tools.DocumentationTool; //导入依赖的package包/类
/**
 * Read the "package-list" file which is available locally.
 *
 * @param path URL or directory path to the packages.
 * @param pkgListPath Path to the local "package-list" file.
 */
private void readPackageListFromFile(String path, DocFile pkgListPath)
        throws Fault {
    DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
    if (! (file.isAbsolute() || linkoffline)){
        file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
    }
    try {
        if (file.exists() && file.canRead()) {
            boolean pathIsRelative =
                    !isUrl(path)
                    && !DocFile.createFileForInput(configuration, path).isAbsolute();
            readPackageList(file.openInputStream(), path, pathIsRelative);
        } else {
            throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
        }
    } catch (IOException exc) {
       throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:26,代码来源:Extern.java



注:本文中的javax.tools.DocumentationTool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FrameworkMessage类代码示例发布时间:2022-05-22
下一篇:
Java InvalidXPathException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap