Class Vocabulary


  • public class Vocabulary
    extends java.lang.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:
    Vocabularies in the VO
    • Constructor Summary

      Constructors 
      Constructor Description
      Vocabulary​(java.lang.String uri, VocabTerm[] terms, java.lang.String flavour)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String getFlavour()
      Returns the vocabulary flavour string.
      java.util.Map<java.lang.String,​VocabTerm> getTerms()
      Returns a map of the terms contained in this vocabulary.
      java.lang.String getUri()
      Returns the URI defining the namespace of this vocabulary.
      static void main​(java.lang.String[] args)
      Test.
      static Vocabulary readVocabulary​(java.net.URL vocabUrl)
      Returns a vocabulary read from a given URL.
      static Vocabulary readVocabularyDesise​(java.net.URL vocabUrl)
      Reads a vocabulary using desise encoding.
      static Vocabulary readVocabularyRdfXml​(java.net.URL vocabUrl)
      Deprecated.
      does very basic vocabulary parsing; use readVocabularyDesise instead
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Vocabulary

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

      • getUri

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

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

        public java.util.Map<java.lang.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​(java.net.URL vocabUrl)
                                         throws java.io.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:
        java.io.IOException
      • readVocabularyDesise

        public static Vocabulary readVocabularyDesise​(java.net.URL vocabUrl)
                                               throws java.io.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:
        java.io.IOException
      • readVocabularyRdfXml

        @Deprecated
        public static Vocabulary readVocabularyRdfXml​(java.net.URL vocabUrl)
                                               throws java.io.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:
        java.io.IOException
      • main

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