1 | private String generateClassifierAttributes(Object modelElement) { | | 1 | private String generateClassifierOperations(Object modelElement) { |
2 | if (!Model.getFacade().isAClassifier(modelElement)) { | | 2 | if (!Model.getFacade().isAClassifier(modelElement)) { |
3 | throw new ClassCastException(modelElement.getClass() | | 3 | throw new ClassCastException(modelElement.getClass() |
4 | + " has wrong object type, Classifier required"); | | 4 | + " has wrong object type, Classifier required"); |
5 | } | | 5 | } |
6 | | | 6 | |
7 | String sClsAttr = ""; | | 7 | String sClsOp = ""; |
8 | | | 8 | |
9 | if (Model.getFacade().isAClass(modelElement)) { | | 9 | sClsOp += INDENT + "// --- OPERATIONS ---\n"; |
10 | sClsAttr += INDENT + "// --- ATTRIBUTES ---\n"; | | 10 | |
11 | | | 11 | /* generate constructor */ |
12 | Collection colAttributes = | | 12 | Object objTaggedValue = |
13 | Model.getFacade().getAttributes(modelElement); | | 13 | Model.getFacade().getTaggedValue(modelElement, "constructor"); |
14 | | | 14 | if (objTaggedValue != null) { |
15 | if (colAttributes != null) { | | 15 | String sTaggedValueConstructor = |
16 | Iterator itAttributes = colAttributes.iterator(); | | 16 | Model.getFacade().getValueOfTag(objTaggedValue); |
17 | while (itAttributes.hasNext()) { | | 17 | |
18 | Object attr = itAttributes.next(); | | 18 | if (sTaggedValueConstructor != null |
19 | | | 19 | && sTaggedValueConstructor.equals("true")) { |
20 | sClsAttr += "\n"; | | 20 | if (findConstructor(modelElement) == null) { |
21 | | | 21 | String sConstructor = null; |
22 | PHPDocumentor objPHPDoc = null; | | 22 | |
23 | try { | | 23 | if (iLanguageMajorVersion < 5) { |
24 | objPHPDoc = new PHPDocumentor(attr); | | 24 | sConstructor = "function " + NameGenerator.generate( |
25 | } catch (Exception exp) { | | 25 | modelElement, iLanguageMajorVersion); |
26 | LOG.error("Generating attribute DocBlock FAILED: " | | 26 | } else { |
27 | + exp.getMessage()); | | 27 | sConstructor = "public function __construct"; |
28 | } finally { | | 28 | } |
29 | if (objPHPDoc != null) { | | 29 | |
30 | sClsAttr += objPHPDoc.toString(INDENT); | | 30 | sClsOp += "\n"; |
31 | } | | 31 | sClsOp += INDENT + "/**\n"; |
32 | } | | 32 | sClsOp += INDENT + " * Class constructor\n"; |
33 | | | 33 | sClsOp += INDENT + " *\n"; |
34 | sClsAttr += INDENT + generateAttribute(attr, false) + "\n"; | | 34 | sClsOp += INDENT + " * @access public\n"; |
35 | } | | 35 | sClsOp += INDENT + " *\n"; |
36 | } | | 36 | sClsOp += INDENT + " * @return void\n"; |
37 | | | 37 | sClsOp += INDENT + " *\n"; |
38 | sClsAttr += "\n"; | | 38 | sClsOp += INDENT + " * @author ArgoUML PHP Module" |
39 | } | | 39 | + " (revised $Date: 2010-01-12 20:15:17 +0100 (Tue, 12 Jan 2010) $)\n"; |
40 | | | 40 | sClsOp += INDENT + " */\n"; |
41 | return sClsAttr; | | 41 | |
42 | } | | 42 | sClsOp += INDENT + sConstructor + "()\n"; |
| | | 43 | sClsOp += INDENT + "{\n"; |
| | | 44 | sClsOp += generateSection(modelElement, INDENT, |
| | | 45 | sConstructor.substring(sConstructor.lastIndexOf(" "))); |
| | | 46 | sClsOp += INDENT + "}\n"; |
| | | 47 | } |
| | | 48 | } |
| | | 49 | } |
| | | 50 | |
| | | 51 | if (Model.getFacade().isAClass(modelElement)) { |
| | | 52 | for (Object spec : Model.getFacade() |
| | | 53 | .getSpecifications(modelElement)) { |
| | | 54 | for (Object operation : Model.getFacade().getOperations(spec)) { |
| | | 55 | sClsOp += "\n"; |
| | | 56 | |
| | | 57 | PHPDocumentor objPHPDoc = null; |
| | | 58 | try { |
| | | 59 | objPHPDoc = new PHPDocumentor(operation); |
| | | 60 | } catch (Exception exp) { |
| | | 61 | LOG.error("Generating operation DocBlock " + "FAILED: " |
| | | 62 | + exp.getMessage()); |
| | | 63 | } finally { |
| | | 64 | if (objPHPDoc != null) { |
| | | 65 | sClsOp += objPHPDoc.toString(INDENT); |
| | | 66 | } |
| | | 67 | } |
| | | 68 | |
| | | 69 | sClsOp += INDENT + generateOperation(operation, false); |
| | | 70 | sClsOp += generateMethodBody(operation, true); |
| | | 71 | } |
| | | 72 | } |
| | | 73 | } |
| | | 74 | |
| | | 75 | for (Object operation : Model.getFacade().getOperations(modelElement)) { |
| | | 76 | |
| | | 77 | sClsOp += "\n"; |
| | | 78 | PHPDocumentor objPHPDoc = null; |
| | | 79 | try { |
| | | 80 | objPHPDoc = new PHPDocumentor(operation); |
| | | 81 | } catch (Exception exp) { |
| | | 82 | LOG.error("Generating operation DocBlock FAILED: " |
| | | 83 | + exp.getMessage()); |
| | | 84 | } finally { |
| | | 85 | if (objPHPDoc != null) { |
| | | 86 | sClsOp += objPHPDoc.toString(INDENT); |
| | | 87 | } |
| | | 88 | } |
| | | 89 | |
| | | 90 | sClsOp += INDENT + generateOperation(operation, false); |
| | | 91 | |
| | | 92 | if (Model.getFacade().isAClass(modelElement)) { |
| | | 93 | sClsOp += generateMethodBody(operation, false); |
| | | 94 | } else { |
| | | 95 | if (iLanguageMajorVersion < 5) { |
| | | 96 | sClsOp += "\n" + INDENT + "{\n"; |
| | | 97 | sClsOp += INDENT + INDENT |
| | | 98 | + "die('abstract method called');\n"; |
| | | 99 | sClsOp += INDENT + "}\n"; |
| | | 100 | } else { |
| | | 101 | sClsOp += ";\n"; |
| | | 102 | } |
| | | 103 | } |
| | | 104 | } |
| | | 105 | |
| | | 106 | return sClsOp; |
| | | 107 | } |