001/**
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package com.github.commonsrdf.api;
015
016import java.util.Optional;
017
018/**
019 * An RDF-1.1 Literal, as defined by <a href=
020 * "http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal" >RDF-1.1
021 * Concepts and Abstract Syntax</a>, a W3C Recommendation published on 25
022 * February 2014
023 */
024public interface Literal extends RDFTerm {
025
026    /**
027     * The lexical form of this literal, represented by a <a
028     * href="http://www.unicode.org/versions/latest/">Unicode string</a>.
029     *
030     * @return The lexical form of this literal.
031     * @see <a
032     * href="http://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">RDF-1.1
033     * Literal lexical form</a>
034     */
035    String getLexicalForm();
036
037    /**
038     * The IRI identifying the datatype that determines how the lexical form
039     * maps to a literal value.
040     *
041     * @return The datatype IRI for this literal.
042     * @see <a
043     * href="http://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri">RDF-1.1
044     * Literal datatype IRI</a>
045     */
046    IRI getDatatype();
047
048    /**
049     * If and only if the datatype IRI is <a
050     * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
051     * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, the language
052     * tag for this Literal is a non-empty language tag as defined by <a
053     * href="http://tools.ietf.org/html/bcp47">BCP47</a>.<br>
054     * If the datatype IRI is not <a
055     * href="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
056     * >http://www.w3.org/1999/02/22-rdf-syntax-ns#langString</a>, this method
057     * must return {@link Optional#empty()}.
058     *
059     * @return The {@link Optional} language tag for this literal. If
060     * {@link Optional#isPresent()} returns true, the value returned by
061     * {@link Optional#get()} must be a non-empty string conforming to
062     * BCP47.
063     * @see <a
064     * href="http://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF-1.1
065     * Literal language tag</a>
066     */
067    Optional<String> getLanguageTag();
068
069}