Class DqcFactory


  • public class DqcFactory
    extends Object
    Reads an XML document and constructs an QueryCapability object.

    Example of normal use:

     DqcFactory fac = new DqcFactory(true);
     QueryCapability dqc = fac.readXML(url);
     System.out.println(" dqc hasFatalError= " + dqc.hasFatalError());
     System.out.println(" dqc messages= \n" + dqc.getErrorMessages());
     fac.writeXML(dqc, System.out);
     

    Implementation details: Uses JAXP to load an XML Parser and construct a DOM tree. Uses a pluggable "converter" to transform the DOM to the thredds.catalog.query objects.

    • Field Detail

      • debugVersion

        public static boolean debugVersion
      • showParsedXML

        public static boolean showParsedXML
    • Constructor Detail

      • DqcFactory

        public DqcFactory​(boolean validate)
        Constructor. Can use this to read as many catalogs as you want, but should only use in single thread.
        Parameters:
        validate - : do XML validation or not.
    • Method Detail

      • setPersistenceCache

        public static void setPersistenceCache​(DiskCache2 dc)
      • appendErr

        public void appendErr​(String err)
      • appendFatalErr

        public void appendFatalErr​(String err)
      • appendWarning

        public void appendWarning​(String err)
      • readXML

        public QueryCapability readXML​(String uriString)
                                throws IOException
        Create an QueryCapability from an XML document at a named URL. check dqc.isValid, dqc.getErrorMessages() to see if ok. If Disk caching is set, cache the dqc and check IfModifiedSince.
        Parameters:
        uriString - : the URI name that the XML doc is at.
        Returns:
        an QueryCapability object
        Throws:
        IOException - on failure
      • readXML

        public QueryCapability readXML​(InputStream docIs,
                                       URI uri)
                                throws IOException
        Create an QueryCapability from an InputStream. check dqc.isValid, dqc.getErrorMessages() to see if ok.
        Parameters:
        docIs - : the InputStream to read from
        uri - : the URI of the document, used for resolving relative references.
        Returns:
        an QueryCapability object
        Throws:
        IOException - on failure
      • writeXML

        public String writeXML​(QueryCapability dqc)
                        throws IOException
        Write the catalog as an XML document to a String.
        Parameters:
        dqc - : write this QueryCapability to an XML representation.
        Returns:
        string containing XML representation
        Throws:
        IOException - on failure
      • writeXML

        public void writeXML​(QueryCapability dqc,
                             OutputStream os)
                      throws IOException
        Write the catalog as an XML document to the specified stream.
        Parameters:
        dqc - : write this QueryCapability to an XML representation.
        os - write to this OutputStream
        Throws:
        IOException - on an error.
      • writeXML

        public boolean writeXML​(QueryCapability dqc,
                                String filename)
        Write the catalog as an XML document to the specified filename.
        Parameters:
        dqc - : write this QueryCapability to an XML representation.
        filename - write to this filename
        Returns:
        true if success