Coverage Report - org.argouml.model.euml.DataTypesFactoryEUMLImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DataTypesFactoryEUMLImpl
0%
0/30
0%
0/6
1.722
 
 1  
 // $Id: DataTypesFactoryEUMLImpl.java 18698 2010-08-28 10:11:16Z bobtarling $
 2  
 /*******************************************************************************
 3  
  * Copyright (c) 2007,2010 Tom Morris and other contributors
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    Tom Morris - initial implementation
 11  
  *    Bogdan Pistol - multiplicity workaround 
 12  
  *******************************************************************************/
 13  
 package org.argouml.model.euml;
 14  
 
 15  
 import java.util.List;
 16  
 
 17  
 import org.argouml.model.AbstractModelFactory;
 18  
 import org.argouml.model.DataTypesFactory;
 19  
 import org.argouml.model.NotImplementedException;
 20  
 import org.eclipse.uml2.uml.OpaqueExpression;
 21  
 import org.eclipse.uml2.uml.UMLFactory;
 22  
 
 23  
 /**
 24  
  * The implementation of the DataTypesFactory for EUML2.
 25  
  */
 26  0
 class DataTypesFactoryEUMLImpl implements DataTypesFactory,
 27  
         AbstractModelFactory {
 28  
 
 29  
     /**
 30  
      * The model implementation.
 31  
      */
 32  
     private EUMLModelImplementation modelImpl;
 33  
 
 34  
     /**
 35  
      * Constructor.
 36  
      *
 37  
      * @param implementation The ModelImplementation.
 38  
      */
 39  0
     public DataTypesFactoryEUMLImpl(EUMLModelImplementation implementation) {
 40  0
         modelImpl = implementation;
 41  0
     }
 42  
 
 43  
     public Object createActionExpression(String language, String body) {
 44  0
         return createExpression(language, body);
 45  
     }
 46  
 
 47  
     public Object createArgListsExpression(String language, String body) {
 48  0
         return createExpression(language, body);
 49  
     }
 50  
 
 51  
     public Object createBooleanExpression(String language, String body) {
 52  0
         return createExpression(language, body);
 53  
     }
 54  
 
 55  
     public OpaqueExpression createExpression(String language, String body) {
 56  
         // TODO: We can choose between something which matches UML 1.4 in name
 57  
         // or something that matches in functionality.  We've chosen
 58  
         // functionality for now, but this will create a name conflict during
 59  
         // the migration process. - tfm
 60  0
         OpaqueExpression expression =
 61  
                 UMLFactory.eINSTANCE.createOpaqueExpression();
 62  0
         expression.getLanguages().add(language);
 63  0
         expression.getBodies().add(body);
 64  0
         return expression;
 65  
     }
 66  
 
 67  
     public Object createIterationExpression(String language, String body) {
 68  0
         return createExpression(language, body);
 69  
     }
 70  
 
 71  
     public Object createMappingExpression(String language, String body) {
 72  0
         return createExpression(language, body);
 73  
     }
 74  
 
 75  
     
 76  
     // TODO: Callers will need to be refactored to work around the
 77  
     // change in the way multiplicities work - tfm
 78  
     
 79  
     public Object createMultiplicity(int lower, int upper) {
 80  0
         throw new NotImplementedException();
 81  
     }
 82  
 
 83  
     public Object createMultiplicity(List range) {
 84  0
         throw new NotImplementedException();
 85  
     }
 86  
 
 87  
     public Object createMultiplicity(String str) {
 88  0
         throw new NotImplementedException();
 89  
     }
 90  
 
 91  
     public Object createMultiplicityRange(String str) {
 92  0
         throw new NotImplementedException();
 93  
     }
 94  
 
 95  
     public Object createMultiplicityRange(int lower, int upper) {
 96  0
         throw new NotImplementedException();
 97  
     }
 98  
 
 99  
     public Object createObjectSetExpression(String language, String body) {
 100  0
         return createExpression(language, body);
 101  
     }
 102  
 
 103  
     public Object createProcedureExpression(String language, String body) {
 104  0
         return createExpression(language, body);
 105  
     }
 106  
 
 107  
     public Object createTimeExpression(String language, String body) {
 108  0
         return createExpression(language, body);
 109  
     }
 110  
 
 111  
     public Object createTypeExpression(String language, String body) {
 112  0
         return createExpression(language, body);
 113  
     }
 114  
 
 115  
     /**
 116  
      * Convert an integer to a string using MultiplicityRange notation.
 117  
      * 
 118  
      * @param i integer to convert
 119  
      * @return String version of integer or "*" for unlimited (-1)
 120  
      */
 121  
     static String boundToString(int i) {
 122  0
         if (i == -1) {
 123  0
             return "*";
 124  
         } else {
 125  0
             return Integer.toString(i);
 126  
         }
 127  
     }
 128  
 
 129  
     /**
 130  
      * Convert a MultiplicityRange bound string to an integer.
 131  
      * 
 132  
      * @param b String containing a single MultiplicityRange bound
 133  
      * @return integer representation
 134  
      */
 135  
     private static int stringToBound(String b) {
 136  
         try {
 137  0
             if (b.equals("n") || b.equals("*")) {
 138  0
                 return -1;
 139  
             } else {
 140  0
                 return Integer.parseInt(b);
 141  
             }
 142  0
         } catch (Exception ex) {
 143  0
             throw new IllegalArgumentException(
 144  
                     "illegal range bound : " + b); //$NON-NLS-1$
 145  
         }
 146  
     }
 147  
 
 148  
 }