public static Map<String,String> formatImportedVars( Instance instance ) {

		// The map we will return
		Map<String, String> importedVars = new HashMap<String, String>();
		for( Map.Entry<String,Collection<Import>> entry : instance.getImports().entrySet()) {
			Collection<Import> importList = entry.getValue();
			String importTypeName = entry.getKey();

			// For each ImportType, put the number of Import it has, so the script knows
			importedVars.put(importTypeName + "_size", "" + importList.size());

			// Now put each var contained in an Import
			int i = 0;
			for( Import imprt : importList ) {
				// "workers_0_name=tomcat1"

				/*int index = imprt.getInstancePath().lastIndexOf( '/' );
                String instanceName = imprt.getInstancePath().substring( index + 1 );
                importedVars.put(importTypeName + "_" + i + "_name", instanceName);*/

				importedVars.put(importTypeName + "_" + i + "_name", imprt.getInstancePath());
				for (Entry<String, String> entry2 : imprt.getExportedVars().entrySet()) {
					// "workers_0_ip=127.0.0.1"
					String vname = VariableHelpers.parseVariableName(entry2.getKey()).getValue();
					importedVars.put(importTypeName + "_" + i + "_" + vname, entry2.getValue());
				}

				++i;
			}
		}

		return importedVars;
	}
public static Map < String , String > formatImportedVars ( Instance instance ) { Map < String , String > importedVars = new HashMap < String , String > ( ) ; for ( Map . Entry < String , Collection < Import > > entry : instance . getImports ( ) . entrySet ( ) ) { Collection < Import > importList = entry . getValue ( ) ; String importTypeName = entry . getKey ( ) ; importedVars . put ( importTypeName + "_size" , "" + importList . size ( ) ) ; int i = 0 ; for ( Import imprt : importList ) { importedVars . put ( importTypeName + "_" + i + "_name" , imprt . getInstancePath ( ) ) ; for ( Entry < String , String > entry2 : imprt . getExportedVars ( ) . entrySet ( ) ) { String vname = VariableHelpers . parseVariableName ( entry2 . getKey ( ) ) . getValue ( ) ; importedVars . put ( importTypeName + "_" + i + "_" + vname , entry2 . getValue ( ) ) ; } ++ i ; } } return importedVars ; }
Formats imported variables to be used in a script as environment variables.
<p>
Simple vars are formatted a simple way ("myVarName=varValue"), while imported
variables must be formatted in a more complex way.
</p>
<p>
Taking the example of Apache needing workers in the example Apache-Tomcat-SQL,
we chose to adopt the following style:
<pre>
==========================
"workers_size=3"
"workers_0_name=tomcat1"
"workers_0_ip=127.0.0.1"
"workers_0_portAJP=8009"
"workers_1_name=tomcat2"
.....
"workers_2_portAJP=8010"
==========================
</pre>
With this way of formatting vars, the script will know
everything it needs to use these vars
</p>

@param instance the instance whose imports must be formatted
@return a non-null map