Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 77   Methods: 4
NCLOC: 40   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
MarkupWriterSourceImpl.java 75% 85.7% 100% 86.4%
coverage coverage
 1   
 // Copyright 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.markup;
 16   
 
 17   
 import java.io.PrintWriter;
 18   
 import java.util.Map;
 19   
 
 20   
 import org.apache.commons.logging.Log;
 21   
 import org.apache.hivemind.util.Defense;
 22   
 import org.apache.tapestry.IMarkupWriter;
 23   
 import org.apache.tapestry.util.ContentType;
 24   
 
 25   
 /**
 26   
  * @author Howard M. Lewis Ship
 27   
  * @since 4.0
 28   
  */
 29   
 public class MarkupWriterSourceImpl implements MarkupWriterSource
 30   
 {
 31   
     private Log _log;
 32   
 
 33   
     private MarkupFilter _defaultFilter = new AsciiMarkupFilter();
 34   
 
 35   
     private Map _contributions;
 36   
 
 37  45
     public void setContributions(Map contributions)
 38   
     {
 39  45
         _contributions = contributions;
 40   
     }
 41   
 
 42  158
     public IMarkupWriter newMarkupWriter(PrintWriter writer, ContentType contentType)
 43   
     {
 44  158
         Defense.notNull(writer, "writer");
 45  158
         Defense.notNull(contentType, "contentType");
 46   
 
 47  158
         MarkupFilter filter = findFilter(contentType);
 48   
 
 49  158
         return new MarkupWriterImpl(contentType.toString(), writer, filter);
 50   
     }
 51   
 
 52  158
     private MarkupFilter findFilter(ContentType contentType)
 53   
     {
 54   
         // Look for an exact match (caseless).
 55   
 
 56  158
         String key = contentType.toString().toLowerCase();
 57   
 
 58  158
         MarkupFilter result = (MarkupFilter) _contributions.get(key);
 59   
 
 60  158
         if (result == null)
 61  23
             result = (MarkupFilter) _contributions.get(contentType.getMimeType());
 62   
 
 63  158
         if (result == null)
 64   
         {
 65  0
             _log.error(MarkupMessages.noFilterMatch(contentType));
 66   
 
 67  0
             result = _defaultFilter;
 68   
         }
 69   
 
 70  158
         return result;
 71   
     }
 72   
 
 73  45
     public void setLog(Log log)
 74   
     {
 75  45
         _log = log;
 76   
     }
 77   
 }