Coverage Report - org.apache.myfaces.flow.FlowCallNodeImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
FlowCallNodeImpl
0%
0/42
0%
0/10
1.615
 
 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.flow;
 20  
 
 21  
 import java.util.Collections;
 22  
 import java.util.HashMap;
 23  
 import java.util.Map;
 24  
 import javax.el.ValueExpression;
 25  
 import javax.faces.context.FacesContext;
 26  
 import javax.faces.flow.FlowCallNode;
 27  
 import javax.faces.flow.Parameter;
 28  
 
 29  
 /**
 30  
  *
 31  
  * @since 2.2
 32  
  * @author Leonardo Uribe
 33  
  */
 34  
 public class FlowCallNodeImpl extends FlowCallNode implements Freezable
 35  
 {
 36  
     private String _id;
 37  
     private String _calledFlowId;
 38  
     private ValueExpression _calledFlowIdEL;
 39  
     private String _calledFlowDocumentId;
 40  
     private ValueExpression _calledFlowDocumentIdEL;
 41  
     
 42  
     private Map<String, Parameter> _outboundParametersMap;
 43  
     private Map<String, Parameter> _unmodifiableOutboundParametersMap;
 44  
     
 45  
     private boolean _initialized;
 46  
 
 47  
     public FlowCallNodeImpl(String id)
 48  0
     {
 49  0
         this._id = id;
 50  0
         _outboundParametersMap = new HashMap<String, Parameter>();
 51  0
         _unmodifiableOutboundParametersMap = Collections.unmodifiableMap(_outboundParametersMap);
 52  0
     }
 53  
     
 54  
     @Override
 55  
     public Map<String, Parameter> getOutboundParameters()
 56  
     {
 57  0
         return _unmodifiableOutboundParametersMap;
 58  
     }
 59  
     
 60  
     public void putOutboundParameter(String key, Parameter value)
 61  
     {
 62  0
         checkInitialized();
 63  0
         _outboundParametersMap.put(key, value);
 64  0
     }
 65  
 
 66  
     @Override
 67  
     public String getCalledFlowDocumentId(FacesContext context)
 68  
     {
 69  0
         if (_calledFlowDocumentIdEL != null)
 70  
         {
 71  0
             return (String) _calledFlowDocumentIdEL.getValue(context.getELContext());
 72  
         }
 73  0
         return _calledFlowDocumentId;
 74  
     }
 75  
 
 76  
     @Override
 77  
     public String getCalledFlowId(FacesContext context)
 78  
     {
 79  0
         if (_calledFlowIdEL != null)
 80  
         {
 81  0
             return (String) _calledFlowIdEL.getValue(context.getELContext());
 82  
         }
 83  0
         return _calledFlowId;
 84  
     }
 85  
 
 86  
     @Override
 87  
     public String getId()
 88  
     {
 89  0
         return _id;
 90  
     }
 91  
 
 92  
     public void setId(String id)
 93  
     {
 94  0
         checkInitialized();
 95  0
         this._id = id;
 96  0
     }
 97  
 
 98  
     public void setCalledFlowId(String calledFlowId)
 99  
     {
 100  0
         checkInitialized();
 101  0
         this._calledFlowId = calledFlowId;
 102  0
         this._calledFlowIdEL = null;
 103  0
     }
 104  
 
 105  
     public void setCalledFlowDocumentId(String calledFlowDocumentId)
 106  
     {
 107  0
         checkInitialized();
 108  0
         this._calledFlowDocumentId = calledFlowDocumentId;
 109  0
         this._calledFlowDocumentIdEL = null;
 110  0
     }
 111  
     
 112  
     public void freeze()
 113  
     {
 114  0
         _initialized = true;
 115  
         
 116  0
         for (Map.Entry<String, Parameter> entry : _outboundParametersMap.entrySet())
 117  
         {
 118  0
             if (entry.getValue() instanceof Freezable)
 119  
             {
 120  0
                 ((Freezable)entry.getValue()).freeze();
 121  
             }
 122  0
         }
 123  0
     }
 124  
     
 125  
     private void checkInitialized() throws IllegalStateException
 126  
     {
 127  0
         if (_initialized)
 128  
         {
 129  0
             throw new IllegalStateException("Flow is inmutable once initialized");
 130  
         }
 131  0
     }
 132  
 
 133  
     /**
 134  
      * @param calledFlowIdEL the _calledFlowIdEL to set
 135  
      */
 136  
     public void setCalledFlowId(ValueExpression calledFlowIdEL)
 137  
     {
 138  0
         this._calledFlowIdEL = calledFlowIdEL;
 139  0
         this._calledFlowId = null;
 140  0
     }
 141  
 
 142  
     /**
 143  
      * @param calledFlowDocumentIdEL the _calledFlowDocumentIdEL to set
 144  
      */
 145  
     public void setCalledFlowDocumentId(ValueExpression calledFlowDocumentIdEL)
 146  
     {
 147  0
         this._calledFlowDocumentIdEL = calledFlowDocumentIdEL;
 148  0
         this._calledFlowDocumentId = null;
 149  0
     }
 150  
 }