thredds.catalog.query
Class DqcFactory

java.lang.Object
  extended by thredds.catalog.query.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.

Author:
John Caron

Field Summary
static boolean debugURL
           
static boolean debugVersion
           
static boolean showParsedXML
           
 
Constructor Summary
DqcFactory(boolean validate)
          Constructor.
 
Method Summary
 void appendErr(String err)
           
 void appendFatalErr(String err)
           
 void appendWarning(String err)
           
static void main(String[] args)
           
 QueryCapability readXML(InputStream docIs, URI uri)
          Create an QueryCapability from an InputStream.
 QueryCapability readXML(String uriString)
          Create an QueryCapability from an XML document at a named URL.
 QueryCapability readXML(String docAsString, URI uri)
           
static void setPersistenceCache(DiskCache2 dc)
           
 String writeXML(QueryCapability dqc)
          Write the catalog as an XML document to a String.
 void writeXML(QueryCapability dqc, OutputStream os)
          Write the catalog as an XML document to the specified stream.
 boolean writeXML(QueryCapability dqc, String filename)
          Write the catalog as an XML document to the specified filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugURL

public static boolean debugURL

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 docAsString,
                               URI uri)
                        throws IOException
Throws:
IOException

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 reletive 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

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.