org.semanticweb.owlapi.model.OWLLiteral Maven / Gradle / Ivy
/*
* This file is part of the OWL API.
*
* The contents of this file are subject to the LGPL License, Version 3.0.
*
* Copyright (C) 2011, The University of Manchester
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*
* Alternatively, the contents of this file may be used under the terms of the Apache License, Version 2.0
* in which case, the provisions of the Apache License Version 2.0 are applicable instead of those above.
*
* Copyright 2011, University of Manchester
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
package org.semanticweb.owlapi.model;
/**
* Author: Matthew Horridge
* The University Of Manchester
* Bio-Health Informatics Group
* Date: 24-Oct-2006
*
* Represents a Literal in the OWL 2 Specification.
*
* Each literal consists of a lexical form, which is a string, and a datatype. A literal consisting of a lexical form
* "abc"
and a datatype identified by the IRI datatypeIRI
is written as "abc"^^datatypeIRI
.
*
* Note that literals whose datatype is rdf:PlainLiteral
can be abbreviated. For example,
* literals of the form "abc@"^^rdf:PlainLiteral
can be abbreviated in the functional-style syntax, and
* other concrete syntaxes to "abc". Literals of the form "abc@langTag"^^rdf:PlainLiteral where "langTag" is not empty
* are abbreviated in functional-style syntax documents (and other concrete syntaxes) to "abc"@langTag whenever possible.
*/
public interface OWLLiteral extends OWLObject, OWLAnnotationObject, OWLAnnotationValue, OWLPropertyAssertionObject {
/**
* Determines if the datatype of this literal is rdf:PlainLiteral
. Note that literals that are
* abbreviated in the functional syntax (and other concrete syntaxes) and are of the form "abc"
* or "abc"@langTag
will be of the type rdf:PlainLiteral
after parsing.
* @return true
if the datatype of this literal is rdf:PlainLiteral, otherwise false
.
*/
boolean isRDFPlainLiteral();
/**
* Gets the lexical value of this literal. Note that if the datatype is rdf:PlainLiteral
then the
* abbreviated lexical form will be returned. That is, the language tag is not included.
* @return The lexical value of this literal. If the datatype is rdf:PlainLiteral
then the return
* values are as follows: If the literal is of the form "abc@"^^rdf:PlainLiteral
then the return value
* will be "abc" (without the language tag included). If the literal is of the form
* "abc@langTag"^^rdf:PlainLiteral
then the return value will be "abc" (without the language tag included).
*/
String getLiteral();
/**
* Gets the OWLDatatype
which types this literal.
* @return The OWLDatatype
that types this literal. Note that for strings with language tag (previously
* considered to be untyped literals) the datatype will be rdf:PlainLiteral. The return value is
* never null
.
*/
OWLDatatype getDatatype();
/**
* Determines if this literal has a language tag.
* @return true
if this literal has a non-empty language tag, otherwise false
*/
boolean hasLang();
/**
* Gets the language tag of this literal.
* @return The language tag of this literal. If the literal does not have a language tag, because it is
* not of the type rdf:PlainLiteral
, or because its language tag is empty, then the empty string
* will be returned. (The null
value is never returned).
*/
String getLang();
/**
* Determines if this OWLLiteral
has a particular language tag.
* @param lang The specific lang to test for. The tag will be normalised - white space will be trimmed from
* the end and it will be converted to lower case.
* @return true
if this literal has a language tag equal to lang
, otherwise
* false
.
*/
boolean hasLang(String lang);
/**
* Determines if this literal is typed with a datatype that has an IRI that is
* "http://www.w3.org/2001/XMLSchema#"integer
.
* @return true
if this literal is typed with "http://www.w3.org/2001/XMLSchema#"integer
,
* i.e. this literal represents an integer, otherwise false
.
*/
boolean isInteger();
/**
* Parses the lexical value of this literal into an integer. The lexical value of this literal should be in
* the lexical space of the integer datatype ("http://www.w3.org/2001/XMLSchema#"integer
)
* @return An integer value that is represented by this literal.
* @throws NumberFormatException if the lexical form could not be parsed into an integer because it is not in
* the lexical space of the integer datatype.
*/
int parseInteger() throws NumberFormatException;
/**
* Determines if this literal is typed with a datatype that has an IRI that is
* "http://www.w3.org/2001/XMLSchema#"boolean
.
* @return true
if this literal is typed with "http://www.w3.org/2001/XMLSchema#"boolean
,
* i.e. this literal represents a boolean, otherwise false
.
*/
boolean isBoolean();
/**
* Parses the lexical value of this literal into a boolean. The lexical value of this literal should be in
* the lexical space of the boolean datatype ("http://www.w3.org/2001/XMLSchema#"boolean
).
* @return A boolean value that is represented by this literal.
* @throws NumberFormatException if the lexical form could not be parsed into a boolean because it is not in
* the lexical space of the boolean datatype.
*/
boolean parseBoolean() throws NumberFormatException;
/**
* Determines if this literal is typed with a datatype that has an IRI that is
* "http://www.w3.org/2001/XMLSchema#"double
.
* @return true
if this literal is typed with "http://www.w3.org/2001/XMLSchema#"double
,
* i.e. this literal represents a double, otherwise false
.
*/
boolean isDouble();
/**
* Parses the lexical value of this literal into a double. The lexical value of this literal should be in
* the lexical space of the double datatype ("http://www.w3.org/2001/XMLSchema#"double
).
* @return A double value that is represented by this literal.
* @throws NumberFormatException if the lexical form could not be parsed into a double because it is not in
* the lexical space of the double datatype.
*/
double parseDouble() throws NumberFormatException;
/**
* Determines if this literal is typed with a datatype that has an IRI that is
* "http://www.w3.org/2001/XMLSchema#"float
.
* @return true
if this literal is typed with "http://www.w3.org/2001/XMLSchema#"float
,
* i.e. this literal represents a float, otherwise false
.
*/
boolean isFloat();
/**
* Parses the lexical value of this literal into a float. The lexical value of this literal should be in
* the lexical space of the float datatype ("http://www.w3.org/2001/XMLSchema#"float
).
* @return A float value that is represented by this literal.
* @throws NumberFormatException if the lexical form could not be parsed into a float because it is not in
* the lexical space of the float datatype.
*/
float parseFloat() throws NumberFormatException;
@SuppressWarnings("javadoc")
void accept(OWLDataVisitor visitor);
@SuppressWarnings("javadoc")
O accept(OWLDataVisitorEx visitor);
}