Coverage Report - javax.faces.event.ExceptionQueuedEventContext
 
Classes in this File Line Coverage Branch Coverage Complexity
ExceptionQueuedEventContext
0%
0/22
0%
0/12
0
 
 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 javax.faces.event;
 20  
 
 21  
 import java.util.Collections;
 22  
 import java.util.HashMap;
 23  
 import java.util.List;
 24  
 import java.util.Map;
 25  
 
 26  
 import javax.faces.component.UIComponent;
 27  
 import javax.faces.context.FacesContext;
 28  
 
 29  
 /**
 30  
  * @author Simon Lessard (latest modification by $Author: slessard $)
 31  
  * @version $Revision: 696523 $ $Date: 2009-03-14 16:58:24 -0400 (mer., 17 sept. 2008) $
 32  
  * 
 33  
  * @since 2.0
 34  
  */
 35  
 public class ExceptionQueuedEventContext implements SystemEventListenerHolder
 36  
 {
 37  
     // TODO: -=Leonardo Uribe=- This type of constants should be the same 
 38  
     // for ri and myfaces, to keep binary compatibility and pass TCK test.
 39  0
     public static final String IN_AFTER_PHASE_KEY = ExceptionQueuedEventContext.class.getName() + ".IN_AFTER_PHASE";
 40  0
     public static final String IN_BEFORE_PHASE_KEY = ExceptionQueuedEventContext.class.getName() + ".IN_BEFORE_PHASE";
 41  
     
 42  
     private Map<Object, Object> _attributes;
 43  
     private UIComponent _component;
 44  
     private FacesContext _context;
 45  
     private PhaseId _phase;
 46  
     private Throwable _thrown;
 47  
 
 48  
     public ExceptionQueuedEventContext(FacesContext context, Throwable thrown)
 49  
     {
 50  0
         this(context, thrown, null);
 51  0
     }
 52  
 
 53  
     public ExceptionQueuedEventContext(FacesContext context, Throwable thrown, UIComponent component)
 54  
     {
 55  0
         this(context, thrown, component, null);
 56  0
     }
 57  
 
 58  
     public ExceptionQueuedEventContext(FacesContext context, Throwable thrown, UIComponent component, PhaseId phaseId)
 59  0
     {
 60  0
         _context = context;
 61  0
         _thrown = thrown;
 62  0
         _component = component;
 63  0
         _phase = (phaseId == null ? context.getCurrentPhaseId() : phaseId);
 64  0
     }
 65  
     
 66  
     public Map<Object,Object> getAttributes()
 67  
     {
 68  0
         if (_attributes == null)
 69  
         {
 70  0
             _attributes = new HashMap<Object, Object>();
 71  
         }
 72  
         
 73  0
         return _attributes;
 74  
     }
 75  
     
 76  
     public UIComponent getComponent()
 77  
     {
 78  0
         return _component;
 79  
     }
 80  
     
 81  
     public FacesContext getContext()
 82  
     {
 83  0
         return _context;
 84  
     }
 85  
     
 86  
     public Throwable getException()
 87  
     {
 88  0
         return _thrown;
 89  
     }
 90  
 
 91  
     /**
 92  
      * {@inheritDoc}
 93  
      */
 94  
     public List<SystemEventListener> getListenersForEventClass(Class<? extends SystemEvent> facesEventClass)
 95  
     {
 96  0
         return Collections.singletonList((SystemEventListener)getContext().getExceptionHandler());
 97  
     }
 98  
     
 99  
     public PhaseId getPhaseId()
 100  
     {
 101  0
         return _phase;
 102  
     }
 103  
     
 104  
     public boolean inAfterPhase()
 105  
     {
 106  0
         return (_attributes != null && _attributes.containsKey(IN_AFTER_PHASE_KEY));
 107  
     }
 108  
     
 109  
     public boolean inBeforePhase()
 110  
     {
 111  0
         return (_attributes != null && _attributes.containsKey(IN_BEFORE_PHASE_KEY));
 112  
     }
 113  
 }