Dresden OCL Toolkit

tudresden.ocl.codegen.decl
Class CodeAgent

java.lang.Object
  extended bytudresden.ocl.codegen.decl.CodeAgent

public class CodeAgent
extends Object

Chooses code templates from a XML file that relates to a given specification.

Author:
Sten Loecher

Field Summary
(package private)  Hashtable arguments
           
(package private) static String ATTRID
           
(package private) static String CONNECTOR
           
(package private)  boolean connectorEnabled
           
(package private) static String CONTRUE
           
(package private) static String LI
           
(package private) static String MISARG
           
(package private) static String MISPARNAME
           
(package private) static String NAME
           
(package private) static String NOPATTERN
           
(package private) static String NOTEMPLATE
           
(package private) static String PARAM
           
(package private) static String RULE
           
(package private)  String ruleAndSpec
           
(package private) static String SPEC
           
(package private) static String TAGPATTERN
           
(package private) static String TEMPLATE
           
(package private)  Document xmlDocument
           
(package private) static String XMLFILE
           
(package private)  org.apache.xerces.parsers.DOMParser xmlParser
           
(package private)  NodeList xmlPattern
           
 
Constructor Summary
CodeAgent(String rules)
          Creates a CodeAgent object.
 
Method Summary
 void enableConnector()
          Enables connector lines.
private  String getCode(Node template)
           
 String getCodeFor(String rule, String spec)
           
private  Node getPatternForRule(String rule)
           
private  Node getTemplateForSpec(Node pattern, String spec)
           
static void main(String[] args)
           
 void reset()
          Cleans up the CodeAgent object.
 void setArgument(String argSpec, String argCont)
          Adds an argument specification to the current state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arguments

Hashtable arguments

xmlParser

org.apache.xerces.parsers.DOMParser xmlParser

xmlDocument

Document xmlDocument

xmlPattern

NodeList xmlPattern

connectorEnabled

boolean connectorEnabled

ruleAndSpec

String ruleAndSpec

TAGPATTERN

static final String TAGPATTERN
See Also:
Constant Field Values

XMLFILE

static final String XMLFILE
See Also:
Constant Field Values

ATTRID

static final String ATTRID
See Also:
Constant Field Values

RULE

static final String RULE
See Also:
Constant Field Values

CONNECTOR

static final String CONNECTOR
See Also:
Constant Field Values

CONTRUE

static final String CONTRUE
See Also:
Constant Field Values

NOPATTERN

static final String NOPATTERN
See Also:
Constant Field Values

NOTEMPLATE

static final String NOTEMPLATE
See Also:
Constant Field Values

TEMPLATE

static final String TEMPLATE
See Also:
Constant Field Values

SPEC

static final String SPEC
See Also:
Constant Field Values

LI

static final String LI
See Also:
Constant Field Values

PARAM

static final String PARAM
See Also:
Constant Field Values

NAME

static final String NAME
See Also:
Constant Field Values

MISARG

static final String MISARG
See Also:
Constant Field Values

MISPARNAME

static final String MISPARNAME
See Also:
Constant Field Values
Constructor Detail

CodeAgent

public CodeAgent(String rules)
Creates a CodeAgent object.

Parameters:
rules - the URL of the file containing the mapping rules
Method Detail

main

public static void main(String[] args)

setArgument

public void setArgument(String argSpec,
                        String argCont)
Adds an argument specification to the current state.

Parameters:
argSpec - the name or placeholder of the argument
argCont - the replacement for the placeholder in the template

getCodeFor

public String getCodeFor(String rule,
                         String spec)
                  throws Exception
Parameters:
rule - the name of the grammar rule
spec - a specification that determines the template more precisely
Returns:
a code template with replaced placeholders
Throws:
Exception

reset

public void reset()
Cleans up the CodeAgent object. That is, deleting all arguments and disabling connector lines.


enableConnector

public void enableConnector()
Enables connector lines.


getPatternForRule

private Node getPatternForRule(String rule)

getTemplateForSpec

private Node getTemplateForSpec(Node pattern,
                                String spec)

getCode

private String getCode(Node template)
                throws Exception
Throws:
Exception

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.