org.eclipse.xtend.expression
Class TypeNameUtil

java.lang.Object
  extended by org.eclipse.xtend.expression.TypeNameUtil

public class TypeNameUtil
extends java.lang.Object

Utility class for retrieving information from various type name presentations used within Xtend's type system.

The following type formats can occur:

Examples:

'<typename>' is the fully qualified name namespace1::namespace2::name

Author:
Sven Efftinge (http://www.efftinge.de) - Initial implementation, Arno Haase - Initial implementation, Karsten Thoms - Documentation

Constructor Summary
TypeNameUtil()
           
 
Method Summary
static java.lang.String convertJavaTypeName(java.lang.String javaTypeName)
          Converts a Java qualified name (dot seperated) to Xtend qualified name ('::' seperated).
static java.lang.String getCollectionTypeName(java.lang.String name)
          Retrieves the collection type.
static java.lang.String getLastSegment(java.lang.String fqn)
          Retrieves only the last segment of a qualified name and therefore cuts the namespace part
static java.lang.String getName(java.lang.Class<?> class1)
          Gets the internal representation of a class name.
static java.lang.String getPackage(java.lang.String insertString)
           
static java.lang.String getSimpleName(java.lang.String fqn)
          Cuts the namespace qualification from the type string.
static java.lang.String getTypeName(java.lang.String name)
          Retrieves the type name
static java.lang.String withoutLastSegment(java.lang.String fqn)
          Cuts the last segment from a qualified type name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeNameUtil

public TypeNameUtil()
Method Detail

getCollectionTypeName

public static java.lang.String getCollectionTypeName(java.lang.String name)
Retrieves the collection type.

Parameters:
name - Qualified type string
Returns:
The name of the collection type if present ('List', 'Set'), otherwise null

getTypeName

public static java.lang.String getTypeName(java.lang.String name)
Retrieves the type name

Parameters:
name - Qualified type string
Returns:
The type's name

getName

public static java.lang.String getName(java.lang.Class<?> class1)
Gets the internal representation of a class name.

Parameters:
class1 - A class instance for which the name should be retrieved
Returns:
Xtend's classname representation ( package1::package2::TheClassname)

withoutLastSegment

public static java.lang.String withoutLastSegment(java.lang.String fqn)
Cuts the last segment from a qualified type name.

Parameters:
fqn - Qualified type name
Returns:
 ns1::ns2::name   -> ns1::ns2
 name             -> <null>
 

getLastSegment

public static java.lang.String getLastSegment(java.lang.String fqn)
Retrieves only the last segment of a qualified name and therefore cuts the namespace part

Parameters:
fqn - Qualified type name
Returns:
 ns1::ns2::name   -> name
 name             -> name
 

getSimpleName

public static java.lang.String getSimpleName(java.lang.String fqn)
Cuts the namespace qualification from the type string.

Parameters:
fqn - Qualified type string
Returns:
 ns1::ns2::type             -> type
 List[type]                 -> List[type]
 List[Metamodel!ns1::type]  -> List[Metamodel!type]
 

getPackage

public static java.lang.String getPackage(java.lang.String insertString)

convertJavaTypeName

public static java.lang.String convertJavaTypeName(java.lang.String javaTypeName)
Converts a Java qualified name (dot seperated) to Xtend qualified name ('::' seperated).

Parameters:
javaTypeName - A java qualifier
Returns:
All dots are replaced by '::'. Returns null if javaTypeName is null.