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 booleandebugVersionstatic booleanshowParsedXML
-
Constructor Summary
Constructors Constructor Description DqcFactory(boolean validate)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendErr(String err)voidappendFatalErr(String err)voidappendWarning(String err)static voidmain(String[] args)QueryCapabilityreadXML(InputStream docIs, URI uri)Create an QueryCapability from an InputStream.QueryCapabilityreadXML(String uriString)Create an QueryCapability from an XML document at a named URL.QueryCapabilityreadXML(String docAsString, URI uri)static voidsetPersistenceCache(ucar.nc2.util.DiskCache2 dc)StringwriteXML(QueryCapability dqc)Write the catalog as an XML document to a String.voidwriteXML(QueryCapability dqc, OutputStream os)Write the catalog as an XML document to the specified stream.booleanwriteXML(QueryCapability dqc, String filename)Write the catalog as an XML document to the specified filename.
-
-
-
Method Detail
-
setPersistenceCache
public static void setPersistenceCache(ucar.nc2.util.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 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
-
-