Clover Coverage Report - krad-web-framework 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
11   108   9   1.22
0   41   0.82   4.5
9     1  
2    
 
  DocumentSerializationState       Line # 32 7 0% 6 13 0% 0.0
  DocumentSerializationState.SerializationPropertyElement       Line # 33 4 0% 3 7 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2007-2008 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.rice.kns.util.documentserializer;
17   
18    import java.util.ArrayList;
19    import java.util.Collection;
20    import java.util.List;
21   
22    import org.kuali.rice.kns.bo.BusinessObject;
23   
24    /**
25    * This object keeps track of most of the open tags while a document is serialized. Note that instances of this class
26    * may not necessarily hold all open tags of a document while it is being serialized. For example, tags enclosing list elements
27    * and map entries are not contained within here. See {@link DocumentSerializerServiceImpl} to determine when this object's state
28    * is modified.
29    *
30    * This class's manipulators behave much like a stack, but it has random access characteristics like an array.
31    */
 
32    public class DocumentSerializationState {
 
33    protected class SerializationPropertyElement {
34    private String elementName;
35    private PropertyType propertyType;
36   
 
37  0 toggle public SerializationPropertyElement(String elementName, PropertyType propertyType) {
38  0 this.elementName = elementName;
39  0 this.propertyType = propertyType;
40    }
41   
 
42  0 toggle public String getElementName() {
43  0 return this.elementName;
44    }
45   
 
46  0 toggle public PropertyType getPropertyType() {
47  0 return this.propertyType;
48    }
49    }
50   
51    private List<SerializationPropertyElement> pathElements;
52   
 
53  0 toggle public DocumentSerializationState() {
54  0 pathElements = new ArrayList<SerializationPropertyElement>();
55    }
56   
57    /**
58    * The number of property elements in this state object.
59    *
60    * @return
61    */
 
62  0 toggle public int numPropertyElements() {
63  0 return pathElements.size();
64    }
65   
66    /**
67    * Adds an additional state element into this object.
68    *
69    * @param elementName
70    * @param propertyType the type of the property when it was serialized
71    */
 
72  0 toggle public void addSerializedProperty(String elementName, PropertyType propertyType) {
73  0 SerializationPropertyElement serializationPropertyElement = new SerializationPropertyElement(elementName, propertyType);
74  0 pathElements.add(serializationPropertyElement);
75    }
76   
77    /**
78    * Removes the last added serialized property
79    *
80    */
 
81  0 toggle public void removeSerializedProperty() {
82  0 pathElements.remove(pathElements.size() - 1);
83    }
84   
85    /**
86    * Retrieves the element name of the state element. A parameter value of 0 represents the first element that was added
87    * by calling {@link #addSerializedProperty(String, PropertyType)} that hasn't been removed, and a value of
88    * {@link #numPropertyElements()} - 1 represents the element last added that hasn't been removed.
89    *
90    * @param propertyIndex most be between 0 and the value returned by {@link #numPropertyElements()} - 1
91    * @return
92    */
 
93  0 toggle public String getElementName(int propertyIndex) {
94  0 return pathElements.get(propertyIndex).getElementName();
95    }
96   
97    /**
98    * Retrieves the property type of the state element. A parameter value of 0 represents the first element that was added
99    * by calling {@link #addSerializedProperty(String, PropertyType)} that hasn't been removed, and a value of
100    * {@link #numPropertyElements()} - 1 represents the element last added that hasn't been removed.
101    *
102    * @param propertyIndex most be between 0 and the value returned by {@link #numPropertyElements()} - 1
103    * @return
104    */
 
105  0 toggle public PropertyType getPropertyType(int propertyIndex) {
106  0 return pathElements.get(propertyIndex).getPropertyType();
107    }
108    }