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