本文整理汇总了Java中org.eclipse.wst.validation.ValidationResult类的典型用法代码示例。如果您正苦于以下问题:Java ValidationResult类的具体用法?Java ValidationResult怎么用?Java ValidationResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationResult类属于org.eclipse.wst.validation包,在下文中一共展示了ValidationResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private List validate(String html) throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
if (!project.exists()) {
project.create(new NullProgressMonitor());
project.open(new NullProgressMonitor());
}
// Add tsconfig.json in order to the project has angular nature
IFile tsconfigJson = project.getFile("tsconfig.json");
if (!tsconfigJson.exists()) {
tsconfigJson.create(IOUtils.toInputStream("{}"), 1, new NullProgressMonitor());
}
IFile file = project.getFile("test.html");
if (file.exists()) {
file.setContents(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
} else {
file.create(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
}
HTMLValidator validator = new HTMLValidator();
ValidationResult result = validator.validate(file, 1, new ValidationState(), new NullProgressMonitor());
IReporter reporter = result.getReporter(new NullProgressMonitor());
return reporter.getMessages();
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:25,代码来源:HTMLAngularValidatorTest.java
示例2: validateRegions
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
protected void validateRegions(IResource resource, IDocument document,
ValidationResult result, List<ElementRegion> regions,
String message, int severity) {
Map<String, ElementRegion> duplicateCheckMap = new HashMap<String, ElementRegion>();
List<String> reportedRegionValues = new ArrayList<String>();
for (ElementRegion region : regions) {
if (duplicateCheckMap.containsKey(region.getValue())) {
result.add(createMessage(resource, document,
region.getValueRegion(), severity, message));
if (!reportedRegionValues.contains(region.getValue())) {
reportedRegionValues.add(region.getValue());
result.add(createMessage(resource, document,
duplicateCheckMap.get(region.getValue())
.getValueRegion(), severity, message));
}
} else {
duplicateCheckMap.put(region.getValue(), region);
}
}
}
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:23,代码来源:AbstractXmlValidator.java
示例3: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
IDocument document = null;
// get document
try {
final IDocumentProvider provider = new TextFileDocumentProvider();
provider.connect(resource);
document = provider.getDocument(resource);
provider.disconnect(resource);
} catch (CoreException e) {
e.printStackTrace();
}
ValidationResult result = new ValidationResult();
if (document != null) {
// validate definitions names
List<ElementRegion> definitionNameRegions = tilesXmlParser
.getDefinitionNameRegions(document);
validateRegions(resource, document, result, definitionNameRegions,
DUP_DEFINITION_MESSAGE_TEXT, IMarker.SEVERITY_WARNING);
}
return result;
}
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:26,代码来源:TilesXmlValidator.java
示例4: validateResultMapId
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateResultMapId(IJavaProject project, IFile file, IDOMDocument doc,
ValidationResult result, IDOMAttr attr, String attrValue, IReporter reporter)
throws JavaModelException, XPathExpressionException
{
if (attrValue.indexOf(',') == -1)
{
validateReference(project, file, doc, result, attr, attrValue, "resultMap", reporter);
}
else
{
String[] resultMapArr = attrValue.split(",");
for (String resultMapRef : resultMapArr)
{
String ref = resultMapRef.trim();
if (ref.length() > 0)
{
validateReference(project, file, doc, result, attr, ref, "resultMap", reporter);
}
}
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:22,代码来源:XmlValidator.java
示例5: validateStatementId
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateStatementId(IDOMElement element, IFile file, IDOMDocument doc,
ValidationResult result, IJavaProject project, IDOMAttr attr, String attrValue)
throws JavaModelException, XPathExpressionException
{
if (attrValue == null)
{
return;
}
String qualifiedName = MybatipseXmlUtil.getNamespace(doc);
IType mapperType = project.findType(qualifiedName);
if (mapperType != null
&& !JavaMapperCache.getInstance().methodExists(project, qualifiedName, attrValue))
{
addMarker(result, file, doc.getStructuredDocument(), attr, MISSING_STATEMENT_METHOD,
IMarker.SEVERITY_WARNING, IMarker.PRIORITY_HIGH,
"Method '" + attrValue + "' not found or there is an overload method"
+ " (same name with different parameters) in mapper interface " + qualifiedName);
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:21,代码来源:XmlValidator.java
示例6: addMarker
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void addMarker(ValidationResult result, IFile file, IStructuredDocument doc,
IDOMAttr attr, String problemType, int severity, int priority, String message)
{
int start = attr.getValueRegionStartOffset();
int length = attr.getValueRegionText().length();
int lineNo = doc.getLineOfOffset(start);
ValidatorMessage marker = ValidatorMessage.create(message, file);
marker.setType(MARKER_ID);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.PRIORITY, priority);
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.LINE_NUMBER, lineNo);
if (start != 0)
{
marker.setAttribute(IMarker.CHAR_START, start);
marker.setAttribute(IMarker.CHAR_END, start + length);
}
// Adds custom attributes.
marker.setAttribute("problemType", problemType);
marker.setAttribute("errorValue", attr.getValue());
result.add(marker);
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:23,代码来源:XmlValidator.java
示例7: validateFile
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
protected void validateFile(IValidationContext helper, IReporter reporter,
IFile file, ValidationResult result) {
if ((reporter != null) && (reporter.isCancelled() == true)) {
throw new OperationCanceledException();
}
if (!shouldValidate(file)) {
return;
}
IDOMModel model = getModel(file.getProject(), file);
if (model == null)
return;
try {
Collection dependencies = null;
NodeImpl document = null;
if (model.getDocument() instanceof NodeImpl) {
document = (NodeImpl) model.getDocument();
}
validate(reporter, file, model);
} finally {
releaseModel(model);
}
}
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:24,代码来源:WebResourcesValidator.java
示例8: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
/**
* Extracts byte[] from XML.
*/
@Override
public ValidationResult validate(ValidationEvent event, ValidationState state,
IProgressMonitor monitor) {
IFile file = (IFile) event.getResource();
try (InputStream in = file.getContents()) {
byte[] bytes = ByteStreams.toByteArray(in);
validate(file, bytes);
} catch (IOException | CoreException ex) {
logger.log(Level.SEVERE, ex.getMessage());
}
return new ValidationResult();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:16,代码来源:XmlValidator.java
示例9: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
try {
validateDockerFile((IFile) resource, reporter, result);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:16,代码来源:DockerfileValidator.java
示例10: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
fReporter = result.getReporter(monitor);
validateFile((IFile) resource, fReporter);
return result;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:10,代码来源:JSONSyntaxValidator.java
示例11: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
/**
* Perform the validation using version 2 of the validation framework.
*/
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
ValidationResult result = new ValidationResult();
IFile file = null;
if (resource instanceof IFile)
file = (IFile) resource;
if (file != null && shouldValidate(file)) {
IReporter reporter = result.getReporter(monitor);
NestedValidatorContext nestedcontext = getNestedContext(state,
false);
boolean teardownRequired = false;
if (nestedcontext == null) {
// validationstart was not called, so manually setup and tear
// down
nestedcontext = getNestedContext(state, true);
nestedcontext.setProject(file.getProject());
setupValidation(nestedcontext);
teardownRequired = true;
} else {
nestedcontext.setProject(file.getProject());
}
validate(file, null, result, reporter, nestedcontext);
if (teardownRequired)
teardownValidation(nestedcontext);
}
return result;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:34,代码来源:AbstractNestedValidator.java
示例12: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(final IResource resource, int kind, ValidationState state,
IProgressMonitor monitor)
{
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
final IReporter reporter = result.getReporter(monitor);
validateFile((IFile)resource, reporter, result);
return result;
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:12,代码来源:XmlValidator.java
示例13: validateFile
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateFile(IFile file, IReporter reporter, ValidationResult result)
{
if ((reporter != null) && (reporter.isCancelled() == true))
{
throw new OperationCanceledException();
}
IStructuredModel model = null;
try
{
file.deleteMarkers(MARKER_ID, false, IResource.DEPTH_ZERO);
model = StructuredModelManager.getModelManager().getModelForRead(file);
IDOMModel domModel = (IDOMModel)model;
IDOMDocument domDoc = domModel.getDocument();
NodeList nodes = domDoc.getChildNodes();
IJavaProject project = JavaCore.create(file.getProject());
for (int k = 0; k < nodes.getLength(); k++)
{
Node child = nodes.item(k);
if (child instanceof IDOMElement)
{
validateElement(project, (IDOMElement)child, file, domDoc, reporter, result);
}
}
}
catch (Exception e)
{
Activator.log(Status.WARNING, "Error occurred during validation.", e);
}
finally
{
if (model != null)
{
model.releaseFromRead();
}
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:39,代码来源:XmlValidator.java
示例14: validateNamespace
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateNamespace(IFile file, IDOMDocument doc, ValidationResult result,
IDOMAttr attr, String attrValue)
{
if (attrValue == null || attrValue.length() == 0)
{
addMarker(result, file, doc.getStructuredDocument(), attr, NAMESPACE_MANDATORY,
IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH, "Namespace must be specified.");
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:10,代码来源:XmlValidator.java
示例15: validateReference
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateReference(IJavaProject project, IFile file, IDOMDocument doc,
ValidationResult result, IDOMAttr attr, String attrValue, String targetElement,
IReporter reporter) throws JavaModelException, XPathExpressionException
{
if (!ValidatorHelper.isReferenceValid(project, MybatipseXmlUtil.getNamespace(doc), doc,
attrValue, targetElement))
{
addMarker(result, file, doc.getStructuredDocument(), attr, MISSING_SQL,
IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH,
targetElement + " with id='" + attrValue + "' not found.");
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:13,代码来源:XmlValidator.java
示例16: validateProperty
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateProperty(IDOMElement element, IFile file, IDOMDocument doc,
ValidationResult result, IJavaProject project, IDOMAttr attr, String attrValue,
IReporter reporter) throws JavaModelException
{
String qualifiedName = MybatipseXmlUtil.findEnclosingType(element);
if (qualifiedName == null || MybatipseXmlUtil.isDefaultTypeAlias(qualifiedName))
{
return;
}
IType type = project.findType(qualifiedName);
if (type == null)
{
qualifiedName = TypeAliasCache.getInstance().resolveAlias(project, qualifiedName,
reporter);
if (qualifiedName != null)
type = project.findType(qualifiedName);
}
if (type == null || !isValidatable(project, type))
{
// Skip validation when enclosing type is missing or it's a map.
return;
}
Map<String, String> fields = BeanPropertyCache.searchFields(project, qualifiedName,
attrValue, false, -1, true);
if (fields.size() == 0)
{
addMarker(result, file, doc.getStructuredDocument(), attr, MISSING_TYPE,
IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH,
"Property '" + attrValue + "' not found in class " + qualifiedName);
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:32,代码来源:XmlValidator.java
示例17: validateJavaType
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void validateJavaType(IJavaProject project, IFile file, IDOMDocument doc,
IDOMAttr attr, String qualifiedName, ValidationResult result, IReporter reporter)
throws JavaModelException
{
if (!MybatipseXmlUtil.isDefaultTypeAlias(qualifiedName)
&& project.findType(qualifiedName) == null
&& TypeAliasCache.getInstance().resolveAlias(project, qualifiedName, reporter) == null)
{
addMarker(result, file, doc.getStructuredDocument(), attr, MISSING_TYPE,
IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH,
"Class/TypeAlias '" + qualifiedName + "' not found.");
}
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:14,代码来源:XmlValidator.java
示例18: warnDeprecated
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
private void warnDeprecated(IFile file, IDOMDocument doc, ValidationResult result,
String tagName, IDOMAttr attr)
{
addMarker(result, file, doc.getStructuredDocument(), attr, DEPRECATED,
IMarker.SEVERITY_WARNING, IMarker.PRIORITY_HIGH,
"'" + tagName + "' is deprecated and should not be used.");
}
开发者ID:mybatis,项目名称:mybatipse,代码行数:8,代码来源:XmlValidator.java
示例19: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
validateFile(null, reporter, (IFile) resource, result);
return result;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:11,代码来源:WebResourcesValidator.java
示例20: validate
import org.eclipse.wst.validation.ValidationResult; //导入依赖的package包/类
@Override
public ValidationReport validate(String uri, InputStream inputstream,
NestedValidatorContext context, ValidationResult result) {
JSONValidator validator = JSONValidator.getInstance();
JSONValidationConfiguration configuration = new JSONValidationConfiguration();
// try {
// // Preferences pluginPreferences =
// // JSONCorePlugin.getDefault().getPluginPreferences();
// configuration.setFeature(
// JSONValidationConfiguration.INDICATE_NO_GRAMMAR,
// indicateNoGrammar);
// final IPreferencesService preferencesService = Platform
// .getPreferencesService();
// configuration
// .setFeature(
// JSONValidationConfiguration.INDICATE_NO_DOCUMENT_ELEMENT,
// preferencesService
// .getInt(JSONCorePlugin.getDefault()
// .getBundle().getSymbolicName(),
// JSONCorePreferenceNames.INDICATE_NO_DOCUMENT_ELEMENT,
// -1, fPreferenceScopes));
// configuration.setFeature(JSONValidationConfiguration.USE_XINCLUDE,
// preferencesService.getBoolean(JSONCorePlugin.getDefault()
// .getBundle().getSymbolicName(),
// JSONCorePreferenceNames.USE_XINCLUDE, false,
// fPreferenceScopes));
// configuration
// .setFeature(
// JSONValidationConfiguration.HONOUR_ALL_SCHEMA_LOCATIONS,
// preferencesService
// .getBoolean(
// JSONCorePlugin.getDefault()
// .getBundle()
// .getSymbolicName(),
// JSONCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS,
// true, fPreferenceScopes));
// } catch (Exception e) {
// // TODO: Unable to set the preference. Log this problem.
// }
JSONValidationReport valreport = validator.validate(uri, inputstream,
configuration, result, context);
return valreport;
}
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:47,代码来源:Validator.java
注:本文中的org.eclipse.wst.validation.ValidationResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论