boolean isTextValue = isTextValue(parentLocalName);
int size = tree.getChildCount();
if(size == 0){
if(contentHandler instanceof UnmarshalRecord){
UnmarshalRecord ur = (UnmarshalRecord)contentHandler;
XPathNode node = ur.getNonAttributeXPathNode(uri, parentLocalName, parentLocalName, null);
if(node != null){
NodeValue nv = node.getNodeValue();
if(nv == null && node.getTextNode() != null){
nv = node.getTextNode().getUnmarshalNodeValue();
}
if(nv != null && nv.isContainerValue()){
ur.getContainerInstance(((ContainerValue)nv));
}
}
}
}
startCollection();
if(size == 1){
CommonTree ct = (CommonTree) tree.getChild(0);
if(ct != null && ct.getType() == JSONLexer.NULL){
contentHandler.setNil(true);
}
if(!isTextValue){
contentHandler.startElement(uri, parentLocalName, parentLocalName, attributes.setTree(ct, attributePrefix, namespaces, namespaceSeparator, namespaceAware));
}
parse(ct);
if(!isTextValue){
contentHandler.endElement(uri, parentLocalName, parentLocalName);
}
}else{
XPathFragment groupingXPathFragment = null;
XPathFragment itemXPathFragment = null;
if(contentHandler instanceof UnmarshalRecord) {
UnmarshalRecord unmarshalRecord = (UnmarshalRecord) contentHandler;
if(unmarshalRecord.getUnmarshaller().isWrapperAsCollectionName()) {
XPathNode unmarshalRecordXPathNode = unmarshalRecord.getXPathNode();
if(null != unmarshalRecordXPathNode) {
XPathFragment currentFragment = new XPathFragment();
currentFragment.setLocalName(parentLocalName);
currentFragment.setNamespaceURI(uri);
currentFragment.setNamespaceAware(namespaceAware);
XPathNode groupingXPathNode = unmarshalRecordXPathNode.getNonAttributeChildrenMap().get(currentFragment);
if(groupingXPathNode != null) {
if(groupingXPathNode.getUnmarshalNodeValue() instanceof CollectionGroupingElementNodeValue) {
groupingXPathFragment = groupingXPathNode.getXPathFragment();
contentHandler.startElement(uri, parentLocalName, parentLocalName, new AttributesImpl());
XPathNode itemXPathNode = groupingXPathNode.getNonAttributeChildren().get(0);
itemXPathFragment = itemXPathNode.getXPathFragment();
} else if(groupingXPathNode.getUnmarshalNodeValue() == null) {
XPathNode itemXPathNode = groupingXPathNode.getNonAttributeChildren().get(0);
if(itemXPathNode != null) {
if(((MappingNodeValue)itemXPathNode.getUnmarshalNodeValue()).isContainerValue()) {
groupingXPathFragment = groupingXPathNode.getXPathFragment();
contentHandler.startElement(uri, parentLocalName, parentLocalName, new AttributesImpl());
itemXPathFragment = itemXPathNode.getXPathFragment();
}
}
}
}
}