in src/main/java/com/netflix/imflibrary/utils/DOMNodeObjectModel.java [73:136]
public DOMNodeObjectModel(@Nonnull Node node){
this.node = node;
this.nodeType = node.getNodeType();
this.localName = node.getLocalName();
this.localNamespaceURI = node.getNamespaceURI();
if(this.localName == null){
imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_CPL_ERROR, IMFErrorLogger
.IMFErrors.ErrorLevels.NON_FATAL,
String.format("DOM Node Local Name is not set for a node of type %d", node.getNodeType()));
return;
}
Node child = node.getFirstChild();
switch(child.getNodeType()){
case Node.ELEMENT_NODE:
while(child != null) {
Node grandChild = child.getFirstChild();
if (grandChild != null){
if(grandChild.getNodeType() == Node.TEXT_NODE) {
DOMNodeElementTuple domNodeElementTuple = new DOMNodeElementTuple(child.getNamespaceURI(), child.getLocalName());
Map<String, Integer> values = fields.get(domNodeElementTuple);
Map<String, Integer> fieldsLocalNameValues = fieldsLocalNameMap.get(domNodeElementTuple.getLocalName());
if (values == null) {
values = new HashMap<String, Integer>();
fields.put(domNodeElementTuple, values);
}
if(fieldsLocalNameValues == null){
fieldsLocalNameValues = new HashMap<String, Integer>();
fieldsLocalNameMap.put(domNodeElementTuple.getLocalName(), fieldsLocalNameValues);
}
Integer count = 0;
if(values.containsKey(child.getFirstChild().getNodeValue())) {
count = values.get(child.getFirstChild().getNodeValue());
}
values.put(child.getFirstChild().getNodeValue(), count+1);
Integer localNameCount = 0;
if(fieldsLocalNameValues.containsKey(domNodeElementTuple.getNamespaceURI())){
localNameCount = fieldsLocalNameValues.get(domNodeElementTuple.getNamespaceURI());
}
fieldsLocalNameValues.put(domNodeElementTuple.getNamespaceURI(), localNameCount+1);
} else {
Integer count = 0;
DOMNodeObjectModel domNode = new DOMNodeObjectModel(child);
if(childrenDOMNodes.containsKey(domNode))
{
count = childrenDOMNodes.get(domNode);
}
childrenDOMNodes.put(domNode, count+1);
imfErrorLogger.addAllErrors(domNode.getErrors());
}
}
child = child.getNextSibling();
}
break;
case Node.COMMENT_NODE:
//Ignore comment nodes
break;
default:
String message = String.format("Unsupported DOM Node type %d ", child.getNodeType());
imfErrorLogger.addError(IMFErrorLogger.IMFErrors.ErrorCodes.IMF_CPL_ERROR, IMFErrorLogger
.IMFErrors.ErrorLevels.FATAL,
message);
throw new IMFException(message, imfErrorLogger);
}
}