ch.sahits.codegen.java.gui.input
Class XHTMLModelParser

java.lang.Object
  extended by ch.sahits.codegen.input.XMLJDomParser
      extended by ch.sahits.codegen.java.gui.input.XHTMLModelParser
All Implemented Interfaces:
IInputParser

public final class XHTMLModelParser
extends XMLJDomParser
implements IInputParser

This parser generates a IJavaForm model from a XHTML file. This parser can generate a model for a two or three column layout if they are of the form of testForm2Col.xhtml. A flow layout is also possible. For an example see testForm1Col.xhtml. Since a flow layout is unstructured, there are some constraints that are known. There my be others. If you come across an undocumented case check it out, and either add the case here or improve the parsing that it works. Known issues:

Since:
0.9.4
Author:
Andi Hotz

Field Summary
 
Fields inherited from class ch.sahits.codegen.input.XMLJDomParser
document, root
 
Constructor Summary
XHTMLModelParser()
           
 
Method Summary
protected  java.util.List<Element> collectRadioFields(Element parent, java.lang.String radioGroupName)
          Collect all radio buttons that are in the subtree of parent that belong to one and the same group
 java.lang.String getFileExtension()
          This class can parse XHTML files
 java.lang.String getParserName()
          Retrieve the name of this class
 int getRanking()
          This method rates the implementation.
 int getWorkload()
          Defines how complex the generation of the model is.
protected  boolean hasChild(Element elem, java.lang.String[] childNames)
          Check whether any of the elements children are of at least a given type
protected  boolean hasFormField(Element elem)
          Check if the element has a form field as a child.
 boolean hasTextWithFormField(Element elem)
          Check wether there is some form field with some text
 void init(java.lang.String inputFile)
          Since the namespace must be validated a connection error to the namespace can result in quircky errors that make no sense what so ever.
protected  boolean isFormField(Content elem)
          Check whether an element is of type form field.
protected  boolean isTextNode(Content cont)
          Check wether the element node is some sort of text node.
 EDBConnectionData needsDataBaseInformationForCompleetion()
          Indicate if the input file is self contained or if for compleetion of the model information from the second page is needed.
 IGeneratedJavaClass parse()
          Create a model object
 
Methods inherited from class ch.sahits.codegen.input.XMLJDomParser
getAllAttributes, getAllElements, getAttributeValue, getFirstElement, getPredecessor, hasChild, hasChild, hasText, lookup, setNamespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XHTMLModelParser

public XHTMLModelParser()
Method Detail

init

public void init(java.lang.String inputFile)
          throws java.lang.Exception
Since the namespace must be validated a connection error to the namespace can result in quircky errors that make no sense what so ever.

Specified by:
init in interface IInputParser
Overrides:
init in class XMLJDomParser
Parameters:
inputFile - Input parser
Throws:
java.lang.Exception - one of the following
java.io.IOException - Could not read from input file
java.net.MalformedURLException - malformed input file

getParserName

public java.lang.String getParserName()
Retrieve the name of this class

Overrides:
getParserName in class XMLJDomParser
Returns:
fully classified class name

getFileExtension

public java.lang.String getFileExtension()
This class can parse XHTML files

Specified by:
getFileExtension in interface IInputParser
Overrides:
getFileExtension in class XMLJDomParser
Returns:
xhtml

parse

public IGeneratedJavaClass parse()
Create a model object

Specified by:
parse in interface IInputParser
Overrides:
parse in class XMLJDomParser
Returns:
Instance of IGeneratedJavaClass

hasChild

protected boolean hasChild(Element elem,
                           java.lang.String[] childNames)
Check whether any of the elements children are of at least a given type

Parameters:
elem - element to be checked
childNames - array of accepted child names
Returns:
true if the element has at least on child with an accepted name
See Also:
XMLJDomParser.hasChild(Element, String)

hasFormField

protected boolean hasFormField(Element elem)
Check if the element has a form field as a child. Accepted fields are "input","textarea","button","select".

Parameters:
elem - element to be checked
Returns:
true if a child is found

isFormField

protected boolean isFormField(Content elem)
Check whether an element is of type form field. Accepted fields are "input","textarea","button","select".

Parameters:
elem - element to be checked
Returns:
true if the element is of on of the accepted types

hasTextWithFormField

public boolean hasTextWithFormField(Element elem)
Check wether there is some form field with some text

Parameters:
elem - Element to be checked
Returns:
true if the element contains text and a form field (not recursive)

isTextNode

protected boolean isTextNode(Content cont)
Check wether the element node is some sort of text node. Text nodes are:

Parameters:
cont - Content element to be checked to be checked (Should be either of type Text or Element
Returns:
true if elem is a text node that contains actual text (witspaces, carrage return, tabs are ignored)

collectRadioFields

protected java.util.List<Element> collectRadioFields(Element parent,
                                                     java.lang.String radioGroupName)
Collect all radio buttons that are in the subtree of parent that belong to one and the same group

Parameters:
parent - node to start the search
radioGroupName - name of the radio group
Returns:
List of radio button elements

getWorkload

public int getWorkload()
Defines how complex the generation of the model is.

Specified by:
getWorkload in interface IInputParser
Returns:
Number of work steps

getRanking

public int getRanking()
This method rates the implementation. Since this Interface is used for an extension point Implementations with the highest ranking are choosen. Since this is the default implementation the ranking is low

Specified by:
getRanking in interface IInputParser
Overrides:
getRanking in class XMLJDomParser
Returns:
1

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.

Specified by:
needsDataBaseInformationForCompleetion in interface IInputParser
Returns: