/** * Convenience method. Rather than store the is-this-vmd-configured-on-this-IProject algorithm * in two places, refer back to the reader's cache. */ public boolean isConfiguredOnProject(IProject project) { return ValidationRegistryReader.getReader().isConfiguredOnProject(this, project); }
/** * @deprecated For use by the validation framework only. */ public boolean isConfigured(IProject project, ValidatorMetaData vmd) { return ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, project); }
protected void setEnabledValidators(Set evmds) { // Check that every VMD in the set is configured on this project. // Necessary because the user can manually choose which validators // to launch, and the validator may not be installed. _enabledValidators.clear(); Iterator iterator = evmds.iterator(); while (iterator.hasNext()) { ValidatorMetaData vmd = (ValidatorMetaData) iterator.next(); if (ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, getProject())) { _enabledValidators.add(vmd); } } }
/** * Given a set of validators, usually the global preference set, change the set so that it * contains only the validators configured on this project. */ private static ValidatorMetaData[] extractProjectValidators(ValidatorMetaData[] vmds, IResource resource) { ValidationRegistryReader reader = ValidationRegistryReader.getReader(); int length = (vmds == null) ? 0 : vmds.length; ValidatorMetaData[] temp = new ValidatorMetaData[length]; if (length == 0) { return temp; } int count = 0; IProject project = (IProject) resource; for (int i = 0; i < vmds.length; i++) { ValidatorMetaData vmd = vmds[i]; if (reader.isConfiguredOnProject(vmd, project)) { temp[count++] = vmd; } } ValidatorMetaData[] result = new ValidatorMetaData[count]; System.arraycopy(temp, 0, result, 0, count); temp = null; return result; }
/** * Given a set of validators, usually the global preference set, change the set so that it * contains only the validators configured on this project. */ private static ValidatorMetaData[] extractProjectValidators(ValidatorMetaData[] vmds, IResource resource, boolean onlyReferenced) { ValidationRegistryReader reader = ValidationRegistryReader.getReader(); int length = (vmds == null) ? 0 : vmds.length; ValidatorMetaData[] temp = new ValidatorMetaData[length]; if (length == 0) { return temp; } int count = 0; IProject project = (IProject) resource; for (int i = 0; i < vmds.length; i++) { ValidatorMetaData vmd = vmds[i]; if (reader.isConfiguredOnProject(vmd, project)) { if (!onlyReferenced || vmd.isDependentValidator()) temp[count++] = vmd; } } ValidatorMetaData[] result = new ValidatorMetaData[count]; System.arraycopy(temp, 0, result, 0, count); temp = null; return result; }
/** * Return true if the validator identified by validatorId will validate the given resource. If * either parameter is null, false is returned. If the validator is not registered with the * validation framework (i.e., either no validator in the activated plugins is identified by * that plugin id, or the given IResource's project does not run that particular validator), * then this method will return false. */ public boolean isApplicableTo(String validatorId, IResource res) { if ((validatorId == null) || (res == null)) { return false; } ValidatorMetaData vmd = ValidationRegistryReader.getReader().getValidatorMetaData(validatorId); if (vmd == null) { // validator not registered with the framework return false; } if (!ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, res.getProject())) { return false; } return vmd.isApplicableTo(res); }
if (!ValidationRegistryReader.getReader().isConfiguredOnProject(vmd, project)) { throw new IllegalArgumentException(ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_EXC_BADVAL, new String[]{vmd.getValidatorDisplayName(), project.getName()}));