2 * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.oc;
11 import java.util.regex.Pattern;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
18 static final Logger LOGGER = LoggerFactory.getLogger(Utils.class);
21 * Invoked to format the UUID if UUID is not in correct format.
24 * An instance of UUID string.
26 * @return Correctly formated UUID string.
28 public static String uuidFormater(String uuid) {
29 String uuidPattern = null;
30 String id1 = uuid.substring(0, 8);
31 String id2 = uuid.substring(8, 12);
32 String id3 = uuid.substring(12, 16);
33 String id4 = uuid.substring(16, 20);
34 String id5 = uuid.substring(20, 32);
35 uuidPattern = (id1 + "-" + id2 + "-" + id3 + "-" + id4 + "-" + id5);
40 * Invoked to check the UUID if UUID is not a valid hexa-decimal number.
43 * An instance of UUID string.
45 * @return boolean value.
47 public static boolean isValidHexNumber(String uuid) {
49 Pattern hex = Pattern.compile("^[0-9a-f]+$");
50 uuid = uuid.replaceAll("-", "");
51 boolean valid = hex.matcher(uuid).matches();
52 if (uuid.length() != 32) {
60 } catch (NumberFormatException ex) {
61 LOGGER.error("Exception : " + ex);
67 * Invoked to format the UUID/Name in correct format.
70 * An instance of UUID/Name string.
72 * @return Correctly formated UUID/name string.
75 public static String uuidNameFormat(String value){
76 String[] pattern = value.split("=");
77 value = pattern[1].replace("]", "");