Class IRI

java.lang.Object
org.semanticweb.owlapi.model.IRI
All Implemented Interfaces:
Serializable, CharSequence, Comparable<OWLObject>, org.apache.commons.rdf.api.BlankNodeOrIRI, org.apache.commons.rdf.api.IRI, org.apache.commons.rdf.api.RDFTerm, HasAnnotationPropertiesInSignature, HasAnnotationValue, HasAnonymousIndividuals, HasClassesInSignature, HasComponents, HasContainsEntityInSignature, HasDataPropertiesInSignature, HasDatatypesInSignature, HasHashIndex, HasIndex, HasIndividualsInSignature, HasObjectPropertiesInSignature, HasShortForm, HasSignature, IsAnonymous, OWLAnnotationObject, OWLAnnotationSubject, OWLAnnotationValue, OWLObject, OWLPrimitive, SWRLPredicate

public class IRI extends Object implements OWLAnnotationSubject, OWLAnnotationValue, SWRLPredicate, CharSequence, OWLPrimitive, HasShortForm, org.apache.commons.rdf.api.IRI
Represents International Resource Identifiers.
Since:
3.0.0
Author:
Matthew Horridge, The University of Manchester, Information Management Group
See Also:
  • Method Details

    • create

      public static IRI create(String str)
      Creates an IRI from the specified String.
      Parameters:
      str - The String that specifies the IRI
      Returns:
      The IRI that has the specified string representation.
    • create

      public static IRI create(@Nullable String prefix, @Nullable String suffix)
      Creates an IRI by concatenating two strings. The full IRI is an IRI that contains the characters in prefix + suffix.
      Parameters:
      prefix - The first string
      suffix - The second string
      Returns:
      An IRI whose characters consist of prefix + suffix.
      Since:
      3.3
    • create

      public static IRI create(File file)
      Parameters:
      file - the file to create the IRI from
      Returns:
      file.toURI() IRI
    • create

      public static IRI create(URI uri)
      Parameters:
      uri - the URI to create the IRI from
      Returns:
      the IRI wrapping the URI
    • create

      public static IRI create(URL url)
      Parameters:
      url - the URL to create the IRI from
      Returns:
      an IRI wrapping url.toURI()
      Throws:
      OWLRuntimeException - if the URL is ill formed
    • generateDocumentIRI

      public static IRI generateDocumentIRI()
      Gets an auto-generated ontology document IRI.
      Returns:
      An auto-generated ontology document IRI. The IRI has the form owlapi:ontologyNNNNNNNNNNN
    • getNextDocumentIRI

      public static IRI getNextDocumentIRI(String prefix)
      Parameters:
      prefix - prefix for result
      Returns:
      a fresh IRI
    • typeIndex

      public int typeIndex()
      Specified by:
      typeIndex in interface HasIndex
      Returns:
      index for this type. This is not a hashcode for instances, rather a sorting index for the types.
    • isIRI

      public boolean isIRI()
      Specified by:
      isIRI in interface OWLObject
      Returns:
      true if this object is an IRI.
    • toURI

      public URI toURI()
      Obtains this IRI as a URI. Note that Java URIs handle unicode characters, so there is no loss during this translation.
      Returns:
      The URI
    • isAbsolute

      public boolean isAbsolute()
      Determines if this IRI is absolute.
      Returns:
      true if this IRI is absolute or false if this IRI is not absolute
    • getScheme

      @Nullable public String getScheme()
      Returns:
      the IRI scheme, e.g., http, urn
    • getNamespace

      public String getNamespace()
      Returns:
      the prefix
    • resolve

      public IRI resolve(String s)
      Parameters:
      s - the IRI string to be resolved
      Returns:
      s resolved against this IRI (with the URI::resolve() method, unless this IRI is opaque)
    • isReservedVocabulary

      public boolean isReservedVocabulary()
      Determines if this IRI is in the reserved vocabulary. An IRI is in the reserved vocabulary if it starts with <http://www.w3.org/1999/02/22-rdf-syntax-ns#> or <http://www.w3.org/2000/01/rdf-schema#> or <http://www.w3.org/2001/XMLSchema#> or <http://www.w3.org/2002/07/owl#>
      Returns:
      true if the IRI is in the reserved vocabulary, otherwise false.
    • isBuiltinAnnotationProperty

      public boolean isBuiltinAnnotationProperty()
      Built in annotation properties do not need declarations. Adding this method to IRIs so during parsing any undeclared properties can easily be disambiguated between builtin annotation properties and properties that are guessed to be annotation properties because of missing declarations.
      Returns:
      true if this IRI equals one of the vocabulary annotation properties
    • isThing

      public boolean isThing()
      Determines if this IRI is equal to the IRI that owl:Thing is named with.
      Returns:
      true if this IRI is equal to <http://www.w3.org/2002/07/owl#Thing> and otherwise false
    • isNothing

      public boolean isNothing()
      Determines if this IRI is equal to the IRI that owl:Nothing is named with.
      Returns:
      true if this IRI is equal to <http://www.w3.org/2002/07/owl#Nothing> and otherwise false
    • isPlainLiteral

      public boolean isPlainLiteral()
      Determines if this IRI is equal to the IRI that is named rdf:PlainLiteral.
      Returns:
      true if this IRI is equal to <http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral>, otherwise false
    • getFragment

      public String getFragment()
      Gets the last part of the IRI that is a valid NCName; note that for some IRIs this can be empty.
      Returns:
      The IRI fragment, or empty string if the IRI does not have a fragment
    • getRemainder

      public Optional<String> getRemainder()
      Returns:
      the remainder (coincident with NCName usually) for this IRI.
    • toQuotedString

      public String toQuotedString()
      Obtained this IRI surrounded by angled brackets.
      Returns:
      This IRI surrounded by < and >
    • length

      public int length()
      Specified by:
      length in interface CharSequence
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public CharSequence subSequence(int start, int end)
      Specified by:
      subSequence in interface CharSequence
    • prefixedBy

      public String prefixedBy(String prefix)
      Parameters:
      prefix - prefix to use for replacing the IRI namespace
      Returns:
      prefix plus IRI ncname
    • getShortForm

      public String getShortForm()
      Description copied from interface: HasShortForm
      Gets the short form.
      Specified by:
      getShortForm in interface HasShortForm
      Returns:
      A string that represents the short form.
    • accept

      public void accept(OWLObjectVisitor visitor)
      Description copied from interface: OWLObject
      Accepts a visitor
      Specified by:
      accept in interface OWLObject
      Parameters:
      visitor - The visitor
    • accept

      public <O> O accept(OWLObjectVisitorEx<O> visitor)
      Description copied from interface: OWLObject
      Accepts a visitor
      Specified by:
      accept in interface OWLObject
      Type Parameters:
      O - visitor return type
      Parameters:
      visitor - The visitor
      Returns:
      visitor value
    • accept

      public void accept(OWLAnnotationSubjectVisitor visitor)
      Specified by:
      accept in interface OWLAnnotationSubject
      Parameters:
      visitor - visitor to accept
    • accept

      public <E> E accept(OWLAnnotationSubjectVisitorEx<E> visitor)
      Specified by:
      accept in interface OWLAnnotationSubject
      Type Parameters:
      E - visitor return type
      Parameters:
      visitor - visitor to accept
      Returns:
      visitor value
    • compareTo

      public int compareTo(@Nullable OWLObject o)
      Specified by:
      compareTo in interface Comparable<OWLObject>
    • toString

      public String toString()
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface org.apache.commons.rdf.api.IRI
      Specified by:
      hashCode in interface org.apache.commons.rdf.api.RDFTerm
      Overrides:
      hashCode in class Object
    • initHashCode

      public int initHashCode()
      Specified by:
      initHashCode in interface OWLObject
      Returns:
      hash code for the object; called on first use, cached by OWLObjectImpl in the default implementation.
    • accept

      public void accept(OWLAnnotationValueVisitor visitor)
      Specified by:
      accept in interface OWLAnnotationValue
      Parameters:
      visitor - visitor to accept
    • accept

      public <O> O accept(OWLAnnotationValueVisitorEx<O> visitor)
      Specified by:
      accept in interface OWLAnnotationValue
      Type Parameters:
      O - visitor return type
      Parameters:
      visitor - visitor to accept
      Returns:
      visitor value
    • asIRI

      public Optional<IRI> asIRI()
      Specified by:
      asIRI in interface OWLAnnotationObject
      Returns:
      if the value is an IRI, return an optional containing it. Return Optional.absent otherwise.
    • equals

      public boolean equals(@Nullable Object obj)
      Specified by:
      equals in interface org.apache.commons.rdf.api.IRI
      Specified by:
      equals in interface org.apache.commons.rdf.api.RDFTerm
      Overrides:
      equals in class Object
    • ntriplesString

      public String ntriplesString()
      Specified by:
      ntriplesString in interface org.apache.commons.rdf.api.RDFTerm
    • getIRIString

      public String getIRIString()
      Specified by:
      getIRIString in interface org.apache.commons.rdf.api.IRI
    • components

      public Stream<?> components()
      Specified by:
      components in interface HasComponents
      Returns:
      components as a stream. The stream is ordered (by visit order) but not sorted. Implementations that override components() must ensure the order is compatible with equals() and hashCode().
    • hashIndex

      public int hashIndex()
      Specified by:
      hashIndex in interface HasHashIndex
      Returns:
      index for this type. This is not a hashcode for instances, rather a hashcode for the types.