|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry5.internal.transform.BridgeClassTransformation
public class BridgeClassTransformation
A re-implementation of ClassTransformation
around an instance of PlasticClass
, acting as a bridge
for code written against the 5.2 and earlier APIs to work with the 5.3 API.
Constructor Summary | |
---|---|
BridgeClassTransformation(PlasticClass plasticClass,
TransformationSupport support,
MutableComponentModel model)
|
Method Summary | ||
---|---|---|
void |
addComponentEventHandler(String eventType,
int minContextValues,
String methodDescription,
ComponentEventHandler handler)
Adds advice to the Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent) method. |
|
void |
addImplementedInterface(Class interfaceClass)
Transforms the class to implement the indicated interface. |
|
|
addIndirectInjectedField(Class<T> type,
String suggestedName,
ComponentValueProvider<T> provider)
Like ClassTransformation.addInjectedField(Class, String, Object) , but instead of specifying the value,
a provider for the value is specified. |
|
String |
addInjectedField(Class type,
String suggestedName,
Object value)
Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter. |
|
TransformField |
createField(int modifiers,
String type,
String suggestedName)
Defines a new declared field for the class. |
|
|
getAnnotation(Class<T> annotationClass)
Searches for the specified annotation, returning the matching annotation instance. |
|
String |
getClassName()
Returns the fully qualified class name of the class being transformed. |
|
TransformField |
getField(String fieldName)
Locates a declared field by its field name. |
|
org.slf4j.Logger |
getLogger()
Returns a logger, based on the class name being transformed, to which warnings or errors concerning the class being transformed may be logged. |
|
TransformMethod |
getOrCreateMethod(TransformMethodSignature signature)
Locates and returns the method if declared in this class; If not, the method is added to the class. |
|
boolean |
isDeclaredMethod(TransformMethodSignature signature)
Determines if the class being transformed includes a declared (not inherited) method with the provided signature. |
|
boolean |
isField(String fieldName)
Returns true if the indicated name is a private instance field. |
|
boolean |
isRootTransformation()
Returns true if this transformation represents a root class (one that extends directly from Object), or false if this transformation is an sub-class of another transformed class. |
|
List<TransformField> |
matchFields(Predicate<TransformField> predicate)
Finds all unclaimed fields matched by the provided predicate. |
|
List<TransformField> |
matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
Returns a sorted list of declared instance fields with the indicated annotation. |
|
List<TransformMethod> |
matchMethods(Predicate<TransformMethod> predicate)
Finds all methods matched by the provided predicate. |
|
List<TransformMethod> |
matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
Finds all methods matched by the provided predicate. |
|
List<TransformField> |
matchUnclaimedFields()
Matches all fields that are not claimed. |
|
String |
newMemberName(String suggested)
Returns the name of a new member (field or method). |
|
String |
newMemberName(String prefix,
String baseName)
As with ClassTransformation.newMemberName(String) , but the suggested name is constructed from the prefix
and base name. |
|
Class |
toClass(String type)
Converts a type name into a corresponding class (possibly, a transformed class). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BridgeClassTransformation(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model)
Method Detail |
---|
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
AnnotationProvider
getAnnotation
in interface AnnotationProvider
annotationClass
- used to select the annotation to return
public String getClassName()
ClassTransformation
getClassName
in interface ClassTransformation
public String newMemberName(String suggested)
ClassTransformation
newMemberName
in interface ClassTransformation
suggested
- the suggested value for the member
public String newMemberName(String prefix, String baseName)
ClassTransformation
ClassTransformation.newMemberName(String)
, but the suggested name is constructed from the prefix
and base name. An
underscore will separate the prefix from the base name.
newMemberName
in interface ClassTransformation
prefix
- for the generated namebaseName
- a name, often of an existing field or method
public List<TransformField> matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
ClassTransformation
matchFieldsWithAnnotation
in interface ClassTransformation
public List<TransformMethod> matchMethods(Predicate<TransformMethod> predicate)
ClassTransformation
matchMethods
in interface ClassTransformation
predicate
- Used to filter the list
public List<TransformMethod> matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
ClassTransformation
matchMethodsWithAnnotation
in interface ClassTransformation
annotationType
- Used to filter the list
public List<TransformField> matchFields(Predicate<TransformField> predicate)
ClassTransformation
matchFields
in interface ClassTransformation
predicate
- used for matching
public TransformField getField(String fieldName)
ClassTransformation
getField
in interface ClassTransformation
fieldName
- of declared field
public List<TransformField> matchUnclaimedFields()
ClassTransformation
matchUnclaimedFields
in interface ClassTransformation
public boolean isField(String fieldName)
ClassTransformation
isField
in interface ClassTransformation
public TransformField createField(int modifiers, String type, String suggestedName)
ClassTransformation
createField
in interface ClassTransformation
modifiers
- modifiers for the field (typically, Modifier.PRIVATE
)type
- the type for the field, as a stringsuggestedName
- the desired name for the field, which may be modified (for uniqueness) when
returned
public String addInjectedField(Class type, String suggestedName, Object value)
ClassTransformation
addInjectedField
in interface ClassTransformation
type
- the type of object to injectsuggestedName
- the suggested name for the new fieldvalue
- to be injected. This value is retained.
public <T> TransformField addIndirectInjectedField(Class<T> type, String suggestedName, ComponentValueProvider<T> provider)
ClassTransformation
ClassTransformation.addInjectedField(Class, String, Object)
, but instead of specifying the value,
a provider for the value is specified. In the generated class' constructor, the provider
will be passed the ComponentResources
and will return the final value; thus
each component instance will receive a matching unique instance via the provider.
addIndirectInjectedField
in interface ClassTransformation
type
- type of value to injectsuggestedName
- suggested name for the new fieldprovider
- injected into the component to provide the value
public void addImplementedInterface(Class interfaceClass)
ClassTransformation
TODO: Checking that the names of methods in the interface do not conflict with the names of methods present in the (unmodified) class.
addImplementedInterface
in interface ClassTransformation
interfaceClass
- the interface to be implemented by the classpublic Class toClass(String type)
ClassTransformation
toClass
in interface ClassTransformation
public org.slf4j.Logger getLogger()
ClassTransformation
getLogger
in interface ClassTransformation
public boolean isRootTransformation()
ClassTransformation
isRootTransformation
in interface ClassTransformation
public TransformMethod getOrCreateMethod(TransformMethodSignature signature)
ClassTransformation
getOrCreateMethod
in interface ClassTransformation
signature
- identifies the method to locate, override or createpublic boolean isDeclaredMethod(TransformMethodSignature signature)
ClassTransformation
isDeclaredMethod
in interface ClassTransformation
signature
- identifies method to search for
public void addComponentEventHandler(String eventType, int minContextValues, String methodDescription, ComponentEventHandler handler)
ClassTransformation
Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent)
method.
If the handler is invoked,
the return value of the method will be overriden to true. Updates
the model to
indicate that there is a handler for the named event. Existing handlers, or super-class handlers,
are invoked first.
addComponentEventHandler
in interface ClassTransformation
eventType
- name of event to be handledminContextValues
- minimum number of event context values required to invoke the methodmethodDescription
- Text description of what the handler does (used with Event.setMethodDescription(String)
)handler
- the handler to invoke
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |