Java Doc for BaseTranslator.java in  » UML » AndroMDA-3.2 » org » andromda » translation » ocl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » AndroMDA 3.2 » org.andromda.translation.ocl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.andromda.translation.ocl.BaseTranslator

All known Subclasses:   org.andromda.translation.ocl.testsuite.TraceTranslator,  org.andromda.translation.ocl.validation.ValidationJavaTranslator,  org.andromda.translation.ocl.query.QueryTranslator,  org.andromda.translation.ocl.testsuite.ContextElementFinder,
BaseTranslator
abstract public class BaseTranslator extends DepthFirstAdapter implements Translator(Code)
The "base" translator which all Translator's should extend, provides some basic functionality, such as the retrieveal of translation fragments from the translation template file, pre-processing, post-processing, etc.

The primary methods (in addition to methods you'll extend to handle expression parsing) to take note of when extending this class are:


author:
   Chad Brandon


Field Summary
protected  Loggerlogger
     The logger instance that can be used by all decendant classes.


Method Summary
public  ObjectgetContextElement()
     Returns the context element for the expression being translated.
public  ExpressiongetExpression()
     Returns the current value of the Expression.
protected  OperationDeclarationgetOperation()
     Gets the operation declaration of the constraint (if the context is an operation), otherwise returns null.
protected  StringgetTranslationFragment(String fragmentName)
     Finds the "fragment" with the specified fragmentName from the library translation file.

IMPORTANT: as a best practice, it is recommended that you use handleTranslationFragment(Node node) if at all possible (instead of this method), it will help your code be cleaner and the methods smaller and more maintainable.

protected  voidhandleTranslationFragment(Object node)
     Calls the handlerMethod defined on the <fragment/> element if fragmentName matches one the fragments defined within the current translation file.

A handlerMethod must have two arguments:

  1. The first argument must be a java.lang.String which will be the body of the corresponding kind element for the matching fragment.
public  voidinAClassifierContextDeclaration(AClassifierContextDeclaration declaration)
     Sets the element type which represents the context of the expression for expressions having classifiers as their context.
public  voidinADefClassifierExpressionBody(ADefClassifierExpressionBody expressionBody)
     Sets the kind and name of the expression for def expressions.
public  voidinAInvClassifierExpressionBody(AInvClassifierExpressionBody expressionBody)
     Sets the kind and name of the expression for inv expressions.
public  voidinAOperationContextDeclaration(AOperationContextDeclaration declaration)
     Sets the element type which represents the context of the expression for expressions having operations as their context.
public  voidinAOperationExpressionBody(AOperationExpressionBody operationExpressionBody)
     Sets the kind and name of the expression for operation contexts.
protected  booleanisOperationArgument(String argument)
     Indicates if the given argument is an operation argument (if the context declaration is an operation)
Parameters:
  argument - the argument to check.
public  voidpostProcess()
     Performs any post processing.
public  voidpreProcess()
     Performs any initlization.
protected  voidprocess(String expression)
     Parses the expression and applies this Translator to it.
public  Expressiontranslate(String translationName, String expression, Object contextElement)
    

NOTE: null is allowed for contextElement (even though it isn't within ExpressionTranslator.translate() since the TraceTranslator doesn't need a contextElement and we don't want to slow down the trace by having to read and load a model each time.


Field Detail
logger
protected Logger logger(Code)
The logger instance that can be used by all decendant classes.





Method Detail
getContextElement
public Object getContextElement()(Code)
Returns the context element for the expression being translated. the context element.



getExpression
public Expression getExpression()(Code)
Returns the current value of the Expression. This stores the translation being translated. Expression stores the the translation.



getOperation
protected OperationDeclaration getOperation()(Code)
Gets the operation declaration of the constraint (if the context is an operation), otherwise returns null. the operation declaration or null.



getTranslationFragment
protected String getTranslationFragment(String fragmentName)(Code)
Finds the "fragment" with the specified fragmentName from the library translation file.

IMPORTANT: as a best practice, it is recommended that you use handleTranslationFragment(Node node) if at all possible (instead of this method), it will help your code be cleaner and the methods smaller and more maintainable.

Will retrieve the contents of the fragment kind that corresponds to the kind of expression currently being translated. (i.e. if 'context LegalAgreement inv: allInstances -> isUnique(documentTitle')' is being translated, then the body of the element <kind name="inv"> would be returned).

NOTE: You would use this method instead of handleTranslationFragment(Node node) if you just want to retrieve the value of the fragment and don't want to have a handlerMethod which actually handles the processing of the output. For example you may want to add a fragment called 'constraintTail' which would always be added to your translation at the end of the constraint, the 'tail'. There isn't any part of the expression that matches this, but you still want to store it in a translation template since it could be different between translations within your Translation-Library.


Parameters:
  fragmentName - the name of the fragment to retrieve from the translation String the output String from the translated fragment.
See Also:   BaseTranslator.handleTranslationFragment(Node node)



handleTranslationFragment
protected void handleTranslationFragment(Object node)(Code)
Calls the handlerMethod defined on the <fragment/> element if fragmentName matches one the fragments defined within the current translation file.

A handlerMethod must have two arguments:

  1. The first argument must be a java.lang.String which will be the body of the corresponding kind element for the matching fragment. (i.e. if 'context LegalAgreement inv: allInstances -> isUnique(documentTitle')' is being translated, then the body of the element <kind name="inv"/> would be returned)
  2. The second argument is of type java.lang.Object and is the node that is currently being parsed at the time the matching of the fragmentName occurred.

For example this handlerMethod might be defined within your translation file to handle the 'allInstances' expression:

 

<fragment name="(\s*${elementName}\s*\.)?\s*allInstances.*" handlerMethod="handleAllInstances"> <kind name="body"> from $completeElementName as $lowerCaseElementName </kind> </fragment>

And the implementation of the handleAllInstances method would be:

 public void handleAllInstances(String translation, Object node)
 {
 //some handling code
 }
 


Parameters:
  node - the node being parsed, the toString value of this node is what is matched against the translationfragment. We also need to pass the node to our
handlerMethod so that itcan be used it for additional processing (if we need it).
See Also:    getTranslationFragment(java.lang.String)



inAClassifierContextDeclaration
public void inAClassifierContextDeclaration(AClassifierContextDeclaration declaration)(Code)
Sets the element type which represents the context of the expression for expressions having classifiers as their context. If subclasses override this method, they MUST call this method before their own implementation.
Parameters:
  declaration - the AClassifierContextDeclaration instance from which we retrieve the element type.



inADefClassifierExpressionBody
public void inADefClassifierExpressionBody(ADefClassifierExpressionBody expressionBody)(Code)
Sets the kind and name of the expression for def expressions. If subclasses override this method, they MUST call this method before their own implementation.
Parameters:
  expressionBody -



inAInvClassifierExpressionBody
public void inAInvClassifierExpressionBody(AInvClassifierExpressionBody expressionBody)(Code)
Sets the kind and name of the expression for inv expressions. If subclasses override this method, they MUST call this method before their own implementation.
Parameters:
  expressionBody -



inAOperationContextDeclaration
public void inAOperationContextDeclaration(AOperationContextDeclaration declaration)(Code)
Sets the element type which represents the context of the expression for expressions having operations as their context. If subclasses override this method, they MUST call this method before their own implementation.
Parameters:
  declaration - the AOperationContextDeclaration instance from which we retrieve the element type.



inAOperationExpressionBody
public void inAOperationExpressionBody(AOperationExpressionBody operationExpressionBody)(Code)
Sets the kind and name of the expression for operation contexts. If subclasses override this method, they MUST call this method before their own implementation.
Parameters:
  operationExpressionBody -



isOperationArgument
protected boolean isOperationArgument(String argument)(Code)
Indicates if the given argument is an operation argument (if the context declaration is an operation)
Parameters:
  argument - the argument to check. true/false



postProcess
public void postProcess()(Code)
Performs any post processing. Subclasses should override to perform any final cleanup/processing.



preProcess
public void preProcess()(Code)
Performs any initlization. Subclasses should override this method if they want to provide any initilization before translation begins.



process
protected void process(String expression) throws IOException(Code)
Parses the expression and applies this Translator to it.
Parameters:
  expression - the expression to process.
throws:
  IOException - if an IO error occurs during processing.



translate
public Expression translate(String translationName, String expression, Object contextElement)(Code)

NOTE: null is allowed for contextElement (even though it isn't within ExpressionTranslator.translate() since the TraceTranslator doesn't need a contextElement and we don't want to slow down the trace by having to read and load a model each time.


See Also:   org.andromda.core.translation.ExpressionTranslator.translate(java.lang.Stringjava.lang.Objectjava.lang.String)



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.