1 | /** |
2 | * Copyright 2005-2011 Steve McDuff d-duff@users.sourceforge.net |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | package org.deduced.viewer.web.serializer; |
17 | |
18 | import java.io.Serializable; |
19 | |
20 | import org.deduced.PropertyCollection; |
21 | import org.deduced.viewer.model.implementation.LabelImplementation; |
22 | import org.deduced.viewer.web.shared.LabelModel; |
23 | import org.deduced.viewer.web.shared.Model; |
24 | |
25 | /** |
26 | * LabelModel Serializer |
27 | * |
28 | * @author Steve McDuff |
29 | */ |
30 | public class LabelModelSerializer extends UserInterfaceModelSerializer |
31 | { |
32 | /** |
33 | * fill LabelModel |
34 | * |
35 | * @param model the model to serialize |
36 | * @param labelModel the model to fill |
37 | */ |
38 | private static void fillLabelModel( |
39 | PropertyCollection<?, ?> model, LabelModel labelModel) |
40 | { |
41 | labelModel.setText(LabelImplementation.getText(model)); |
42 | } |
43 | |
44 | /** |
45 | * (non-JSDoc) |
46 | * |
47 | * @see org.deduced.viewer.web.serializer.WebSerializer#createSerializedObject(org.deduced.PropertyCollection) |
48 | */ |
49 | @Override |
50 | public Model createSerializedObject( |
51 | PropertyCollection<?, ?> collection) |
52 | { |
53 | return new LabelModel(); |
54 | } |
55 | |
56 | /** |
57 | * (non-JSDoc) |
58 | * |
59 | * @see org.deduced.viewer.web.serializer.UserInterfaceModelSerializer#fillSerializedObject(java.io.Serializable, |
60 | * org.deduced.PropertyCollection, |
61 | * org.deduced.viewer.web.serializer.MasterWebSerializer) |
62 | */ |
63 | @Override |
64 | public void fillSerializedObject( |
65 | Serializable serializedObject, PropertyCollection<?, ?> collection, |
66 | MasterWebSerializer masterSerializer) |
67 | { |
68 | fillLabelModel(collection, (LabelModel) serializedObject); |
69 | super.fillSerializedObject(serializedObject, collection, |
70 | masterSerializer); |
71 | } |
72 | } |