1 package com.proalpha.pds.templates.jet.openEdge;
3 import com.openedge.pdt.core.template.ITemplateGenerator;
4 import com.openedge.pdt.core.template.TemplateGenerationException;
5 import com.openedge.pdt.text.template.OETemplateUtil;
6 import com.openedge.pdt.core.template.ITemplateArgs;
8 import com.openedge.core.metadata.OOABLProperty;
9 import com.openedge.core.metadata.ReferenceProperty;
10 import com.openedge.core.metadata.DataTypeProperty;
11 import com.openedge.core.metadata.Mode;
15 protected static String nl;
16 public static synchronized pAProperty create(String lineSeparator)
24 public final String NL = nl ==
null ? (System.getProperties().getProperty(
"line.separator")) : nl;
25 protected final String TEXT_1 =
" ";
26 protected final String TEXT_2 = NL +
" define ";
27 protected final String TEXT_3 =
" property ";
28 protected final String TEXT_4 =
" as ";
29 protected final String TEXT_5 =
" ";
30 protected final String TEXT_6 = NL +
"\t";
31 protected final String TEXT_7 =
"get():" + NL +
"" + NL +
" end get." + NL +
" ";
32 protected final String TEXT_8 =
"get.";
33 protected final String TEXT_9 =
"set(input arg as ";
34 protected final String TEXT_10 =
"):" + NL +
"" + NL +
" end set.";
35 protected final String TEXT_11 =
"set.";
36 protected final String TEXT_12 = NL +
" ";
41 public String generate(ITemplateArgs argument)
throws TemplateGenerationException
43 final StringBuffer stringBuffer =
new StringBuffer();
45 OOABLProperty data = (OOABLProperty) argument.getObj(
"propertyinfo");
46 ReferenceProperty refProperty =
null;
47 DataTypeProperty dataTypeProperty =
null;
48 if (data instanceof ReferenceProperty)
49 refProperty = (ReferenceProperty) data;
50 if (data instanceof DataTypeProperty)
51 dataTypeProperty = (DataTypeProperty) data;
53 stringBuffer.append(TEXT_1);
54 stringBuffer.append(OETemplateUtil.generateAnnotations(data.getAnnotations(), NL));
55 stringBuffer.append(TEXT_2);
56 stringBuffer.append(Mode.ACESSORS[data.getMode()]);
57 stringBuffer.append( data.isStatic()?
" static":
"");
58 stringBuffer.append(TEXT_3);
59 stringBuffer.append(data.getName());
60 if(dataTypeProperty !=
null) {
61 stringBuffer.append(TEXT_4);
62 stringBuffer.append(dataTypeProperty.getType());
63 stringBuffer.append(TEXT_5);
64 stringBuffer.append(dataTypeProperty.isInitial()?
"initial "+dataTypeProperty.getInitialValue()+
" ":
"" );
65 stringBuffer.append(dataTypeProperty.isNoUndo()?
"no-undo":
"");
66 }
else if (refProperty !=
null) {
67 stringBuffer.append(TEXT_4);
68 stringBuffer.append(OETemplateUtil.isProgressKeyWord(refProperty.getType())?
"class":
"" );
69 stringBuffer.append(TEXT_5);
70 stringBuffer.append(refProperty.getType());
71 stringBuffer.append(TEXT_5);
72 stringBuffer.append(refProperty.isNoUndo()?
" no-undo":
"");
73 stringBuffer.append(TEXT_5);
76 stringBuffer.append(TEXT_6);
77 stringBuffer.append((data.getGetMode() < data.getMode())?Mode.ACESSORS[data.getGetMode()] +
" ":
"");
78 if (data.isGetBody()) {
79 stringBuffer.append(TEXT_7);
81 stringBuffer.append(TEXT_8);
84 stringBuffer.append((data.getSetMode() < data.getMode())?Mode.ACESSORS[data.getSetMode()] +
" ":
"");
85 if (data.isSetBody()) {
86 stringBuffer.append(TEXT_9);
87 stringBuffer.append(data.getType());
88 stringBuffer.append(TEXT_10);
90 stringBuffer.append(TEXT_11);
92 stringBuffer.append(TEXT_12);
93 return stringBuffer.toString();