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


Java SourceVersion.RELEASE_5属性代码示例

本文整理汇总了Java中javax.lang.model.SourceVersion.RELEASE_5属性的典型用法代码示例。如果您正苦于以下问题:Java SourceVersion.RELEASE_5属性的具体用法?Java SourceVersion.RELEASE_5怎么用?Java SourceVersion.RELEASE_5使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.SourceVersion的用法示例。


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

示例1: resolveSourceVersion

public static SourceVersion resolveSourceVersion(FileObject file) {
    String sourceLevel = SourceLevelQuery.getSourceLevel(file);
    if (sourceLevel == null) {
        return SourceVersion.latest();
    } else if (sourceLevel.startsWith("1.6")) {
        return SourceVersion.RELEASE_6;
    } else if (sourceLevel.startsWith("1.5")) {
        return SourceVersion.RELEASE_5;
    } else if (sourceLevel.startsWith("1.4")) {
        return SourceVersion.RELEASE_4;
    } else if (sourceLevel.startsWith("1.3")) {
        return SourceVersion.RELEASE_3;
    } else if (sourceLevel.startsWith("1.2")) {
        return SourceVersion.RELEASE_2;
    } else if (sourceLevel.startsWith("1.1")) {
        return SourceVersion.RELEASE_1;
    } else if (sourceLevel.startsWith("1.0")) {
        return SourceVersion.RELEASE_0;
    }
    
    return SourceVersion.latest();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavadocUtilities.java

示例2: getRuntimeSourceVersion

private static SourceVersion getRuntimeSourceVersion() {
    final String specVer = System.getProperty("java.specification.version", "");    //NOI18N
    final String parts[] = specVer.split("\\.");    //NOI18N
    try {
        int major;
        int minor;
        if (parts.length == 1) {
            major = Integer.parseInt(parts[0]);
            minor = 0;
        } else if (parts.length == 2) {
            major = Integer.parseInt(parts[0]);
            minor = Integer.parseInt(parts[1]);
        } else {
            return SourceVersion.RELEASE_5;
        }
        final SourceVersion[] sourceVersions = SourceVersion.values();
        do {
            final int ordinal = major >= 9 ? major : minor;
            if (sourceVersions.length > ordinal) {
                return sourceVersions[ordinal];
            }
            //Downgrade
            if (major > 9) {
                major -= 1;
            } else if (major == 9) {
                major = 1;
                minor = 8;
            } else {
                minor -= 1;
            }
        } while ((major > 1) || (minor >= 0));
    } catch (NumberFormatException e) {
        logger.log(
            Level.WARNING,
            "Invalid java.specification.version: {0}, using 1.5",   //NOI18N
            specVer);
    }
    return SourceVersion.RELEASE_5;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:HQLEditorController.java

示例3: genTestObjectWildcard

/**
 * Generate an object to be used with the various wildcard pattern forms.
 * Explicitly supports only specific package wildcards with specific objects.
 * @param pattern a wildcard pattern ending in "*"
 * @param allowed a boolean indicating to generate the allowed or disallowed case
 * @return an object within or outside the wildcard
 */
static Object genTestObjectWildcard(String pattern, boolean allowed) {
    if (pattern.endsWith(".**")) {
        // package hierarchy wildcard
        if (pattern.startsWith("javax.lang.")) {
            return SourceVersion.RELEASE_5;
        }
        if (pattern.startsWith("java.")) {
            return 4;
        }
        if (pattern.startsWith("javax.")) {
            return SourceVersion.RELEASE_6;
        }
        return otherObject;
    } else if (pattern.endsWith(".*")) {
        // package wildcard
        if (pattern.startsWith("javax.lang.model")) {
            return SourceVersion.RELEASE_6;
        }
    } else {
        // class wildcard
        if (pattern.equals("*")) {
            return otherObject; // any object will do
        }
        if (pattern.startsWith("java.util.Hash")) {
            return new Hashtable<String, String>();
        }
    }
    Assert.fail("Object could not be generated for pattern: "
            + pattern
            + ", allowed: " + allowed);
    return null;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:39,代码来源:SerialFilterTest.java

示例4: run

@TriggerTreeKind(Kind.METHOD)
public static ErrorDescription run(HintContext ctx) {
    CompilationInfo compilationInfo = ctx.getInfo();
    TreePath treePath = ctx.getPath();
    TypeElement el = compilationInfo.getElements().getTypeElement("java.lang.Override"); //NOI18N

    if (el == null || !GeneratorUtils.supportsOverride(compilationInfo))
        return null;

    Element e = compilationInfo.getTrees().getElement(treePath);

    if (e != null && e.getKind() == ElementKind.METHOD) {
        ExecutableElement ee = (ExecutableElement) e;
        List<ElementDescription> result = new ArrayList<ElementDescription>();

        Element enclEl = ee.getEnclosingElement();
        if (!enclEl.getKind().isClass() && !enclEl.getKind().isInterface())
            return null;

        AnnotationType type = ComputeOverriding.detectOverrides(compilationInfo, (TypeElement) enclEl, ee, result);

        boolean hasOverriddenAnnotation = false;

        for (AnnotationMirror am : ee.getAnnotationMirrors()) {
            if (compilationInfo.getTypes().isSameType(am.getAnnotationType(), el.asType())) {
                hasOverriddenAnnotation = true;
                break;
            }
        }

        if (hasOverriddenAnnotation) {
            return null;
        }

        boolean addHint = false;

        if (type == AnnotationType.OVERRIDES) {
            addHint = true;
        } else {
            if (type == AnnotationType.IMPLEMENTS) {
                addHint = compilationInfo.getSourceVersion() != SourceVersion.RELEASE_5;
            }
        }

        if (addHint) {
            String desc = NbBundle.getMessage(AddOverrideAnnotation.class, "HINT_AddOverrideAnnotation");
            return ErrorDescriptionFactory.forName(ctx, treePath, desc, new FixImpl(compilationInfo, treePath).toEditorFix());
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:AddOverrideAnnotation.java


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