Coverage Report - org.apache.myfaces.config.impl.digester.elements.FacesConfigImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
FacesConfigImpl
0%
0/176
0%
0/112
2.667
 
 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.config.impl.digester.elements;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collections;
 24  
 import java.util.HashMap;
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 import org.apache.myfaces.config.element.AbsoluteOrdering;
 28  
 import org.apache.myfaces.config.element.Application;
 29  
 import org.apache.myfaces.config.element.Behavior;
 30  
 import org.apache.myfaces.config.element.ComponentTagDeclaration;
 31  
 import org.apache.myfaces.config.element.Converter;
 32  
 import org.apache.myfaces.config.element.FacesConfigExtension;
 33  
 import org.apache.myfaces.config.element.FacesFlowDefinition;
 34  
 import org.apache.myfaces.config.element.Factory;
 35  
 import org.apache.myfaces.config.element.ManagedBean;
 36  
 import org.apache.myfaces.config.element.NamedEvent;
 37  
 import org.apache.myfaces.config.element.NavigationRule;
 38  
 import org.apache.myfaces.config.element.Ordering;
 39  
 import org.apache.myfaces.config.element.RenderKit;
 40  
 import org.apache.myfaces.config.element.facelets.FaceletTagLibrary;
 41  
 
 42  
 /**
 43  
  * @author <a href="mailto:oliver@rossmueller.com">Oliver Rossmueller</a>
 44  
  */
 45  0
 public class FacesConfigImpl extends org.apache.myfaces.config.element.FacesConfig implements Serializable
 46  
 {
 47  
 
 48  
     private List<Application> applications;
 49  
     private List<Factory> factories;
 50  
     private Map<String, String> components;
 51  
     private Map<String, ComponentTagDeclaration> componentTagDeclarations;
 52  
     private List<Converter> converters;
 53  
     private List<ManagedBean> managedBeans;
 54  
     private List<NavigationRule> navigationRules;
 55  
     private List<RenderKit> renderKits;
 56  
     private List<String> lifecyclePhaseListener;
 57  
     private Map<String, String> validators;
 58  
     private List<Behavior> behaviors;
 59  
     private List<NamedEvent> namedEvents;
 60  
     private List<FacesConfigExtension> facesConfigExtensions;
 61  
     private List <FacesFlowDefinition> facesFlowDefinitions;
 62  
     private List <String> protectedViewsUrlPatternList;
 63  
     private List <String> resourceResolvers;
 64  
     private List<FaceletTagLibrary> faceletTagLibraryList;
 65  
     
 66  
     private transient List<Application> unmodifiableApplications;
 67  
     private transient List<Factory> unmodifiableFactories;
 68  
     private transient Map<String, String> unmodifiableComponents;
 69  
     private transient Map<String, ComponentTagDeclaration> unmodifiableComponentTagDeclarations;
 70  
     private transient List<Converter> unmodifiableConverters;
 71  
     private transient List<ManagedBean> unmodifiableManagedBeans;
 72  
     private transient List<NavigationRule> unmodifiableNavigationRules;
 73  
     private transient List<RenderKit> unmodifiableRenderKits;
 74  
     private transient List<String> unmodifiableLifecyclePhaseListener;
 75  
     private transient Map<String, String> unmodifiableValidators;
 76  
     private transient List<Behavior> unmodifiableBehaviors;
 77  
     private transient List<NamedEvent> unmodifiableNamedEvents;
 78  
     private transient List<FacesConfigExtension> unmodifiableFacesConfigExtensions;
 79  
     private transient List <FacesFlowDefinition> unmodifiableFacesFlowDefinitions;
 80  
     private transient List <String> unmodifiableProtectedViewsUrlPatternList;
 81  
     private transient List <String> unmodifiableResourceResolvers;
 82  
     private transient List<FaceletTagLibrary> unmodifiableFaceletTagLibraryList;
 83  
     
 84  
     private String metadataComplete;
 85  
     private String version;
 86  
     //Ordering variables
 87  
     //This information are not merged, and helps
 88  
     //with preprocessing of faces-config files
 89  
     private String name;
 90  
     private AbsoluteOrdering absoluteOrdering;
 91  
     private Ordering ordering;
 92  
 
 93  
     public void addApplication(Application application)
 94  
     {
 95  0
         if (applications == null)
 96  
         {
 97  0
             applications = new ArrayList<Application>();
 98  
         }
 99  0
         applications.add(application); 
 100  0
     }
 101  
 
 102  
     public void addFactory(Factory factory)
 103  
     {
 104  0
         if (factories == null)
 105  
         {
 106  0
             factories = new ArrayList<Factory>();
 107  
         }
 108  0
         factories.add(factory);
 109  0
     }
 110  
 
 111  
     public void addComponent(String componentType, String componentClass)
 112  
     {
 113  0
         if (components == null)
 114  
         {
 115  0
             components = new HashMap<String, String>();
 116  
         }
 117  0
         components.put(componentType, componentClass);
 118  0
     }
 119  
     
 120  
     public void addComponentTagDeclaration(String componentType, 
 121  
             ComponentTagDeclaration tagDeclaration)
 122  
     {
 123  0
         if (componentTagDeclarations == null)
 124  
         {
 125  0
             componentTagDeclarations = new HashMap<String, ComponentTagDeclaration>();
 126  
         }
 127  0
         componentTagDeclarations.put(componentType, tagDeclaration);
 128  0
     }
 129  
 
 130  
     public void addConverter(Converter converter)
 131  
     {
 132  0
         if (converters == null)
 133  
         {
 134  0
             converters = new ArrayList<Converter>();
 135  
         }
 136  0
         converters.add(converter);
 137  0
     }
 138  
 
 139  
     public void addManagedBean(ManagedBean bean)
 140  
     {
 141  0
         if (managedBeans == null)
 142  
         {
 143  0
             managedBeans = new ArrayList<ManagedBean>();
 144  
         }
 145  0
         managedBeans.add(bean);
 146  0
     }
 147  
 
 148  
     public void addNavigationRule(NavigationRule rule)
 149  
     {
 150  0
         if (navigationRules == null)
 151  
         {
 152  0
             navigationRules = new ArrayList<NavigationRule>();
 153  
         }
 154  0
         navigationRules.add(rule);
 155  0
     }
 156  
 
 157  
     public void addRenderKit(RenderKit renderKit)
 158  
     {
 159  0
         if (renderKits == null)
 160  
         {
 161  0
             renderKits = new ArrayList<RenderKit>();
 162  
         }
 163  0
         renderKits.add(renderKit);
 164  0
     }
 165  
 
 166  
     public void addLifecyclePhaseListener(String value)
 167  
     {
 168  0
         if (lifecyclePhaseListener == null)
 169  
         {
 170  0
             lifecyclePhaseListener = new ArrayList<String>();
 171  
         }
 172  0
         lifecyclePhaseListener.add(value);
 173  0
     }
 174  
 
 175  
     public void addValidator(String id, String validatorClass)
 176  
     {
 177  0
         if (validators == null)
 178  
         {
 179  0
             validators = new HashMap<String, String>();
 180  
         }
 181  0
         validators.put(id, validatorClass);
 182  0
     }
 183  
     
 184  
     public void addBehavior (Behavior behavior)
 185  
     {
 186  0
         if (behaviors == null)
 187  
         {
 188  0
             behaviors = new ArrayList<Behavior>();
 189  
         }
 190  0
         behaviors.add (behavior);
 191  0
     }
 192  
     
 193  
     public void addNamedEvent (NamedEvent namedEvent)
 194  
     {
 195  0
         if (namedEvents == null)
 196  
         {
 197  0
             namedEvents = new ArrayList<NamedEvent>();
 198  
         }
 199  0
         namedEvents.add(namedEvent);
 200  0
     }
 201  
     
 202  
     public void addFacesConfigExtension(FacesConfigExtension elem)
 203  
     {
 204  0
         if (facesConfigExtensions == null)
 205  
         {
 206  0
             facesConfigExtensions = new ArrayList<FacesConfigExtension>();
 207  
         }
 208  0
         facesConfigExtensions.add(elem);
 209  0
     }
 210  
     
 211  
     public void addFacesFlowDefinition(FacesFlowDefinition elem)
 212  
     {
 213  0
         if (facesFlowDefinitions == null)
 214  
         {
 215  0
             facesFlowDefinitions = new ArrayList<FacesFlowDefinition>();
 216  
         }
 217  0
         facesFlowDefinitions.add(elem);
 218  0
     }
 219  
     
 220  
     public void addProtectedViewUrlPattern(String urlPattern)
 221  
     {
 222  0
         if (protectedViewsUrlPatternList == null)
 223  
         {
 224  0
             protectedViewsUrlPatternList = new ArrayList<String>();
 225  
         }
 226  0
         protectedViewsUrlPatternList.add(urlPattern);
 227  0
     }
 228  
     
 229  
     public void addResourceResolver(String resourceResolverClass)
 230  
     {
 231  0
         if (resourceResolvers == null)
 232  
         {
 233  0
             resourceResolvers = new ArrayList<String>();
 234  
         }
 235  0
         resourceResolvers.add(resourceResolverClass);
 236  0
     }
 237  
 
 238  
     public void addFaceletTagLibrary(FaceletTagLibrary library)
 239  
     {
 240  0
         if (faceletTagLibraryList == null)
 241  
         {
 242  0
             faceletTagLibraryList = new ArrayList<FaceletTagLibrary>();
 243  
         }
 244  0
         faceletTagLibraryList.add(library);
 245  0
     }
 246  
 
 247  
     public List<Application> getApplications()
 248  
     {
 249  0
         if (applications == null)
 250  
         {
 251  0
             return Collections.emptyList();
 252  
         }
 253  0
         if (unmodifiableApplications == null)
 254  
         {
 255  0
             unmodifiableApplications = 
 256  
                 Collections.unmodifiableList(applications);
 257  
         }
 258  0
         return unmodifiableApplications;
 259  
     }
 260  
 
 261  
     public List<Factory> getFactories()
 262  
     {
 263  0
         if (factories == null)
 264  
         {
 265  0
             return Collections.emptyList();
 266  
         }
 267  0
         if (unmodifiableFactories == null)
 268  
         {
 269  0
             unmodifiableFactories = 
 270  
                 Collections.unmodifiableList(factories);
 271  
         }
 272  0
         return unmodifiableFactories;
 273  
     }
 274  
 
 275  
     public Map<String, String> getComponents()
 276  
     {
 277  0
         if (components == null)
 278  
         {
 279  0
             return Collections.emptyMap();
 280  
         }
 281  0
         if (unmodifiableComponents == null)
 282  
         {
 283  0
             unmodifiableComponents = 
 284  
                 Collections.unmodifiableMap(components);
 285  
         }
 286  0
         return unmodifiableComponents;
 287  
     }
 288  
     
 289  
     public Map<String, ComponentTagDeclaration> getComponentTagDeclarations()
 290  
     {
 291  0
         if (componentTagDeclarations == null)
 292  
         {
 293  0
             return Collections.emptyMap();
 294  
         }
 295  0
         if (unmodifiableComponentTagDeclarations == null)
 296  
         {
 297  0
             unmodifiableComponentTagDeclarations = 
 298  
                 Collections.unmodifiableMap(componentTagDeclarations);
 299  
         }
 300  0
         return unmodifiableComponentTagDeclarations;
 301  
     }
 302  
 
 303  
     public List<Converter> getConverters()
 304  
     {
 305  0
         if (converters == null)
 306  
         {
 307  0
             return Collections.emptyList();
 308  
         }
 309  0
         if (unmodifiableConverters == null)
 310  
         {
 311  0
             unmodifiableConverters = 
 312  
                 Collections.unmodifiableList(converters);
 313  
         }
 314  0
         return unmodifiableConverters;
 315  
     }
 316  
 
 317  
     public List<ManagedBean> getManagedBeans()
 318  
     {
 319  0
         if (managedBeans == null)
 320  
         {
 321  0
             return Collections.emptyList();
 322  
         }
 323  0
         if (unmodifiableManagedBeans == null)
 324  
         {
 325  0
             unmodifiableManagedBeans = 
 326  
                 Collections.unmodifiableList(managedBeans);
 327  
         }
 328  0
         return unmodifiableManagedBeans;
 329  
     }
 330  
 
 331  
     public List<NavigationRule> getNavigationRules()
 332  
     {
 333  0
         if (navigationRules == null)
 334  
         {
 335  0
             return Collections.emptyList();
 336  
         }
 337  0
         if (unmodifiableNavigationRules == null)
 338  
         {
 339  0
             unmodifiableNavigationRules = 
 340  
                 Collections.unmodifiableList(navigationRules);
 341  
         }
 342  0
         return unmodifiableNavigationRules;
 343  
     }
 344  
 
 345  
     public List<RenderKit> getRenderKits()
 346  
     {
 347  0
         if (renderKits == null)
 348  
         {
 349  0
             return Collections.emptyList();
 350  
         }
 351  0
         if (unmodifiableRenderKits == null)
 352  
         {
 353  0
             unmodifiableRenderKits = 
 354  
                 Collections.unmodifiableList(renderKits);
 355  
         }
 356  0
         return unmodifiableRenderKits;
 357  
     }
 358  
 
 359  
     public List<String> getLifecyclePhaseListener()
 360  
     {
 361  0
         if (lifecyclePhaseListener == null)
 362  
         {
 363  0
             return Collections.emptyList();
 364  
         }
 365  0
         if (unmodifiableLifecyclePhaseListener == null)
 366  
         {
 367  0
             unmodifiableLifecyclePhaseListener = 
 368  
                 Collections.unmodifiableList(lifecyclePhaseListener);
 369  
         }
 370  0
         return unmodifiableLifecyclePhaseListener;
 371  
     }
 372  
 
 373  
     public Map<String, String> getValidators()
 374  
     {
 375  0
         if (validators == null)
 376  
         {
 377  0
             return Collections.emptyMap();
 378  
         }
 379  0
         if (unmodifiableValidators == null)
 380  
         {
 381  0
             unmodifiableValidators = 
 382  
                 Collections.unmodifiableMap(validators);
 383  
         }
 384  0
         return unmodifiableValidators;
 385  
     }
 386  
     
 387  
     public List<Behavior> getBehaviors ()
 388  
     {
 389  0
         if (behaviors == null)
 390  
         {
 391  0
             return Collections.emptyList();
 392  
         }
 393  0
         if (unmodifiableBehaviors == null)
 394  
         {
 395  0
             unmodifiableBehaviors = 
 396  
                 Collections.unmodifiableList(behaviors);
 397  
         }
 398  0
         return unmodifiableBehaviors;
 399  
     }
 400  
     
 401  
     public List<NamedEvent> getNamedEvents ()
 402  
     {
 403  0
         if (namedEvents == null)
 404  
         {
 405  0
             return Collections.emptyList();
 406  
         }
 407  0
         if (unmodifiableNamedEvents == null)
 408  
         {
 409  0
             unmodifiableNamedEvents = 
 410  
                 Collections.unmodifiableList(namedEvents);
 411  
         }
 412  0
         return unmodifiableNamedEvents;
 413  
     }
 414  
     
 415  
     public RenderKit getRenderKit(String renderKitId)
 416  
     {
 417  0
         for (RenderKit rk : getRenderKits())
 418  
         {
 419  0
             if (renderKitId != null && renderKitId.equals(rk.getId()))
 420  
             {
 421  0
                 return rk;
 422  
             }
 423  0
             else if (renderKitId == null && rk.getId() == null)
 424  
             {
 425  0
                 return rk;
 426  
             }
 427  0
         }
 428  0
         return null;
 429  
     }
 430  
     
 431  
     public String getName()
 432  
     {
 433  0
         return name;
 434  
     }
 435  
 
 436  
     public void setName(String name)
 437  
     {
 438  0
         this.name = name;
 439  0
     }
 440  
     
 441  
     public org.apache.myfaces.config.element.AbsoluteOrdering getAbsoluteOrdering()
 442  
     {
 443  0
         return absoluteOrdering;
 444  
     }
 445  
 
 446  
     public void setAbsoluteOrdering(org.apache.myfaces.config.element.AbsoluteOrdering absoluteOrdering)
 447  
     {
 448  0
         this.absoluteOrdering = absoluteOrdering;
 449  0
     }
 450  
 
 451  
     public org.apache.myfaces.config.element.Ordering getOrdering()
 452  
     {
 453  0
         return ordering;
 454  
     }
 455  
 
 456  
     public void setOrdering(org.apache.myfaces.config.element.Ordering ordering)
 457  
     {
 458  0
         this.ordering = ordering;
 459  0
     }
 460  
 
 461  
     public String getMetadataComplete()
 462  
     {
 463  0
         return metadataComplete;
 464  
     }
 465  
 
 466  
     public void setMetadataComplete(String metadataComplete)
 467  
     {
 468  0
         this.metadataComplete = metadataComplete;
 469  0
     }
 470  
     
 471  
     public String getVersion ()
 472  
     {
 473  0
         return version;
 474  
     }
 475  
     
 476  
     public void setVersion (String version)
 477  
     {
 478  0
         this.version = version;
 479  0
     }
 480  
 
 481  
     @Override
 482  
     public List<org.apache.myfaces.config.element.FacesConfigExtension> getFacesConfigExtensions()
 483  
     {
 484  0
         if (facesConfigExtensions == null)
 485  
         {
 486  0
             return Collections.emptyList();
 487  
         }
 488  0
         if (unmodifiableFacesConfigExtensions == null)
 489  
         {
 490  0
             unmodifiableFacesConfigExtensions = 
 491  
                 Collections.unmodifiableList(facesConfigExtensions);
 492  
         }
 493  0
         return unmodifiableFacesConfigExtensions;
 494  
     }
 495  
     
 496  
     @Override
 497  
     public List<FacesFlowDefinition> getFacesFlowDefinitions()
 498  
     {
 499  0
         if (facesFlowDefinitions == null)
 500  
         {
 501  0
             return Collections.emptyList();
 502  
         }
 503  0
         if (unmodifiableFacesFlowDefinitions == null)
 504  
         {
 505  0
             unmodifiableFacesFlowDefinitions = 
 506  
                 Collections.unmodifiableList(facesFlowDefinitions);
 507  
         }
 508  0
         return unmodifiableFacesFlowDefinitions;
 509  
     }
 510  
     
 511  
     public List<String> getProtectedViewsUrlPatternList()
 512  
     {
 513  0
         if (protectedViewsUrlPatternList == null)
 514  
         {
 515  0
             return Collections.emptyList();
 516  
         }
 517  0
         if (unmodifiableProtectedViewsUrlPatternList == null)
 518  
         {
 519  0
             unmodifiableProtectedViewsUrlPatternList = 
 520  
                 Collections.unmodifiableList(protectedViewsUrlPatternList);
 521  
         }
 522  0
         return unmodifiableProtectedViewsUrlPatternList;
 523  
     }
 524  
     
 525  
     public List<String> getResourceResolversList()
 526  
     {
 527  0
         if (resourceResolvers == null)
 528  
         {
 529  0
             return Collections.emptyList();
 530  
         }
 531  0
         if (unmodifiableResourceResolvers == null)
 532  
         {
 533  0
             unmodifiableResourceResolvers = 
 534  
                 Collections.unmodifiableList(resourceResolvers);
 535  
         }
 536  0
         return unmodifiableResourceResolvers;
 537  
     }
 538  
     
 539  
     @Override
 540  
     public List<FaceletTagLibrary> getFaceletTagLibraryList()
 541  
     {
 542  0
         if (faceletTagLibraryList == null)
 543  
         {
 544  0
             return Collections.emptyList();
 545  
         }
 546  0
         if (unmodifiableFaceletTagLibraryList == null)
 547  
         {
 548  0
             unmodifiableFaceletTagLibraryList = 
 549  
                 Collections.unmodifiableList(faceletTagLibraryList);
 550  
         }
 551  0
         return unmodifiableFaceletTagLibraryList;
 552  
     }
 553  
 }