org.patterncoder.source
Class PatternFileReaderDom

java.lang.Object
  extended by org.patterncoder.source.PatternFileReaderDom
All Implemented Interfaces:
PatternFileReader

public class PatternFileReaderDom
extends java.lang.Object
implements PatternFileReader

Reads in xml files, using the DOM xml parser. Implements the PatternFileReader interface providing methods for retrieving pattern related data from file.


Constructor Summary
PatternFileReaderDom()
          Creates new instance of PatternFileReaderDom.
PatternFileReaderDom(javax.xml.parsers.DocumentBuilder parser)
          Creates new instance of PatternFileReaderDom.
 
Method Summary
 java.util.HashMap<java.lang.Object,PatternClass> getPatternComponents()
          Creates a list of PatternClass objects which have been created using the "class" data from the parsed file.
 java.lang.String getPatternDesc()
          Returns the description of the pattern from the associated pattern file
 java.lang.String getPatternImage()
          Returns the image file name of the pattern from the associated pattern file
 java.lang.String getPatternName()
          Returns the name of the pattern from the associated pattern file
 java.util.List<WizardPanelDescriptor> getWizardDescriptors(Wizard parent, PatternModel model)
          Creates a list of WizardPanelDescriptor objects associated with the pattern source file being read in.
 void parseFile(java.io.File sourceFile)
          Calls the parse method from the instantiated parser object on the supplied source file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternFileReaderDom

public PatternFileReaderDom()
                     throws PatternCoderException
Creates new instance of PatternFileReaderDom.

Automatically creates a new parser object from the DOM factory methods.

Throws:
PatternCoderException

PatternFileReaderDom

public PatternFileReaderDom(javax.xml.parsers.DocumentBuilder parser)
Creates new instance of PatternFileReaderDom.

Allows the parser to be set.

Parameters:
parser - The parser object to use to parse pattern files.
Method Detail

parseFile

public void parseFile(java.io.File sourceFile)
               throws java.io.IOException,
                      org.xml.sax.SAXException
Calls the parse method from the instantiated parser object on the supplied source file.

Generates a DOM tree object used by the other methods to retrieve information about the patterns. The parseFile method must be called prior to calling any other methods.

Specified by:
parseFile in interface PatternFileReader
Parameters:
sourceFile - The input file to be parsed(XML).
Throws:
java.io.IOException - Thrown if file does not exist.
org.xml.sax.SAXException

getPatternName

public java.lang.String getPatternName()
Returns the name of the pattern from the associated pattern file

Specified by:
getPatternName in interface PatternFileReader
Returns:
The name of the pattern.

getPatternDesc

public java.lang.String getPatternDesc()
Returns the description of the pattern from the associated pattern file

Specified by:
getPatternDesc in interface PatternFileReader
Returns:
The description of the pattern.

getPatternImage

public java.lang.String getPatternImage()
Returns the image file name of the pattern from the associated pattern file

Specified by:
getPatternImage in interface PatternFileReader
Returns:
The name of the image file i.e Singleton.bmp.

getPatternComponents

public java.util.HashMap<java.lang.Object,PatternClass> getPatternComponents()
Creates a list of PatternClass objects which have been created using the "class" data from the parsed file. This list contains the classes that should be created as part of the pattern implementation.

Specified by:
getPatternComponents in interface PatternFileReader
Returns:
list of PatternClass objects.
See Also:
PatternClass

getWizardDescriptors

public java.util.List<WizardPanelDescriptor> getWizardDescriptors(Wizard parent,
                                                                  PatternModel model)
Creates a list of WizardPanelDescriptor objects associated with the pattern source file being read in. These descriptors identify the wizard steps involved and are used to create the wizard process structure. The data model is passed in as the components of the wizard are created here and need this reference.

Specified by:
getWizardDescriptors in interface PatternFileReader
Parameters:
model - the current data model.
Returns:
a list of WizardPanelDescriptor objects.