private void updateProfiles() { profiles.removeAllItems(); for (Profile profile : Profile.values()) { if (profile.compareTo(reqProfile) >= 0) { profiles.addItem(profile); } } profiles.setSelectedItem(reqProfile); }
private void validateBinaryFile( @NonNull final FileObject fo, @NonNull final ViolationCollector collector) { final Profile profileToCheck = context.getRequredProfile(); final TypeCache tc = context.getTypeCache(); try { try (InputStream in = fo.getInputStream()) { ClassFile cf = new ClassFile(in); for (ClassName className : cf.getAllClassNames()) { final Profile p = tc.profileForType(className); if (p != null && profileToCheck.compareTo(p) < 0) { collector.reportProfileViolation( new Violation( root, p, map(fo), ElementHandleAccessor.getInstance().create(ElementKind.CLASS, className.getInternalName().replace('/', '.')) //NOI18N )); } } } } catch (IOException ioe) { LOG.log( Level.INFO, "Cannot validate file: {0}", //NOI18N FileUtil.getFileDisplayName(fo)); } }
@Override protected void validate(@NonNull final ViolationCollector collector) { if (context.isCancelled()) { return; } Profile current = null; if (context.shouldValidate(Validation.BINARIES_BY_MANIFEST)) { final Union2<Profile,String> res = findProfileInManifest(root); if (!res.hasFirst()) { //Invalid value of profile in manifest of dependent jar collector.reportProfileViolation(new Violation(root, null, null, null)); return; } current = res.first(); if (current != Profile.DEFAULT && current.compareTo(context.getRequredProfile()) > 0) { //Hiher profile in manifest of dependent jar collector.reportProfileViolation(new Violation(root, res.first(), null, null)); return; } } if (context.shouldValidate(Validation.BINARIES_BY_CLASS_FILES)) { if (current == null || current == Profile.DEFAULT) { validateBinaryRoot(root, collector); } } }
@CheckForNull static Profile max (@NullAllowed Profile a, @NullAllowed Profile b) { if (b == null) { return a; } if (a == null) { return b; } return a.compareTo(b) <= 0 ? b : a; }