Coverage Report - org.apache.tapestry.engine.ServiceEncodingImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceEncodingImpl
0%
0/31
N/A
1
 
 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.util.QueryParameterMap;
 19  
 
 20  
 /**
 21  
  * Implementation of {@link org.apache.tapestry.engine.ServiceEncoding}, which adds the ability to
 22  
  * determine when the encoding has been modified.
 23  
  * 
 24  
  * @author Howard M. Lewis Ship
 25  
  * @since 4.0
 26  
  */
 27  
 public class ServiceEncodingImpl implements ServiceEncoding
 28  
 {
 29  
     protected String _servletPath;
 30  
 
 31  
     protected String _pathInfo;
 32  
 
 33  
     /**
 34  
      * Map of query parameter values; key is string name, value is either a string, an array of
 35  
      * strings, or null. Could have done this with subclassing rather than delegation.
 36  
      */
 37  
 
 38  
     protected final QueryParameterMap _parameters;
 39  
 
 40  
     protected boolean _modified;
 41  
 
 42  
     /**
 43  
      * Creates a new instance with a new map of parameters.
 44  
      */
 45  
 
 46  
     public ServiceEncodingImpl(String servletPath)
 47  
     {
 48  0
         this(servletPath, null, new QueryParameterMap());
 49  0
     }
 50  
 
 51  
     public ServiceEncodingImpl(String servletPath, QueryParameterMap parametersMap)
 52  
     {
 53  0
         this(servletPath, null, parametersMap);
 54  0
     }
 55  
 
 56  
     public ServiceEncodingImpl(String servletPath, String pathInfo, QueryParameterMap parameters)
 57  0
     {
 58  0
         Defense.notNull(servletPath, "servletPath");
 59  0
         Defense.notNull(parameters, "parameters");
 60  
 
 61  0
         _servletPath = servletPath;
 62  0
         _pathInfo = pathInfo;
 63  0
         _parameters = parameters;
 64  0
     }
 65  
     
 66  
     public boolean isModified()
 67  
     {
 68  0
         return _modified;
 69  
     }
 70  
 
 71  
     public void resetModified()
 72  
     {
 73  0
         _modified = false;
 74  0
     }
 75  
 
 76  
     public String getParameterValue(String name)
 77  
     {
 78  0
         return _parameters.getParameterValue(name);
 79  
     }
 80  
 
 81  
     public String[] getParameterValues(String name)
 82  
     {
 83  0
         return _parameters.getParameterValues(name);
 84  
     }
 85  
 
 86  
     public void setServletPath(String servletPath)
 87  
     {
 88  0
         Defense.notNull(servletPath, "servletPath");
 89  
 
 90  0
         _servletPath = servletPath;
 91  0
         _modified = true;
 92  0
     }
 93  
 
 94  
     public void setParameterValue(String name, String value)
 95  
     {
 96  0
         _parameters.setParameterValue(name, value);
 97  
 
 98  0
         _modified = true;
 99  0
     }
 100  
 
 101  
     public void setParameterValues(String name, String[] values)
 102  
     {
 103  0
         _parameters.setParameterValues(name, values);
 104  
 
 105  0
         _modified = true;
 106  0
     }
 107  
 
 108  
     public String getServletPath()
 109  
     {
 110  0
         return _servletPath;
 111  
     }
 112  
 
 113  
     public String[] getParameterNames()
 114  
     {
 115  0
         return _parameters.getParameterNames();
 116  
     }
 117  
 
 118  
     public String getPathInfo()
 119  
     {
 120  0
         return _pathInfo;
 121  
     }
 122  
     
 123  
     public void setPathInfo(String pathInfo) 
 124  
     {
 125  0
         _pathInfo = pathInfo;
 126  0
     }
 127  
 }