package com.ubt.jimu.blockly.feature.course; import com.ubt.jimu.blockly.bean.JimuSound; import com.ubt.jimu.blockly.feature.blockly.BlocklyEmotion; import com.ubt.jimu.blockly.feature.blockly.BlocklyLight; import com.ubt.jimu.controller.data.widget.JockstickDataConverter; import com.ubt.jimu.utils.JsonHelper; import com.ubtech.utils.XmlHelper; import com.unity3d.ads.metadata.MediationMetaData; import java.io.File; import java.util.HashMap; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; /* loaded from: classes.dex */ public class BlocklyDomCompare { private final String TAG = BlocklyDomCompare.class.getSimpleName(); public final String correct = "0"; public final String error = "-1"; public final String attri = "x,y,id,SceneLight,PROGRAM_BRANCH"; private String checkProgramDocument(Node node, Node node2) { if (node == null || node2 == null) { return "-1"; } if (!node.hasChildNodes() && !node2.hasChildNodes()) { return node.getNodeType() != node2.getNodeType() ? "-1" : node.getNodeType() == 3 ? !compareTextNode(node, node2) ? getNodeId(node2) : "0" : compareAttribute(node, node2) ? "0" : getNodeId(node2); } NodeList childNodes = node.getChildNodes(); NodeList childNodes2 = node2.getChildNodes(); if (childNodes == null && childNodes2 == null) { return "0"; } if (childNodes == null || childNodes2 == null || childNodes.getLength() == 0 || childNodes2.getLength() == 0) { return getNodeId(node2); } int i = 0; String str = "0"; while (true) { if (i < childNodes.getLength()) { if (i < childNodes2.getLength()) { Node item = childNodes.item(i); Node item2 = childNodes2.item(i); if (!compareAttribute(item, item2)) { str = getNodeId(item2); break; } if (item != null && !item.getNodeName().equals(item2.getNodeName())) { str = getNodeId(item2); break; } str = checkProgramDocument(item, item2); if (!"0".equals(str)) { break; } i++; } else { str = getNodeId(childNodes2.item(childNodes2.getLength() - 1)); break; } } else { break; } } return (i == childNodes.getLength() && "0".equals(str) && childNodes.getLength() < childNodes2.getLength()) ? getNodeId(childNodes2.item(i)) : str; } private boolean compareAttribute(Node node, Node node2) { if (node == null && node2 == null) { return true; } if (node != null && node2 != null) { NamedNodeMap attributes = node.getAttributes(); NamedNodeMap attributes2 = node2.getAttributes(); if (attributes == null && attributes2 == null) { return true; } if (attributes != null && attributes2 != null && attributes.getLength() == attributes2.getLength()) { HashMap hashMap = new HashMap(); HashMap hashMap2 = new HashMap(); for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); if (!"x,y,id,SceneLight,PROGRAM_BRANCH".contains(item.getNodeName())) { hashMap.put(item.getNodeName(), item.getNodeValue()); } } for (int i2 = 0; i2 < attributes2.getLength(); i2++) { Node item2 = attributes2.item(i2); if (!"x,y,id,SceneLight,PROGRAM_BRANCH".contains(item2.getNodeName())) { hashMap2.put(item2.getNodeName(), item2.getNodeValue()); } } if (hashMap.size() != hashMap2.size()) { return false; } for (String str : hashMap.keySet()) { if (!((String) hashMap.get(str)).equals(hashMap2.get(str))) { return false; } } return true; } } return false; } private boolean compareEmotion(Node node, Node node2) { BlocklyEmotion blocklyEmotion = (BlocklyEmotion) JsonHelper.a(node.getNodeValue(), (Class) BlocklyEmotion.class); BlocklyEmotion blocklyEmotion2 = (BlocklyEmotion) JsonHelper.a(node2.getNodeValue(), (Class) BlocklyEmotion.class); if (blocklyEmotion == null && blocklyEmotion2 == null) { return true; } if (blocklyEmotion == null || blocklyEmotion2 == null) { return false; } return blocklyEmotion.equals(blocklyEmotion2); } private boolean compareLight(Node node, Node node2) { BlocklyLight blocklyLight = (BlocklyLight) JsonHelper.a(node.getNodeValue(), (Class) BlocklyLight.class); BlocklyLight blocklyLight2 = (BlocklyLight) JsonHelper.a(node2.getNodeValue(), (Class) BlocklyLight.class); if (blocklyLight == null && blocklyLight2 == null) { return true; } if (blocklyLight == null || blocklyLight2 == null) { return false; } return blocklyLight.equals(blocklyLight2); } private boolean compareSound(Node node, Node node2) { JimuSound jimuSound = (JimuSound) JsonHelper.a(node.getNodeValue(), (Class) JimuSound.class); JimuSound jimuSound2 = (JimuSound) JsonHelper.a(node2.getNodeValue(), (Class) JimuSound.class); if (jimuSound == null && jimuSound2 == null) { return true; } if (jimuSound == null || jimuSound2 == null) { return false; } return jimuSound.equals(jimuSound2); } private boolean compareTextNode(Node node, Node node2) { NamedNodeMap attributes = node.getParentNode().getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "PROGRAM_BRANCH".equals(item.getNodeValue())) { return true; } if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Effect".equals(item.getNodeValue())) { return compareSound(node, node2); } if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Light".equals(item.getNodeValue())) { return compareLight(node, node2); } if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Emotion".equals(item.getNodeValue())) { return compareEmotion(node, node2); } } return node.getNodeValue().equals(node2.getNodeValue()); } private String getNodeId(Node node) { if (node == null) { return "-1"; } if (!node.hasAttributes()) { return getNodeId(node.getParentNode()); } NamedNodeMap attributes = node.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); if (JockstickDataConverter.ID.equals(item.getNodeName())) { return item.getNodeValue(); } } return getNodeId(node.getParentNode()); } public static void main(String[] strArr) { System.out.println(new BlocklyDomCompare().check(new File("C:\\Users\\lenovo\\Desktop\\2018\\Jimu-开发设计文档\\Jimu3.0-android\\课程\\standarXml.xml"), new File("C:\\Users\\lenovo\\Desktop\\2018\\Jimu-开发设计文档\\Jimu3.0-android\\课程\\currentXml.xml"))); System.out.println("-------华丽的分割线-----------"); } private void traverse(Node node) { if (node == null) { return; } if (node.hasChildNodes()) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); if (item.hasChildNodes()) { System.out.println(item.getNodeName()); NamedNodeMap attributes = item.getAttributes(); if (attributes != null) { for (int i2 = 0; i2 < attributes.getLength(); i2++) { Node item2 = attributes.item(i2); System.out.println("属性:" + item2.getNodeName() + ":" + item2.getNodeValue()); } } } traverse(item); } return; } if (node.getNodeType() == 3) { System.out.println("文本节点:" + node.getNodeName() + ":" + node.getNodeValue()); return; } if (node.getNodeValue() != null && !"".equals(node.getNodeValue().trim())) { System.out.println("非文本节点:" + node.getNodeName() + ":" + node.getNodeValue()); } NamedNodeMap attributes2 = node.getAttributes(); if (attributes2 != null) { for (int i3 = 0; i3 < attributes2.getLength(); i3++) { Node item3 = attributes2.item(i3); System.out.println("属性:" + item3.getNodeName() + ":" + item3.getNodeValue()); } } } public String check(File file, File file2) { try { Document a = XmlHelper.a(file); Document a2 = XmlHelper.a(file2); Element documentElement = a.getDocumentElement(); Element documentElement2 = a2.getDocumentElement(); removeWhiteSpaceTextElement(documentElement); removeWhiteSpaceTextElement(documentElement2); return checkProgramDocument(documentElement, documentElement2); } catch (Exception e) { e.printStackTrace(); return "-1"; } } public int removeWhiteSpaceTextElement(Node node) { int i = 0; if (node == null) { return 0; } if (node.getNodeType() == 1) { Node firstChild = node.getFirstChild(); while (firstChild != null) { Node nextSibling = firstChild.getNextSibling(); i += removeWhiteSpaceTextElement(firstChild); firstChild = nextSibling; } return i; } if (node.getNodeType() != 3) { return 0; } Text text = (Text) node; if (!text.getData().trim().isEmpty()) { return 0; } text.getParentNode().removeChild(text); return 1; } /* JADX ERROR: Types fix failed jadx.core.utils.exceptions.JadxOverflowException: Type inference error: updates count limit reached at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:59) at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31) at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:19) at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:96) */ public java.lang.String check(java.lang.String r8, java.lang.String r9) { /* r7 = this; java.lang.String r0 = "-1" org.w3c.dom.Document r8 = com.ubtech.utils.XmlHelper.a(r8) // Catch: java.lang.Exception -> L61 org.w3c.dom.Document r9 = com.ubtech.utils.XmlHelper.a(r9) // Catch: java.lang.Exception -> L61 org.w3c.dom.Element r8 = r8.getDocumentElement() // Catch: java.lang.Exception -> L61 org.w3c.dom.Element r9 = r9.getDocumentElement() // Catch: java.lang.Exception -> L61 r7.removeWhiteSpaceTextElement(r8) // Catch: java.lang.Exception -> L61 r7.removeWhiteSpaceTextElement(r9) // Catch: java.lang.Exception -> L61 org.w3c.dom.NodeList r1 = r8.getChildNodes() // Catch: java.lang.Exception -> L61 org.w3c.dom.NodeList r2 = r9.getChildNodes() // Catch: java.lang.Exception -> L61 int r3 = r1.getLength() // Catch: java.lang.Exception -> L61 r4 = 1 if (r3 != r4) goto L2c java.lang.String r8 = r7.checkProgramDocument(r8, r9) // Catch: java.lang.Exception -> L61 goto L66 L2c: r8 = 0 r9 = 0 L2e: int r3 = r1.getLength() // Catch: java.lang.Exception -> L61 if (r9 >= r3) goto L65 org.w3c.dom.Node r3 = r1.item(r9) // Catch: java.lang.Exception -> L61 r5 = r0 r0 = 0 L3a: int r6 = r2.getLength() // Catch: java.lang.Exception -> L5e if (r0 >= r6) goto L55 org.w3c.dom.Node r6 = r2.item(r0) // Catch: java.lang.Exception -> L5e java.lang.String r5 = r7.checkProgramDocument(r3, r6) // Catch: java.lang.Exception -> L5e java.lang.String r6 = "0" boolean r6 = r6.equals(r5) // Catch: java.lang.Exception -> L5e if (r6 == 0) goto L52 r0 = 1 goto L56 L52: int r0 = r0 + 1 goto L3a L55: r0 = 0 L56: if (r0 == 0) goto L5c int r9 = r9 + 1 r0 = r5 goto L2e L5c: r8 = r5 goto L66 L5e: r8 = move-exception r0 = r5 goto L62 L61: r8 = move-exception L62: r8.printStackTrace() L65: r8 = r0 L66: return r8 */ throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.blockly.feature.course.BlocklyDomCompare.check(java.lang.String, java.lang.String):java.lang.String"); } }