opendap.crawler
Class EMLBuilder

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

public class EMLBuilder
extends java.lang.Object

This class handles the task of getting an EML given a DDX document. It can test the returned document to see if it is well-formed and it can cache the document.

Author:
jimg

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

Constructor Detail

EMLBuilder

public EMLBuilder()
           throws java.lang.Exception
Throws:
java.lang.Exception

EMLBuilder

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

EMLBuilder

public EMLBuilder(java.lang.String namePrefix,
                  java.lang.String xslt)
           throws java.lang.Exception
Throws:
java.lang.Exception

EMLBuilder

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

isWellFormedEML

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

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

getEML

public java.lang.String getEML(java.lang.String ddxUrl,
                               java.lang.String ddxString)
                        throws java.lang.Exception
Build and cache an EML 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 EML
ddxString - Build EML from this document
Returns:
The EML document
Throws:
java.lang.Exception

getEML

public java.lang.String getEML(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 EML
ddxString - Build EML from this document
params - Array element pairs: name1, value1, name2, value2, ...
Returns:
The EML document
Throws:
java.lang.Exception

getCachedEMLDoc

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

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

saveEMLCache

public void saveEMLCache()
                  throws java.lang.Exception
Save the EML cache.

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