|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.errai.codegen.Context
public class Context
This class represents a context in which Statement
s are generated.
Statement
s can be validated prior to
compilation.
Method Summary | ||
---|---|---|
Context |
addImport(MetaClass clazz)
Imports the given class. |
|
void |
addInterningCallback(InterningCallback interningCallback)
Adds an InterningCallback to the context. |
|
Context |
addLabel(Label label)
Add a Label to the current scope. |
|
void |
addLiteralizableClass(Class clazz)
Mark a class "literalizable". |
|
void |
addLiteralizableClass(MetaClass clazz)
Mark a class "literalizable". |
|
void |
addLiteralizableClasses(Collection<Class<?>> clazzes)
|
|
void |
addLiteralizableMetaClasses(Collection<MetaClass> clazzes)
|
|
Context |
addVariable(String name,
Class<?> type)
Add a variable to the current scope. |
|
Context |
addVariable(String name,
Class<?> type,
Object initialization)
Add a variable to the current scope and initialize it. |
|
Context |
addVariable(Variable variable)
Add a Variable to the current scope. |
|
void |
attachClass(MetaClass clazz)
Attaches a class to the current scope. |
|
Context |
autoImport()
Enables automatic import of classes used during code generation. |
|
static Context |
create()
Creates a new and empty context. |
|
static Context |
create(Context parent)
Create a new sub context for the given parent context. |
|
VariableReference |
getClassMember(String name)
Returns a reference to the class member Variable with the given name. |
|
Collection<Variable> |
getDeclaredVariables()
Returns all variables in this scope (does not include variables of parent scopes). |
|
LabelReference |
getLabel(String name)
Returns the a reference to the Label with the given name. |
|
Class |
getLiteralizableTargetType(Class clazz)
Returns the literalizable target type for any matching subtype. |
|
Class |
getLiteralizableTargetType(MetaClass clazz)
Returns the literalizable target type for any matching subtype. |
|
Set<String> |
getMissingSymbols()
|
|
|
getRenderingCache(RenderCacheStore<K,V> store)
|
|
Set<String> |
getRequiredImports()
Returns all imports except the optional ones (java.lang.*). |
|
VariableReference |
getVariable(String name)
Returns a reference to the Variable with the given name. |
|
Map<String,Variable> |
getVariables()
Returns all variables in this scope (does not include variables of parent scopes). |
|
boolean |
hasImport(MetaClass clazz)
Checks whether the given class has been imported. |
|
Statement |
intern(LiteralValue<?> literalValue)
|
|
boolean |
isAmbiguous(String varName)
Checks if the the given variable name is ambiguous in this scope. |
|
boolean |
isAutoImportActive()
Checks if automatic import is active. |
|
boolean |
isInScope(MetaField field)
Checks is the given MetaField is in scope (part of the attached class contexts). |
|
boolean |
isInScope(MetaMethod method)
Checks is the given MetaMethod is in scope (part of the attached class contexts). |
|
boolean |
isLiteralizableClass(Class clazz)
Returns true if the specified class is literalizable. |
|
boolean |
isLiteralizableClass(MetaClass clazz)
Returns true if the specified class is literalizable. |
|
boolean |
isPermissiveMode()
Check is permissive mode is active for this context. |
|
boolean |
isScoped(Variable variable)
Checks is the given Variable is in scope. |
|
void |
setPermissiveMode(boolean permissiveMode)
Sets permissive mode active for this context. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Context create()
public static Context create(Context parent)
parent
- the parent context to use.
public Context addVariable(String name, Class<?> type)
name
- the name of the variable, must not be null.type
- the type of the variable, must not be null.
public Context addVariable(String name, Class<?> type, Object initialization)
name
- the name of the variable, must not be null.type
- the type of the variable, must not be null.initialization
- the Statement
or literal value to initialize the Variable
, can be null.
public Context addVariable(Variable variable)
Variable
to the current scope.
variable
- the variable instance to add, must not be null.
public Context addLabel(Label label)
Label
to the current scope.
label
- the label instance to add, must not be null.
public Context addImport(MetaClass clazz)
clazz
- the class to import, must not be null. If it is an array type (of any number of dimensions), its non-array
component type will be imported.
public boolean hasImport(MetaClass clazz)
clazz
- the class to check, must not be null.
public Set<String> getRequiredImports()
public Context autoImport()
public VariableReference getVariable(String name)
Variable
with the given name.
name
- the name of the variable.
VariableReference
found, can not be null.
OutOfScopeException
- if variable with the given name can not be found.public VariableReference getClassMember(String name)
Variable
with the given name.
name
- the name of the class member variable.
VariableReference
found, can not be null.
OutOfScopeException
- if member variable with the given name can not be found.public LabelReference getLabel(String name)
Label
with the given name.
name
- the name of the label.
LabelReference
found, can not be null.
OutOfScopeException
- if label with the given name can not be found.public boolean isScoped(Variable variable)
Variable
is in scope.
variable
- the variable to check.
public boolean isInScope(MetaMethod method)
MetaMethod
is in scope (part of the attached class contexts).
method
- the method to check.
public boolean isInScope(MetaField field)
MetaField
is in scope (part of the attached class contexts).
field
- the field to check.
public boolean isAmbiguous(String varName)
varName
- the variable name to check.
public Collection<Variable> getDeclaredVariables()
Variable
, empty if no variables are in scope.public void addLiteralizableClasses(Collection<Class<?>> clazzes)
public void addLiteralizableMetaClasses(Collection<MetaClass> clazzes)
public void addLiteralizableClass(Class clazz)
SnapshotMaker
for further details.
clazz
- the class, interface or superclass to be considered literalizable.public void addLiteralizableClass(MetaClass clazz)
SnapshotMaker
for further details.
clazz
- the class, interface or superclass to be considered literalizable.public boolean isLiteralizableClass(Class clazz)
clazz
- the class, interface or superclass to be tested if literalizable
addLiteralizableClass(Class)
public boolean isLiteralizableClass(MetaClass clazz)
clazz
- the class, interface or superclass to be tested if literalizable
addLiteralizableClass(MetaClass)
public Class getLiteralizableTargetType(Class clazz)
clazz
- the class, interface or superclass to obtain a literalizable target type for.clazz
- . If there are no matches, returns null.
public Class getLiteralizableTargetType(MetaClass clazz)
clazz
- the class, interface or superclass to obtain a literalizable target type for.clazz
- . If there are no matches, returns null.
public Map<String,Variable> getVariables()
Variable
, empty if no variables are in scope.public void attachClass(MetaClass clazz)
clazz
- class to attach.public boolean isAutoImportActive()
public boolean isPermissiveMode()
public void setPermissiveMode(boolean permissiveMode)
permissiveMode
- public <K,V> Map<K,V> getRenderingCache(RenderCacheStore<K,V> store)
public void addInterningCallback(InterningCallback interningCallback)
InterningCallback
to the context. Multiple callbacks can be registered. But, in the event that
multiple callbacks fire and intern the same values, the last callback fired will be the effective
interning behavior.
interningCallback
- public Statement intern(LiteralValue<?> literalValue)
public String toString()
toString
in class Object
public Set<String> getMissingSymbols()
|
Errai 3.0.1-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |