本文整理汇总了Java中org.eclipse.wst.validation.ValidationResult类的典型用法代码示例。如果您正苦于以下问题:Java ValidationResult类的具体用法?Java ValidationResult怎么用?Java ValidationResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationResult类属于org.eclipse.wst.validation包,在下文中一共展示了ValidationResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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.");
}
}
示例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.");
}
}