public String importType(String fqcn) {
		String result = fqcn;

		//if(fqcn==null) return "/** (null) **/"; 

		String additionalTypePart = null;
		if ( fqcn.indexOf( '<' ) >= 0 ) {
			additionalTypePart = result.substring( fqcn.indexOf( '<' ) );
			result = result.substring( 0, fqcn.indexOf( '<' ) );
			fqcn = result;
		}
		else if ( fqcn.indexOf( '[' ) >= 0 ) {
			additionalTypePart = result.substring( fqcn.indexOf( '[' ) );
			result = result.substring( 0, fqcn.indexOf( '[' ) );
			fqcn = result;
		}

		String pureFqcn = fqcn.replace( '$', '.' );

		boolean canBeSimple;

		String simpleName = unqualify( fqcn );
		if ( simpleNames.containsKey( simpleName ) ) {
			String existingFqcn = simpleNames.get( simpleName );
			if ( existingFqcn.equals( pureFqcn ) ) {
				canBeSimple = true;
			}
			else {
				canBeSimple = false;
			}
		}
		else {
			canBeSimple = true;
			simpleNames.put( simpleName, pureFqcn );
			imports.add( pureFqcn );
		}


		if ( inSamePackage( fqcn ) || ( imports.contains( pureFqcn ) && canBeSimple ) ) {
			result = unqualify( result );
		}
		else if ( inJavaLang( fqcn ) ) {
			result = result.substring( "java.lang.".length() );
		}

		if ( additionalTypePart != null ) {
			result = result + additionalTypePart;
		}

		result = result.replace( '$', '.' );
		return result;
	}
public String importType ( String fqcn ) { String result = fqcn ; String additionalTypePart = null ; if ( fqcn . indexOf ( '<' ) >= 0 ) { additionalTypePart = result . substring ( fqcn . indexOf ( '<' ) ) ; result = result . substring ( 0 , fqcn . indexOf ( '<' ) ) ; fqcn = result ; } else if ( fqcn . indexOf ( '[' ) >= 0 ) { additionalTypePart = result . substring ( fqcn . indexOf ( '[' ) ) ; result = result . substring ( 0 , fqcn . indexOf ( '[' ) ) ; fqcn = result ; } String pureFqcn = fqcn . replace ( '$' , '.' ) ; boolean canBeSimple ; String simpleName = unqualify ( fqcn ) ; if ( simpleNames . containsKey ( simpleName ) ) { String existingFqcn = simpleNames . get ( simpleName ) ; if ( existingFqcn . equals ( pureFqcn ) ) { canBeSimple = true ; } else { canBeSimple = false ; } } else { canBeSimple = true ; simpleNames . put ( simpleName , pureFqcn ) ; imports . add ( pureFqcn ) ; } if ( inSamePackage ( fqcn ) || ( imports . contains ( pureFqcn ) && canBeSimple ) ) { result = unqualify ( result ) ; } else if ( inJavaLang ( fqcn ) ) { result = result . substring ( "java.lang." . length ( ) ) ; } if ( additionalTypePart != null ) { result = result + additionalTypePart ; } result = result . replace ( '$' , '.' ) ; return result ; }
Add fqcn to the import list. Returns fqcn as needed in source code.
Attempts to handle fqcn with array and generics references.
<p/>
e.g.
java.util.Collection<org.marvel.Hulk> imports java.util.Collection and returns Collection
org.marvel.Hulk[] imports org.marvel.Hulk and returns Hulk

@param fqcn Fully qualified class name

@return import string