+ private void addChildToParent(final Builder parent, final DataSchemaNodeBuilder child, final String childLocalName) {
+ final int line = child.getLine();
+ if (parent == null) {
+ // if parent == null => node is defined under module
+ // All leafs, leaf-lists, lists, containers, choices, rpcs,
+ // notifications, and anyxmls defined within a parent node or at the
+ // top level of the module or its submodules share the same
+ // identifier namespace.
+ for (DataSchemaNodeBuilder childNode : childNodes) {
+ if (childNode.getQName().getLocalName().equals(childLocalName)) {
+ throw new YangParseException(name, line, "Duplicate node found at line " + childNode.getLine());
+ }
+ }
+ for (RpcDefinitionBuilder rpc : addedRpcs) {
+ if (rpc.getQName().getLocalName().equals(childLocalName)) {
+ throw new YangParseException(name, line, "Duplicate node found at line " + rpc.getLine());
+ }
+ }
+ for (NotificationBuilder notification : addedNotifications) {
+ if (notification.getQName().getLocalName().equals(childLocalName)) {
+ throw new YangParseException(name, line, "Duplicate node found at line " + notification.getLine());
+ }
+ }
+ childNodes.add(child);
+ } else {
+ // no need for checking rpc and notification because they can be
+ // defined only under module or submodule
+ if (parent instanceof DataNodeContainerBuilder) {
+ DataNodeContainerBuilder parentNode = (DataNodeContainerBuilder) parent;
+ for (DataSchemaNodeBuilder childNode : parentNode.getChildNodeBuilders()) {
+ if (childNode.getQName().getLocalName().equals(childLocalName)) {
+ throw new YangParseException(name, line, "Duplicate node found at line " + childNode.getLine());
+ }
+ }
+ parentNode.addChildNode(child);
+ } else if (parent instanceof ChoiceBuilder) {
+ ChoiceBuilder parentNode = (ChoiceBuilder) parent;
+ for (ChoiceCaseBuilder caseBuilder : parentNode.getCases()) {
+ if (caseBuilder.getQName().getLocalName().equals(childLocalName)) {
+ throw new YangParseException(name, line, "Duplicate node found at line "
+ + caseBuilder.getLine());
+ }
+ }
+ parentNode.addChildNode(child);
+ } else {
+ throw new YangParseException(name, line, "Unresolved parent of node '" + childLocalName + "'.");
+ }
+ }
+ }
+
+ private ModuleImport createModuleImport(final String moduleName, final Date revision, final String prefix) {
+ final ModuleImport moduleImport = new ModuleImport() {