Class Vocabulary

java.lang.Object
uk.ac.starlink.vo.Vocabulary

public class Vocabulary extends Object
Represents information from an IVOA Vocabulary.

This class is written with reference to Version 2.0 of the document Vocabularies in the VO, and particularly the Desise serialization described there. Note that document is in Working Draft status at time of writing.

See Also:
  • Constructor Details

    • Vocabulary

      public Vocabulary(String uri, VocabTerm[] terms, String flavour)
      Constructor.
      Parameters:
      uri - namespace URI
      terms - entries in the vocabulary
      flavour - vocabulary flavour string
  • Method Details

    • getUri

      public String getUri()
      Returns the URI defining the namespace of this vocabulary.
      Returns:
      vocabulary namespace URI
    • getFlavour

      public String getFlavour()
      Returns the vocabulary flavour string.
      Returns:
      flavour
    • getTerms

      public Map<String,VocabTerm> getTerms()
      Returns a map of the terms contained in this vocabulary. The map keys are unqualified term names (no # character).
      Returns:
      term->properties map
    • readVocabulary

      public static Vocabulary readVocabulary(URL vocabUrl) throws IOException
      Returns a vocabulary read from a given URL. The URL will usually be equal to the namespace in which the terms are required (http://www.ivoa.net/rdf/<vocab-name>).
      Parameters:
      vocabUrl - resource URL
      Returns:
      vocabulary object
      Throws:
      IOException
    • readVocabularyDesise

      public static Vocabulary readVocabularyDesise(URL vocabUrl) throws IOException
      Reads a vocabulary using desise encoding. The vocabulary must be available on (Accept-header) request from the URL in question in application/x-desise+json format. In accordance with the Vocabularies in VO 2.0 standard, all IVOA vocabularies can be so retrieved using URLs equivalent to their namespace URIs, of the form http://www.ivoa.net/rdf/<vocab-name>.
      Parameters:
      vocabUrl - vocabulary URL, typically equal to the namespace URI
      Returns:
      fully populated vocabulary
      Throws:
      IOException
    • readVocabularyRdfXml

      @Deprecated public static Vocabulary readVocabularyRdfXml(URL vocabUrl) throws IOException
      Deprecated.
      does very basic vocabulary parsing; use readVocabularyDesise instead
      Reads a vocabulary using RDF XML encoding. In accordance with the IVOA Vocabularies standard, the vocabulary must be available from the URL in question in application/rdf+xml format.

      Note: The RDF parsing performed by this method is very sketchy and pulls out only a minimum of information from the retrieved XML (the term values themselves). This implementation is present mainly for historical reasons. For practical purposes, the much more thorough readVocabularyDesise(java.net.URL) method should be used instead. It would be possible to ehance this implementation to get more or all the available information from the XML, but since the desise-format variant ought to be available for all IVOA vocabularies, why go to the effort?

      Parameters:
      vocabUrl - vocabulary namespace and resource URL
      Returns:
      vocabulary object
      Throws:
      IOException
    • main

      public static void main(String[] args) throws IOException
      Test.
      Throws:
      IOException