Clover coverage report - Code Coverage for tapestry-contrib release 4.0-beta-8
Coverage timestamp: Sat Sep 24 2005 11:56:21 EDT
file stats: LOC: 82   Methods: 4
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleTableStateAdaptor.java 0% 0% 0% 0%
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    /*
 16    * Created on Jul 6, 2005
 17    */
 18    package org.apache.tapestry.contrib.table.model.simple;
 19   
 20    import java.util.StringTokenizer;
 21   
 22    import org.apache.hivemind.ApplicationRuntimeException;
 23    import org.apache.tapestry.contrib.table.components.TableMessages;
 24    import org.apache.tapestry.services.DataSqueezer;
 25    import org.apache.tapestry.util.io.SqueezeAdaptor;
 26   
 27    public class SimpleTableStateAdaptor implements SqueezeAdaptor
 28    {
 29   
 30    private static final String PREFIX = "t";
 31   
 32    /**
 33    * @see SqueezeAdaptor#getPrefix()
 34    */
 35  0 public String getPrefix()
 36    {
 37  0 return PREFIX;
 38    }
 39   
 40    /**
 41    * @see SqueezeAdaptor#getDataClass()
 42    */
 43  0 public Class getDataClass()
 44    {
 45  0 return SimpleTableState.class;
 46    }
 47   
 48  0 public String squeeze(DataSqueezer squeezer, Object data)
 49    {
 50  0 SimpleTableState objState = (SimpleTableState) data;
 51   
 52  0 StringBuffer buf = new StringBuffer();
 53  0 buf.append(objState.getPagingState().getPageSize());
 54  0 buf.append(":");
 55  0 buf.append(objState.getPagingState().getCurrentPage());
 56  0 buf.append(":");
 57  0 String strSortColumn = objState.getSortingState().getSortColumn();
 58  0 if (strSortColumn == null)
 59  0 strSortColumn = "";
 60  0 buf.append(strSortColumn);
 61  0 buf.append(":");
 62  0 buf.append(objState.getSortingState().getSortOrder() ? 'T' : 'F');
 63   
 64  0 return buf.toString();
 65    }
 66   
 67  0 public Object unsqueeze(DataSqueezer squeezer, String string)
 68    {
 69  0 StringTokenizer strTok = new StringTokenizer(string, ":");
 70  0 if (strTok.countTokens() != 4)
 71  0 throw new ApplicationRuntimeException(TableMessages.invalidTableStateFormat(string));
 72  0 int nPageSize = Integer.parseInt(strTok.nextToken());
 73  0 int nCurrentPage = Integer.parseInt(strTok.nextToken());
 74  0 String strSortColumn = strTok.nextToken();
 75  0 if (strSortColumn.equals(""))
 76  0 strSortColumn = null;
 77  0 boolean bSortOrder = strTok.nextToken().equals("T");
 78   
 79  0 return new SimpleTableState(nPageSize, nCurrentPage, strSortColumn, bSortOrder);
 80    }
 81   
 82    }