当前位置: 首页>>代码示例>>Java>>正文


Java Option.hasArg方法代码示例

本文整理汇总了Java中com.sun.tools.javac.main.JavacOption.Option.hasArg方法的典型用法代码示例。如果您正苦于以下问题:Java Option.hasArg方法的具体用法?Java Option.hasArg怎么用?Java Option.hasArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.main.JavacOption.Option的用法示例。


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

示例1: processArgs

import com.sun.tools.javac.main.JavacOption.Option; //导入方法依赖的package包/类
/** Process command line arguments: store all command line options
 *  in `options' table and return all source filenames.
 *  @param flags    The array of command line arguments.
 */
public List<File> processArgs(String[] flags) { // XXX sb protected
    int ac = 0;
    while (ac < flags.length) {
        String flag = flags[ac];
        ac++;

        int j;
        // quick hack to speed up file processing:
        // if the option does not begin with '-', there is no need to check
        // most of the compiler options.
        int firstOptionToCheck = flag.charAt(0) == '-' ? 0 : recognizedOptions.length-1;
        for (j=firstOptionToCheck; j<recognizedOptions.length; j++)
            if (recognizedOptions[j].matches(flag)) break;

        if (j == recognizedOptions.length) {
            error("err.invalid.flag", flag);
            return null;
        }

        Option option = recognizedOptions[j];
        if (option.hasArg()) {
            if (ac == flags.length) {
                error("err.req.arg", flag);
                return null;
            }
            String operand = flags[ac];
            ac++;
            if (option.process(options, flag, operand))
                return null;
        } else {
            if (option.process(options, flag))
                return null;
        }
    }

    if (!checkDirectory("-d"))
        return null;
    if (!checkDirectory("-s"))
        return null;

    String sourceString = options.get("-source");
    Source source = (sourceString != null)
        ? Source.lookup(sourceString)
        : Source.DEFAULT;
    String targetString = options.get("-target");
    Target target = (targetString != null)
        ? Target.lookup(targetString)
        : Target.DEFAULT;
    // We don't check source/target consistency for CLDC, as J2ME
    // profiles are not aligned with J2SE targets; moreover, a
    // single CLDC target may have many profiles.  In addition,
    // this is needed for the continued functioning of the JSR14
    // prototype.
    if (Character.isDigit(target.name.charAt(0))) {
        if (target.compareTo(source.requiredTarget()) < 0) {
            if (targetString != null) {
                if (sourceString == null) {
                    warning("warn.target.default.source.conflict",
                            targetString,
                            source.requiredTarget().name);
                } else {
                    warning("warn.source.target.conflict",
                            sourceString,
                            source.requiredTarget().name);
                }
                return null;
            } else {
                options.put("-target", source.requiredTarget().name);
            }
        } else {
            if (targetString == null && !source.allowGenerics()) {
                options.put("-target", Target.JDK1_4.name);
            }
        }
    }
    return filenames.toList();
}
 
开发者ID:lucasicf,项目名称:metricgenerator-jdk-compiler,代码行数:82,代码来源:Main.java


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