innoQ Logo

com.innoq.generator.jsp
Class JspMain

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.innoq.generator.jsp.JspAbstractBase
              extended bycom.innoq.generator.jsp.JspBase
                  extended bycom.innoq.generator.jsp.JspMain
All Implemented Interfaces:
javax.servlet.jsp.HttpJspPage, javax.servlet.jsp.JspPage, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class JspMain
extends JspBase

Base class of the master template. Depending on model elements you are able to define specific templates for generation. You have to overwrite getTemplates(MBase).

Example:

<%! public String[] getTemplates(MBase element) { String s = getMetaModel().getStereotype(element); String name = getMetaModel().getName(element); if ("Persistent".equals(s)) { return new String[]{"class.jsp", "drop_and_create.jsp"}; } else if (getMetaModel().isInterface(element)) { return new String[]{"interface.jsp"}; } else { return new String[]{"class.jsp"}; } } %>

Version:
$Id: JspMain.java,v 1.27 2004/10/04 16:00:59 mt Exp $
See Also:
Serialized Form

Nested Class Summary
static class JspMain.GenerationResult
           
 
Field Summary
 
Fields inherited from class com.innoq.generator.jsp.JspAbstractBase
TRANSFORMATION_PROPERTIES_KEY
 
Constructor Summary
JspMain()
           
 
Method Summary
 void addToElementsForGeneration(java.util.Collection pCollection)
          Adds a complete list of elements to generation.
 void addToElementsForGeneration(java.lang.Object pObject)
          Adds an element to list of elements for generation.
 void addToPart(java.lang.String pKey, java.lang.Object pElement)
          Deprecated. Use JspBase.addToAttributeList(String, Object) instead
 boolean canBeGenerated(ru.novosoft.uml.MBase modelElement)
          Defines for which elements the generation should be executed.
 boolean doPreprocessing()
          Hook method - main templates that use preprocessing must overwrite this method to return true
 FileContext getContext()
          Returns the context.
abstract  java.lang.String getName()
          Returns the transformation name.
 java.lang.String[] getPostprocessTemplates()
          Returns an array of templates that should be executed without a specific model element after all the templates returned by getTemplates(MBase) have been executed.
 java.lang.String[] getTemplates(ru.novosoft.uml.MBase modelElement)
          Returns the templates for a model element.
 java.lang.String[] getTemplates(java.lang.Object modelElement)
          Returns the templates for a model element.
 boolean isMainJSP()
           
 boolean isModelChanged()
          Indicates whether the model has changed.
 com.innoq.generator.logging.ValidationMessage isValid(ru.novosoft.uml.MBase modelElement)
          Hook which is called for every Modellelement before the generation run starts.
 void preprocessElements(ru.novosoft.uml.MBase modelElement)
          Hook which is called for every Modellelement before the generation run starts.
 void preprocessElements(java.lang.Object modelElement)
          Hook which is called for every Modellelement before the generation run starts.
 void removeFromElementsForGeneration(java.util.Collection pCollection)
          Remove a complete list from elements for generation.
 void removeFromElementsForGeneration(java.lang.Object pObject)
          Remove an element from list for generation.
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Service method of JSP.
 void setModelChanged(boolean pModelChanged)
          Sets the model changed status.
 
Methods inherited from class com.innoq.generator.jsp.JspBase
addToAttributeList, getAttribute, getAttributeList, getDirectory, getElement, getFileExtension, getFilename, getName, getPath, getPath, getPath, getPostfix, getPostfix, getPostfix, getPrefix, getPrefix, getPrefix, getRoot, setAttribute
 
Methods inherited from class com.innoq.generator.jsp.JspAbstractBase
_jspService, addProperties, destroy, getMetaModel, getProperties, getProperty, getProperty, getServletConfig, init, init, jspDestroy, jspInit, setMetaModel, setProperties, setProperty
 
Methods inherited from class javax.servlet.http.HttpServlet
service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, log, log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.Servlet
getServletInfo, service
 

Constructor Detail

JspMain

public JspMain()
Method Detail

doPreprocessing

public boolean doPreprocessing()
Hook method - main templates that use preprocessing must overwrite this method to return true

Returns:
boolean indicating if preprocessing should be activated
See Also:
preprocessElements(MBase), preprocessElements(Object)

preprocessElements

public void preprocessElements(ru.novosoft.uml.MBase modelElement)
Hook which is called for every Modellelement before the generation run starts. This is the interface to collect any model information prior to generation

Parameters:
modelElement - element modelElement
See Also:
preprocessElements(Object), doPreprocessing()

preprocessElements

public void preprocessElements(java.lang.Object modelElement)
Hook which is called for every Modellelement before the generation run starts. This is the interface to collect any model information prior to generation

Parameters:
modelElement - element modelElement.
See Also:
preprocessElements(MBase), doPreprocessing()

isValid

public com.innoq.generator.logging.ValidationMessage isValid(ru.novosoft.uml.MBase modelElement)
Hook which is called for every Modellelement before the generation run starts. This is the interface to check if every model element is valid against the uml profile.

Parameters:
modelElement - element modelElement.
See Also:
preprocessElements(MBase), doPreprocessing()

getTemplates

public java.lang.String[] getTemplates(ru.novosoft.uml.MBase modelElement)
Returns the templates for a model element. To write a valid master template you have to implement this method.

Parameters:
modelElement - element modelElement.
Returns:
list of JSP-templates
See Also:
getPostprocessTemplates(), getName()

getTemplates

public java.lang.String[] getTemplates(java.lang.Object modelElement)
Returns the templates for a model element. To write a valid master template you have to implement this method.

Parameters:
modelElement - element modelElement.
Returns:
list of JSP-templates
See Also:
getPostprocessTemplates(), getName()

getName

public abstract java.lang.String getName()
Returns the transformation name. To write a valid master template you have to implement this method.

Overrides:
getName in class JspBase
Returns:
Name of transformation.
See Also:
JspBase.getElement()

getPostprocessTemplates

public java.lang.String[] getPostprocessTemplates()
Returns an array of templates that should be executed without a specific model element after all the templates returned by getTemplates(MBase) have been executed.

This is ideal for generating makefiles.

Returns:
array of templatenames, default it an empty array
See Also:
getTemplates(MBase)

isModelChanged

public boolean isModelChanged()
Indicates whether the model has changed.

Returns:
model change status
See Also:
setModelChanged(boolean)

setModelChanged

public void setModelChanged(boolean pModelChanged)
Sets the model changed status.

Parameters:
pModelChanged - value of status
See Also:
isModelChanged()

canBeGenerated

public boolean canBeGenerated(ru.novosoft.uml.MBase modelElement)
Defines for which elements the generation should be executed. You can overwrite this method, if the behavior should be different from the default. The default returns true only for classes and interfaces:

getMetaModel().isClass(modelElement) || getMetaModel().isInterface(modelElement);

Parameters:
modelElement - Element to check for.
Returns:
false, if no generation, otherwise true

addToPart

public final void addToPart(java.lang.String pKey,
                            java.lang.Object pElement)
Deprecated. Use JspBase.addToAttributeList(String, Object) instead


getContext

public final FileContext getContext()
Returns the context.

Returns:
request context.
See Also:
JspBase.getAttributeList(String), JspBase.addToAttributeList(String, Object)

service

public final void service(javax.servlet.http.HttpServletRequest req,
                          javax.servlet.http.HttpServletResponse res)
                   throws javax.servlet.ServletException,
                          java.io.IOException
Service method of JSP.

This method will be called by the container. Do not call it yourself!

Overrides:
service in class JspAbstractBase
Throws:
javax.servlet.ServletException
java.io.IOException

removeFromElementsForGeneration

public void removeFromElementsForGeneration(java.lang.Object pObject)
Remove an element from list for generation.

Parameters:
pObject -

removeFromElementsForGeneration

public void removeFromElementsForGeneration(java.util.Collection pCollection)
Remove a complete list from elements for generation.

Parameters:
pCollection -

addToElementsForGeneration

public void addToElementsForGeneration(java.lang.Object pObject)
Adds an element to list of elements for generation.

Parameters:
pObject -

addToElementsForGeneration

public void addToElementsForGeneration(java.util.Collection pCollection)
Adds a complete list of elements to generation.

Parameters:
pCollection -

isMainJSP

public boolean isMainJSP()
Overrides:
isMainJSP in class JspAbstractBase

innoQ Logo

iQgen Logo

Copyright © 2001-2004 innoQ GmbH. Alle Rechte vorbehalten. All Rights Reserved.