Coverage Report - org.apache.tapestry.engine.DirectServiceParameter
 
Classes in this File Line Coverage Branch Coverage Complexity
DirectServiceParameter
0%
0/30
0%
0/12
1.75
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.engine;
 16  
 
 17  
 import org.apache.hivemind.util.Defense;
 18  
 import org.apache.tapestry.IDirect;
 19  
 import org.apache.tapestry.IDynamicInvoker;
 20  
 
 21  
 import java.util.Collection;
 22  
 
 23  
 /**
 24  
  * Parameter object used by {@link org.apache.tapestry.engine.DirectService}.
 25  
  * 
 26  
  * @author Howard M. Lewis Ship
 27  
  * @since 4.0
 28  
  */
 29  
 public class DirectServiceParameter
 30  
 {
 31  
     private IDirect _direct;
 32  
 
 33  
     private Object[] _serviceParameters;
 34  
 
 35  
     private String[] _updateParts;
 36  
     
 37  
     private boolean _json;
 38  
     
 39  
     private boolean _async;
 40  
     
 41  
     public DirectServiceParameter(IDirect direct)
 42  
     {
 43  0
         this(direct, null);
 44  0
     }
 45  
     
 46  
     public DirectServiceParameter(IDirect direct, Object[] serviceParameters)
 47  
     {
 48  0
         this(direct, serviceParameters, null);
 49  0
     }
 50  
     
 51  
     public DirectServiceParameter(IDirect direct, Object[] serviceParameters, IDynamicInvoker invoker)
 52  0
     {
 53  0
         Defense.notNull(direct, "direct");
 54  
         
 55  0
         _direct = direct;
 56  0
         _serviceParameters = serviceParameters;
 57  
         
 58  0
         if (invoker == null) {
 59  
             
 60  0
             Collection comps = direct.getUpdateComponents();
 61  0
             if (comps == null)
 62  0
                 _updateParts = new String[0];
 63  
             else
 64  0
                 _updateParts = (String[])comps.toArray(new String[comps.size()]);
 65  
             
 66  0
             _json = direct.isJson();
 67  0
             _async = direct.isAsync();
 68  0
         } else {
 69  
             
 70  0
             Collection comps = invoker.getUpdateComponents();
 71  0
             if (comps == null)
 72  0
                 _updateParts = new String[0];
 73  
             else
 74  0
                 _updateParts = (String[])comps.toArray(new String[comps.size()]);
 75  
             
 76  0
             _json = invoker.isJson();
 77  0
             _async = invoker.isAsync();
 78  
         }
 79  
         
 80  
         // if they gave only an updateComponents param make it async by default
 81  
         
 82  0
         if (!_json && !_async && _updateParts.length > 0)
 83  0
             _async = true;
 84  0
     }
 85  
     
 86  
     public IDirect getDirect()
 87  
     {
 88  0
         return _direct;
 89  
     }
 90  
 
 91  
     public Object[] getServiceParameters()
 92  
     {
 93  0
         return _serviceParameters;
 94  
     }
 95  
 
 96  
     public String[] getUpdateParts()
 97  
     {
 98  0
         return _updateParts;
 99  
     }
 100  
     
 101  
     public boolean isJson()
 102  
     {
 103  0
         return _json;
 104  
     }
 105  
     
 106  
     public boolean isAsync()
 107  
     {
 108  0
         return _async;
 109  
     }
 110  
 }