|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.inject.rebind.util.SourceWriteUtil
public class SourceWriteUtil
Simple helper object for source writing.
Constructor Summary | |
---|---|
protected |
SourceWriteUtil(KeyUtil keyUtil,
NameGenerator nameGenerator,
MemberCollector memberCollector,
BindingIndex bindingIndex)
|
Method Summary | |
---|---|
java.lang.String |
appendFieldInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
java.lang.Iterable<com.google.gwt.core.ext.typeinfo.JField> fields,
java.lang.String injecteeName)
Appends a field injecting method for each passed field to the sourceWriter and returns a string that invokes all written
methods. |
java.lang.String |
appendMemberInjection(com.google.gwt.user.rebind.SourceWriter writer,
Key<?> key)
Appends a full member injection (methods and fields) to the provided writer. |
java.lang.String |
createConstructorInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
com.google.gwt.core.ext.typeinfo.JConstructor constructor)
Appends a constructor injecting method to the sourceWriter and
returns a string that invokes the written method. |
java.lang.String |
createFieldInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
com.google.gwt.core.ext.typeinfo.JField field,
java.lang.String injecteeName)
Appends a field injecting method to the sourceWriter and returns a
string that invokes the written method. |
java.lang.String |
createMethodCallWithInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
com.google.gwt.core.ext.typeinfo.JAbstractMethod method,
java.lang.String injecteeName)
Appends a new method to the sourceWriter that calls the passed
method and returns a string that invokes the written method. |
java.lang.String |
createMethodCallWithInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
com.google.gwt.core.ext.typeinfo.JAbstractMethod method,
java.lang.String injecteeName,
java.lang.String[] parameterNames)
Appends a new method to the sourceWriter that calls the passed
method and returns a string that invokes the written method. |
java.lang.String |
createMethodInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter,
java.lang.Iterable<? extends com.google.gwt.core.ext.typeinfo.JAbstractMethod> methods,
java.lang.String injecteeName)
Appends a method injecting method to the sourceWriter and returns
a string that invokes the written method. |
java.lang.String |
getSourceName(java.lang.reflect.Type type)
Returns a string representation of the passed type's name while ensuring that all type names (base and parameters) are converted to source type names. |
java.lang.String |
getSourceName(TypeLiteral<?> typeLiteral)
Alternate toString method for TypeLiterals that fixes a JDK bug that was replicated in Guice. |
void |
writeBindingContext(com.google.gwt.user.rebind.SourceWriter writer,
BindingContext context)
Writes out a binding context, followed by a newline. |
void |
writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer,
BindingContext bindingContext,
Key key)
Write the Javadoc for the binding of a particular key, showing the context of the binding. |
void |
writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer,
BindingContext bindingContext,
java.lang.String description)
Write a Javadoc comment for a binding, including its context. |
void |
writeMethod(com.google.gwt.user.rebind.SourceWriter writer,
java.lang.String signature,
java.lang.String body)
Writes a method with the given signature and body to the source writer. |
void |
writeNativeMethod(com.google.gwt.user.rebind.SourceWriter writer,
java.lang.String signature,
java.lang.String body)
Writes a native method with the given signature and body to the source writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Inject protected SourceWriteUtil(KeyUtil keyUtil, NameGenerator nameGenerator, MemberCollector memberCollector, BindingIndex bindingIndex)
Method Detail |
---|
public java.lang.String appendFieldInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, java.lang.Iterable<com.google.gwt.core.ext.typeinfo.JField> fields, java.lang.String injecteeName)
sourceWriter
and returns a string that invokes all written
methods.
sourceWriter
- writer to which the injecting method is writtenfields
- fields to be injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call string
public java.lang.String createFieldInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, com.google.gwt.core.ext.typeinfo.JField field, java.lang.String injecteeName)
sourceWriter
and returns a
string that invokes the written method.
sourceWriter
- writer to which the injecting method is writtenfield
- field to be injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call string
public java.lang.String createMethodInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, java.lang.Iterable<? extends com.google.gwt.core.ext.typeinfo.JAbstractMethod> methods, java.lang.String injecteeName)
sourceWriter
and returns
a string that invokes the written method. The values for the passed
method's parameters are retrieved through the
Ginjector
.
If the passed method collection contains only one actual method, the native
method will pass on (i.e. return) the result of the actual method's
invocation, if any.
The passed method collection can contain constructors (they'll be treated
correctly) if no injecteeName
is passed. The same applies for
static methods.
If a method without parameters is provided, that method will be called and
no parameters will be passed.
sourceWriter
- writer to which the injecting method is writtenmethods
- methods to be called & injectedinjecteeName
- variable that references the object into which values
are injected, in the context of the returned call string. If
null
all passed methods are called as static/constructors.
public java.lang.String createConstructorInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, com.google.gwt.core.ext.typeinfo.JConstructor constructor)
sourceWriter
and
returns a string that invokes the written method. The written method
returns the constructed object.
sourceWriter
- writer to which the injecting method is writtenconstructor
- constructor to call
public java.lang.String createMethodCallWithInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, com.google.gwt.core.ext.typeinfo.JAbstractMethod method, java.lang.String injecteeName)
sourceWriter
that calls the passed
method and returns a string that invokes the written method. The written
method returns the passed method's return value, if any.
If a method without parameters is provided, that method will be called and
no parameters will be passed.
sourceWriter
- writer to which the injecting method is writtenmethod
- method to call (can be constructor)injecteeName
- variable that references the object into which values
are injected, in the context of the returned call string. If null
all passed methods are called as static/constructors.
public java.lang.String createMethodCallWithInjection(com.google.gwt.user.rebind.SourceWriter sourceWriter, com.google.gwt.core.ext.typeinfo.JAbstractMethod method, java.lang.String injecteeName, java.lang.String[] parameterNames)
sourceWriter
that calls the passed
method and returns a string that invokes the written method. The written
method returns the passed method's return value, if any.
If a method without parameters is provided, that method will be called and
no parameters will be passed. If the passed method declared any checked
exceptions, the generated method will catch and rethrow those as
CreationException
.
sourceWriter
- writer to which the injecting method is writtenmethod
- method to call (can be constructor)injecteeName
- variable that references the object into which values
are injected, in the context of the returned call string. If null
all passed methods are called as static/constructors.parameterNames
- array with parameter names that can replace getter
methods (usually used to fetch injected values) in the returned
string. The array length must match the number of method
parameters. A null
value denotes that the getter method
should be used.
public void writeBindingContext(com.google.gwt.user.rebind.SourceWriter writer, BindingContext context)
Binding contexts may contain newlines; this routine translates those for the SourceWriter to ensure that indents, Javadoc comments, etc are handled properly.
public void writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer, BindingContext bindingContext, java.lang.String description)
description
- The description of the binding printed before its
location, such as "Foo bound at: "writer
- The writer to use in displaying the context.bindingContext
- The context of the binding.public void writeBindingContextJavadoc(com.google.gwt.user.rebind.SourceWriter writer, BindingContext bindingContext, Key key)
key
- The bound key.writer
- The writer to use to write this comment.bindingContext
- The context of the binding.public void writeMethod(com.google.gwt.user.rebind.SourceWriter writer, java.lang.String signature, java.lang.String body)
writer
- writer that the method is written tosignature
- method's signaturebody
- method's bodypublic void writeNativeMethod(com.google.gwt.user.rebind.SourceWriter writer, java.lang.String signature, java.lang.String body)
writer
- writer that the method is written tosignature
- method's signaturebody
- method's bodypublic java.lang.String appendMemberInjection(com.google.gwt.user.rebind.SourceWriter writer, Key<?> key)
writer
- source writer to write tokey
- key for which the injection is performed
public java.lang.String getSourceName(TypeLiteral<?> typeLiteral) throws NoSourceNameException
typeLiteral
- type for which string will be returned
NoSourceNameException
- if source name is not available for typepublic java.lang.String getSourceName(java.lang.reflect.Type type) throws NoSourceNameException
type
- type for which string will be returned
NoSourceNameException
- if source name is not available for type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |