blob: 09feb0868b514b3e39f95ced2be3d27806705169 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*******************************************************************************
* Copyright (c) 2006 CEA List.
* All rights reserved. This program and the accompanying materials
* are property of the CEA, their use is subject to specific agreement
* with the CEA.
*
* Contributors:
* CEA List - initial API and implementation
*******************************************************************************/
package org.eclipse.papyrus.cpp.codegen.jet.util;
import org.eclipse.uml2.uml.*;
public class CppTemplateBindingParameter
{
protected static String nl;
public static synchronized CppTemplateBindingParameter create(String lineSeparator)
{
nl = lineSeparator;
CppTemplateBindingParameter result = new CppTemplateBindingParameter();
nl = null;
return result;
}
public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
public String generate(Object argument)
{
final StringBuffer stringBuffer = new StringBuffer();
//////////////////////////////////////////////////////////////////////////////////////////
// Java preparation
//////////////////////////////////////////////////////////////////////////////////////////
// Retrieve the TemplateParameter
// Retrieve the TemplateParameter
TemplateParameterSubstitution currentTParam = (TemplateParameterSubstitution) argument;
String typeName = "";
if (currentTParam.getActual() == null) {
typeName ="param undefined";
}
else {
ParameterableElement actual = currentTParam.getActual();
if (actual instanceof LiteralInteger) {
typeName = "" + ((LiteralInteger) currentTParam.getActual()).getValue();
}
else {
typeName = ((NamedElement) currentTParam.getActual()).getName();
} // value = currentTParam.getFormal().getParameteredElement().getName();
}
//////////////////////////////////////////////////////////////////////////////////////////
// The following part contains the template
//////////////////////////////////////////////////////////////////////////////////////////
stringBuffer.append( typeName );
return stringBuffer.toString();
}
}
|