innoQ Logo

com.innoq.generator.jsp
Class JspBase

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

public abstract class JspBase
extends JspAbstractBase

Base class for all template classes. It provides some hooks to control the generation process. In particular you may specify the name of the file to generate by overwriting the methods getPrefix(char), getPostfix(), getPath(), and getFilename().

Additionally you may access the current model element through getElement() and the current metamodel through JspAbstractBase.getMetaModel().

Version:
$Id: JspBase.java,v 1.10 2004/09/21 14:45:39 mt Exp $
See Also:
JspMain, Serialized Form

Field Summary
 
Fields inherited from class com.innoq.generator.jsp.JspAbstractBase
TRANSFORMATION_PROPERTIES_KEY
 
Constructor Summary
JspBase()
           
 
Method Summary
 void addToAttributeList(java.lang.String key, java.lang.Object object)
          Adds an object to a List stored under a key.
 java.lang.Object getAttribute(java.lang.String key)
          Retrives an object using the key
 java.util.List getAttributeList(java.lang.String key)
          Returns a List of objects stored under a specific key using the method addToAttributeList(String, Object).
 java.lang.String getDirectory()
          Returns the directory you have defined as output directory.
 ru.novosoft.uml.MBase getElement()
          Returns the current model element.
 java.lang.String getFileExtension()
          Returns the file extension.
 java.lang.String getFilename()
          Creates the fully qualified filename.
 java.lang.String getName()
          Returns the name of the current model element.
 java.lang.String getName(ru.novosoft.uml.MBase modelElement)
          Returns the name of a given model element.
 java.lang.String getPath()
          Returns the complete path:
getPrefix(pSeparator, m) + metaModel.getNamespaceName(m, pSeparator) + getPostfix(pSeparator, m);
 java.lang.String getPath(char pSeparator)
          Returns the complete path: getPrefix(pSeparator, getElement()) + getMetaModel().getNamespaceName(getElement(), pSeparator) + getPostfix(pSeparator, getElement());
 java.lang.String getPath(char pSeparator, ru.novosoft.uml.MBase modelElement)
          Returns the complete path:
getPrefix(pSeparator, modelElement) + getModelElement().getNamespaceName(modelElement, pSeparator) + getPostfix(pSeparator, modelElement);
 java.lang.String getPostfix()
          Returns the postfix for the current model element.
 java.lang.String getPostfix(char pSeparator)
          Returns the postfix for the current model element.
 java.lang.String getPostfix(char pSeparator, ru.novosoft.uml.MBase modelElement)
          Returns the postfix for a given model element.
 java.lang.String getPrefix()
          Returns the prefix for the current model element.
 java.lang.String getPrefix(char pSeparator)
          Returns the postfix for the current model element.
 java.lang.String getPrefix(char pSeparator, ru.novosoft.uml.MBase modelElement)
          Returns the prefix for a given model element.
 ru.novosoft.uml.MBase getRoot()
          Returns the root model element.
 void setAttribute(java.lang.String key, java.lang.Object object)
          Stores an object using a key.
 
Methods inherited from class com.innoq.generator.jsp.JspAbstractBase
_jspService, addProperties, destroy, getMetaModel, getProperties, getProperty, getProperty, getServletConfig, init, init, isMainJSP, jspDestroy, jspInit, service, 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

JspBase

public JspBase()
Method Detail

addToAttributeList

public final void addToAttributeList(java.lang.String key,
                                     java.lang.Object object)
Adds an object to a List stored under a key. If the List does not exist yet, it is created.

Parameters:
key - Key a List of objects shall be stored under
object - Object that shall be appended to the list of objects stored under key
See Also:
getAttributeList(String)

getAttributeList

public final java.util.List getAttributeList(java.lang.String key)
Returns a List of objects stored under a specific key using the method addToAttributeList(String, Object).

Parameters:
key - key of the object list
Returns:
the list or null, if no list was stored under the given key
Throws:
java.lang.ClassCastException - if a different Object than a List was stores as attribute.
See Also:
addToAttributeList(String, Object)

setAttribute

public final void setAttribute(java.lang.String key,
                               java.lang.Object object)
Stores an object using a key. The Objects will be available in the current generation run only. Neither key nor object can be null

Parameters:
key - the key
object - the object to store
Throws:
java.lang.NullPointerException - if key or value are null
See Also:
getAttribute(String)

getAttribute

public final java.lang.Object getAttribute(java.lang.String key)
Retrives an object using the key

Parameters:
key - the key
Returns:
the object that is stored under the key, may be null
Throws:
java.lang.NullPointerException - if key or value are null
See Also:
setAttribute(String, Object)

getFilename

public java.lang.String getFilename()
Creates the fully qualified filename. Be careful to overwrite this method. The filename will be created like this: getDirectory() + File.separator + getPath(File.separatorChar, element) + File.separator + getName() + "." + getFileExtension();

Specified by:
getFilename in class JspAbstractBase
Returns:
filename.
See Also:
getDirectory(), getPath(), getName(), getFileExtension()

getName

public java.lang.String getName()
Returns the name of the current model element.

Specified by:
getName in class JspAbstractBase
See Also:
getElement()

getName

public java.lang.String getName(ru.novosoft.uml.MBase modelElement)
Returns the name of a given model element. Equivalent to getMetaModel().getName(modelElement).

Parameters:
modelElement - Model element.
Returns:
Name of model element.
See Also:
getName()

getElement

public ru.novosoft.uml.MBase getElement()
Returns the current model element.

Returns:
MBase model element.
See Also:
getName()

getRoot

public ru.novosoft.uml.MBase getRoot()
Returns the root model element.

Returns:
MBase model root.

getFileExtension

public java.lang.String getFileExtension()
Returns the file extension. E.g. "java". If you want the generated file to have a different file extension, you have to overwrite this method. E.g. "sql" for a SQL script.

Returns:
File extension, default: java.
See Also:
getFilename()

getDirectory

public java.lang.String getDirectory()
Returns the directory you have defined as output directory.

Returns:
Output directory, otherwise temp directory
See Also:
getFilename()

getPrefix

public java.lang.String getPrefix(char pSeparator)
Returns the postfix for the current model element. You can realize a project specific extension by overwriting this method. Your extension will be prepended to the namespace part of the path. "com" + pSeparator + "innoq" + pSeparator + "tutorial_1" + pSeparator;

Parameters:
pSeparator - Separator to be used.
See Also:
getPath(char, MBase)

getPostfix

public java.lang.String getPostfix(char pSeparator)
Returns the postfix for the current model element. You can realize a project specific extension by overwriting this method. Your extension will be appended to the namespace part of the path.

Parameters:
pSeparator - Separator to be used.
See Also:
getPath(char, MBase)

getPath

public java.lang.String getPath()
Returns the complete path:
getPrefix(pSeparator, m) + metaModel.getNamespaceName(m, pSeparator) + getPostfix(pSeparator, m);

See Also:
getPath(char, MBase)

getPostfix

public java.lang.String getPostfix()
Returns the postfix for the current model element. You can realize a project specific extension by overwriting this method. Your extension will be appended to the namespace part of the path.

See Also:
getPath(char, MBase)

getPrefix

public java.lang.String getPrefix()
Returns the prefix for the current model element. You can realize a project specific extension by overwriting this method. Your extension will be prepended to the namespace part of the path.

See Also:
getPath(char, MBase)

getPath

public java.lang.String getPath(char pSeparator)
Returns the complete path:

getPrefix(pSeparator, getElement()) + getMetaModel().getNamespaceName(getElement(), pSeparator) + getPostfix(pSeparator, getElement());

Returns:
the path of the file to generate
See Also:
getFilename()

getPath

public java.lang.String getPath(char pSeparator,
                                ru.novosoft.uml.MBase modelElement)
Returns the complete path:
getPrefix(pSeparator, modelElement) + getModelElement().getNamespaceName(modelElement, pSeparator) + getPostfix(pSeparator, modelElement);

Returns:
the path of the file to generate
See Also:
getFilename()

getPostfix

public java.lang.String getPostfix(char pSeparator,
                                   ru.novosoft.uml.MBase modelElement)
Returns the postfix for a given model element. You can realize a project specific extension by overwriting this method. Your extension will be appended to the namespace part of the path.

Parameters:
pSeparator - Separator to be used.
modelElement - Model element
Returns:
the default implementation returns an empty String ""

getPrefix

public java.lang.String getPrefix(char pSeparator,
                                  ru.novosoft.uml.MBase modelElement)
Returns the prefix for a given model element. You can realize a project specific extension by overwriting this method. Your extension will be prepended to the namespace part of the path.

Parameters:
pSeparator - Separator to be used.
modelElement - Model element
Returns:
the default implementation returns an empty String ""

innoQ Logo

iQgen Logo

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