org.eclipse.emf.ecore.util
Class EcoreValidator.EGenericTypeBuilder

java.lang.Object
  extended by org.eclipse.emf.ecore.util.EcoreValidator.EGenericTypeBuilder
Enclosing class:
EcoreValidator

public static class EcoreValidator.EGenericTypeBuilder
extends java.lang.Object

A utility for parsing generic types and generic type parameters.

Since:
2.3

Field Summary
static EcoreValidator.EGenericTypeBuilder INSTANCE
          A singleton instance of the generic type build.
 
Constructor Summary
EcoreValidator.EGenericTypeBuilder()
           
 
Method Summary
protected  BasicDiagnostic createDiagnostic(int severity, java.lang.String source, int code, java.lang.String messageKey, java.lang.Object[] messageSubstitutions, java.lang.Object[] data)
          Creates a new basic diagnostic.
protected  ResourceLocator getResourceLocator()
          Returns the resource locator for fetching messages.
protected  java.lang.String getString(java.lang.String key, java.lang.Object[] substitutions)
          Returns a translated message with the given substitutions.
protected  EGenericType handleInstanceTypeName(char[] instanceTypeName, int start, int end, DiagnosticChain diagnostics)
          A well formed instance type name must syntactically denote a valid Java type name; names denoting keywords are considered well formed.
protected  EGenericType handleTypeArgument(char[] instanceTypeName, int start, int end, DiagnosticChain diagnostics)
          A well formed type argument must denote a valid Java type argument.
protected  java.util.List<EGenericType> handleTypeArguments(char[] instanceTypeName, int start, int end, DiagnosticChain diagnostics)
          Well formed type arguments must syntactically denote a comma separated sequence of well formed type arguments.
protected  ETypeParameter handleTypeParameter(char[] typeParameters, int start, int end, DiagnosticChain diagnostics)
          A well formed type parameter must denote a valid Java type parameter.
protected  java.util.List<ETypeParameter> handleTypeParameters(char[] typeParameters, int start, int end, DiagnosticChain diagnostics)
          Well formed type parameters must syntactically denote a comma separated sequence of well formed type parameters delimited by "<>".
protected  boolean isIdentifierPart(int codePoint)
          Returns whether this code point is a valid part of an identifier, i.e., whether it's valid after the first character.
protected  boolean isIdentifierStart(int codePoint)
          Returns whether this code point is a valid start of an identifier.
 Diagnostic parseInstanceTypeName(java.lang.String instanceTypeName)
          Parses an instance type name and returns a diagnostic representing the result of the analysis.
 Diagnostic parseTypeArgumentList(java.lang.String typeArgumentList)
          Parses a list of type arguments and returns a diagnostic representing the result of the analysis.
 Diagnostic parseTypeParameter(java.lang.String typeParameter)
          Parses a type parameter and returns a diagnostic representing the result of the analysis.
 Diagnostic parseTypeParameterList(java.lang.String typeParameterList)
          Parses a list of type parameters and returns a diagnostic representing the result of the analysis.
protected  void report(DiagnosticChain diagnostics, java.lang.String message, int index)
          Creates a new diagnostic for a problem at the given index.
protected  void report(DiagnosticChain diagnostics, java.lang.String key, java.lang.Object[] substitutions, int index)
          Creates a new diagnostic for a problem at the given index.
protected  EClassifier resolveEClassifier(java.lang.String instanceTypeName)
          Finds or creates an classifier with the given instance type name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final EcoreValidator.EGenericTypeBuilder INSTANCE
A singleton instance of the generic type build.

Constructor Detail

EcoreValidator.EGenericTypeBuilder

public EcoreValidator.EGenericTypeBuilder()
Method Detail

parseInstanceTypeName

public Diagnostic parseInstanceTypeName(java.lang.String instanceTypeName)
Parses an instance type name and returns a diagnostic representing the result of the analysis. The data of the diagnostic will contain as the first object, the resulting generic type.

Parameters:
instanceTypeName - an instance type name.
Returns:
the diagnostic result of the analysis.

parseTypeParameterList

public Diagnostic parseTypeParameterList(java.lang.String typeParameterList)
Parses a list of type parameters and returns a diagnostic representing the result of the analysis. The data of the diagnostic will contain as the first object, the resulting list of type parameters.

Parameters:
typeParameterList - a comma separated list of type parameters delimited by '<' and '>'.
Returns:
the diagnostic result of the analysis.

parseTypeArgumentList

public Diagnostic parseTypeArgumentList(java.lang.String typeArgumentList)
Parses a list of type arguments and returns a diagnostic representing the result of the analysis. The data of the diagnostic will contain as the first object, the resulting list of type arguments.

Parameters:
typeArgumentList - a comma separated list of type arguments.
Returns:
the diagnostic result of the analysis.
Since:
2.4

parseTypeParameter

public Diagnostic parseTypeParameter(java.lang.String typeParameter)
Parses a type parameter and returns a diagnostic representing the result of the analysis. The data of the diagnostic will contain as the first object, the resulting type parameter.

Parameters:
typeParameter - comma separated list of type parameters delimited by '<' and '>'.
Returns:
the diagnostic result of the analysis.

resolveEClassifier

protected EClassifier resolveEClassifier(java.lang.String instanceTypeName)
Finds or creates an classifier with the given instance type name.

Parameters:
instanceTypeName - the instance type name for which a classifier is needed.
Returns:
a classifier with the instance type name.

report

protected void report(DiagnosticChain diagnostics,
                      java.lang.String key,
                      java.lang.Object[] substitutions,
                      int index)
Creates a new diagnostic for a problem at the given index.

Parameters:
diagnostics - the target for the new diagnostic.
key - the key for the message.
substitutions - the substitutions for the key; null if there are no substitutions.
index - the index at which the problem occurred.

report

protected void report(DiagnosticChain diagnostics,
                      java.lang.String message,
                      int index)
Creates a new diagnostic for a problem at the given index.

Parameters:
diagnostics - the target for the new diagnostic.
message - the text describing the problem.
index - the index at which the problem occurred.

handleInstanceTypeName

protected EGenericType handleInstanceTypeName(char[] instanceTypeName,
                                              int start,
                                              int end,
                                              DiagnosticChain diagnostics)
A well formed instance type name must syntactically denote a valid Java type name; names denoting keywords are considered well formed. It must start with a qualified name consisting of one or more "." separated identifiers, where each identifier must start with a Java identifier start character, that is followed by zero or more Java identifier part characters. The methods isIdentifierStart(int) and isIdentifierPart(int) are used so that this behavior can be specialized. This qualified name may optionally be followed by zero or more pairs of "[]" characters or by type arguments consisting of the pair of "<>" characters with embedded well formed type arguments.

Parameters:
instanceTypeName - the instance type name in question.
start - the start of the characters under consideration.
end - the end of the characters under consideration.
diagnostics - the target in which to accumulate diagnostics.
Returns:
the generic type representing the instance type name.

isIdentifierStart

protected boolean isIdentifierStart(int codePoint)
Returns whether this code point is a valid start of an identifier.

Parameters:
codePoint - the code point in question.
Returns:
whether this code point is a valid start of an identifier.

isIdentifierPart

protected boolean isIdentifierPart(int codePoint)
Returns whether this code point is a valid part of an identifier, i.e., whether it's valid after the first character.

Parameters:
codePoint - the code point in question.
Returns:
whether this code point is a valid part of an identifier.

handleTypeArguments

protected java.util.List<EGenericType> handleTypeArguments(char[] instanceTypeName,
                                                           int start,
                                                           int end,
                                                           DiagnosticChain diagnostics)
Well formed type arguments must syntactically denote a comma separated sequence of well formed type arguments. Whitespace before or after arguments is ignored.

Parameters:
instanceTypeName - the instance type name in question.
start - the start of the characters under consideration.
end - the end of the characters under consideration.
diagnostics - the target in which to accumulate diagnostics.
Returns:
a list of generic type representing the type arguments.

handleTypeArgument

protected EGenericType handleTypeArgument(char[] instanceTypeName,
                                          int start,
                                          int end,
                                          DiagnosticChain diagnostics)
A well formed type argument must denote a valid Java type argument. It may start with a "?" which may be optionally followed by the keyword "extends" or "super" which in turn, when present, must be followed by a well formed type instance name. White space before the keyword is optional but at least one space character is expected after the keyword. Otherwise, the whole string must be a well formed instance type name.

Parameters:
instanceTypeName - the instance type name in question.
start - the start of the characters under consideration.
end - the end of the characters under consideration.
diagnostics - the target in which to accumulate diagnostics.
Returns:
the generic type representing the type argument.

handleTypeParameters

protected java.util.List<ETypeParameter> handleTypeParameters(char[] typeParameters,
                                                              int start,
                                                              int end,
                                                              DiagnosticChain diagnostics)
Well formed type parameters must syntactically denote a comma separated sequence of well formed type parameters delimited by "<>". Whitespace before or after parameters is ignored.

Parameters:
typeParameters - the type parameters question.
start - the start of the characters under consideration.
end - the end of the characters under consideration.
diagnostics - the target in which to accumulate diagnostics.
Returns:
a list of type parameters.

handleTypeParameter

protected ETypeParameter handleTypeParameter(char[] typeParameters,
                                             int start,
                                             int end,
                                             DiagnosticChain diagnostics)
A well formed type parameter must denote a valid Java type parameter. It must start with a well formed java identifier which may be optionally followed by the keyword "extends" which in turn, when present, must be followed by one or more '&' separated well formed type arguments representing the bounds. White space before the keyword is optional but at least one space character is expected after the keyword.

Parameters:
typeParameters - the instance type name in question.
start - the start of the characters under consideration.
end - the end of the characters under consideration.
diagnostics - the target in which to accumulate diagnostics.
Returns:
the type parameter.

createDiagnostic

protected BasicDiagnostic createDiagnostic(int severity,
                                           java.lang.String source,
                                           int code,
                                           java.lang.String messageKey,
                                           java.lang.Object[] messageSubstitutions,
                                           java.lang.Object[] data)
Creates a new basic diagnostic. It calls getString(String, Object[]) for the message substitution.

Parameters:
severity - an indicator of the severity of the problem.
source - the unique identifier of the source.
code - the source-specific identity code.
messageKey - the key of the message.
messageSubstitutions - the substitutions for the key; null if there are no substitutions.
data - the data associated with the diagnostic
Returns:
a new diagnostic.
Since:
2.4
See Also:
BasicDiagnostic.BasicDiagnostic(int, String, int, String, Object[])

getString

protected java.lang.String getString(java.lang.String key,
                                     java.lang.Object[] substitutions)
Returns a translated message with the given substitutions. The resource locator is used.

Parameters:
key - the key for the message.
substitutions - the substitutions for the key; null if there are no substitutions.
Returns:
the message.
Since:
2.4

getResourceLocator

protected ResourceLocator getResourceLocator()
Returns the resource locator for fetching messages.

Returns:
the resource locator for fetching messages.
Since:
2.4

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.