Created sal-clustering-commons and moved
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / PathUtils.java
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/PathUtils.java
new file mode 100644 (file)
index 0000000..cf51743
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *
+ *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ *  This program and the accompanying materials are made available under the
+ *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ *  and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ */
+
+package org.opendaylight.controller.cluster.datastore.node.utils;
+
+public class PathUtils {
+    public static String getParentPath(String currentElementPath){
+        String parentPath = "";
+
+        if(currentElementPath != null){
+            String[] parentPaths = currentElementPath.split("/");
+            if(parentPaths.length > 2){
+                for(int i=0;i<parentPaths.length-1;i++){
+                    if(parentPaths[i].length() > 0){
+                        parentPath += "/" + parentPaths[i];
+                    }
+                }
+            }
+        }
+        return parentPath;
+    }
+}