|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2020 Eclipse RDF4J contributors. |
| 3 | + * |
| 4 | + * All rights reserved. This program and the accompanying materials |
| 5 | + * are made available under the terms of the Eclipse Distribution License v1.0 |
| 6 | + * which accompanies this distribution, and is available at |
| 7 | + * http://www.eclipse.org/org/documents/edl-v10.php. |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: BSD-3-Clause |
| 10 | + *******************************************************************************/ |
| 11 | + |
| 12 | +package org.eclipse.rdf4j.model.base; |
| 13 | + |
| 14 | +import org.eclipse.rdf4j.common.annotation.InternalUseOnly; |
| 15 | +import org.eclipse.rdf4j.model.IRI; |
| 16 | +import org.eclipse.rdf4j.model.Namespace; |
| 17 | + |
| 18 | +/** |
| 19 | + * Utility methods related to RDF vocabularies. |
| 20 | + * |
| 21 | + * @author Alessandro Bollini |
| 22 | + * @implNote To be eventually removed or merged with {@code org.eclipse.rdf4j.model.util.Vocabularies}. |
| 23 | + * @since 3.5.0 |
| 24 | + */ |
| 25 | +@InternalUseOnly |
| 26 | +public final class Vocabularies { |
| 27 | + |
| 28 | + private Vocabularies() { |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Create a new vocabulary namespace |
| 33 | + * |
| 34 | + * @param prefix prefix |
| 35 | + * @param namespace full namespace |
| 36 | + * @return |
| 37 | + */ |
| 38 | + public static Namespace createNamespace(String prefix, String namespace) { |
| 39 | + return new VocabularyNamespace(prefix, namespace); |
| 40 | + } |
| 41 | + |
| 42 | + private static class VocabularyNamespace extends AbstractNamespace { |
| 43 | + |
| 44 | + private final String prefix; |
| 45 | + private final String namespace; |
| 46 | + |
| 47 | + public VocabularyNamespace(String prefix, String namespace) { |
| 48 | + |
| 49 | + this.prefix = prefix; |
| 50 | + this.namespace = namespace; |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public String getPrefix() { |
| 55 | + return prefix; |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public String getName() { |
| 60 | + return namespace; |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Create an (interned) IRI |
| 66 | + * |
| 67 | + * @param namespace |
| 68 | + * @param localName |
| 69 | + * @return |
| 70 | + */ |
| 71 | + public static IRI createIRI(String namespace, String localName) { |
| 72 | + return new InternedIRI(namespace, localName); |
| 73 | + } |
| 74 | + |
| 75 | +} |
0 commit comments