edu.sc.seis.fissuresUtil.xml
Class DataSetToXML

java.lang.Object
  extended by edu.sc.seis.fissuresUtil.xml.DataSetToXML

public class DataSetToXML
extends java.lang.Object


Field Summary
static java.lang.String DSML_SCHEMA2_0
           
protected  boolean saveLocally
           
protected  boolean useDataSetRef
          If true, then each dataset is put into a separate dsml file.
 
Constructor Summary
DataSetToXML()
           
 
Method Summary
static edu.iris.Fissures.AuditInfo[] createAuditInfo(java.net.URL base, java.lang.String id)
           
 org.w3c.dom.Element createDocument(DataSet dataset, java.io.File dataDirectory, SeismogramFileTypes fileType)
           
static java.lang.String createFileName(DataSet dataset)
           
 DataSet createWithStAX(javax.xml.stream.XMLStreamReader parser, java.net.URL base)
          Creates the dataset from the input.
 DataSet extract(java.net.URL base, org.w3c.dom.Element element)
          Extracts the dataset from the element, which is assumed to be a <dataset> element.
static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
           
 org.w3c.dom.Element insert(org.w3c.dom.Document doc, DataSet dataset, java.io.File directory, SeismogramFileTypes fileType)
          DOM insert
 org.w3c.dom.Element insert(org.w3c.dom.Element parent, DataSet dataset, java.io.File directory, SeismogramFileTypes fileType)
          DOM insert inserts the dataset, and all child datasets recursively, into the document, along with dataset seismograms and parameters if they can be stored.
 org.w3c.dom.Element insert(org.w3c.dom.Element parent, java.lang.String name, java.lang.Object parameter)
          DOM insert inserts the parameter into the given element.
 org.w3c.dom.Element insert(org.w3c.dom.Element parent, URLDataSetSeismogram urlDSS, java.net.URL base)
          inserts a URLDataSetSeismogram element into the parent.
 void insertInto(org.w3c.dom.Element element, DataSet dataset, java.io.File directory, SeismogramFileTypes fileType)
          DOM insertInto
 org.w3c.dom.Element insertParameter(org.w3c.dom.Element parent, java.lang.String name, java.lang.String typeDef, java.lang.String typeName, java.lang.String value)
          DOM insertParameter inserts the parameter into the given element.
 org.w3c.dom.Element insertRef(org.w3c.dom.Element element, DataSet dataset, java.io.File directory)
          DOM insertRef inserts the child dataset as a datasetRef element.
 org.w3c.dom.Element insertRef(org.w3c.dom.Element parent, java.lang.String datasetURL, java.lang.String linkTitle)
          DOM insertRef inserts the child dataset as a datasetRef element.
static DataSet load(java.net.URL datasetURL)
          Load a xml dataset from a URL.
 java.io.File save(DataSet dataset, java.io.File saveDirectory)
          Saves the given dataset to an xml file in the given directory.
 java.io.File save(DataSet dataset, java.io.File saveDirectory, SeismogramFileTypes fileType)
          Saves the given dataset to an xml file in the given directory.
 void writeToFile(org.w3c.dom.Element datasetElement, java.io.File outFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DSML_SCHEMA2_0

public static final java.lang.String DSML_SCHEMA2_0
See Also:
Constant Field Values

saveLocally

protected boolean saveLocally

useDataSetRef

protected boolean useDataSetRef
If true, then each dataset is put into a separate dsml file. Otherwise the child datasets are embedded in the parent dsml file.

Constructor Detail

DataSetToXML

public DataSetToXML()
Method Detail

save

public java.io.File save(DataSet dataset,
                         java.io.File saveDirectory)
                  throws java.io.IOException,
                         javax.xml.parsers.ParserConfigurationException,
                         java.net.MalformedURLException
Saves the given dataset to an xml file in the given directory. The file is returned.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

save

public java.io.File save(DataSet dataset,
                         java.io.File saveDirectory,
                         SeismogramFileTypes fileType)
                  throws java.io.IOException,
                         javax.xml.parsers.ParserConfigurationException,
                         java.net.MalformedURLException
Saves the given dataset to an xml file in the given directory. The file is returned.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

createFileName

public static java.lang.String createFileName(DataSet dataset)

writeToFile

public void writeToFile(org.w3c.dom.Element datasetElement,
                        java.io.File outFile)
                 throws java.io.IOException,
                        java.net.MalformedURLException
Throws:
java.io.IOException
java.net.MalformedURLException

getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                            throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

createDocument

public org.w3c.dom.Element createDocument(DataSet dataset,
                                          java.io.File dataDirectory,
                                          SeismogramFileTypes fileType)
                                   throws java.io.IOException,
                                          javax.xml.parsers.ParserConfigurationException,
                                          java.net.MalformedURLException
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insert

public org.w3c.dom.Element insert(org.w3c.dom.Element parent,
                                  DataSet dataset,
                                  java.io.File directory,
                                  SeismogramFileTypes fileType)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  java.net.MalformedURLException
DOM insert inserts the dataset, and all child datasets recursively, into the document, along with dataset seismograms and parameters if they can be stored. Note that all dataSetSeismograms are converted to URLDataSetSeismograms and stored in a directory structure that mirrors the dataset structure under the given directory.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insert

public org.w3c.dom.Element insert(org.w3c.dom.Document doc,
                                  DataSet dataset,
                                  java.io.File directory,
                                  SeismogramFileTypes fileType)
                           throws java.io.IOException,
                                  javax.xml.parsers.ParserConfigurationException,
                                  java.net.MalformedURLException
DOM insert

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insertInto

public void insertInto(org.w3c.dom.Element element,
                       DataSet dataset,
                       java.io.File directory,
                       SeismogramFileTypes fileType)
                throws java.io.IOException,
                       javax.xml.parsers.ParserConfigurationException,
                       java.net.MalformedURLException
DOM insertInto

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insert

public org.w3c.dom.Element insert(org.w3c.dom.Element parent,
                                  URLDataSetSeismogram urlDSS,
                                  java.net.URL base)
inserts a URLDataSetSeismogram element into the parent. The URLDataSetSeismogram Element is returned. URLs are made relative to the given base.


insertRef

public org.w3c.dom.Element insertRef(org.w3c.dom.Element element,
                                     DataSet dataset,
                                     java.io.File directory)
                              throws java.io.IOException,
                                     javax.xml.parsers.ParserConfigurationException,
                                     java.net.MalformedURLException
DOM insertRef inserts the child dataset as a datasetRef element. The URL is assumed to be in a subdirectory relative to the current dataset.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insertRef

public org.w3c.dom.Element insertRef(org.w3c.dom.Element parent,
                                     java.lang.String datasetURL,
                                     java.lang.String linkTitle)
                              throws java.io.IOException,
                                     javax.xml.parsers.ParserConfigurationException,
                                     java.net.MalformedURLException
DOM insertRef inserts the child dataset as a datasetRef element. The URL is assumed to be in a subdirectory relative to the current dataset.

Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
java.net.MalformedURLException

insert

public org.w3c.dom.Element insert(org.w3c.dom.Element parent,
                                  java.lang.String name,
                                  java.lang.Object parameter)
DOM insert inserts the parameter into the given element.


insertParameter

public org.w3c.dom.Element insertParameter(org.w3c.dom.Element parent,
                                           java.lang.String name,
                                           java.lang.String typeDef,
                                           java.lang.String typeName,
                                           java.lang.String value)
DOM insertParameter inserts the parameter into the given element.


load

public static DataSet load(java.net.URL datasetURL)
                    throws java.io.IOException,
                           javax.xml.parsers.ParserConfigurationException,
                           IncomprehensibleDSMLException,
                           UnsupportedFileTypeException
Load a xml dataset from a URL.

Parameters:
datasetURL - an URL to an xml dataset
Returns:
a XMLDataSet populated form the URL
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
IncomprehensibleDSMLException
UnsupportedFileTypeException

createWithStAX

public DataSet createWithStAX(javax.xml.stream.XMLStreamReader parser,
                              java.net.URL base)
                       throws javax.xml.stream.XMLStreamException,
                              java.net.MalformedURLException,
                              UnsupportedFileTypeException
Creates the dataset from the input.

Throws:
javax.xml.stream.XMLStreamException
java.net.MalformedURLException
UnsupportedFileTypeException

extract

public DataSet extract(java.net.URL base,
                       org.w3c.dom.Element element)
                throws java.net.MalformedURLException,
                       UnsupportedFileTypeException
Extracts the dataset from the element, which is assumed to be a <dataset> element.

Throws:
java.net.MalformedURLException
UnsupportedFileTypeException

createAuditInfo

public static edu.iris.Fissures.AuditInfo[] createAuditInfo(java.net.URL base,
                                                            java.lang.String id)