ch.sahits.codegen.php
Class PHPXMLInputParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by ch.sahits.codegen.php.PHPXMLInputParser
All Implemented Interfaces:
IInputParser, IXMLGeneralInputFileParser, IXMLInputFileParser, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class PHPXMLInputParser
extends org.xml.sax.helpers.DefaultHandler
implements IXMLGeneralInputFileParser

XML Parser vor the PHP input file that conforms to http://sahits.ch/xsd/phpClassTemplate.xsd

Since:
2.1.0
Author:
Andi Hotz, Sahits GmbH

Constructor Summary
PHPXMLInputParser()
          Initialize the Parser and do the work
 
Method Summary
 void characters(char[] ch, int start, int length)
          Handle the text according to the parent tag
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 IGeneratedObject generateModel()
          Generate the IPHPModel
 java.lang.String getFileExtension()
          This parser parses XML files
 int getRanking()
          The ranking for xml input parsers is ignored since each xml file must specify the parser
 int getWorkload()
          Retrieve the workload of the parsing
 void ignorableWhitespace(char[] ch, int start, int length)
          Pass throught to characters(char[], int, int) to ensure no whitespaces are ignored
 void init(java.lang.String path2xml)
          Initialize the parser
 boolean isInitialized()
          Check if the parser is initialized
 EDBConnectionData needsDataBaseInformationForCompleetion()
          Indicate if the input file is self contained or if for compleetion of the model information from the second page is needed.
 IGeneratedObject parse()
          This method is depricated use the appropriate generateModel method instead.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Event for starting tag
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PHPXMLInputParser

public PHPXMLInputParser()
Initialize the Parser and do the work

Method Detail

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Event for starting tag

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Handle the text according to the parent tag

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Pass throught to characters(char[], int, int) to ensure no whitespaces are ignored

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.ignorableWhitespace(char[], int, int)

getWorkload

public int getWorkload()
Retrieve the workload of the parsing

Specified by:
getWorkload in interface IInputParser
Returns:
30

init

public void init(java.lang.String path2xml)
Initialize the parser

Specified by:
init in interface IInputParser
Parameters:
path2xml - path to the XML file

isInitialized

public boolean isInitialized()
Check if the parser is initialized

Specified by:
isInitialized in interface IXMLInputFileParser
Returns:
true, if the parser is initialized

generateModel

public IGeneratedObject generateModel()
Generate the IPHPModel

Specified by:
generateModel in interface IXMLGeneralInputFileParser
Returns:
Instance of the IPHPModel

getFileExtension

public java.lang.String getFileExtension()
This parser parses XML files

Specified by:
getFileExtension in interface IInputParser
Returns:
xml

parse

public IGeneratedObject parse()
This method is depricated use the appropriate generateModel method instead.

Specified by:
parse in interface IInputParser
Specified by:
parse in interface IXMLGeneralInputFileParser
Returns:
null

getRanking

public int getRanking()
The ranking for xml input parsers is ignored since each xml file must specify the parser

Specified by:
getRanking in interface IInputParser
Returns:
0

needsDataBaseInformationForCompleetion

public EDBConnectionData needsDataBaseInformationForCompleetion()
Indicate if the input file is self contained or if for compleetion of the model information from the second page is needed. This parser combines a database model and a PHP model. The PHP model is generated through the XML input file and the database model must be supplied by the second page.

Specified by:
needsDataBaseInformationForCompleetion in interface IInputParser
Returns:
true if data from the second page is needed