diff options
author | vbhadrir | 2005-04-18 15:40:27 +0000 |
---|---|---|
committer | vbhadrir | 2005-04-18 15:40:27 +0000 |
commit | 98e5b514b4882d78886af4f8bdee897752e49b95 (patch) | |
tree | fb8fdad5a41315485b02ac7740dbd50becdbfc6a /plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst | |
parent | 1b9674a645b00f3de4a68d2223cc0fc7565451f6 (diff) | |
download | webtools.common-98e5b514b4882d78886af4f8bdee897752e49b95.tar.gz webtools.common-98e5b514b4882d78886af4f8bdee897752e49b95.tar.xz webtools.common-98e5b514b4882d78886af4f8bdee897752e49b95.zip |
renamed eclispe typo to eclipse in validation framework plugin
Diffstat (limited to 'plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst')
8 files changed, 949 insertions, 1 deletions
diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/FileDelta.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/FileDelta.java new file mode 100644 index 000000000..a0229a5d9 --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/FileDelta.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + + + +/** + * <p> + * Default implementation of the IFileDelta + * </p> + * + * @see org.eclipse.wst.validation.internal.core.IFileDelta + * + * [issue: CS - is there a reason that we need to expose this impl class as an API? + * It would seem better to only expose IFileDelta. I can't think of a reason where + * a typical client would need to create one of these.] + */ +public class FileDelta implements IFileDelta { + private int fileDelta = 0; + private String fileName = null; + + /** + * <p> + * Creates a default instance of the FileDelta + * </p> + */ + public FileDelta() { + super(); + } + + /** + * <p> + * Constructor is used to initialize the fields. + * </p> + * + * @param aFileName specifies the file name + * @param aFileDelta specifies the + */ + public FileDelta(String aFileName, int aFileDelta) { + fileName = aFileName; + fileDelta = aFileDelta; + } + + /** + * @see IFileDelta#getDeltaType() + */ + public int getDeltaType() { + return fileDelta; + } + + /** + * @see IFileDelta#getFileName() + */ + public String getFileName() { + return fileName; + } + + /** + * <p> + * Set the flag which indicates the type of change that the file + * has undergone. + * </p> + */ + public void setDeltaType(int deltaType) { + fileDelta = deltaType; + } + + /** + * <p> + * Set the name of the file which has changed. + * </p> + */ + public void setFileName(String aFileName) { + fileName = aFileName; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IFileDelta.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IFileDelta.java new file mode 100644 index 000000000..21a9cd62a --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IFileDelta.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + +/** + * <p> + * This interface is used, for incremental validation, to encapsulate the change + * status of a resource. IFileDelta contains the name of the file which has + * changed, and a flag which indicates the type of change which has occurred. + * + * @since 1.0 + * </p> + * [issue: LM - From speaking with Vijay the name IFileDelta doesn't really capture + * what this interface is for. Validation may occur of files, it may occur on resources, + * or it may occur on something more abstract simply known as an artifact. The delta part + * of the name also seems misleading as this interface doesn't provide the delta but + * rather provides the type of change. I suggest renaming this interface to IModifiedArtifact + * or something along those lines to better capture its use. ] + */ +public interface IFileDelta { + public static final int ADDED = 1; // the file has been added + public static final int CHANGED = 2; // the file has been changed + public static final int DELETED = 3; // the file has been deleted + + /** + * <p> + * Returns the flag which indicates the type of change which has occurred: + * IFileDelta.ADDED, IFileDelta.CHANGED, or IFileDelta.DELETED. + * </p> + * @return returns the delta type. + * @since WTP 1.0 + * + * [issue: LM - From my experience a validator simply needs to know what artifact needs + * to be validated. Can you provide a use case where the type of change is needed for + * validation? ] + */ + public int getDeltaType(); + + /** + * <p> + * Returns the name of the eclipse resource file which has changed. The return value must not be + * null or the empty string (""). + * </p> + * @return returns the file name. + * @since WTP 1.0 + * + * [issue: LM - Following my comments above this method should be renamed to getArtifactName or + * something that follows along with the interface rename. ] + */ + public String getFileName(); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IMessageAccess.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IMessageAccess.java new file mode 100644 index 000000000..91e149c2e --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/IMessageAccess.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + + +import java.util.Locale; +import java.util.List; + + +/** + * <p> + * Interface which can be used to access messages which are stored within a reporter which retains + * its message history. + * </p> + * + * [issue: CS - This interface seems like overkill. I'd think that an IReport should simply have a getMessages() method. + * I think MessageFiltering should take place at the 'display' level and not at this level of the API.] + */ +public interface IMessageAccess { + /** + * @param filter + * A filter which specifies a subset of messages to retrieve. null specifies, "all + * messages". + * @return List list of messages related to the target object + */ + public abstract List getMessages(MessageFilter filter); + + /** + * @param filter + * A filter which specifies a subset of messages to retrieve. null specifies, "all + * messages". + * @param locale + * The target local to translate the messages into. null specifies, "use default + * locale". + * @return List a list of messages related to the target object, translated into the specified + * locale. + */ + public abstract List getMessagesAsText(MessageFilter filter, Locale targetLocale); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/Message.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/Message.java new file mode 100644 index 000000000..ff87d4ec3 --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/Message.java @@ -0,0 +1,373 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + + +import java.util.HashMap; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.eclipse.wst.validation.internal.provisional.core.IMessage; + +/** + * <p> + * Default implementation of the IMessage interface, provided for the convenience of the + * IValidators. If an IValidator needs to run in both AAT and WSAD then this IMessage implementation + * should be used; if the IValidator runs in WSAD alone, the WSAD LocalizedMessage may be used in + * place of this implementation. + * <p> + * @see org.eclipse.wst.validation.internal.provisional.core.IMessage + * + * [issue: CS - I'd suggest splitting this class into Message and BundleMessage (where the latter inherits + * from the former. We have many messages that come (from xerces) pretranslated and don't require 'bundle' + * related fields and methods. Splitting this class would make it easier to understand where bundle related + * function is coming into play. Below I've listed out what would go into BundleMessage to demonstrate how + * we can simplify the 'Message' class by factoring out the bundle related details. + * + * Message + * private Object targetObject = null; + * private String groupName = null; + * private int lineNumber = IMessage.LINENO_UNSET; + * private int length = IMessage.OFFSET_UNSET; + * private int offset = IMessage.OFFSET_UNSET; + * + * + * BundleMessage + * private String id = null; + * private String[] params = null; + * private String bundleName = null; + * + * - getId() + * - getBundle(...) + * - getBundleName() + * - getParams() + * - getText(Locale) + * - getText(ClassLoader) + * - getText(Locale, ClassLoader) + * - setId(String) + * - setBundleName(String) + * - setParams(String[]) + * ] + */ +public class Message implements IMessage { + private String id = null; + private String[] params = null; + private int severity = MessageFilter.ANY_SEVERITY; + private Object targetObject = null; + private String bundleName = null; + private String groupName = null; + private int lineNumber = IMessage.LINENO_UNSET; + private int length = IMessage.OFFSET_UNSET; + private int offset = IMessage.OFFSET_UNSET; + private HashMap messageAttributes; + + /** + * <p> + * Creates a default instance of the Message + * </p> + */ + public Message() { + super(); + } + + /** + * <p> + * Creates a Message object with bundle name, severity and a unique id + * </p> + * + * @param aBundleName + * Must not be null or the empty string (""). + * @param aSeverity + * Must be one of the constants specified in SeverityEnum. + * @param anId + * Must not be null or the empty string (""). + */ + public Message(String aBundleName, int aSeverity, String anId) { + this(aBundleName, aSeverity, anId, null, null); + } + + /** + * <p> + * Creates a Message object with bundle name, severity, a unique id, and + * a list of parameters. + * </p> + * + * @param aBundleName + * Must not be null or the empty string (""). + * @param aSeverity + * Must be one of the constants specified in SeverityEnum. + * @param anId + * Must not be null or the empty string (""). + * @param aParams + * May be null, if there are no parameters in the message. + */ + public Message(String aBundleName, int aSeverity, String anId, String[] aParams) { + this(aBundleName, aSeverity, anId, aParams, null); + } + + /** + * <p> + * Creates a Message object with bundle name, severity, a unique id, and + * a list of parameters and the target object. + * </p> + * + * @param aBundleName + * Must not be null or the empty string (""). + * @param aSeverity + * Must be one of the constants specified in SeverityEnum. + * @param anId + * Must not be null or the empty string (""). + * @param aParams + * May be null, if there are no parameters in the message. + * @param targetObject + * May be null, if the message does not pertain to a particular + * object. + */ + public Message(String aBundleName, int aSeverity, String anId, String[] aParams, Object aTargetObject) { + bundleName = aBundleName; + severity = aSeverity; + id = anId; + params = aParams; + targetObject = aTargetObject; + } + + public Message(String aBundleName, int aSeverity, String anId, String[] aParams, Object aTargetObject, String aGroupName) { + bundleName = aBundleName; + severity = aSeverity; + id = anId; + params = aParams; + targetObject = aTargetObject; + groupName = aGroupName; + } + + /** + * @return the resource bundle which contains the messages, as identified by + * + * @link #getBundleName() + */ + public ResourceBundle getBundle(Locale locale, ClassLoader classLoader) { + ResourceBundle bundle = null; + try { + if (classLoader == null) { + bundle = ResourceBundle.getBundle(getBundleName(), locale); + } else { + bundle = ResourceBundle.getBundle(getBundleName(), locale, classLoader); + } + } catch (MissingResourceException e) { + e.printStackTrace(); + } + return bundle; + } + + /** + * @see IMessage#getBundleName() + */ + public String getBundleName() { + return bundleName; + } + + /** + * @see IMessage#getGroupName() + */ + public String getGroupName() { + return groupName; + } + + /** + * @see IMessage#getId() + */ + public String getId() { + return id; + } + + /** + * @see IMessage#getLength() + */ + public int getLength() { + return length; + } + + /** + * @see IMessage#getLineNumber() + */ + public int getLineNumber() { + return lineNumber; + } + + /** + * @see IMessage#getOffset() + */ + public int getOffset() { + return offset; + } + + /** + * @see IMessage#getParams() + */ + public String[] getParams() { + return params; + } + + /** + * @see IMessage#getSeverity() + */ + public int getSeverity() { + return severity; + } + + /** + * @see IMessage#getTargetObject() + */ + public Object getTargetObject() { + return targetObject; + } + + /** + * @see IMessage#getText() + */ + public String getText() { + return getText(Locale.getDefault(), null); + } + + /** + * @see IMessage#getText(ClassLoader) + */ + public String getText(ClassLoader classLoader) { + return getText(Locale.getDefault(), classLoader); + } + + /** + * @see IMessage#getText(Locale) + */ + public String getText(Locale locale) { + return getText(locale, null); + } + + /** + * @see IMessage#getText(Locale, ClassLoader) + */ + public java.lang.String getText(Locale locale, ClassLoader classLoader) { + String message = ""; //$NON-NLS-1$ + + if (locale == null) { + return message; + } + + ResourceBundle bundle = getBundle(locale, classLoader); + if (bundle == null) { + return message; + } + + try { + message = bundle.getString(getId()); + + if (getParams() != null) { + message = java.text.MessageFormat.format(message, getParams()); + } + } catch (MissingResourceException exc) { + System.err.println(exc.getMessage()); + System.err.println(getId()); + } catch (NullPointerException exc) { + System.err.println(exc.getMessage()); + System.err.println(getId()); + } + + return message; + } + + /** + * @see IMessage#setBundleName(String) + */ + public void setBundleName(String aBundleName) { + bundleName = aBundleName; + } + + /** + * @see IMessage#setGroupName(String) + */ + public void setGroupName(String name) { + groupName = name; + } + + /** + * @see IMessage#setId(String) + */ + public void setId(String newId) { + id = newId; + } + + /** + * @see IMessage#setLength(int) + */ + public void setLength(int length) { + if (length < 0) { + length = IMessage.OFFSET_UNSET; + } + this.length = length; + } + + /** + * @see IMessage#setLineNo(int) + */ + public void setLineNo(int lineNumber) { + if (lineNumber < 0) { + this.lineNumber = IMessage.LINENO_UNSET; + } else { + this.lineNumber = lineNumber; + } + } + + /** + * @see IMessage#setOffset(int) + */ + public void setOffset(int offset) { + if (offset < 0) { + offset = IMessage.OFFSET_UNSET; + } + this.offset = offset; + } + + /** + * @see IMessage#setParams(String[]) + */ + public void setParams(String[] newParams) { + params = newParams; + } + + /** + * @see IMessage#setSeverity(int) + */ + public void setSeverity(int newSeverity) { + severity = newSeverity; + } + + /** + * @see IMessage#setTargetObject(Object) + */ + public void setTargetObject(Object obj) { + targetObject = obj; + } + + public Object getAttribute(String attributeName) { + if(messageAttributes != null) { + return messageAttributes.get(attributeName); + } + return null; + } + + public void setAttribute(String attributeName, Object value) { + if(messageAttributes == null) { + messageAttributes = new HashMap(); + } + messageAttributes.put(attributeName,value); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/MessageFilter.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/MessageFilter.java new file mode 100644 index 000000000..a3800613e --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/MessageFilter.java @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + +import org.eclipse.wst.validation.internal.provisional.core.IValidator; + + +/** + * <p> + * Encapsulates common message filtering parameters. Message Filters are used when retrieving + * messages via an IMessageAccess. The filter encapsulates a simple set of typical filter criteria + * which is used to select a subset of messages to retrieve. If multiple attributes of the message + * filter are specified, they should be logically AND'd together by the MessageAccess + * implementation. + * </p> + */ +public class MessageFilter { + public static final int ANY_SEVERITY = -1; + + /** + * <p> + * Messages matching this severity(s) will be retrieved. One of SeverityEnum XXX_severity + * constants, or ANY_SEVERITY to specify that messages of any severity will be returned. This + * field can be combined with other filter attributes to narrow the selection set further. + * </p> + */ + private int severity = ANY_SEVERITY; + + /** + * <p> + * The validator which reported the messages that should be returned. All messages which were + * reported using validator matching this validator will be returned. This field can be combined + * with other filter attributes to narrow the selection set further. + * </p> + */ + private IValidator validator; + + /** + * <p> + * The target object of the messages that should be returned, or null to specify to retrieve + * messages of any target. All messages having a target object matching this object will be + * returned. This field can be combined with other filter attributes to narrow the selection set + * further. + * </p> + */ + private Object targetObject; + + /** + * @deprecated + */ + public MessageFilter() { + super(); + } + + /** + * + * @param aSeverity + * Severity of the message + * @param validator + * IValidator which reported the message + * @param aTargetObject + * Target object of the message + */ + public MessageFilter(int aSeverity, IValidator validator, Object aTargetObject) { + super(); + severity = aSeverity; + this.validator = validator; + targetObject = aTargetObject; + } + + /** + * @return the severity filter constraint. + */ + public int getSeverity() { + return severity; + } + + /** + * @return the target object filter constraint. + */ + public java.lang.Object getTargetObject() { + return targetObject; + } + + /** + * @return the validator to filter on. + */ + public IValidator getValidator() { + return validator; + } + + /** + * Set the severity filter constraint. + * + * @param newSeverity + * severity filter constraint + */ + public void setSeverity(int newSeverity) { + severity = newSeverity; + } + + /** + * Set the target object filter constraint. + * + * @param newTargetObject + * target object filter constraint + */ + public void setTargetObject(java.lang.Object newTargetObject) { + targetObject = newTargetObject; + } + + /** + * Set the validator to return messages for. + * + * @param validator + * validator to return messages for + */ + public void setValidator(IValidator validator) { + this.validator = validator; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidationException.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidationException.java new file mode 100644 index 000000000..1c6c55804 --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidationException.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + + +import java.util.Locale; + +import org.eclipse.wst.validation.internal.provisional.core.IMessage; + +/** + * <p> + * This exception is the only exception which should be thrown by IValidators. The message in this + * exception must be suitable for showing to the user. All ValidationExceptions will have their + * message extracted when they're caught, and the message will be shown to the user. + * + * @since 1.0 + * </p> + */ +public class ValidationException extends Exception { + private Throwable _lowLevelException = null; + private IMessage _message = null; + private ClassLoader _loader = null; + private final static long serialVersionUID = -3387516993124229949L; + + /** + * Constructs a new exception with a given message string. <br> + * <br> + * + * @param message + * IMessage, which is Locale-independent, which contains the message to be shown to + * be shown to the user. + */ + public ValidationException(IMessage message) { + this(message, null); + } + + /** + * Constructs a new exception with a given message string, and low-level exception. <br> + * <br> + * + * @param message + * IMessage Locale-independent message to be shown to the user. + * @param exception + * relevant low-level exception, or <code>null</code> if none. <br> + *   For example, when a method fails because of a network + * communications   problem, this would be the + * <code>java.io.IOException</code>   describing the exact nature + * of the problem. + */ + public ValidationException(IMessage message, Throwable exception) { + super(); + _message = message; + _lowLevelException = exception; + } + + /** + * @return the low-level exception associated with this ValidationException. + */ + public Throwable getAssociatedException() { + return _lowLevelException; + } + + /** + * @return the IMessage to be shown to the user, or null if this exception should be handled + * internally. + */ + public IMessage getAssociatedMessage() { + return _message; + } + + /** + * @return if the IValidator which threw this exception was loaded by a different ClassLoader than the + * framework, this method returns the ClassLoader of the IValidator. + */ + public ClassLoader getClassLoader() { + return _loader; + } + + /** + * @return the error message string of this <code>Throwable</code> object if it was + * {@link java.lang.Throwable#Throwable(String) created}with an error message string; + * or <code>null</code> if it was {@link java.lang.Throwable#Throwable() created}with + * no error message. + * + */ + public String getMessage() { + return _message.getText(getClassLoader()); + } + + /** + * @param locale + * The locale of which to get the message. + * @return the error message string of this <code>Throwable</code> object if it was + * {@link java.lang.Throwable#Throwable(String) created}with an error message string; + * or <code>null</code> if it was {@link java.lang.Throwable#Throwable() created}with + * no error message. + */ + public String getMessage(Locale locale) { + return _message.getText(locale, getClassLoader()); + } + + /** + * <p> + * If the IValidator which threw this exception was loaded by a different ClassLoader than the + * framework, this method should set the ClassLoader to be the ClassLoader of the IValidator. + * </p> + * @param loader + * ClassLoader of the validator + */ + public void setClassLoader(ClassLoader loader) { + _loader = loader; + } + + /** + * <p> + * Returns a short description of this throwable object. If this <code>Throwable</code> object + * was {@link java.lang.Throwable#Throwable(String) created}with an error message string, then + * the result is the concatenation of three strings: + * <ul> + * <li>The name of the actual class of this object + * <li>": " (a colon and a space) + * <li>The result of the {@link #getMessage}method for this object + * </ul> + * If this <code>Throwable</code> object was {@link java.lang.Throwable#Throwable() created} + * with no error message string, then the name of the actual class of this object is returned. + * </p> + * + * @return a string representation of this <code>Throwable</code>. + */ + public String toString() { + return toString(Locale.getDefault()); + } + + /** + * <p> + * Returns a short description of this throwable object. If this <code>Throwable</code> object + * was {@link java.lang.Throwable#Throwable(String) created}with an error message string, then + * the result is the concatenation of three strings: + * <ul> + * <li>The name of the actual class of this object + * <li>": " (a colon and a space) + * <li>The result of the {@link #getMessage}method for this object + * </ul> + * If this <code>Throwable</code> object was {@link java.lang.Throwable#Throwable() created} + * with no error message string, then the name of the actual class of this object is returned. + * </p> + * + * @return a string representation of this <code>Throwable</code>. + */ + public String toString(Locale locale) { + String s = getClass().getName(); + String message = getMessage(locale); + return (message != null) ? (s + ": " + message) : s; //$NON-NLS-1$ + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java new file mode 100644 index 000000000..8325e929d --- /dev/null +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/core/ValidatorLauncher.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.validation.internal.core; + +import org.eclipse.wst.validation.internal.provisional.core.IReporter; +import org.eclipse.wst.validation.internal.provisional.core.IValidationContext; +import org.eclipse.wst.validation.internal.provisional.core.IValidator; + + + +/** + * <p> + * This singleton launches the validation on a single validator. Clients should call this class's + * <code>start</code> method to begin the validation. + * </p> + */ +public class ValidatorLauncher { + private static ValidatorLauncher _launcher = null; + + + /** + * Default constructor + */ + private ValidatorLauncher() { + //Default constructor + } + + /** + * @return the singleton launcher. + */ + public static ValidatorLauncher getLauncher() { + if (_launcher == null) { + _launcher = new ValidatorLauncher(); + } + return _launcher; + } + + /** + * <p> + * This method is the launch point of the validation. It runs validation on the validator + * accessed by the IValidationContext. When the validation is complete, each validator may perform resource + * cleanup, if necessary. + * + * <br> + * <br> + * If <code>helper</code>,<code>validator</code>, or <code>reporter</code> are null, + * validation is not performed. <code>changedFiles</code> may be null, or empty, if a full + * build should be done. + * </p> + * + * @param helper + * loads an object. + * @param validator + * validator object to launch validation. + * @param reporter + * Is an instance of an IReporter interface, which is used for + * interaction with the user. + * @param changedFiles + * Is an array of files which have been added, changed, or deleted + * since the last validation. If <code>changedFiles</code> is null, or if it is an empty + * array, then a full validation should be performed. Otherwise, validation on just the files + * listed in the array should performed if the validator supports incremental validation. + */ + public void start(IValidationContext helper, IValidator validator, IReporter reporter) throws ValidationException { + if ((helper == null) || (validator == null) || (reporter == null)) { + return; + } + + // Can't force each validator to check if it's cancelled or not, + // so check for cancellation here. Hopefully the user won't wait + // too long. + if (reporter.isCancelled()) { + return; + } + + // If the validator is about to perform a full build, remove all of its previous validation + // messages. + if ((helper.getURIs() == null) || (helper.getURIs().length == 0)) { + reporter.removeAllMessages(validator); + } + + validator.validate(helper, reporter); + validator.cleanup(reporter); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IValidator.java b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IValidator.java index 63035472d..7eb61cbd4 100644 --- a/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IValidator.java +++ b/plugins/org.eclipse.wst.validation/validate_core/org/eclipse/wst/validation/internal/provisional/core/IValidator.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.wst.validation.internal.provisional.core; -import org.eclispe.wst.validation.internal.core.ValidationException; +import org.eclipse.wst.validation.internal.core.ValidationException; /** * This is the base interface for all Validators. A Validator is a class which verifies that objects |