com.google.gwt.uibinder.rebind
Class FieldManager

java.lang.Object
  extended by com.google.gwt.uibinder.rebind.FieldManager

public class FieldManager
extends java.lang.Object

This class handles all FieldWriter instances created for the current template.


Constructor Summary
FieldManager(TypeOracle types, MortalLogger logger)
           
 
Method Summary
 FieldWriter lookup(java.lang.String fieldName)
           
 void pop()
          Remove the field at the top of the parsedFieldStack.
 void push(FieldWriter fieldWriter)
           
 FieldWriter registerField(JClassType fieldType, java.lang.String fieldName)
          Used to declare fields of an existing type.
 FieldWriter registerFieldForGeneratedCssResource(ImplicitCssResource cssResource)
          Used to declare fields that will hold generated instances generated CssResource interfaces.
 FieldWriter registerFieldOfGeneratedType(JClassType assignableType, java.lang.String typePackage, java.lang.String typeName, java.lang.String fieldName)
          Used to declare fields of a type (other than CssResource) that is to be generated.
 void registerFieldReference(java.lang.String fieldReferenceString, JType type)
          Called to register a {field.reference} encountered during parsing, to be validated against the type oracle once parsing is complete.
 void validate()
          To be called after parsing is complete.
 void writeGwtFieldsDeclaration(IndentedWriter writer, java.lang.String ownerTypeName)
          Writes all stored gwt fields.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldManager

public FieldManager(TypeOracle types,
                    MortalLogger logger)
Method Detail

lookup

public FieldWriter lookup(java.lang.String fieldName)
Parameters:
fieldName - the name of the FieldWriter to find
Returns:
the FieldWriter instance indexed by fieldName or null in case fieldName is not found

pop

public void pop()
Remove the field at the top of the parsedFieldStack.


push

public void push(FieldWriter fieldWriter)
Parameters:
fieldWriter - the field to push on the top of the parsedFieldStack

registerField

public FieldWriter registerField(JClassType fieldType,
                                 java.lang.String fieldName)
                          throws UnableToCompleteException
Used to declare fields of an existing type. If your field will hold a type that is being generated, see registerFieldOfGeneratedType(JClassType, java.lang.String, java.lang.String, java.lang.String).

When making a field we peek at the parsedFieldStack to make sure that the field that holds the widget currently being parsed will depended upon the field being declared. This ensures, for example, that dom id fields (see #declareDomIdHolder()) used by an HTMLPanel will be declared before it is.

Parameters:
fieldType - the type of the new field
fieldName - the name of the new field
Returns:
a new FieldWriter instance
Throws:
UnableToCompleteException - on duplicate name

registerFieldForGeneratedCssResource

public FieldWriter registerFieldForGeneratedCssResource(ImplicitCssResource cssResource)
                                                 throws UnableToCompleteException
Used to declare fields that will hold generated instances generated CssResource interfaces. If your field will hold a reference of an existing type, see registerField(JClassType, java.lang.String). For other generated types, use registerFieldOfGeneratedType(JClassType, java.lang.String, java.lang.String, java.lang.String) registerFieldForGeneratedCssResource(com.google.gwt.uibinder.rebind.model.ImplicitCssResource).

When making a field we peek at the parsedFieldStack to make sure that the field that holds the widget currently being parsed will depended upon the field being declared. This ensures, for example, that dom id fields (see #declareDomIdHolder()) used by an HTMLPanel will be declared before it is.

Returns:
a new FieldWriter instance
Throws:
UnableToCompleteException - on duplicate name

registerFieldOfGeneratedType

public FieldWriter registerFieldOfGeneratedType(JClassType assignableType,
                                                java.lang.String typePackage,
                                                java.lang.String typeName,
                                                java.lang.String fieldName)
                                         throws UnableToCompleteException
Used to declare fields of a type (other than CssResource) that is to be generated. If your field will hold a reference of an existing type, see registerField(JClassType, java.lang.String). For generated CssResources, see registerFieldForGeneratedCssResource(com.google.gwt.uibinder.rebind.model.ImplicitCssResource).

When making a field we peek at the parsedFieldStack to make sure that the field that holds the widget currently being parsed will depended upon the field being declared. This ensures, for example, that dom id fields (see #declareDomIdHolder()) used by an HTMLPanel will be declared before it is.

Parameters:
assignableType - class or interface extened or implemented by this type
typeName - the full qualified name for the class associated with the field
fieldName - the name of the field
Returns:
a new FieldWriter instance
Throws:
UnableToCompleteException - on duplicate name

registerFieldReference

public void registerFieldReference(java.lang.String fieldReferenceString,
                                   JType type)
Called to register a {field.reference} encountered during parsing, to be validated against the type oracle once parsing is complete.

Throws:
UnableToCompleteException

validate

public void validate()
              throws UnableToCompleteException
To be called after parsing is complete. Surveys all {field.reference}s and checks they refer to existing types, and have appropriate return types.

Throws:
UnableToCompleteException - if any {field.references} can't be resolved

writeGwtFieldsDeclaration

public void writeGwtFieldsDeclaration(IndentedWriter writer,
                                      java.lang.String ownerTypeName)
                               throws UnableToCompleteException
Writes all stored gwt fields.

Parameters:
writer - the writer to output
ownerTypeName - the name of the class being processed
Throws:
UnableToCompleteException