private void addCtxValue(TreeNode cycled, String[] pathParts, String value) { boolean pathCreated = false; for (int i = 2 + 1; i < pathParts.length; i++) { String encodedName = "/" + pathParts[i]; TreeNode child = cycled.findChildByEncodedName(encodedName); if (child == null) { int type = ContextPathUtil.prefix2type(encodedName.substring(0, 4)); cycled = cycled.addNode(type, encodedName); pathCreated = true; } else { cycled = child; } } if (pathCreated) { entryCounter++; } if (value != null) { cycled.addValue(value); modCount++; } else { // check whether the path was really created modCount = (pathCreated) ? modCount + 1 : modCount; } }
private boolean updateCtxValue(TreeNode cycled, String[] pathParts, String value) { for (int i = 2 + 1; i < pathParts.length; i++) { String encodedName = "/" + pathParts[i]; TreeNode child = cycled.findChildByEncodedName(encodedName); if (child == null) { return false; } else { cycled = child; } } cycled.addValue(value); return true; }
// /FL!..$ota_flow_manager_pkg.pks/PS!..$ota_flow_manager_pkg/Va!..$pc_bs_15m_dflt [Value] // 1|INTEGER public void _addContextPath(String ctxPath, String value) { String[] path = ctxPath.split("/"); // validate root context if (!("/" + path[1]).startsWith(ContextPath.FILE_CTX_PRX) || ctxPath.indexOf(' ') != -1) { throw new ValidationException("Broken Context Path occurred: FILE CTX Path must be first!"); } else { switch (path.length) { case 0: case 1: throw new ValidationException("Broken Context Path occurred"); case 2: // load file attributes String fileName = path[1].substring(6); FileEntitiesHolder fileHolder = files.get(fileName); if (fileHolder == null) { fileHolder = new FileEntitiesHolder(fileName); files.put(fileName, fileHolder); } value = (value == null || value.length() == 0) ? "" : value; fileHolder.value = value; return; default: break; } } TreeNode cycled = root; boolean pathCreated = false; for (int i = 2; i < path.length; i++) { String encodedName = "/" + path[i]; int type = ContextPathUtil.prefix2type(encodedName.substring(0, 4)); TreeNode child = cycled.findChildByEncodedName(encodedName); if (child == null) { if (i == 2) { // add node level 1 - cycled = addTopNode(root, type, encodedName, path[1].substring(6)); } else { cycled = cycled.addNode(type, encodedName); } pathCreated = true; } else { cycled = child; } } /* todo -- entryCounter not correct any longer, FIXME if (cycled.getValue() == null) { entryCounter++; } cycled.addValue(value == null ? "" : value); */ if (pathCreated) { entryCounter++; } if (value != null) { cycled.addValue(value); modCount++; } else { // check whether the path was really created modCount = (pathCreated) ? modCount + 1 : modCount; } // log adding entry println("[Path] " + ctxPath + " [Value] " + value); }