Class LiteralImpl
java.lang.Object
com.github.owlcs.ontapi.owlapi.OWLObjectImpl
com.github.owlcs.ontapi.owlapi.objects.LiteralImpl
- All Implemented Interfaces:
AsNode,Serializable,Comparable<org.semanticweb.owlapi.model.OWLObject>,org.semanticweb.owlapi.model.HasAnnotationPropertiesInSignature,org.semanticweb.owlapi.model.HasAnnotationValue,org.semanticweb.owlapi.model.HasAnonymousIndividuals,org.semanticweb.owlapi.model.HasClassesInSignature,org.semanticweb.owlapi.model.HasComponents,org.semanticweb.owlapi.model.HasContainsEntityInSignature,org.semanticweb.owlapi.model.HasDataPropertiesInSignature,org.semanticweb.owlapi.model.HasDatatypesInSignature,org.semanticweb.owlapi.model.HasHashIndex,org.semanticweb.owlapi.model.HasIndex,org.semanticweb.owlapi.model.HasIndividualsInSignature,org.semanticweb.owlapi.model.HasLang,org.semanticweb.owlapi.model.HasObjectPropertiesInSignature,org.semanticweb.owlapi.model.HasSignature,org.semanticweb.owlapi.model.IsAnonymous,org.semanticweb.owlapi.model.OWLAnnotationObject,org.semanticweb.owlapi.model.OWLAnnotationValue,org.semanticweb.owlapi.model.OWLLiteral,org.semanticweb.owlapi.model.OWLObject,org.semanticweb.owlapi.model.OWLPrimitive,org.semanticweb.owlapi.model.OWLPropertyAssertionObject
- Direct Known Subclasses:
ONTLiteralImpl
public class LiteralImpl
extends OWLObjectImpl
implements org.semanticweb.owlapi.model.OWLLiteral, AsNode
An ONT-API implementation of
OWLLiteral, encapsulated Jena Literal Label.
Created by @szz on 06.09.2018.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.jena.graph.impl.LiteralLabelprotected static final org.apache.jena.datatypes.TypeMapperFields inherited from class com.github.owlcs.ontapi.owlapi.OWLObjectImpl
DEFAULT_COMPARATOR, hashCode, NO_ANNOTATIONS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLiteralImpl(org.apache.jena.graph.impl.LiteralLabel label) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.jena.graph.NodeasNode()Answers theNodeassociated with this object.static LiteralImplasONT(org.semanticweb.owlapi.model.OWLLiteral literal) Converts any instance ofOWLLiteralto theONT-API Literal implementation.protected static intcalcHashCode(int index, org.apache.jena.graph.impl.LiteralLabel label, org.semanticweb.owlapi.model.OWLDatatype datatype, String lang) Calculates a hash-code forLiteralImplgiven as its components.protected static intcalcLiteralLabelHashCode(org.apache.jena.graph.impl.LiteralLabel label) Calculates a hash-code for lexical form.booleancontainsEntityInSignature(org.semanticweb.owlapi.model.OWLEntity entity) static LiteralImplcreateLiteral(boolean b) Creates a literal impl wrapping the given boolean primitive.static LiteralImplcreateLiteral(double d) Creates a literal impl wrapping the given double number.static LiteralImplcreateLiteral(float f) Creates a literal impl wrapping the given float number.static LiteralImplcreateLiteral(int i) Creates a literal impl wrapping the given int number.static LiteralImplstatic LiteralImplcreateLiteral(String val, String lang) Creates a literal impl by the given lexical from and language tag.static LiteralImplcreateLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype owl) Creates a literal impl by the given string andOWL Datatype.booleanAnswers whether some other object is "equal to" this one.static booleanequals(org.apache.jena.graph.impl.LiteralLabel left, org.apache.jena.graph.impl.LiteralLabel right) Answerstrueif the argument-literals are equal to each other andfalseotherwise.protected Set<org.semanticweb.owlapi.model.OWLAnnotationProperty> Obtains the annotation properties that are in the signature of this object.protected Set<org.semanticweb.owlapi.model.OWLAnonymousIndividual> Gets the anonymous individuals occurring in this object.protected Set<org.semanticweb.owlapi.model.OWLClassExpression> Gets all the nested (includes top level) class expressions that are used in this object.protected Set<org.semanticweb.owlapi.model.OWLDataProperty> Obtains the data properties that are in the signature of this object.org.semanticweb.owlapi.model.OWLDatatypeReturns theOWL-API datatypeparsed from the encapsulatedLiteralLabel.protected Set<org.semanticweb.owlapi.model.OWLDatatype> Gets the datatypes that are in the signature of this object.Returns the datatype URI.static StringgetDatatypeURI(org.apache.jena.graph.impl.LiteralLabel label) Gets the valid (in OWL-API sense) datatype URI from the givenlabel.getLang()org.apache.jena.graph.impl.LiteralLabelReturns aJena Literal Label, that is encapsulated by this object.protected Set<org.semanticweb.owlapi.model.OWLClass> Gets the classes in the signature of this object.protected Set<org.semanticweb.owlapi.model.OWLNamedIndividual> Gets all the individuals that are in the signature of this object.protected Set<org.semanticweb.owlapi.model.OWLObjectProperty> Obtains the (named) object properties that are in the signature of this object.static org.apache.jena.datatypes.RDFDatatypegetRDFDatatype(String uri) Gets theRDFDatatypefor the givenuri.protected Set<org.semanticweb.owlapi.model.OWLEntity> Gets the signature of this object.booleanhasLang()booleanintbooleanbooleanisDouble()booleanisFloat()booleanbooleanstatic LiteralImplnewLiteral(Object lex, String lang, org.apache.jena.datatypes.RDFDatatype dt) Creates anLiteralImplinstance with the given lexical form, language tag andRDF Datatype.static LiteralImplnewLiteral(String txt, String lang, org.semanticweb.owlapi.model.OWLDatatype owl) Creates anLiteralImplinstance by string value andOWL Datatype.static LiteralImplnewLiteral(org.apache.jena.graph.impl.LiteralLabel label) Creates anLiteralImplinstance for the specifiesLiteralLabel.static StringnormalizeLanguageTag(String lang) Normalises the language tagbooleanstatic booleanparseBoolean(String txt) static LiteralImpldoublestatic LiteralImplparseDoubleLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) floatstatic LiteralImplparseFloatLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) intstatic LiteralImplparseIntegerLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) Methods inherited from class com.github.owlcs.ontapi.owlapi.OWLObjectImpl
annotationPropertiesInSignature, anonymousIndividuals, classesInSignature, compareIterators, compareTo, createSet, createSet, createSortedSet, createSortedSet, dataPropertiesInSignature, datatypesInSignature, equalIterators, equalStreams, forOutput, getAnnotationPropertiesInSignature, getAnonymousIndividuals, getClassesInSignature, getDataPropertiesInSignature, getDatatypesInSignature, getIndividualsInSignature, getNestedClassExpressions, getObjectPropertiesInSignature, getSignature, hashCode, individualsInSignature, mergeAnnotations, nestedClassExpressions, notSame, objectPropertiesInSignature, prepareAnnotations, signature, toContentList, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.semanticweb.owlapi.model.HasAnnotationPropertiesInSignature
annotationPropertiesInSignature, getAnnotationPropertiesInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasAnnotationValue
anonymousIndividualValue, ifAnonymousIndividual, ifAnonymousIndividualOrElse, ifIri, ifIriOrElse, ifLiteral, ifLiteralOrElse, ifValue, iriValue, literalValue, map, map, mapAnonymousIndividual, mapAnonymousIndividualOrElse, mapAnonymousIndividualOrElseGet, mapIri, mapIriOrElse, mapIriOrElseGet, mapLiteral, mapLiteralOrElse, mapLiteralOrElseGet, mapValue, whenMethods inherited from interface org.semanticweb.owlapi.model.HasAnonymousIndividuals
anonymousIndividuals, getAnonymousIndividualsMethods inherited from interface org.semanticweb.owlapi.model.HasClassesInSignature
classesInSignature, getClassesInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasComponents
componentsAnnotationsFirst, componentsWithoutAnnotationsMethods inherited from interface org.semanticweb.owlapi.model.HasDataPropertiesInSignature
dataPropertiesInSignature, getDataPropertiesInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasDatatypesInSignature
datatypesInSignature, getDatatypesInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasIndividualsInSignature
getIndividualsInSignature, individualsInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasObjectPropertiesInSignature
getObjectPropertiesInSignature, objectPropertiesInSignatureMethods inherited from interface org.semanticweb.owlapi.model.HasSignature
getSignature, signature, unsortedSignatureMethods inherited from interface org.semanticweb.owlapi.model.IsAnonymous
isAnonymous, isNamedMethods inherited from interface org.semanticweb.owlapi.model.OWLAnnotationObject
asAnonymousIndividual, asIRIMethods inherited from interface org.semanticweb.owlapi.model.OWLAnnotationValue
annotationValueMethods inherited from interface org.semanticweb.owlapi.model.OWLLiteral
accept, accept, accept, accept, accept, accept, asLiteral, components, hashIndex, isLiteral, typeIndexMethods inherited from interface org.semanticweb.owlapi.model.OWLObject
getNestedClassExpressions, hasSharedStructure, isAnonymousExpression, isAxiom, isBottomEntity, isIndividual, isIRI, isOntology, isTopEntity, nestedClassExpressions
-
Field Details
-
typeMapper
protected static final org.apache.jena.datatypes.TypeMapper typeMapper -
label
protected final transient org.apache.jena.graph.impl.LiteralLabel label
-
-
Constructor Details
-
LiteralImpl
protected LiteralImpl(org.apache.jena.graph.impl.LiteralLabel label)
-
-
Method Details
-
createLiteral
-
createLiteral
Creates a literal impl by the given lexical from and language tag. The method normalises language tag to the trimmed lower-case form. Notice that language tag in general case may contain upper-case letters, and two similar but different strings are not equal. To create a literal with the retention of the syntax of a language-tag, use methodsnewLiteral(LiteralLabel)ornewLiteral(String, String, OWLDatatype)- Parameters:
val- String, lexical form, notnulllang- String, ornullfor Plain Literals- Returns:
LiteralImpl- See Also:
-
createLiteral
Creates a literal impl wrapping the given int number.- Parameters:
i- int- Returns:
LiteralImpl
-
createLiteral
Creates a literal impl wrapping the given boolean primitive.- Parameters:
b- boolean- Returns:
LiteralImpl
-
createLiteral
Creates a literal impl wrapping the given double number.- Parameters:
d- double- Returns:
LiteralImpl
-
createLiteral
Creates a literal impl wrapping the given float number.- Parameters:
f- float- Returns:
LiteralImpl
-
createLiteral
Creates a literal impl by the given string andOWL Datatype. If the datatype isrdf:PlainLiteralorrdf:langStringthe method will parse and normalize datatype from the first (String) argument, seecreateLiteral(String, String)description. If the datatype isxsd:string, then no parsing is performed and the returned literal will have the same lexical form as specified. In other cases the string is parsed, and the lexical form may differ from what was specified. For example, if the input are"1e-07"andxsd:double, the output will be"1.OE7"^^xsd:double.- Parameters:
txt- String, notnullowl-OWLDatatype, notnull- Returns:
LiteralImpl- See Also:
-
normalizeLanguageTag
Normalises the language tag- Parameters:
lang- String, possiblenull- Returns:
- String
- See Also:
-
parseBooleanLiteral
-
parseBoolean
-
parseDoubleLiteral
public static LiteralImpl parseDoubleLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) -
parseFloatLiteral
public static LiteralImpl parseFloatLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) -
parseIntegerLiteral
public static LiteralImpl parseIntegerLiteral(String txt, org.semanticweb.owlapi.model.OWLDatatype dt) -
asONT
Converts any instance ofOWLLiteralto theONT-API Literal implementation.- Parameters:
literal-OWLLiteral- Returns:
LiteralImpl
-
newLiteral
public static LiteralImpl newLiteral(String txt, String lang, org.semanticweb.owlapi.model.OWLDatatype owl) Creates anLiteralImplinstance by string value andOWL Datatype. This method works withJena Type Mapper, but it does not change it.- Parameters:
txt- String, notnulllang- String, can benullowl-OWLDatatype, notnull- Returns:
LiteralImpl
-
getRDFDatatype
Gets theRDFDatatypefor the givenuri.- Parameters:
uri- String, notnull- Returns:
RDFDatatype
-
newLiteral
public static LiteralImpl newLiteral(Object lex, String lang, org.apache.jena.datatypes.RDFDatatype dt) Creates anLiteralImplinstance with the given lexical form, language tag andRDF Datatype.- Parameters:
lex- String, notnulllang- String ornullfor plain or typed literalsdt-RDFDatatype, may benullin some circumstances- Returns:
LiteralImpl
-
newLiteral
Creates anLiteralImplinstance for the specifiesLiteralLabel.- Parameters:
label-LiteralLabel, notnull- Returns:
LiteralImpl
-
calcLiteralLabelHashCode
protected static int calcLiteralLabelHashCode(org.apache.jena.graph.impl.LiteralLabel label) Calculates a hash-code for lexical form. The original (OWL-API) logic is preserved.- Parameters:
label-LiteralLabel, notnull- Returns:
- int
-
calcHashCode
protected static int calcHashCode(int index, org.apache.jena.graph.impl.LiteralLabel label, org.semanticweb.owlapi.model.OWLDatatype datatype, String lang) Calculates a hash-code forLiteralImplgiven as its components.- Parameters:
index- int, constant,HasHashIndex.hashIndex()label-LiteralLabel, notnulldatatype-OWLDatatype, notnulllang- String, notnull- Returns:
- int
-
equals
public static boolean equals(org.apache.jena.graph.impl.LiteralLabel left, org.apache.jena.graph.impl.LiteralLabel right) Answerstrueif the argument-literals are equal to each other andfalseotherwise.- Parameters:
left-LiteralLabel, can benullright-LiteralLabel, can benull- Returns:
- boolean
-
getDatatypeURI
Gets the valid (in OWL-API sense) datatype URI from the givenlabel.- Parameters:
label-LiteralLabel, notnull- Returns:
- String
-
asNode
public org.apache.jena.graph.Node asNode()Description copied from interface:AsNodeAnswers theNodeassociated with this object. -
getLiteralLabel
public org.apache.jena.graph.impl.LiteralLabel getLiteralLabel()Returns aJena Literal Label, that is encapsulated by this object.- Returns:
LiteralLabel
-
getLiteral
- Specified by:
getLiteralin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
getLang
- Specified by:
getLangin interfaceorg.semanticweb.owlapi.model.HasLang- Specified by:
getLangin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
getDatatypeURI
Returns the datatype URI. For a lang-literal the datatype URI isrdf:langString. For a plain-literal the datatype URI isxsd:string.- Returns:
- String, cannot be
null
-
getDatatype
public org.semanticweb.owlapi.model.OWLDatatype getDatatype()Returns theOWL-API datatypeparsed from the encapsulatedLiteralLabel. Please note: in the special case of no-lang PlainLiteral (e.g.'...'^^rdf:PlainLiteral) the method returnsInternalizedEntities.XSD_STRING, although the encapsulated label may containRDF.PlainLiteraltype.- Specified by:
getDatatypein interfaceorg.semanticweb.owlapi.model.OWLLiteral- Returns:
OWLDatatype
-
hasLang
public boolean hasLang()- Specified by:
hasLangin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
hasLang
- Specified by:
hasLangin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
isRDFPlainLiteral
public boolean isRDFPlainLiteral()- Specified by:
isRDFPlainLiteralin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
isInteger
public boolean isInteger()- Specified by:
isIntegerin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
isBoolean
public boolean isBoolean()- Specified by:
isBooleanin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
isDouble
public boolean isDouble()- Specified by:
isDoublein interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
isFloat
public boolean isFloat()- Specified by:
isFloatin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
parseInteger
public int parseInteger()- Specified by:
parseIntegerin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
parseBoolean
public boolean parseBoolean()- Specified by:
parseBooleanin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
parseDouble
public double parseDouble()- Specified by:
parseDoublein interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
parseFloat
public float parseFloat()- Specified by:
parseFloatin interfaceorg.semanticweb.owlapi.model.OWLLiteral
-
getSignatureSet
Description copied from class:OWLObjectImplGets the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getSignatureSetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof entities that represents the signature of this object
-
getDatatypeSet
Description copied from class:OWLObjectImplGets the datatypes that are in the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getDatatypeSetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof the datatypes that are in the signature of this object
-
containsEntityInSignature
public boolean containsEntityInSignature(@Nullable org.semanticweb.owlapi.model.OWLEntity entity) - Specified by:
containsEntityInSignaturein interfaceorg.semanticweb.owlapi.model.HasContainsEntityInSignature- Overrides:
containsEntityInSignaturein classOWLObjectImpl
-
getNamedClassSet
Description copied from class:OWLObjectImplGets the classes in the signature of this object. The returned set is a subset of the signature, and is not backed by the signature; it is a modifiable collection and changes are not reflected by the signature.- Overrides:
getNamedClassSetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setcontaining the classes that are in the signature of this object
-
getNamedIndividualSet
Description copied from class:OWLObjectImplGets all the individuals that are in the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getNamedIndividualSetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setcontaining the individuals that are in the signature of this object
-
getDataPropertySet
Description copied from class:OWLObjectImplObtains the data properties that are in the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getDataPropertySetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof the data properties that are in the signature of this object
-
getObjectPropertySet
Description copied from class:OWLObjectImplObtains the (named) object properties that are in the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getObjectPropertySetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof the object properties that are in the signature of this object
-
getAnnotationPropertySet
Description copied from class:OWLObjectImplObtains the annotation properties that are in the signature of this object. The set is a copy, changes are not reflected back.- Overrides:
getAnnotationPropertySetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof the annotation properties that are in the signature of this object
-
getClassExpressionSet
Description copied from class:OWLObjectImplGets all the nested (includes top level) class expressions that are used in this object. The set is a copy, changes are not reflected back.- Overrides:
getClassExpressionSetin classOWLObjectImpl- Returns:
- a modifiable unordered
SetofOWLClassExpressions that represent the nested class expressions used in this object
-
getAnonymousIndividualSet
Description copied from class:OWLObjectImplGets the anonymous individuals occurring in this object. The set is a copy, changes are not reflected back.- Overrides:
getAnonymousIndividualSetin classOWLObjectImpl- Returns:
- a modifiable sorted
Setof the anonymous individuals
-
initHashCode
public int initHashCode()- Specified by:
initHashCodein interfaceorg.semanticweb.owlapi.model.OWLLiteral- Specified by:
initHashCodein interfaceorg.semanticweb.owlapi.model.OWLObject
-
equals
Answers whether some other object is "equal to" this one.The comparison is performed by the lexical form, language tag and
OWL Datatype. So,"01"^^xsd:integerand"1"^^xsd:integerare two different literals. Also,"1e-07"^^xsd:doubleand"1.OE7"^^xsd:doubleare not equal, although the expressionliteral.getLiteralLabel().getValue()will return equal objects for both literals from the mentioned pairs. Also note: the language tag is aString, and therefore the comparison is case-sensitive, e.g. the tags "SU-su" and "su-su" are not equal.- Overrides:
equalsin classOWLObjectImpl- Parameters:
obj-Objectanything- Returns:
trueif this object is the same as the obj argument;falseotherwise
-