2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.core.mybatis;
24 * A bean that represents a single URN mapping.
26 public class URNMapping {
35 public String getName() {
41 * @param name the name
43 public void setName(String name) {
48 * Get the value mapped to the name.
49 * @return the value mapped to the name
51 public String getValue() {
56 * Set the value mapped to the name.
57 * @param value the value mapped to the name
59 public void setValue(String value) {
64 * Get the revision attribute (currently unused).
65 * @return the revision attribute
67 public String getRev() {
72 * Set the revision attribute (currently unused).
73 * @param rev the revision attribute
75 public void setRev(String rev) {
80 * Converts a URN to "normal" form so it can used as a java or groovy
81 * variable identifier. This is done in a way that makes the identifier
82 * as readable as possible, but note that it might result in a loss of
85 * <li> URN_ is prepended </li>
86 * <li> All characters that are not letters or digits are converted to
87 * underscore characters </li>
88 * <li> Sequences of multiple underscores are collapsed to a single
89 * underscore character </li>
93 * aai:endpoint becomes URN_aai_endpoint <br/>
94 * ae:internal-reporting becomes URN_ae_internal_reporting <br/>
97 * @return a normalized identifier
99 public static String createIdentifierFromURN(String urn) {
100 StringBuilder builder = new StringBuilder();
101 builder.append("URN_");
102 char last = builder.charAt(builder.length() - 1);
104 int len = urn.length();
106 for (int i = 0; i < len; i++) {
107 char c = urn.charAt(i);
109 if (!Character.isLetterOrDigit(c) && c != '_') {
113 if (!(c == '_' && last == '_')) {
120 return builder.toString();