1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.util.documentserializer;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22
23
24
25
26 public class PropertySerializerTrieNode implements PropertySerializabilityMetadata {
27 private String pathString;
28 private String propertyNameComponent;
29 private PropertySerializability propertySerializability;
30
31 private List<PropertySerializerTrieNode> childNodes;
32
33 public PropertySerializerTrieNode(String pathString, String propertyNameComponent) {
34 this.pathString = pathString;
35 this.propertyNameComponent = propertyNameComponent;
36 this.childNodes = null;
37 this.propertySerializability = PropertySerializability.SERIALIZE_OBJECT;
38 }
39
40 public void addChildNode(PropertySerializerTrieNode child) {
41 if (childNodes == null) {
42 childNodes = new ArrayList<PropertySerializerTrieNode>();
43 }
44 childNodes.add(child);
45 }
46
47
48
49
50
51
52 public String getPropertyNameComponent() {
53 return propertyNameComponent;
54 }
55
56
57
58
59
60
61
62 public PropertySerializerTrieNode getChildNode(String propertyNameComponent) {
63 if (childNodes == null) {
64 return null;
65 }
66 for (int i = 0; i < childNodes.size(); i++) {
67 PropertySerializerTrieNode childNode = childNodes.get(i);
68 if (childNode.getPropertyNameComponent().equals(propertyNameComponent)) {
69 return childNode;
70 }
71 }
72 return null;
73 }
74
75
76
77
78 public PropertySerializabilityMetadata getSerializableChildProperty(String propertyNameComponent) {
79 return getChildNode(propertyNameComponent);
80 }
81
82
83
84
85 public String getPathString() {
86 return pathString;
87 }
88
89
90
91
92 public PropertySerializability getPropertySerializability() {
93 return propertySerializability;
94 }
95
96
97
98
99 public void setPropertySerializabilityToObjectAndAllPrimitives() {
100 this.propertySerializability = PropertySerializability.SERIALIZE_OBJECT_AND_ALL_PRIMITIVES;
101 }
102
103 @Override
104 public String toString() {
105 StringBuilder buf = new StringBuilder();
106 buf.append("Path String: ").append(pathString).append(" Name component: ").append(propertyNameComponent);
107 if (childNodes == null || childNodes.isEmpty()) {
108 buf.append(" No child nodes.");
109 }
110 else {
111 buf.append(" Child nodes: ");
112 for (Iterator<PropertySerializerTrieNode> i = childNodes.iterator(); i.hasNext();) {
113 buf.append(i.next().getPropertyNameComponent());
114 if (i.hasNext()) {
115 buf.append(", ");
116 }
117 }
118 }
119 return super.toString();
120 }
121 }