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: 67   Methods: 3
NCLOC: 32   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
ComponentAddressAdaptor.java 83.3% 92.9% 100% 91.3%
coverage 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.util.io;
 16   
 
 17   
 import java.io.IOException;
 18   
 
 19   
 import org.apache.tapestry.Tapestry;
 20   
 import org.apache.tapestry.services.DataSqueezer;
 21   
 import org.apache.tapestry.util.ComponentAddress;
 22   
 
 23   
 /**
 24   
  * Squeezes a org.apache.tapestry.ComponentAddress.
 25   
  * 
 26   
  * @author mindbridge
 27   
  * @since 2.2
 28   
  */
 29   
 
 30   
 public class ComponentAddressAdaptor implements ISqueezeAdaptor
 31   
 {
 32   
     private static final String PREFIX = "A";
 33   
 
 34   
     private static final char SEPARATOR = ',';
 35   
 
 36  2
     public String squeeze(DataSqueezer squeezer, Object data) throws IOException
 37   
     {
 38  2
         ComponentAddress address = (ComponentAddress) data;
 39   
 
 40   
         // a 'null' id path is encoded as an empty string
 41  2
         String idPath = address.getIdPath();
 42  2
         if (idPath == null)
 43  1
             idPath = "";
 44   
 
 45  2
         return PREFIX + address.getPageName() + SEPARATOR + idPath;
 46   
     }
 47   
 
 48  2
     public Object unsqueeze(DataSqueezer squeezer, String string) throws IOException
 49   
     {
 50  2
         int separator = string.indexOf(SEPARATOR);
 51  2
         if (separator < 0)
 52  0
             throw new IOException(Tapestry.getMessage("ComponentAddressAdaptor.no-separator"));
 53   
 
 54  2
         String pageName = string.substring(1, separator);
 55  2
         String idPath = string.substring(separator + 1);
 56  2
         if (idPath.equals(""))
 57  1
             idPath = null;
 58   
 
 59  2
         return new ComponentAddress(pageName, idPath);
 60   
     }
 61   
 
 62  34
     public void register(DataSqueezer squeezer)
 63   
     {
 64  34
         squeezer.register(PREFIX, ComponentAddress.class, this);
 65   
     }
 66   
 
 67   
 }