Here you can find the source of getPrefixedTerm(String namespace, String localName)
public static String getPrefixedTerm(String namespace, String localName)
//package com.java2s; /**/* ww w .jav a2 s . com*/ * Copyright 2014-2015 Ontology Engineering Group, Universidad Polit?cnica de Madrid, Spain * <p/> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * <p/> * http://www.apache.org/licenses/LICENSE-2.0 * <p/> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author Nandana Mihindukulasooriya * @since 1.0.0 */ import com.google.common.collect.Maps; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; public class Main { private static AtomicInteger counter = new AtomicInteger(); public static Map<String, String> nsMap = Maps.newHashMap(); public static String getPrefixedTerm(String namespace, String localName) { String prefix = nsMap.get(namespace); if (prefix == null) { prefix = "ns" + counter.getAndIncrement(); nsMap.put(namespace, prefix); } return String.format("%s:%s", prefix, localName); } public static String getPrefixedTerm(String uri) { int i = uri.lastIndexOf('#'); if (i == -1) { i = uri.lastIndexOf('/'); } if (i == -1) { //TODO handle other URIs, do we really have to? throw new IllegalStateException("Unable to extract local name from '" + uri + "'"); } String ns = uri.substring(0, i + 1); String localName = uri.substring(i + 1, uri.length()); return getPrefixedTerm(ns, localName); } }