| 1 | package de.uka.ipd.sdq.pcmbench.ui.provider; |
| 2 | |
| 3 | import de.uka.ipd.sdq.pcm.repository.CollectionDataType; |
| 4 | import de.uka.ipd.sdq.pcm.repository.CompositeDataType; |
| 5 | import de.uka.ipd.sdq.pcm.repository.InfrastructureSignature; |
| 6 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
| 7 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
| 8 | import de.uka.ipd.sdq.pcm.repository.PrimitiveDataType; |
| 9 | import de.uka.ipd.sdq.pcm.repository.util.RepositorySwitch; |
| 10 | |
| 11 | public class SignaturePrinter extends RepositorySwitch<String> { |
| 12 | |
| 13 | |
| 14 | @Override |
| 15 | public String caseCollectionDataType(CollectionDataType object) { |
| 16 | return this.doSwitch(object.getInnerType_CollectionDataType())+"[]"; |
| 17 | } |
| 18 | |
| 19 | @Override |
| 20 | public String caseCompositeDataType(CompositeDataType object) { |
| 21 | return object.getEntityName(); |
| 22 | } |
| 23 | |
| 24 | @Override |
| 25 | public String casePrimitiveDataType(PrimitiveDataType object) { |
| 26 | return object.getType().getLiteral().toLowerCase(); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public String caseParameter(Parameter object) { |
| 31 | String result = ""; |
| 32 | if (object.getDataType__Parameter() != null){ |
| 33 | result += this.doSwitch(object.getDataType__Parameter()); |
| 34 | } else { |
| 35 | result += "void"; |
| 36 | } |
| 37 | result += " " + object.getParameterName(); |
| 38 | return result; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public String caseOperationSignature(OperationSignature object) { |
| 43 | String result = ""; |
| 44 | if (object.getReturnType__OperationSignature() != null) |
| 45 | result += this.doSwitch(object.getReturnType__OperationSignature()); |
| 46 | else |
| 47 | result += "void"; |
| 48 | result += " " + object.getEntityName() + "("; |
| 49 | for (Parameter p : object.getParameters__OperationSignature()) { |
| 50 | result += this.doSwitch(p) + ", "; |
| 51 | } |
| 52 | if (object.getParameters__OperationSignature().size() > 0) |
| 53 | result = result.substring(0, result.length()-2); |
| 54 | result += ")"; |
| 55 | return result; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public String caseInfrastructureSignature(InfrastructureSignature object) { |
| 60 | String result = ""; |
| 61 | result += object.getEntityName() + "("; |
| 62 | for (Parameter p : object.getParameters__InfrastructureSignature()) { |
| 63 | result += this.doSwitch(p) + ", "; |
| 64 | } |
| 65 | if (object.getParameters__InfrastructureSignature().size() > 0) |
| 66 | result = result.substring(0, result.length()-2); |
| 67 | result += ")"; |
| 68 | return result; |
| 69 | } |
| 70 | } |