Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SimpleTableSessionStateManager |
|
| 1.6666666666666667;1.667 |
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.contrib.table.model.simple; | |
16 | ||
17 | import java.io.Serializable; | |
18 | ||
19 | import org.apache.tapestry.contrib.table.model.ITableColumnModel; | |
20 | import org.apache.tapestry.contrib.table.model.ITableDataModel; | |
21 | import org.apache.tapestry.contrib.table.model.ITableModel; | |
22 | import org.apache.tapestry.contrib.table.model.ITableSessionStateManager; | |
23 | ||
24 | /** | |
25 | * A {@link org.apache.tapestry.contrib.table.model.ITableSessionStateManager} | |
26 | * implementation that saves only the paging and sorting state of the table | |
27 | * model into the session. | |
28 | * | |
29 | * @author mindbridge | |
30 | */ | |
31 | public class SimpleTableSessionStateManager implements | |
32 | ITableSessionStateManager | |
33 | { | |
34 | ||
35 | private ITableDataModel m_objDataModel; | |
36 | private ITableColumnModel m_objColumnModel; | |
37 | ||
38 | public SimpleTableSessionStateManager(ITableDataModel objDataModel, | |
39 | ITableColumnModel objColumnModel) | |
40 | 0 | { |
41 | 0 | m_objDataModel = objDataModel; |
42 | 0 | m_objColumnModel = objColumnModel; |
43 | 0 | } |
44 | ||
45 | /** | |
46 | * @see org.apache.tapestry.contrib.table.model.ITableSessionStateManager#getSessionState(ITableModel) | |
47 | */ | |
48 | public Serializable getSessionState(ITableModel objModel) | |
49 | { | |
50 | 0 | SimpleTableModel objSimpleModel = (SimpleTableModel) objModel; |
51 | 0 | return objSimpleModel.getState(); |
52 | } | |
53 | ||
54 | /** | |
55 | * @see org.apache.tapestry.contrib.table.model.ITableSessionStateManager#recreateTableModel(Serializable) | |
56 | */ | |
57 | public ITableModel recreateTableModel(Serializable objState) | |
58 | { | |
59 | 0 | if (objState == null) return null; |
60 | 0 | SimpleTableState objSimpleState = (SimpleTableState) objState; |
61 | 0 | return new SimpleTableModel(m_objDataModel, m_objColumnModel, |
62 | objSimpleState); | |
63 | } | |
64 | ||
65 | } |