6c8ee5e8e0ed2e2d7cde9317a1d105fafdc57f19
[phpeclipse.git] /
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.corext.template.php;
12
13 import java.util.ArrayList;
14
15 import org.eclipse.jface.text.templates.TemplateContextType;
16 import org.eclipse.jface.text.templates.ContextTypeRegistry;
17 import org.eclipse.jface.text.templates.GlobalTemplateVariables;
18 import org.eclipse.jface.text.templates.TemplateContext;
19 import org.eclipse.jface.text.templates.TemplateException;
20 import org.eclipse.jface.text.templates.TemplateVariable;
21 import org.eclipse.jface.text.templates.TemplateVariableResolver;
22
23 import net.sourceforge.phpdt.core.ToolFactory;
24 import net.sourceforge.phpdt.core.compiler.IScanner;
25 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
26 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
27
28 import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility;
29
30 /**
31   */
32 public class CodeTemplateContextType extends TemplateContextType {
33         
34         /* context types */
35         public static final String CATCHBLOCK_CONTEXTTYPE= "php_catchblock_context"; //$NON-NLS-1$
36         public static final String METHODBODY_CONTEXTTYPE= "php_methodbody_context"; //$NON-NLS-1$
37         public static final String CONSTRUCTORBODY_CONTEXTTYPE= "php_constructorbody_context"; //$NON-NLS-1$
38         public static final String GETTERBODY_CONTEXTTYPE= "php_getterbody_context"; //$NON-NLS-1$
39         public static final String SETTERBODY_CONTEXTTYPE= "php_setterbody_context"; //$NON-NLS-1$
40         public static final String NEWTYPE_CONTEXTTYPE= "php_newtype_context"; //$NON-NLS-1$
41         public static final String NEWHTML_CONTEXTTYPE= "php_newhtml_context"; //$NON-NLS-1$
42         public static final String TYPECOMMENT_CONTEXTTYPE= "php_typecomment_context"; //$NON-NLS-1$
43         public static final String FIELDCOMMENT_CONTEXTTYPE= "php_fieldcomment_context"; //$NON-NLS-1$
44         public static final String METHODCOMMENT_CONTEXTTYPE= "php_methodcomment_context"; //$NON-NLS-1$
45         public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE= "php_constructorcomment_context"; //$NON-NLS-1$
46         public static final String OVERRIDECOMMENT_CONTEXTTYPE= "php_overridecomment_context"; //$NON-NLS-1$
47         public static final String GETTERCOMMENT_CONTEXTTYPE= "php_gettercomment_context"; //$NON-NLS-1$
48         public static final String SETTERCOMMENT_CONTEXTTYPE= "php_settercomment_context"; //$NON-NLS-1$
49
50         /* templates */
51         public static final String COMMENT_SUFFIX= "comment"; //$NON-NLS-1$
52         public static final String CATCHBLOCK= "catchblock"; //$NON-NLS-1$
53         public static final String METHODSTUB= "methodbody"; //$NON-NLS-1$      
54         public static final String NEWTYPE= "newtype"; //$NON-NLS-1$    
55         public static final String NEWHTML= "newhtml"; //$NON-NLS-1$    
56         public static final String CONSTRUCTORSTUB= "constructorbody"; //$NON-NLS-1$
57         public static final String GETTERSTUB= "getterbody"; //$NON-NLS-1$
58         public static final String SETTERSTUB= "setterbody"; //$NON-NLS-1$
59         public static final String TYPECOMMENT= "type" + COMMENT_SUFFIX; //$NON-NLS-1$
60         public static final String FIELDCOMMENT= "field" + COMMENT_SUFFIX; //$NON-NLS-1$
61         public static final String METHODCOMMENT= "method" + COMMENT_SUFFIX; //$NON-NLS-1$
62         public static final String CONSTRUCTORCOMMENT= "constructor" + COMMENT_SUFFIX; //$NON-NLS-1$
63         public static final String OVERRIDECOMMENT= "override" + COMMENT_SUFFIX; //$NON-NLS-1$
64         public static final String GETTERCOMMENT= "getter" + COMMENT_SUFFIX; //$NON-NLS-1$
65         public static final String SETTERCOMMENT= "setter" + COMMENT_SUFFIX; //$NON-NLS-1$
66         
67         /* resolver types */
68         public static final String EXCEPTION_TYPE= "exception_type"; //$NON-NLS-1$
69         public static final String EXCEPTION_VAR= "exception_var"; //$NON-NLS-1$
70         public static final String ENCLOSING_METHOD= "enclosing_method"; //$NON-NLS-1$
71         public static final String ENCLOSING_TYPE= "enclosing_type"; //$NON-NLS-1$
72         public static final String BODY_STATEMENT= "body_statement"; //$NON-NLS-1$
73         public static final String FIELD= "field"; //$NON-NLS-1$
74         public static final String FIELD_TYPE= "field_type"; //$NON-NLS-1$
75         public static final String BARE_FIELD_NAME= "bare_field_name"; //$NON-NLS-1$
76         
77         public static final String PARAM= "param"; //$NON-NLS-1$
78         public static final String RETURN_TYPE= "return_type"; //$NON-NLS-1$
79         public static final String SEE_TAG= "see_to_overridden"; //$NON-NLS-1$
80         
81         public static final String TAGS= "tags"; //$NON-NLS-1$
82         
83         public static final String TYPENAME= "type_name"; //$NON-NLS-1$
84         public static final String FILENAME= "file_name"; //$NON-NLS-1$
85         public static final String PACKAGENAME= "package_name"; //$NON-NLS-1$
86         public static final String PROJECTNAME= "project_name"; //$NON-NLS-1$
87
88         public static final String PACKAGE_DECLARATION= "package_declaration"; //$NON-NLS-1$
89         public static final String TYPE_DECLARATION= "type_declaration"; //$NON-NLS-1$
90         public static final String TYPE_COMMENT= "typecomment"; //$NON-NLS-1$
91         
92         
93         /**
94          * Resolver that resolves to the variable defined in the context.
95          */
96         public static class CodeTemplateVariableResolver extends TemplateVariableResolver {
97                 public CodeTemplateVariableResolver(String type, String description) {
98                         super(type, description);
99                 }
100                 
101                 protected String resolve(TemplateContext context) {
102                         return context.getVariable(getType());
103                 }
104         }
105         
106         /**
107          * Resolver for javadoc tags.
108          */
109         public static class TagsVariableResolver extends TemplateVariableResolver {
110                 public TagsVariableResolver() {
111                         super(TAGS,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.tags")); //$NON-NLS-1$
112                 }
113                 
114                 protected String resolve(TemplateContext context) {
115                         return "@"; //$NON-NLS-1$
116                 }
117         }       
118                 
119         /**
120          * Resolver for todo tags.
121          */
122         protected static class Todo extends TemplateVariableResolver {
123
124                 public Todo() {
125                         super("todo", JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.todo")); //$NON-NLS-1$ //$NON-NLS-2$
126                 }
127                 
128                 protected String resolve(TemplateContext context) {
129                         String todoTaskTag= StubUtility.getTodoTaskTag(((CodeTemplateContext) context).getJavaProject());
130                         if (todoTaskTag == null)
131                                 return "XXX"; //$NON-NLS-1$
132         
133                         return todoTaskTag;
134                 }
135         }
136         
137         private boolean fIsComment;
138         
139         public CodeTemplateContextType(String contextName) {
140                 super(contextName);
141                 
142                 fIsComment= false;
143                 
144                 // global
145                 addResolver(new GlobalTemplateVariables.Dollar());
146                 addResolver(new GlobalTemplateVariables.Date());
147                 addResolver(new GlobalTemplateVariables.Year());
148                 addResolver(new GlobalTemplateVariables.Time());
149                 addResolver(new GlobalTemplateVariables.User());
150                 addResolver(new Todo());
151                 
152                 if (CATCHBLOCK_CONTEXTTYPE.equals(contextName)) {
153                         addResolver(new CodeTemplateVariableResolver(EXCEPTION_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.exceptiontype"))); //$NON-NLS-1$
154                         addResolver(new CodeTemplateVariableResolver(EXCEPTION_VAR,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.exceptionvar"))); //$NON-NLS-1$
155                 } else if (METHODBODY_CONTEXTTYPE.equals(contextName)) {
156                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
157                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
158                         addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.bodystatement"))); //$NON-NLS-1$
159                 } else if (CONSTRUCTORBODY_CONTEXTTYPE.equals(contextName)) {
160                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
161                         addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.bodystatement"))); //$NON-NLS-1$
162                 } else if (GETTERBODY_CONTEXTTYPE.equals(contextName)) {
163                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
164                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
165                         addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
166                 } else if (SETTERBODY_CONTEXTTYPE.equals(contextName)) {
167                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
168                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
169                         addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
170                         addResolver(new CodeTemplateVariableResolver(PARAM, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.param"))); //$NON-NLS-1$
171                 } else if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
172                         addResolver(new CodeTemplateVariableResolver(TYPENAME,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typename"))); //$NON-NLS-1$
173                         addResolver(new CodeTemplateVariableResolver(PACKAGE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.packdeclaration"))); //$NON-NLS-1$
174                         addResolver(new CodeTemplateVariableResolver(TYPE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typedeclaration"))); //$NON-NLS-1$
175                         addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typecomment"))); //$NON-NLS-1$
176                         addCompilationUnitVariables();
177                 } else if (NEWHTML_CONTEXTTYPE.equals(contextName)) {
178                         addResolver(new CodeTemplateVariableResolver(TYPENAME,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typename"))); //$NON-NLS-1$
179                         addResolver(new CodeTemplateVariableResolver(PACKAGE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.packdeclaration"))); //$NON-NLS-1$
180                         addResolver(new CodeTemplateVariableResolver(TYPE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typedeclaration"))); //$NON-NLS-1$
181                         addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typecomment"))); //$NON-NLS-1$
182                         addCompilationUnitVariables();
183                 }else if (TYPECOMMENT_CONTEXTTYPE.equals(contextName)) {
184                         addResolver(new CodeTemplateVariableResolver(TYPENAME,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typename"))); //$NON-NLS-1$
185                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
186                         addResolver(new TagsVariableResolver());
187                         addCompilationUnitVariables();
188                         fIsComment= true;
189                 } else if (FIELDCOMMENT_CONTEXTTYPE.equals(contextName)) {
190                         addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.fieldtype"))); //$NON-NLS-1$
191                         addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.fieldname"))); //$NON-NLS-1$
192                         addCompilationUnitVariables();
193                         fIsComment= true;
194                 } else if (METHODCOMMENT_CONTEXTTYPE.equals(contextName)) {
195                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
196                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
197                         addResolver(new CodeTemplateVariableResolver(RETURN_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.returntype"))); //$NON-NLS-1$
198                         addResolver(new TagsVariableResolver());
199                         addCompilationUnitVariables();
200                         fIsComment= true;
201                 } else if (OVERRIDECOMMENT_CONTEXTTYPE.equals(contextName)) {
202                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
203                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
204                         addResolver(new CodeTemplateVariableResolver(SEE_TAG,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.seetag"))); //$NON-NLS-1$
205                         addResolver(new TagsVariableResolver());
206                         addCompilationUnitVariables();
207                         fIsComment= true;
208                 } else if (CONSTRUCTORCOMMENT_CONTEXTTYPE.equals(contextName)) {
209                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
210                         addResolver(new TagsVariableResolver());
211                         addCompilationUnitVariables();
212                         fIsComment= true;
213                 } else if (GETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
214                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
215                         addResolver(new CodeTemplateVariableResolver(FIELD_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldtype"))); //$NON-NLS-1$
216                         addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
217                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
218                         addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.barefieldname"))); //$NON-NLS-1$
219                         addCompilationUnitVariables();
220                         fIsComment= true;
221                 } else if (SETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
222                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
223                         addResolver(new CodeTemplateVariableResolver(FIELD_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldtype"))); //$NON-NLS-1$
224                         addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
225                         addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
226                         addResolver(new CodeTemplateVariableResolver(PARAM, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.param"))); //$NON-NLS-1$
227                         addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.barefieldname"))); //$NON-NLS-1$
228                         addCompilationUnitVariables();
229                         fIsComment= true;
230                 }
231         }
232         
233         private void addCompilationUnitVariables() {
234                 addResolver(new CodeTemplateVariableResolver(FILENAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.filename"))); //$NON-NLS-1$
235                 addResolver(new CodeTemplateVariableResolver(PACKAGENAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.packagename"))); //$NON-NLS-1$
236                 addResolver(new CodeTemplateVariableResolver(PROJECTNAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.projectname"))); //$NON-NLS-1$
237         }
238         
239         /*
240          * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
241          */
242         protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
243                 ArrayList required=  new ArrayList(5);
244                 String contextName= getId();
245 //              if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
246 //                      required.add(PACKAGE_DECLARATION);
247 //                      required.add(TYPE_DECLARATION);
248 //              }
249                 for (int i= 0; i < variables.length; i++) {
250                         String type= variables[i].getType();
251                         if (getResolver(type) == null) {
252                                 throw new TemplateException(JavaTemplateMessages.getFormattedString("CodeTemplateContextType.validate.unknownvariable", type)); //$NON-NLS-1$
253                         }
254                         required.remove(type);
255                 }
256                 if (!required.isEmpty()) {
257                         String missing= (String) required.get(0);
258                         throw new TemplateException(JavaTemplateMessages.getFormattedString("CodeTemplateContextType.validate.missingvariable", missing)); //$NON-NLS-1$
259                 }
260                 super.validateVariables(variables);
261         }       
262         
263         
264
265         /* (non-Javadoc)
266          * @see net.sourceforge.phpdt.internal.corext.template.ContextType#createContext()
267          */
268         public TemplateContext createContext() {
269                 return null;
270         }
271
272         public static void registerContextTypes(ContextTypeRegistry registry) {
273                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CATCHBLOCK_CONTEXTTYPE));
274                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE));
275                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE));
276                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERBODY_CONTEXTTYPE));
277                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERBODY_CONTEXTTYPE));           
278                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWTYPE_CONTEXTTYPE));
279                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWHTML_CONTEXTTYPE));
280                 
281                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE));
282                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE));
283                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE));
284                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE));
285                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.OVERRIDECOMMENT_CONTEXTTYPE));              
286                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERCOMMENT_CONTEXTTYPE));                
287                 registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERCOMMENT_CONTEXTTYPE));                
288         }
289         
290         
291
292         /*
293          * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validate(java.lang.String)
294          */
295         public void validate(String pattern) throws TemplateException {
296                 super.validate(pattern);
297                 if (fIsComment) {
298                         if (!isValidComment(pattern)) {
299                                 throw new TemplateException(JavaTemplateMessages.getString("CodeTemplateContextType.validate.invalidcomment")); //$NON-NLS-1$
300                         }
301                 }
302         }
303                 
304         
305         private boolean isValidComment(String template) {
306                 IScanner scanner= ToolFactory.createScanner(true, false, false, true);// false);
307                 scanner.setSource(template.toCharArray());
308                 try {
309                         int next= scanner.getNextToken();
310                         while (next == ITerminalSymbols.TokenNameCOMMENT_LINE || next == ITerminalSymbols.TokenNameCOMMENT_PHPDOC || next == ITerminalSymbols.TokenNameCOMMENT_BLOCK) {
311                                 next= scanner.getNextToken();
312                         }
313                         return next == ITerminalSymbols.TokenNameEOF;
314                 } catch (InvalidInputException e) {
315                 }
316                 return false;
317         }       
318
319 }