opendap.crawler
Class NCMLBuilder

java.lang.Object
  extended by opendap.crawler.NCMLBuilder

public class NCMLBuilder
extends java.lang.Object

This class handles the task of getting an NCML given a DDX document. It can test the returned document to see if it is well-formed and it can cache the document. This is based on the DDX to NCML builder but, unlike that code, this only handles the case where many DDX documents comprise a single dataset.

Author:
jimg

Constructor Summary
NCMLBuilder(java.lang.String namePrefix)
           
NCMLBuilder(java.lang.String namePrefix, java.lang.String xslt)
           
 
Method Summary
 java.lang.String getCachedNCMLDoc(java.lang.String DDXURL)
          Return the NCML document generated using the DDX from the given DDX URL.
 java.lang.String getNCML(java.lang.String ddxUrl, java.lang.String ddxString)
          Build and cache an NCML document using the given DDX document.
 java.lang.String getNCML(java.lang.String ddxUrl, java.lang.String ddxString, java.lang.String[] params)
          This version takes a varying number of parameters.
 boolean isWellFormedNCML(java.lang.String ncmlString)
          Simple method to test if the NCML will parse.
 void saveNCMLCache()
          Save the NCML cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NCMLBuilder

public NCMLBuilder(java.lang.String namePrefix)
            throws java.lang.Exception
Throws:
java.lang.Exception

NCMLBuilder

public NCMLBuilder(java.lang.String namePrefix,
                   java.lang.String xslt)
            throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

isWellFormedNCML

public boolean isWellFormedNCML(java.lang.String ncmlString)
Simple method to test if the NCML will parse. Generally there's no need to call this but it'll be useful when developing the crawler.

Parameters:
ddxString - The NCML to test
Returns:
true if the NCML parses, false if the SAX parser throws an exception

getNCML

public java.lang.String getNCML(java.lang.String ddxUrl,
                                java.lang.String ddxString)
                         throws java.lang.Exception
Build and cache an NCML document using the given DDX document. Use the DDX's URL as the key for the cache entry. If caching is not on, ignore the DDX URL and don't use the cache.

Parameters:
ddxUrl - Use this as the key when caching the NCML
ddxString - Build NCML from this document
Returns:
The NCML document
Throws:
java.lang.Exception

getNCML

public java.lang.String getNCML(java.lang.String ddxUrl,
                                java.lang.String ddxString,
                                java.lang.String[] params)
                         throws java.lang.Exception
This version takes a varying number of parameters.

Parameters:
ddxUrl - Use this as the key when caching the NCML
ddxString - Build NCML from this document
params - Array element pairs: name1, value1, name2, value2, ...
Returns:
The NCML document
Throws:
java.lang.Exception

getCachedNCMLDoc

public java.lang.String getCachedNCMLDoc(java.lang.String DDXURL)
                                  throws java.lang.Exception
Return the NCML document generated using the DDX from the given DDX URL. This method reads from the NCML cache.

Parameters:
DDXURL - The DDX URL is the key used to reference the NCML document.
Returns:
The NCML in a String.
Throws:
java.lang.Exception - Thrown if caching is not on.

saveNCMLCache

public void saveNCMLCache()
                   throws java.lang.Exception
Save the NCML cache.

Throws:
java.lang.Exception - Thrown if caching is not on.