Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 



org.eclipse.jst.jsf.common.util
Class TypeUtil

java.lang.Object
  extended by 
org.eclipse.jst.jsf.common.util.TypeUtil

public final class TypeUtil
extends java.lang.Object

Utility for handling IType's and type signatures Class is static and cannot be extended or instantiated.


Method Summary
static boolean canNeverBeEqual (java.lang.String typeSig1, java.lang.String typeSig2)
           
static java.lang.String getFullyQualifiedName (java.lang.String typeSignature)
           
static java.lang.String getSignature (IType type)
           
static boolean isEnumMember (IType type, java.lang.String fieldName)
           
static boolean isEnumsCompareCompatible (java.lang.String typeSig1, java.lang.String typeSig2)
           
static java.lang.String matchTypeParameterToArgument (IType type, java.lang.String typeParamSignature, java.util.List<java.lang.String> typeArguments)
           
static java.lang.String resolveMethodSignature (IType owner, java.lang.String unresolvedSignature)
           
static IType resolveType (IJavaProject javaProject, java.lang.String fullyResolvedTypeSignature)
          Attempts to get a Java IType for a fully qualified signature.
static java.lang.String resolveTypeSignature (IType owningType, java.lang.String typeSignature)
          Fully equivalent to: #resolveTypeSignature(owningType, typeSignature, true) If resolved, type signature has generic type parameters erased (absent).
static java.lang.String resolveTypeSignature (IType owningType, java.lang.String typeSignature, boolean eraseTypeParameters)
          Resolve typeSignature in the context of owningType.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveTypeSignature

public static java.lang.String resolveTypeSignature(IType owningType,
                                                    java.lang.String typeSignature)
Fully equivalent to: #resolveTypeSignature(owningType, typeSignature, true) If resolved, type signature has generic type parameters erased (absent).

Parameters:
owningType -
typeSignature -
Returns:
the resolved type signature for typeSignature in owningType or typeSignature unchanged if cannot resolve.

resolveTypeSignature

public static java.lang.String resolveTypeSignature(IType owningType,
                                                    java.lang.String typeSignature,
                                                    boolean eraseTypeParameters)
Resolve typeSignature in the context of owningType. This method will return a type erased signture if eraseTypeParameters == true and will attempt to resolve and include parameters if eraseTypeParamters == false NOTE: special rules apply to the way unresolved type parameters and wildcards are resolved: 1) If a fully unresolved type parameter is found, then it will be replaced with Ljava.lang.Object; i.e. List -> Ljava.util.List; for any unresolved T. 2) Any bounded wildcard will be replaced by the bound: i.e. List -> Ljava.util.List; i.e. List -> Ljava.util.List; Note limitation here: bounds that use 'super' will take the "best case" scenario that the list type is of that type. 3) The unbounded wildcard will be replaced by Ljava.lang.Object; i.e. List -> Ljava.util.List; The reason for this substition is to return the most accurate reasonable approximation of the type within what is known by owningType

Parameters:
owningType -
typeSignature -
eraseTypeParameters - if set to false, type parameters are resolved included in the signature
Returns:
the resolved type signature for typeSignature in owningType or typeSignature unchanged if cannot resolve.

getSignature

public static java.lang.String getSignature(IType type)
Parameters:
type -
Returns:
a type signature for a type

resolveMethodSignature

public static java.lang.String resolveMethodSignature(IType owner,
                                                      java.lang.String unresolvedSignature)
Parameters:
owner -
unresolvedSignature -
Returns:
the resolved method signature for unresolvedSignature in owner

getFullyQualifiedName

public static java.lang.String getFullyQualifiedName(java.lang.String typeSignature)
Parameters:
typeSignature -
Returns:
a fully qualified Java class name from a type signature i.e. Ljava.lang.String; -> java.lang.String

resolveType

public static IType resolveType(IJavaProject javaProject,
                                java.lang.String fullyResolvedTypeSignature)
Attempts to get a Java IType for a fully qualified signature. Note that generic type arguments are generally ignored by JDT when doing such look ups.

Parameters:
javaProject - the project context inside which to resolve the type
fullyResolvedTypeSignature - a fully resolved type signature
Returns:
the IType if resolved, null otherwise

matchTypeParameterToArgument

public static java.lang.String matchTypeParameterToArgument(IType type,
                                                            java.lang.String typeParamSignature,
                                                            java.util.List<java.lang.String> typeArguments)
Parameters:
type -
typeParamSignature - -- must be a Type Variable Signature
typeArguments -
Returns:
the signature for the type argument in typeArguments that matches the named typeParamSignature in type.
Throws:
java.lang.IllegalArgumentException - if typeParamSignature is not valid For example, given type for java.util.Map, typeParamSignature == "V" and typeArguments = {Ljava.util.String;, Lcom.test.Blah;}, the result would be the typeArgument that matches "V", which is "Lcom.test.Blah;} returns null if the match cannot be found.

isEnumMember

public static boolean isEnumMember(IType type,
                                   java.lang.String fieldName)
Parameters:
type -
fieldName -
Returns:
true if fieldName is a member of type. Note that if type is java.lang.Enum then this will always return true since we cannot know what fields the instance has (it could be any enum)

isEnumsCompareCompatible

public static boolean isEnumsCompareCompatible(java.lang.String typeSig1,
                                               java.lang.String typeSig2)
Parameters:
typeSig1 - the type signature of the first enum. Must be non-null, fully resolved enum type.
typeSig2 - the type signature of the second enum. Must be non-null, fully resolved enum type.
Returns:
true if typeSig1.compareTo(typeSig2) is a legal operation (won't throw a CCE)

canNeverBeEqual

public static boolean canNeverBeEqual(java.lang.String typeSig1,
                                      java.lang.String typeSig2)
Parameters:
typeSig1 - the type signature of the first enum. Must be non-null, fully resolved enum type.
typeSig2 - the type signature of the second enum. Must be non-null, fully resolved enum type.
Returns:
true if instances typeSig1 and typeSig2 can never be equal due their being definitively different enum types



 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire