|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.uibinder.rebind.UiBinderWriter
public class UiBinderWriter
Writer for UiBinder generated classes. TODO(rdamazio): Refactor this, extract model classes, improve ordering guarantees, etc. TODO(rjrjr): Line numbers in error messages.
| Constructor Summary | |
|---|---|
UiBinderWriter(JClassType baseClass,
java.lang.String implClassName,
java.lang.String templatePath,
TypeOracle oracle,
MortalLogger logger,
FieldManager fieldManager,
MessagesWriter messagesWriter)
|
|
| Method Summary | |
|---|---|
void |
addDetachStatement(java.lang.String format,
java.lang.Object... args)
Add a statement to be executed right after the current attached element is detached. |
void |
addInitStatement(java.lang.String format,
java.lang.Object... params)
Add a statement to be run after everything has been instantiated, in the style of String.format(java.lang.String, java.lang.Object...). |
void |
addStatement(java.lang.String format,
java.lang.Object... args)
Adds a statement to the block run after fields are declared, in the style of String.format(java.lang.String, java.lang.Object...). |
static java.lang.String |
asCommaSeparatedList(java.lang.String... args)
|
void |
beginAttachedSection(java.lang.String element)
Begin a section where a new attachable element is being parsed--that is, one that will be constructed as a big innerHTML string, and then briefly attached to the dom to allow fields accessing its to be filled (at the moment, HasHTMLParser, HTMLPanelParser, and DomElementParser.). |
java.lang.String |
declareDomField(java.lang.String fieldName)
Declare a field that will hold an Element instance. |
java.lang.String |
declareDomIdHolder()
Declare a variable that will be filled at runtime with a unique id, safe for use as a dom element's id attribute. |
java.lang.String |
declareField(java.lang.String typeName,
XMLElement elem)
Declares a field of the given type name, returning the name of the declared field. |
java.lang.String |
declareFieldIfNeeded(XMLElement elem)
If this element has a gwt:field attribute, create a field for it of the appropriate type, and return the field name. |
java.lang.String |
detokenate(java.lang.String betokened)
Given a string containing tokens returned by tokenForExpression(java.lang.String) or
declareDomField(java.lang.String), return a string with those tokens replaced by the
appropriate expressions. |
void |
die(java.lang.String message)
Post an error message and halt processing. |
void |
die(java.lang.String message,
java.lang.Object... params)
Post an error message and halt processing. |
void |
die(XMLElement context,
java.lang.String message,
java.lang.Object... params)
Post an error message about a specific XMLElement and halt processing. |
void |
endAttachedSection()
End the current attachable section. |
void |
ensureAttached()
Ensure that the specified element is attached to the DOM. |
void |
ensureCurrentFieldAttached()
Ensure that the specified field is attached to the DOM. |
static java.lang.String |
escapeAttributeText(java.lang.String text)
Escape text that will be part of a string literal to be interpreted at runtime as an HTML attribute value. |
static java.lang.String |
escapeText(java.lang.String text,
boolean preserveWhitespace)
Escape text that will be part of a string literal to be interpreted at runtime as HTML, optionally preserving whitespace. |
static java.lang.String |
escapeTextForJavaStringLiteral(java.lang.String text)
Escape characters that would mess up interpretation of this string as a string literal in generated code (that is, protect \, \n and " ). |
JClassType |
findFieldType(XMLElement elem)
Finds the JClassType that corresponds to this XMLElement, which must be a Widget or an Element. |
void |
genPropertySet(java.lang.String fieldName,
java.lang.String propName,
java.lang.String value)
Generates the code to set a property value (assumes that 'value' is a valid Java expression). |
void |
genStringPropertySet(java.lang.String fieldName,
java.lang.String propName,
java.lang.String value)
Generates the code to set a string property. |
AttributeParser |
getBundleAttributeParser(XMLAttribute attribute)
Deprecated. exists only to support BundleAttributeParser, which
will be leaving us soon. |
ImplicitClientBundle |
getBundleClass()
|
MortalLogger |
getLogger()
|
MessagesWriter |
getMessages()
Get the MessagesWriter for this UI, generating it if necessary. |
TypeOracle |
getOracle()
Gets the type oracle. |
OwnerClass |
getOwnerClass()
|
java.lang.String |
getUiFieldAttributeName()
|
boolean |
isBinderElement(XMLElement elem)
|
boolean |
isWidgetElement(XMLElement elem)
|
java.lang.String |
parseElementToField(XMLElement elem)
Parses the object associated with the specified element, and returns the name of the field (possibly private) that will hold it. |
void |
setFieldInitializer(java.lang.String fieldName,
java.lang.String factoryMethod)
Gives the writer the initializer to use for this field instead of the default GWT.create call. |
void |
setFieldInitializerAsConstructor(java.lang.String fieldName,
JClassType type,
java.lang.String... args)
Instructs the writer to initialize the field with a specific constructor invocation, instead of the default GWT.create call. |
java.lang.String |
tokenForExpression(java.lang.String expression)
Returns a string token that can be used in place the given expression inside any string literals. |
void |
warn(java.lang.String message)
Post a warning message. |
void |
warn(java.lang.String message,
java.lang.Object... params)
Post a warning message. |
void |
warn(XMLElement context,
java.lang.String message,
java.lang.Object... params)
Post a warning message. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UiBinderWriter(JClassType baseClass,
java.lang.String implClassName,
java.lang.String templatePath,
TypeOracle oracle,
MortalLogger logger,
FieldManager fieldManager,
MessagesWriter messagesWriter)
throws UnableToCompleteException
UnableToCompleteException| Method Detail |
|---|
public static java.lang.String asCommaSeparatedList(java.lang.String... args)
public static java.lang.String escapeAttributeText(java.lang.String text)
public static java.lang.String escapeText(java.lang.String text,
boolean preserveWhitespace)
public static java.lang.String escapeTextForJavaStringLiteral(java.lang.String text)
public void addDetachStatement(java.lang.String format,
java.lang.Object... args)
format - args - beginAttachedSection(String)
public void addInitStatement(java.lang.String format,
java.lang.Object... params)
String.format(java.lang.String, java.lang.Object...).
public void addStatement(java.lang.String format,
java.lang.Object... args)
String.format(java.lang.String, java.lang.Object...).
public void beginAttachedSection(java.lang.String element)
Succeeding calls made to ensureAttached() and
#ensureFieldAttached must refer to children of this element, until
endAttachedSection() is called.
element - Java expression for the generated code that will return the
dom element to be attached.
public java.lang.String declareDomField(java.lang.String fieldName)
throws UnableToCompleteException
In the generated code, this token will be replaced by an expression to generate a unique dom id at runtime. Further code will be generated to be run after widgets are instantiated, to use that dom id in a getElementById call and assign the Element instance to its field.
fieldName - The name of the field being declared
UnableToCompleteException
public java.lang.String declareDomIdHolder()
throws UnableToCompleteException
UnableToCompleteException
public java.lang.String declareField(java.lang.String typeName,
XMLElement elem)
throws UnableToCompleteException
UnableToCompleteException
public java.lang.String declareFieldIfNeeded(XMLElement elem)
throws UnableToCompleteException
UnableToCompleteExceptionpublic java.lang.String detokenate(java.lang.String betokened)
tokenForExpression(java.lang.String) or
declareDomField(java.lang.String), return a string with those tokens replaced by the
appropriate expressions. (It is not normally necessary for an
XMLElement.Interpreter or ElementParser to make this call,
as the tokens are typically replaced by the TemplateWriter itself.)
public void die(java.lang.String message)
throws UnableToCompleteException
UnableToCompleteException
UnableToCompleteException
public void die(java.lang.String message,
java.lang.Object... params)
throws UnableToCompleteException
UnableToCompleteException
UnableToCompleteException
public void die(XMLElement context,
java.lang.String message,
java.lang.Object... params)
throws UnableToCompleteException
UnableToCompleteException
UnableToCompleteExceptionpublic void endAttachedSection()
beginAttachedSection(String)public void ensureAttached()
beginAttachedSection(String)public void ensureCurrentFieldAttached()
ensureAttached(field + ".getElement()").
beginAttachedSection(String)
public JClassType findFieldType(XMLElement elem)
throws UnableToCompleteException
UnableToCompleteException - If no such widget class exists
java.lang.RuntimeException - if asked to handle a non-widget, non-DOM element
public void genPropertySet(java.lang.String fieldName,
java.lang.String propName,
java.lang.String value)
public void genStringPropertySet(java.lang.String fieldName,
java.lang.String propName,
java.lang.String value)
@Deprecated
public AttributeParser getBundleAttributeParser(XMLAttribute attribute)
throws UnableToCompleteException
BundleAttributeParser, which
will be leaving us soon.
BundleAttributeParser for the given xml
attribute, if any, based on its namespace uri.
UnableToCompleteExceptionpublic ImplicitClientBundle getBundleClass()
public MortalLogger getLogger()
public MessagesWriter getMessages()
MessagesWriter for this UI, generating it if necessary.
public TypeOracle getOracle()
public OwnerClass getOwnerClass()
public java.lang.String getUiFieldAttributeName()
public boolean isBinderElement(XMLElement elem)
public boolean isWidgetElement(XMLElement elem)
public java.lang.String parseElementToField(XMLElement elem)
throws UnableToCompleteException
elem - the xml element to be parsed
UnableToCompleteException
public void setFieldInitializer(java.lang.String fieldName,
java.lang.String factoryMethod)
java.lang.IllegalStateException - if an initializer has already been set
public void setFieldInitializerAsConstructor(java.lang.String fieldName,
JClassType type,
java.lang.String... args)
fieldName - the field to initializetype - the type of the fieldargs - arguments to the constructor callpublic java.lang.String tokenForExpression(java.lang.String expression)
expression - public void warn(java.lang.String message)
public void warn(java.lang.String message,
java.lang.Object... params)
public void warn(XMLElement context,
java.lang.String message,
java.lang.Object... params)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||