/*******************************************************************************
 * Copyright (c) 2016-17 Inria
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * - Philippe Merle <philippe.merle@inria.fr>
 * - Faiez Zalila <faiez.zalila@inria.fr>
 *******************************************************************************/
package org.eclipse.cmf.occi.core.util;

/**
 * This class provides utility functions related to the mapping of OCCI to Ecore.
 * 
 * @author Philippe Merle - Inria
 */
public class Occi2Ecore
{
	/**
	 * Suffix added to the name space of EPackage.
	 */
	static final String ECORE_SUFFIX = "/ecore";

	/**
	 * This class can not be instantiated.
	 */
	private Occi2Ecore()
	{
	}

	/**
	 * Converts an OCCI scheme to an Ecore name space.
	 * @param occiScheme the OCCI scheme.
	 * @return the Ecore name space.
	 */
	public static String convertOcciScheme2EcoreNamespace(final String occiScheme) {
		return occiScheme.substring(0, occiScheme.length()-1) + ECORE_SUFFIX;
	}

	/**
	 * Converts an Ecore name space to an OCCI scheme.
	 * @param ecoreNamespace the Ecore name space.
	 * @return the OCCI scheme.
	 */
	public static String convertEcoreNamespace2OcciScheme(final String ecoreNamespace) {
		return ecoreNamespace.substring(0, ecoreNamespace.length()-ECORE_SUFFIX.length()) + '#';
	}

	/**
	 * Converts an OCCI category term to an Ecore class name.
	 * @param term the OCCI category term.
	 * @return the Ecore class name.
	 */
	public static String convertOcciCategoryTerm2EcoreClassName(String term) {
		return term.substring(0,1).toUpperCase() + term.substring(1);
	}

	/**
	 * Convert an Ecore class name to an OCCI category term.
	 * @param eclassName the given Ecore class name.
	 * @return an OCCI category term.
	 */
	public static String convertEcoreClassName2OcciCategoryTerm(String eclassName)
	{
		return eclassName.substring(0, 1).toLowerCase() + eclassName.substring(1);
	}

	/**
	 * Convert an OCCI attribute name to an Ecore feature name.
	 * @param attributeName the given OCCI attribute name.
	 * @return the converted Ecore attribute name.
	 */
	public static String convertOcciAttributeName2EcoreAttributeName(final String attributeName)
	{
		String[] attributeNameArray = attributeName.split("\\.");
		String newattribute= "";
		for(int i = 0; i < attributeNameArray.length; i++){
			
			if(i == 0){
				newattribute += attributeNameArray[0];
			}
			else{
				newattribute += attributeNameArray[i].substring(0, 1).toUpperCase() + attributeNameArray[i].substring(1);;
			}
		}
		return newattribute;
	}
}

@@ -1766,59 +1766,28 @@
 rn t
-erm.substring(0,1).toUpperCase() + term.substring(1
+oUpperCaseFirst(term
 );%0A%09
@@ -2607,32 +2607,49 @@
 newattribute += 
+toUpperCaseFirst(
 attributeNameArr
@@ -2657,108 +2657,217 @@
 y%5Bi%5D
-.substring(0, 1).to
+);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return newattribute;%0A%09%7D%0A%0A%09/**%0A%09 * 
 Upper
-Case() + attributeNameArray%5Bi%5D.substring(1);;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return newattribute
+ case the first character.%0A%09 */%0A%09private static String toUpperCaseFirst(String string)%0A%09%7B%0A%09%09return string.substring(0, 1).toUpperCase() +string.substring(1)
 ;%0A%09%7D

Add toUpperCaseFirst method.