+/*
+ * 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.sal.rest.impl;
import java.util.ArrayList;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class RestUtil {
-
+
public static final String SQUOTE = "'";
public static final String DQUOTE = "\"";
private static final Pattern PREDICATE_PATTERN = Pattern.compile("\\[(.*?)\\]");
if (xPathParts.length < 2) { // must be at least "/pr:node"
return null;
}
- IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO();
+ IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO(value);
for (int i = 1; i < xPathParts.length; i++) {
String xPathPartTrimmed = xPathParts[i].trim();
-
+
String xPathPartStr = getIdAndPrefixAsStr(xPathPartTrimmed);
IdentityValue identityValue = toIdentity(xPathPartStr, prefixMap);
if (identityValue == null) {
return null;
}
-
+
List<Predicate> predicates = toPredicates(xPathPartTrimmed, prefixMap);
if (predicates == null) {
return null;
}
identityValue.setPredicates(predicates);
-
+
identityValuesDTO.add(identityValue);
}
return identityValuesDTO.getValuesWithNamespaces().isEmpty() ? null : identityValuesDTO;
}
-
+
private static String getIdAndPrefixAsStr(String pathPart) {
int predicateStartIndex = pathPart.indexOf("[");
return predicateStartIndex == -1 ? pathPart : pathPart.substring(0, predicateStartIndex);
}
-
+
private static IdentityValue toIdentity(String xPathPart, PrefixesMaping prefixMap) {
String xPathPartTrimmed = xPathPart.trim();
if (xPathPartTrimmed.isEmpty()) {