|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthredds.catalog.InvCatalogFactory
public class InvCatalogFactory
Reads an XML document and constructs thredds.catalog object.
InvCatalogFactory factory = new InvCatalogFactory("default", validate); InvCatalogImpl catalog = (InvCatalogImpl) factory.readXML( catalogURI); StringBuilder buff = new StringBuilder(); if (!catalog.check( buff)) { javax.swing.JOptionPane.showMessageDialog(this, "Invalid catalog <"+ catalogURI+">\n"+ buff.toString()); }
// write out catalog to String try { System.out.println("\Catalog in XML=\n" + factory.writeXML( catalog)); } catch (IOException e) { e.printStackTrace(); } // write out catalog to a file if (!factory.writeXML( catalog, filename)) System.out.println("Catalog failed to write to file=" + filename); // write out catalog to a stream, catch exceptions try { BufferedOutputStream os = new BufferedOutputStream (new FileOutputStream(filename)); factory.writeXML( catalog, os); os.close(); } catch (IOException e) { e.printStackTrace(); }Implementation details: Uses JDOM to read XML documents. Uses a pluggable InvCatalogConvertIF to transform the JDOM tree to the thredds.catalog objects. The converters are registered based on the namespace used. We are supporting:
Field Summary | |
---|---|
static boolean |
debugDBurl
|
static boolean |
debugOpen
|
static boolean |
debugURL
|
static boolean |
debugVersion
|
static boolean |
debugXML
|
static boolean |
debugXMLopen
|
static boolean |
showCatalogXML
|
static boolean |
showParsedXML
|
static boolean |
showStackTrace
|
Constructor Summary | |
---|---|
InvCatalogFactory(String name,
boolean validate)
Constructor. |
Method Summary | |
---|---|
void |
appendErr(String err)
append an error message. |
void |
appendFatalErr(String err)
append a fatal error message |
void |
appendWarning(String err)
append a warning message |
InvCatalogConvertIF |
getCatalogConverter(String namespace)
Find the InvCatalogConvertIF registered for this namespace. |
List<PathAliasReplacement> |
getDataRootLocationAliasExpanders()
|
static InvCatalogConvertIF |
getDefaultConverter()
|
static InvCatalogFactory |
getDefaultFactory(boolean validate)
Get new Factory for reading and writing catalogs. |
MetadataConverterIF |
getMetadataConverter(String key)
Find the MetadataConverterIF registered for this key |
String |
getName()
An InvCatalogFactory may have a name, in case you need to manage several of them. |
static void |
main(String[] args)
testing |
InvCatalogImpl |
readXML(org.jdom.Document jdomDoc,
URI uri)
Create an InvCatalog from a JDOM document. |
InvCatalogImpl |
readXML(InputStream docIs,
URI uri)
Create an InvCatalog from an InputStream. |
InvCatalogImpl |
readXML(String uriString)
Create an InvCatalog from an XML document at a named URL. |
InvCatalogImpl |
readXML(StringReader catAsStringReader,
URI baseUri)
Create an InvCatalog by reading catalog XML from a StringReader. |
InvCatalogImpl |
readXML(String catAsString,
URI baseUri)
Create an InvCatalog by reading catalog XML from a String. |
InvCatalogImpl |
readXML(URI uri)
Read an InvCatalog from an a URI. |
void |
readXMLasynch(String uriString,
CatalogSetCallback callback)
This allows the possibility of reading a catalog in another thread. |
void |
registerCatalogConverter(String namespace,
InvCatalogConvertIF converter)
Register converters for creating InvCatalogs from specific catalog XML namespaces. |
void |
registerMetadataConverter(String key,
MetadataConverterIF converter)
Register metadata converters for reading metadata objects of a certain type or namespace. |
void |
setDataRootLocationAliasExpanders(List<PathAliasReplacement> dataRootLocAliasExpanders)
|
String |
writeXML(InvCatalogImpl catalog)
Write the catalog as an XML document to a String. |
void |
writeXML(InvCatalogImpl catalog,
OutputStream os)
Write the InvCatalogImpl to the OutputStream as a InvCatalog 1.0 document. |
void |
writeXML(InvCatalogImpl catalog,
OutputStream os,
boolean raw)
Write the InvCatalogImpl to the OutputStream as a InvCatalog 1.0 document. |
void |
writeXML(InvCatalogImpl catalog,
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 |
---|
public static boolean debugURL
public static boolean debugOpen
public static boolean debugVersion
public static boolean showParsedXML
public static boolean showStackTrace
public static boolean debugXML
public static boolean debugDBurl
public static boolean debugXMLopen
public static boolean showCatalogXML
Constructor Detail |
---|
public InvCatalogFactory(String name, boolean validate)
name
- : optional name to keep track of factoriesvalidate
- : do XML validation or not.Method Detail |
---|
public static InvCatalogFactory getDefaultFactory(boolean validate)
validate
- : do XML validation or not.
public static InvCatalogConvertIF getDefaultConverter()
public String getName()
public void setDataRootLocationAliasExpanders(List<PathAliasReplacement> dataRootLocAliasExpanders)
public List<PathAliasReplacement> getDataRootLocationAliasExpanders()
public void registerCatalogConverter(String namespace, InvCatalogConvertIF converter)
namespace
- : namespace of catalog; acts as the versionconverter
- : use this factory for this versionpublic InvCatalogConvertIF getCatalogConverter(String namespace)
namespace
- : find InvCatalogConvertIF for this namespace
public void registerMetadataConverter(String key, MetadataConverterIF converter)
key
- : namespace or metadata type stringconverter
- : use this MetadataConverterIF for the given keyInvMetadata
public void readXMLasynch(String uriString, CatalogSetCallback callback)
uriString
- : read this catalog.callback
- : call this if successfully read.CatalogSetCallback
public InvCatalogImpl readXML(String uriString)
uriString
- : the URI name that the XML doc is at.
public InvCatalogImpl readXML(URI uri)
uri
- : the URI of the document, used for resolving reletive references.
public InvCatalogImpl readXML(String catAsString, URI baseUri)
catAsString
- : the String from which to read the catalog.baseUri
- : the base URI of the document, used for resolving reletive references.
public InvCatalogImpl readXML(StringReader catAsStringReader, URI baseUri)
catAsStringReader
- : the StreamReader from which to read the catalog.baseUri
- : the base URI of the document, used for resolving reletive references.
public InvCatalogImpl readXML(InputStream docIs, URI uri)
docIs
- : the InputStream to read fromuri
- : the URI of the document, used for resolving reletive references.
public InvCatalogImpl readXML(org.jdom.Document jdomDoc, URI uri)
jdomDoc
- a parsed JDOM Documenturi
- : the URI of the document, used for resolving reletive references.
public void writeXML(InvCatalogImpl catalog, OutputStream os, boolean raw) throws IOException
catalog
- - the catalog to be writtenos
- - the OutputStream to write toraw
- if true, write raw, vs converted
IOException
- when the OutputStream can't be written
IllegalStateException
- when the factory doesn't know how to write a 1.0 document.public void writeXML(InvCatalogImpl catalog, OutputStream os) throws IOException
catalog
- - the catalog to be writtenos
- - the OutputStream to write to
IOException
- when the OutputStream can't be written
IllegalStateException
- when the factory doesn't know how to write a 1.0 document.public void writeXML(InvCatalogImpl catalog, String filename) throws IOException
catalog
- write this catalogfilename
- write to this filename
IOException
- on an error.public String writeXML(InvCatalogImpl catalog) throws IOException
catalog
- write this catalog
IOException
- on write errorpublic void appendErr(String err)
err
- append this error messagepublic void appendFatalErr(String err)
err
- append this error messagepublic void appendWarning(String err)
err
- append this error messagepublic MetadataConverterIF getMetadataConverter(String key)
key
- search on this key
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |