Package thredds.catalog.query
Class DqcFactory
- java.lang.Object
-
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
debugVersion
static boolean
showParsedXML
-
Constructor Summary
Constructors Constructor Description DqcFactory(boolean validate)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 fromuri
- : 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
-
-