EMMA Coverage Report (generated Sat Apr 14 15:01:05 EDT 2012)
[all classes][org.deduced.viewer.web.serializer]

COVERAGE SUMMARY FOR SOURCE FILE [ModelSerializer.java]

nameclass, %method, %block, %line, %
ModelSerializer.java100% (1/1)100% (7/7)100% (39/39)100% (14/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ModelSerializer100% (1/1)100% (7/7)100% (39/39)100% (14/14)
ModelSerializer (): void 100% (1/1)100% (3/3)100% (1/1)
fillModel (PropertyCollection, Model): void 100% (1/1)100% (4/4)100% (2/2)
fillSerializedObject (Serializable, PropertyCollection, MasterWebSerializer):... 100% (1/1)100% (5/5)100% (2/2)
getID (PropertyCollection): String 100% (1/1)100% (4/4)100% (1/1)
serialize (PropertyCollection, MasterWebSerializer): Serializable 100% (1/1)100% (11/11)100% (3/3)
serializeEnumeration (PropertyCollection): String 100% (1/1)100% (7/7)100% (3/3)
setID (PropertyCollection, Model): void 100% (1/1)100% (5/5)100% (2/2)

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 */
16package org.deduced.viewer.web.serializer;
17 
18import java.io.Serializable;
19 
20import org.deduced.AbstractPropertyCollection;
21import org.deduced.DeducedUtilities;
22import org.deduced.PropertyCollection;
23import org.deduced.viewer.web.shared.Model;
24 
25/**
26 * Model Serializer
27 * 
28 * @author Steve McDuff
29 * 
30 */
31public abstract class ModelSerializer implements WebSerializer
32{
33        /**
34         * fill the Model
35         * 
36         * @param object collection to serialize
37         * @param model the model to fill
38         */
39        public static void fillModel(
40                PropertyCollection<?, ?> object, Model model)
41        {
42                setID(object, model);
43        }
44 
45        /**
46         * set the ID of a collection on it's serialized form
47         * 
48         * @param collection collection to serialize
49         * @param model the model on which to set the ID
50         */
51        public static void setID(
52                PropertyCollection<?, ?> collection, Model model)
53        {
54                model.setId(getID(collection));
55        }
56 
57        /**
58         * get a collection ID in string form
59         * 
60         * @param collection the collection from which to fetch the ID
61         * @return the collection ID string
62         */
63        public static String getID(
64                PropertyCollection<?, ?> collection)
65        {
66                return AbstractPropertyCollection.getInstanceIdentityKey(collection)
67                        .toString();
68        }
69 
70        /**
71         * (non-JSDoc)
72         * 
73         * @see org.deduced.viewer.web.serializer.WebSerializer#serialize(org.deduced.PropertyCollection,
74         *      org.deduced.viewer.web.serializer.MasterWebSerializer)
75         */
76        @Override
77        public Serializable serialize(
78                PropertyCollection<?, ?> collection,
79                MasterWebSerializer masterSerializer)
80        {
81                Serializable serializedObject = createSerializedObject(collection);
82 
83                fillSerializedObject(serializedObject, collection, masterSerializer);
84 
85                return serializedObject;
86        }
87 
88        /**
89         * (non-JSDoc)
90         * 
91         * @see org.deduced.viewer.web.serializer.WebSerializer#fillSerializedObject(java.io.Serializable,
92         *      org.deduced.PropertyCollection,
93         *      org.deduced.viewer.web.serializer.MasterWebSerializer)
94         */
95        @Override
96        public void fillSerializedObject(
97                Serializable serializedObject, PropertyCollection<?, ?> collection,
98                MasterWebSerializer masterSerializer)
99        {
100                fillModel(collection, (Model) serializedObject);
101        }
102 
103        /**
104         * serialize enumeration
105         * 
106         * @param model the enumeration model
107         * @return the serialized name of the enumeration
108         */
109        public static String serializeEnumeration(
110                PropertyCollection<?, ?> model)
111        {
112                if (model == null)
113                {
114                        return null;
115                }
116 
117                return DeducedUtilities.getCollectionName(model);
118        }
119 
120}

[all classes][org.deduced.viewer.web.serializer]
EMMA 2.0.9525 (unsupported private build) (C) Vladimir Roubtsov