View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.tag;
20  
21  import java.lang.reflect.Constructor;
22  import java.lang.reflect.InvocationTargetException;
23  import java.lang.reflect.Method;
24  import java.net.URL;
25  import java.util.HashMap;
26  import java.util.Map;
27  
28  import javax.el.ELException;
29  import javax.faces.FacesException;
30  import javax.faces.application.Resource;
31  import javax.faces.application.ResourceHandler;
32  import javax.faces.context.FacesContext;
33  import javax.faces.view.facelets.BehaviorConfig;
34  import javax.faces.view.facelets.BehaviorHandler;
35  import javax.faces.view.facelets.ComponentConfig;
36  import javax.faces.view.facelets.ComponentHandler;
37  import javax.faces.view.facelets.ConverterConfig;
38  import javax.faces.view.facelets.ConverterHandler;
39  import javax.faces.view.facelets.FaceletException;
40  import javax.faces.view.facelets.FaceletHandler;
41  import javax.faces.view.facelets.Tag;
42  import javax.faces.view.facelets.TagConfig;
43  import javax.faces.view.facelets.TagHandler;
44  import javax.faces.view.facelets.ValidatorConfig;
45  import javax.faces.view.facelets.ValidatorHandler;
46  import org.apache.myfaces.shared.config.MyfacesConfig;
47  import org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler;
48  import org.apache.myfaces.view.facelets.tag.composite.CompositeResouceWrapper;
49  
50  /**
51   * Base class for defining TagLibraries in Java
52   * 
53   * @author Jacob Hookom
54   * @version $Id$
55   */
56  public abstract class AbstractTagLibrary implements TagLibrary
57  {
58      private final Map<String, TagHandlerFactory> _factories;
59  
60      private final Map<String, Method> _functions;
61  
62      private final String _namespace;
63      private final String _aliasNamespace;
64      private Boolean _strictJsf2FaceletsCompatibility;
65  
66      public AbstractTagLibrary(String namespace, String aliasNamespace)
67      {
68          _namespace = namespace;
69          _aliasNamespace = aliasNamespace;
70          _factories = new HashMap<String, TagHandlerFactory>();
71          _functions = new HashMap<String, Method>();
72      }
73      
74      public AbstractTagLibrary(String namespace)
75      {
76          this(namespace,null);
77      }
78      
79  
80      /*
81       * (non-Javadoc)
82       * 
83       * See org.apache.myfaces.view.facelets.tag.TagLibrary#containsNamespace(java.lang.String)
84       */
85      public boolean containsNamespace(String ns)
86      {
87          return _namespace.equals(ns) || (_aliasNamespace != null && _aliasNamespace.equals(ns));
88      }
89  
90      /*
91       * (non-Javadoc)
92       * 
93       * See org.apache.myfaces.view.facelets.tag.TagLibrary#containsTagHandler(java.lang.String, java.lang.String)
94       */
95      public boolean containsTagHandler(String ns, String localName)
96      {
97          return containsNamespace(ns) && _factories.containsKey(localName);
98      }
99  
100     /*
101      * (non-Javadoc)
102      * 
103      * See org.apache.myfaces.view.facelets.tag.TagLibrary#createTagHandler(java.lang.String, java.lang.String,
104      * org.apache.myfaces.view.facelets.tag.TagConfig)
105      */
106     public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
107     {
108         if (containsNamespace(ns))
109         {
110             TagHandlerFactory f = _factories.get(localName);
111             if (f != null)
112             {
113                 return f.createHandler(tag);
114             }
115         }
116         
117         return null;
118     }
119 
120     /*
121      * (non-Javadoc)
122      * 
123      * See org.apache.myfaces.view.facelets.tag.TagLibrary#containsFunction(java.lang.String, java.lang.String)
124      */
125     public boolean containsFunction(String ns, String name)
126     {
127         return containsNamespace(ns) && _functions.containsKey(name);
128     }
129 
130     /*
131      * (non-Javadoc)
132      * 
133      * See org.apache.myfaces.view.facelets.tag.TagLibrary#createFunction(java.lang.String, java.lang.String)
134      */
135     public Method createFunction(String ns, String name)
136     {
137         return containsNamespace(ns) ? _functions.get(name) : null;
138     }
139 
140     public String getNamespace()
141     {
142         return _namespace;
143     }
144 
145     /**
146      * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name.
147      * 
148      * See ComponentHandler
149      * See javax.faces.application.Application#createComponent(java.lang.String)
150      * @param name
151      *            name to use, "foo" would be &lt;my:foo /&gt;
152      * @param componentType
153      *            componentType to use
154      * @param rendererType
155      *            rendererType to use
156      */
157     protected final void addComponent(String name, String componentType, String rendererType)
158     {
159         _factories.put(name, new ComponentHandlerFactory(componentType, rendererType));
160     }
161 
162     /**
163      * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name. The Facelet
164      * will be compiled with the specified HandlerType (which must extend AbstractComponentHandler).
165      * 
166      * See AbstractComponentHandler
167      * 
168      * @param name
169      *            name to use, "foo" would be &lt;my:foo /&gt;
170      * @param componentType
171      *            componentType to use
172      * @param rendererType
173      *            rendererType to use
174      * @param handlerType
175      *            a Class that extends AbstractComponentHandler
176      */
177     protected final void addComponent(String name, String componentType, String rendererType, 
178                                       Class<? extends TagHandler> handlerType)
179     {
180         _factories.put(name, new UserComponentHandlerFactory(componentType, rendererType, handlerType));
181     }
182     
183     protected final void addComponentFromResourceId(String name, String resourceId)
184     {
185         _factories.put(name, new UserComponentFromResourceIdHandlerFactory(resourceId));
186     }
187 
188     /**
189      * Add a ConvertHandler for the specified converterId
190      * 
191      * See javax.faces.view.facelets.ConverterHandler
192      * See javax.faces.application.Application#createConverter(java.lang.String)
193      * @param name
194      *            name to use, "foo" would be &lt;my:foo /&gt;
195      * @param converterId
196      *            id to pass to Application instance
197      */
198     protected final void addConverter(String name, String converterId)
199     {
200         _factories.put(name, new ConverterHandlerFactory(converterId));
201     }
202 
203     /**
204      * Add a ConvertHandler for the specified converterId of a TagHandler type
205      * 
206      * See javax.faces.view.facelets.ConverterHandler
207      * See javax.faces.view.facelets.ConverterConfig
208      * See javax.faces.application.Application#createConverter(java.lang.String)
209      * 
210      * @param name
211      *            name to use, "foo" would be &lt;my:foo /&gt;
212      * @param converterId
213      *            id to pass to Application instance
214      * @param type
215      *            TagHandler type that takes in a ConverterConfig
216      */
217     protected final void addConverter(String name, String converterId, Class<? extends TagHandler> type)
218     {
219         _factories.put(name, new UserConverterHandlerFactory(converterId, type));
220     }
221 
222     /**
223      * Add a ValidateHandler for the specified validatorId
224      * 
225      * See javax.faces.view.facelets.ValidatorHandler
226      * See javax.faces.application.Application#createValidator(java.lang.String)
227      * 
228      * @param name
229      *            name to use, "foo" would be &lt;my:foo /&gt;
230      * @param validatorId
231      *            id to pass to Application instance
232      */
233     protected final void addValidator(String name, String validatorId)
234     {
235         _factories.put(name, new ValidatorHandlerFactory(validatorId));
236     }
237 
238     /**
239      * Add a ValidateHandler for the specified validatorId
240      * 
241      * See javax.faces.view.facelets.ValidatorHandler
242      * See javax.faces.view.facelets.ValidatorConfig
243      * See javax.faces.application.Application#createValidator(java.lang.String)
244      * @param name
245      *            name to use, "foo" would be &lt;my:foo /&gt;
246      * @param validatorId
247      *            id to pass to Application instance
248      * @param type
249      *            TagHandler type that takes in a ValidatorConfig
250      */
251     protected final void addValidator(String name, String validatorId, Class<? extends TagHandler> type)
252     {
253         _factories.put(name, new UserValidatorHandlerFactory(validatorId, type));
254     }
255 
256     /**
257      * Use the specified HandlerType in compiling Facelets. HandlerType must extend TagHandler.
258      * 
259      * See TagHandler
260      * @param name
261      *            name to use, "foo" would be &lt;my:foo /&gt;
262      * @param handlerType
263      *            must extend TagHandler
264      */
265     protected final void addTagHandler(String name, Class<? extends TagHandler> handlerType)
266     {
267         _factories.put(name, new HandlerFactory(handlerType));
268     }
269 
270     /**
271      * Add a UserTagHandler specified a the URL source.
272      * 
273      * See UserTagHandler
274      * @param name
275      *            name to use, "foo" would be &lt;my:foo /&gt;
276      * @param source
277      *            source where the Facelet (Tag) source is
278      */
279     protected final void addUserTag(String name, URL source)
280     {
281         if (_strictJsf2FaceletsCompatibility == null)
282         {
283             MyfacesConfig config = MyfacesConfig.getCurrentInstance(
284                     FacesContext.getCurrentInstance().getExternalContext());
285 
286             _strictJsf2FaceletsCompatibility = config.isStrictJsf2FaceletsCompatibility();
287         }
288         if (Boolean.TRUE.equals(_strictJsf2FaceletsCompatibility))
289         {
290             _factories.put(name, new LegacyUserTagFactory(source));
291         }
292         else
293         {
294             _factories.put(name, new UserTagFactory(source));
295         }
296     }
297 
298     /**
299      * Add a Method to be used as a Function at Compilation.
300      * 
301      * See javax.el.FunctionMapper
302      * 
303      * @param name
304      *            (suffix) of function name
305      * @param method
306      *            method instance
307      */
308     protected final void addFunction(String name, Method method)
309     {
310         _functions.put(name, method);
311     }
312     
313     /**
314      * @since 2.0
315      * @param name
316      * @param behaviorId 
317      */
318     protected final void addBehavior(String name, String behaviorId)
319     {
320         _factories.put(name, new BehaviorHandlerFactory(behaviorId));
321     }
322     
323     /**
324      * @since 2.0
325      * @param name
326      * @param behaviorId
327      * @param handlerType 
328      */
329     protected final void addBehavior(String name, String behaviorId,
330             Class<? extends TagHandler> handlerType)
331     {
332         _factories.put(name, new UserBehaviorHandlerFactory(behaviorId,handlerType));
333     }    
334 
335     private static class ValidatorConfigWrapper implements ValidatorConfig
336     {
337 
338         private final TagConfig parent;
339         private final String validatorId;
340 
341         public ValidatorConfigWrapper(TagConfig parent, String validatorId)
342         {
343             this.parent = parent;
344             this.validatorId = validatorId;
345         }
346 
347         public String getValidatorId()
348         {
349             return this.validatorId;
350         }
351 
352         public FaceletHandler getNextHandler()
353         {
354             return this.parent.getNextHandler();
355         }
356 
357         public Tag getTag()
358         {
359             return this.parent.getTag();
360         }
361 
362         public String getTagId()
363         {
364             return this.parent.getTagId();
365         }
366     }
367 
368     private static class ConverterConfigWrapper implements ConverterConfig
369     {
370         private final TagConfig parent;
371         private final String converterId;
372 
373         public ConverterConfigWrapper(TagConfig parent, String converterId)
374         {
375             this.parent = parent;
376             this.converterId = converterId;
377         }
378 
379         public String getConverterId()
380         {
381             return this.converterId;
382         }
383 
384         public FaceletHandler getNextHandler()
385         {
386             return this.parent.getNextHandler();
387         }
388 
389         public Tag getTag()
390         {
391             return this.parent.getTag();
392         }
393 
394         public String getTagId()
395         {
396             return this.parent.getTagId();
397         }
398     }
399 
400     private static class HandlerFactory implements TagHandlerFactory
401     {
402         private final static Class<?>[] CONSTRUCTOR_SIG = new Class[]{TagConfig.class};
403 
404         protected final Class<? extends TagHandler> handlerType;
405 
406         public HandlerFactory(Class<? extends TagHandler> handlerType)
407         {
408             this.handlerType = handlerType;
409         }
410 
411         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
412         {
413             try
414             {
415                 return handlerType.getConstructor(CONSTRUCTOR_SIG).newInstance(new Object[] { cfg });
416             }
417             catch (InvocationTargetException ite)
418             {
419                 Throwable t = ite.getCause();
420                 if (t instanceof FacesException)
421                 {
422                     throw (FacesException) t;
423                 }
424                 else if (t instanceof ELException)
425                 {
426                     throw (ELException) t;
427                 }
428                 else
429                 {
430                     throw new FacesException("Error Instantiating: " + handlerType.getName(), t);
431                 }
432             }
433             catch (Exception e)
434             {
435                 throw new FacesException("Error Instantiating: " + handlerType.getName(), e);
436             }
437         }
438     }
439 
440     private static class ComponentConfigWrapper implements ComponentConfig
441     {
442 
443         protected final TagConfig parent;
444 
445         protected final String componentType;
446 
447         protected final String rendererType;
448 
449         public ComponentConfigWrapper(TagConfig parent, String componentType, String rendererType)
450         {
451             this.parent = parent;
452             this.componentType = componentType;
453             this.rendererType = rendererType;
454         }
455 
456         public String getComponentType()
457         {
458             return this.componentType;
459         }
460 
461         public String getRendererType()
462         {
463             return this.rendererType;
464         }
465 
466         public FaceletHandler getNextHandler()
467         {
468             return this.parent.getNextHandler();
469         }
470 
471         public Tag getTag()
472         {
473             return this.parent.getTag();
474         }
475 
476         public String getTagId()
477         {
478             return this.parent.getTagId();
479         }
480     }
481 
482     private static class UserTagFactory implements TagHandlerFactory
483     {
484         protected final URL location;
485 
486         public UserTagFactory(URL location)
487         {
488             this.location = location;
489         }
490 
491         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
492         {
493             return new UserTagHandler(cfg, this.location);
494         }
495     }
496     
497     private static class LegacyUserTagFactory implements TagHandlerFactory
498     {
499         protected final URL location;
500 
501         public LegacyUserTagFactory(URL location)
502         {
503             this.location = location;
504         }
505 
506         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
507         {
508             return new LegacyUserTagHandler(cfg, this.location);
509         }
510     }
511 
512     private static class ComponentHandlerFactory implements TagHandlerFactory
513     {
514 
515         protected final String componentType;
516 
517         protected final String renderType;
518 
519         /**
520          * @param handlerType
521          */
522         public ComponentHandlerFactory(String componentType, String renderType)
523         {
524             this.componentType = componentType;
525             this.renderType = renderType;
526         }
527 
528         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
529         {
530             ComponentConfig ccfg = new ComponentConfigWrapper(cfg, this.componentType, this.renderType);
531             return new ComponentHandler(ccfg);
532         }
533     }
534 
535     private static class UserComponentHandlerFactory implements TagHandlerFactory
536     {
537 
538         private final static Class<?>[] CONS_SIG = new Class[] { ComponentConfig.class };
539 
540         protected final String componentType;
541 
542         protected final String renderType;
543 
544         protected final Class<? extends TagHandler> type;
545 
546         protected final Constructor<? extends TagHandler> constructor;
547 
548         /**
549          * @param handlerType
550          */
551         public UserComponentHandlerFactory(String componentType, String renderType, Class<? extends TagHandler> type)
552         {
553             this.componentType = componentType;
554             this.renderType = renderType;
555             this.type = type;
556             try
557             {
558                 this.constructor = this.type.getConstructor(CONS_SIG);
559             }
560             catch (Exception e)
561             {
562                 throw new FaceletException("Must have a Constructor that takes in a ComponentConfig", e);
563             }
564         }
565 
566         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
567         {
568             try
569             {
570                 ComponentConfig ccfg = new ComponentConfigWrapper(cfg, componentType, renderType);
571                 return constructor.newInstance(new Object[] { ccfg });
572             }
573             catch (InvocationTargetException e)
574             {
575                 throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
576             }
577             catch (Exception e)
578             {
579                 throw new FaceletException("Error Instantiating ComponentHandler: " + this.type.getName(), e);
580             }
581         }
582     }
583 
584     private static class ValidatorHandlerFactory implements TagHandlerFactory
585     {
586 
587         protected final String validatorId;
588 
589         public ValidatorHandlerFactory(String validatorId)
590         {
591             this.validatorId = validatorId;
592         }
593 
594         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
595         {
596             return new ValidatorHandler(new ValidatorConfigWrapper(cfg, this.validatorId));
597         }
598     }
599 
600     private static class ConverterHandlerFactory implements TagHandlerFactory
601     {
602 
603         protected final String converterId;
604 
605         public ConverterHandlerFactory(String converterId)
606         {
607             this.converterId = converterId;
608         }
609 
610         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
611         {
612             return new ConverterHandler(new ConverterConfigWrapper(cfg, this.converterId));
613         }
614     }
615 
616     private static class UserConverterHandlerFactory implements TagHandlerFactory
617     {
618         private final static Class<?>[] CONS_SIG = new Class[] { ConverterConfig.class };
619 
620         protected final String converterId;
621 
622         protected final Class<? extends TagHandler> type;
623 
624         protected final Constructor<? extends TagHandler> constructor;
625 
626         public UserConverterHandlerFactory(String converterId, Class<? extends TagHandler> type)
627         {
628             this.converterId = converterId;
629             this.type = type;
630             try
631             {
632                 this.constructor = this.type.getConstructor(CONS_SIG);
633             }
634             catch (Exception e)
635             {
636                 throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
637             }
638         }
639 
640         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
641         {
642             try
643             {
644                 ConverterConfig ccfg = new ConverterConfigWrapper(cfg, converterId);
645                 return constructor.newInstance(new Object[] { ccfg });
646             }
647             catch (InvocationTargetException e)
648             {
649                 throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
650             }
651             catch (Exception e)
652             {
653                 throw new FaceletException("Error Instantiating ConverterHandler: " + type.getName(), e);
654             }
655         }
656     }
657 
658     private static class UserValidatorHandlerFactory implements TagHandlerFactory
659     {
660         private final static Class<?>[] CONS_SIG = new Class[] { ValidatorConfig.class };
661 
662         protected final String validatorId;
663 
664         protected final Class<? extends TagHandler> type;
665 
666         protected final Constructor<? extends TagHandler> constructor;
667 
668         public UserValidatorHandlerFactory(String validatorId, Class<? extends TagHandler> type)
669         {
670             this.validatorId = validatorId;
671             this.type = type;
672             try
673             {
674                 this.constructor = this.type.getConstructor(CONS_SIG);
675             }
676             catch (Exception e)
677             {
678                 throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
679             }
680         }
681 
682         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
683         {
684             try
685             {
686                 ValidatorConfig ccfg = new ValidatorConfigWrapper(cfg, validatorId);
687                 return constructor.newInstance(new Object[] { ccfg });
688             }
689             catch (InvocationTargetException e)
690             {
691                 throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
692             }
693             catch (Exception e)
694             {
695                 throw new FaceletException("Error Instantiating ValidatorHandler: " + type.getName(), e);
696             }
697         }
698     }
699     
700     private static class BehaviorConfigWrapper implements BehaviorConfig
701     {
702         protected final TagConfig parent;
703 
704         protected final String behaviorId;
705 
706         public BehaviorConfigWrapper(TagConfig parent, String behaviorId)
707         {
708             this.parent = parent;
709             this.behaviorId = behaviorId;
710         }
711 
712         public FaceletHandler getNextHandler()
713         {
714             return this.parent.getNextHandler();
715         }
716 
717         public Tag getTag()
718         {
719             return this.parent.getTag();
720         }
721 
722         public String getTagId()
723         {
724             return this.parent.getTagId();
725         }
726 
727         public String getBehaviorId()
728         {
729             return this.behaviorId;
730         }
731     }
732     
733     private static class BehaviorHandlerFactory implements TagHandlerFactory
734     {
735         protected final String behaviorId;
736                
737         public BehaviorHandlerFactory(String behaviorId)
738         {
739             super();
740             this.behaviorId = behaviorId;
741         }
742 
743         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
744         {
745             BehaviorConfig bcfg = new BehaviorConfigWrapper(cfg,this.behaviorId);
746             return new BehaviorHandler(bcfg);
747         }
748     }
749 
750     private static class UserBehaviorHandlerFactory implements TagHandlerFactory
751     {
752         private final static Class<?>[] CONS_SIG = new Class[] { BehaviorConfig.class };
753 
754         protected final String behaviorId;
755 
756         protected final Class<? extends TagHandler> type;
757 
758         protected final Constructor<? extends TagHandler> constructor;
759 
760         public UserBehaviorHandlerFactory(String behaviorId, Class<? extends TagHandler> type)
761         {
762             this.behaviorId = behaviorId;
763             this.type = type;
764             try
765             {
766                 this.constructor = this.type.getConstructor(CONS_SIG);
767             }
768             catch (Exception e)
769             {
770                 throw new FaceletException("Must have a Constructor that takes in a BehaviorConfig", e);
771             }
772         }
773 
774         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
775         {
776             try
777             {
778                 BehaviorConfig bcfg = new BehaviorConfigWrapper(cfg,this.behaviorId);
779                 return constructor.newInstance(new Object[] { bcfg });
780             }
781             catch (InvocationTargetException e)
782             {
783                 throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
784             }
785             catch (Exception e)
786             {
787                 throw new FaceletException("Error Instantiating BehaviorHandler: " + this.type.getName(), e);
788             }
789         }
790     }
791     
792     private static class UserComponentFromResourceIdHandlerFactory implements TagHandlerFactory
793     {
794         protected final String resourceId;
795         
796         public UserComponentFromResourceIdHandlerFactory(String resourceId)
797         {
798             this.resourceId = resourceId;
799         }
800 
801         public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
802         {
803             FacesContext facesContext = FacesContext.getCurrentInstance();
804             ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
805             Resource compositeComponentResourceWrapped = resourceHandler.createResourceFromId(resourceId);
806             if (compositeComponentResourceWrapped != null)
807             {
808                 Resource compositeComponentResource
809                         = new CompositeResouceWrapper(compositeComponentResourceWrapped);
810                 ComponentConfig componentConfig = new ComponentConfigWrapper(cfg,
811                         "javax.faces.NamingContainer", null);
812 
813                 return new CompositeComponentResourceTagHandler(componentConfig,
814                                                                 compositeComponentResource);
815             }
816             else
817             {
818                 throw new FaceletException(
819                     "Error Instantiating Component from <resource-id> declaration: " + this.resourceId);
820             }
821         }
822     }
823 }