author | tasneems@symbian.org |
Wed, 27 Jan 2010 15:05:37 -0800 | |
changeset 50 | 0560e98b9bf6 |
permissions | -rw-r--r-- |
50
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
1 |
/** |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
3 |
* All rights reserved. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
8 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
9 |
* Initial Contributors: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
11 |
* Contributors: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
12 |
* Description: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
13 |
* Overview: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
14 |
* Details: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
17 |
* Failures and causes: |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
18 |
*/ |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
19 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
20 |
package org.symbian.tools.wrttools.core.validator; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
21 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
22 |
import java.io.File; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
23 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
24 |
import org.symbian.tools.wrttools.core.report.MessageHandler; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
25 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
26 |
/** |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
27 |
* IValidator is an interface that, when implemented, validates a model. A Model |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
28 |
* can be any file for widget project plist,html, javaScript, css are in the set of model. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
29 |
* A validator loads its model through an FileUtil, traverses the model |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
30 |
* itself, and communicates with the user through the IReporter. Because each |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
31 |
* validator instance performs on the same type of model input, and performs the |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
32 |
* same rule checks against that input, no more than one instance of a validator |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
33 |
* is needed. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
34 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
35 |
* When a validator adds a validation message, it identifies itself through a |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
36 |
* unique id; thus, when a particular's file's validation messages need to be |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
37 |
* removed , all messages associated with that file, by that validator, are |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
38 |
* removed. Every message shown to the user, whether it's the message in a |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
39 |
* ValidationException, or a validation error, will be displayed to the user. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
40 |
* Validators do not display messages to the user other than validation messages |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
41 |
* and subtask messages. This is necessary for Locale-neutrality and |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
42 |
* environment-neutrality. If a catastrophic error occurs, from which the |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
43 |
* validator cannot recover, the validator should throw a ValidationException |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
44 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
45 |
* A dummy List<IMessage> is passed as parameter to which the Rule methods will |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
46 |
* add messages when a validation rules is failed. Boolean variable will be |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
47 |
* returned to indicate the overall status of validation even if one procedure |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
48 |
* is failed boolean false will be returned. If returned value is false then |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
49 |
* List<IMessage> messageList size will be greater than zero if returned value |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
50 |
* is true the List<IMessage> messageList will be empty creating a dummy list |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
51 |
* to pass a parameter to the calling method this list will be used by the rules |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
52 |
* method to add the validation messages if any rules validation is failed |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
53 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
54 |
* @author Sailaja Duvvuri |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
55 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
56 |
*/ |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
57 |
public interface IValidator { |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
58 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
59 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
60 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
61 |
/** |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
62 |
* Every validator class must implement this method. Validation logic for each |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
63 |
* type will be different A dummy List<IMessage> is passed as parameter to |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
64 |
* which the Rule methods will add messages when a validation rules is failed. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
65 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
66 |
* Boolean variable will be returned to indicate the overall status of |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
67 |
* validation even if one procedure is failed boolean false will be returned. If |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
68 |
* returned value is false then List<IMessage> messageList size will be greater |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
69 |
* than zero if returned value is true the List<IMessage> messageList will be |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
70 |
* empty creating a dummy list to pass a parameter to the calling method this |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
71 |
* list will be used by the rules method to add the validation messages if any |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
72 |
* rules validation is failed |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
73 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
74 |
* filename is assumed as absolute path. |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
75 |
* need to set the option a relative path will be implemented |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
76 |
* |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
77 |
* @param filenme |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
78 |
* @return |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
79 |
*/ |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
80 |
public boolean validate(File filename)throws Exception ; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
81 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
82 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
83 |
public MessageHandler getMessageHandler() ; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
84 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
85 |
|
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
86 |
public void setMessageHandler(MessageHandler messageHandler) ; |
0560e98b9bf6
Added widget project nature and WRT validators
tasneems@symbian.org
parents:
diff
changeset
|
87 |
} |