Util { public static String makeNCName(String text) { if (StringUtils.isEmpty(text)) { return text; } StringBuilder res = new StringBuilder(); String start = text.substring(0, 1); Matcher m = Util.NCNameStartChar_Pattern.matcher(start); if (m.matches()) { res.append(start); } else { res.append("_"); } for (int i = 1; i < text.length(); i++) { String s = text.substring(i, i + 1); m = Util.NCNameChar_RegExp_Pattern.matcher(s); if (m.matches()) { res.append(s); } else { res.append("_"); } } return res.toString(); }  static String URLdecode(String s); static String URLencode(String s); static String URLencode(QName qname); static String DoubleURLencode(String s); static String DoubleURLencode(QName qname); static boolean isRelativeURI(String uri); static String getPathInsideRepo(GenericId id); static Class<? extends DefinitionsChildId> getComponentIdClassForTExtensibleElements(Class<? extends TExtensibleElements> clazz); @SuppressWarnings("unchecked") static Class<? extends DefinitionsChildId> getComponentIdClass(String idClassName); @SuppressWarnings("unchecked") static Class<? extends GenericId> getGenericIdClassForType(String typeIdType); static String getUrlPath(GenericId id); static String getUrlPath(String pathInsideRepo); static String getUrlPath(RepositoryFileReference ref); static String getURLpathFragmentForCollection(Class<? extends TExtensibleElements> c); static String getEverythingBetweenTheLastDotAndBeforeId(Class<? extends GenericId> cls); static String getTypeForElementId(Class<? extends ToscaElementId> idClass); static String getTypeForComponentId(Class<? extends DefinitionsChildId> idClass); static String getRootPathFragment(Class<? extends DefinitionsChildId> idClass); static String getFolderName(Class<? extends DefinitionsChildId> idClass); static String qname2hrefWithName(String repositoryUiUrl, Class<? extends TExtensibleElements> element, QName qname, String name); static String qname2href(@NonNull String repositoryUiUrl, @NonNull Class<? extends TExtensibleElements> element, @Nullable QName qname, @Nullable String name); static String qname2href(String repositoryUiUrl, Class<? extends TExtensibleElements> element, QName qname); static String renderMinInstances(Integer minInstances); static String renderMaxInstances(String maxInstances); static JAXBElement<T> getJAXBElement(Class<T> clazz, T obj); static String getXMLAsString(Class<T> clazz, T obj); static String getXMLAsString(Element el); static boolean instanceSupportsNameAttribute(Class<? extends DefinitionsChildId> idClass); static String getLastURIPart(String loc); static String makeCSSName(String namespace, String localName); static String makeCSSName(QName qname); static SortedMap<String, SortedSet<String>> convertQNameListToNamespaceToLocalNameList(List<QName> list); static String namespaceToJavaPackage(String namespace); static String makeNCName(String text); static Path determineAndCreateRepositoryPath(); static void createCsarOutputPath(String csarOutputPath); static final String FORBIDDEN_CHARACTER_REPLACEMENT; static final String slashEncoded; }
@Test public void testNCNameFromURL() { assertEquals("http___www.example.org", Util.makeNCName("http: }
@Test public void testNCNameFromNCName() { assertEquals("NCName", Util.makeNCName("NCName")); }