Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 118   Methods: 12
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ServiceEncodingImpl.java - 100% 100% 100%
coverage
 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 java.util.Map;
 18   
 19    import org.apache.hivemind.util.Defense;
 20    import org.apache.tapestry.util.QueryParameterMap;
 21   
 22    /**
 23    * Implementation of {@link org.apache.tapestry.engine.ServiceEncoding}, which adds the ability to
 24    * determine when the encoding has been modified.
 25    *
 26    * @author Howard M. Lewis Ship
 27    * @since 4.0
 28    */
 29    public class ServiceEncodingImpl implements ServiceEncoding
 30    {
 31    private String _servletPath;
 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    private final QueryParameterMap _parameters;
 39   
 40    private boolean _modified;
 41   
 42  11 public boolean isModified()
 43    {
 44  11 return _modified;
 45    }
 46   
 47  1 public void resetModified()
 48    {
 49  1 _modified = false;
 50    }
 51   
 52    /**
 53    * Creates a new instance with a new map of parameters.
 54    */
 55   
 56  5 public ServiceEncodingImpl(String servletPath)
 57    {
 58  5 this(servletPath, new QueryParameterMap());
 59    }
 60   
 61  221 public ServiceEncodingImpl(String servletPath, Map parametersMap)
 62    {
 63  221 this(servletPath, new QueryParameterMap(parametersMap));
 64    }
 65   
 66  359 public ServiceEncodingImpl(String servletPath, QueryParameterMap parameters)
 67    {
 68  359 Defense.notNull(servletPath, "servletPath");
 69  359 Defense.notNull(parameters, "parameters");
 70   
 71  359 _servletPath = servletPath;
 72   
 73  359 _parameters = parameters;
 74    }
 75   
 76  8 public String getParameterValue(String name)
 77    {
 78  8 return _parameters.getParameterValue(name);
 79    }
 80   
 81  2 public String[] getParameterValues(String name)
 82    {
 83  2 return _parameters.getParameterValues(name);
 84    }
 85   
 86  4 public void setServletPath(String servletPath)
 87    {
 88  4 Defense.notNull(servletPath, "servletPath");
 89   
 90  4 _servletPath = servletPath;
 91  4 _modified = true;
 92    }
 93   
 94  10 public void setParameterValue(String name, String value)
 95    {
 96  10 _parameters.setParameterValue(name, value);
 97   
 98  10 _modified = true;
 99    }
 100   
 101  2 public void setParameterValues(String name, String[] values)
 102    {
 103  2 _parameters.setParameterValues(name, values);
 104   
 105  2 _modified = true;
 106    }
 107   
 108  222 public String getServletPath()
 109    {
 110  222 return _servletPath;
 111    }
 112   
 113  1 public String[] getParameterNames()
 114    {
 115  1 return _parameters.getParameterNames();
 116    }
 117   
 118    }