edu.sdsc.inca.util
Class SuiteWrapper

java.lang.Object
  extended by edu.sdsc.inca.util.XmlWrapper
      extended by edu.sdsc.inca.util.SuiteWrapper

public class SuiteWrapper
extends XmlWrapper

Convenience object for accessing suite documents and persisting changes to them.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Field Summary
 
Fields inherited from class edu.sdsc.inca.util.XmlWrapper
CDATA_PATTERN, ELEMENT_CLOSE_PATTERN, PASSWORD_MACRO_VALUE_PATTERN, PROCESSING_INSTRUCTION_PATTERN, XML_COMMENT_PATTERN, XML_NAME_PATTERN, XML_NODE_PATTERN
 
Constructor Summary
SuiteWrapper()
          Create a new SuiteWrapper object containing a blank suite.
SuiteWrapper(java.lang.String filename)
          Create a new SuiteWrapper object from a suite XML file.
SuiteWrapper(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
          Create a new SuiteWrapper object from an XML Beans class instance.
 
Method Summary
 void appendSeriesConfig(edu.sdsc.inca.dataModel.util.SeriesConfig seriesConfig)
          Append a new series config to the existing suite.
 void changeAction(java.lang.String action)
          Change the action in all series configs found in the suite document.
 void copySuiteAttributes(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
          Copy the top level suite attributes: name, guid, and description to supplied suite document.
 edu.sdsc.inca.dataModel.suite.SuiteDocument diff(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
          Compare the existing suite against the passed in suite and return the differences as adds and deletes.
 edu.sdsc.inca.dataModel.util.SeriesConfig getSeriesConfig(int index)
          Return a series config from the suite.
 int getSeriesConfigCount()
          Return the number of series config objects contained in the suite document.
 int[] getSeriesConfigCountByPattern(java.lang.String[] nicknamePatterns, java.lang.String[] namePatterns)
          Count the number of series configs that match the provided patterns.
 edu.sdsc.inca.dataModel.util.SeriesConfig[] getSeriesConfigs()
          Return all series configs in the suite as an array.
 edu.sdsc.inca.dataModel.suite.SuiteDocument getSuiteDocument()
          Return the root element of the suite document.
 void save(java.io.File saveTo)
          Save the suite to the specified file
 
Methods inherited from class edu.sdsc.inca.util.XmlWrapper
configEqual, cryptSensitive, escape, getPrettyPrintOptions, main, prettyPrint, read, save, unescape, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SuiteWrapper

public SuiteWrapper()
Create a new SuiteWrapper object containing a blank suite.


SuiteWrapper

public SuiteWrapper(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
             throws org.apache.xmlbeans.XmlException
Create a new SuiteWrapper object from an XML Beans class instance.

Parameters:
suiteDoc - An instance of SuiteDocument, a class generated
Throws:
org.apache.xmlbeans.XmlException

SuiteWrapper

public SuiteWrapper(java.lang.String filename)
             throws java.io.IOException,
                    org.apache.xmlbeans.XmlException
Create a new SuiteWrapper object from a suite XML file.

Parameters:
filename - Path to a file containing suite XML.
Throws:
java.io.IOException
org.apache.xmlbeans.XmlException
Method Detail

appendSeriesConfig

public void appendSeriesConfig(edu.sdsc.inca.dataModel.util.SeriesConfig seriesConfig)
Append a new series config to the existing suite.

Parameters:
seriesConfig - A new series config object to be added to the end of the existing suite.

changeAction

public void changeAction(java.lang.String action)
Change the action in all series configs found in the suite document.

Parameters:
action - The action to use in all series configs.

copySuiteAttributes

public void copySuiteAttributes(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
Copy the top level suite attributes: name, guid, and description to supplied suite document.

Parameters:
suiteDoc - A suite that where the top level suite attributes will be copied to

diff

public edu.sdsc.inca.dataModel.suite.SuiteDocument diff(edu.sdsc.inca.dataModel.suite.SuiteDocument suiteDoc)
                                                 throws org.apache.xmlbeans.XmlException
Compare the existing suite against the passed in suite and return the differences as adds and deletes.

Parameters:
suiteDoc - Another suite document to compare to the object's suite document.
Returns:
The differences between the suites returned as a suite document represented as adds and deletes.
Throws:
org.apache.xmlbeans.XmlException

getSeriesConfig

public edu.sdsc.inca.dataModel.util.SeriesConfig getSeriesConfig(int index)
Return a series config from the suite.

Parameters:
index - The index of the series config to return.
Returns:
The series config object.

getSeriesConfigs

public edu.sdsc.inca.dataModel.util.SeriesConfig[] getSeriesConfigs()
Return all series configs in the suite as an array.

Returns:
An array of series config objects from the suite document.

getSeriesConfigCount

public int getSeriesConfigCount()
Return the number of series config objects contained in the suite document.

Returns:
An integer containing the number of series config objects.

getSeriesConfigCountByPattern

public int[] getSeriesConfigCountByPattern(java.lang.String[] nicknamePatterns,
                                           java.lang.String[] namePatterns)
Count the number of series configs that match the provided patterns.

Parameters:
nicknamePatterns - Patterns that should be matched against the series nickname
namePatterns - Patterns that should be matched against the series reporter name
Returns:
An integer array of size nicknamePatterns.length + namePatterns.length + 1

getSuiteDocument

public edu.sdsc.inca.dataModel.suite.SuiteDocument getSuiteDocument()
Return the root element of the suite document.

Returns:
The suite root element of the suite document.

save

public void save(java.io.File saveTo)
          throws java.io.IOException
Save the suite to the specified file

Parameters:
saveTo - The file to save the suite to.
Throws:
java.io.IOException