|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta
public class ClassMeta
Base class for various metadata (model) classes.
This holds metadata common to all model classes that represent a JSF entity, eg a component, converter, validator, renderer. In all these cases, the class has a type, a parent and optionally a list of implemented interfaces.
Instances of this type are intended primarily to map to entries in generated JSP TLD files, faces-config.xml files and similar. The "class" attribute on this class contains the name of the java class that implements that entity.
However there are also instances of this class that represent "abstract" entities that are not directly referenced by TLD or faces-config files; they exist to represent ancestor classes of the concrete entities.
The instances are created via annotations on Java classes. Therefore each ClassMeta has a "sourceClass" property that records the name of the annotated class. In simple cases, "class" and "sourceClass" are the same, ie the JSF entity is the class that holds the relevant annotations. But this is not true in the case of "code generation"; here the class property references the actual JSF entity (the generated class).
As described in the documentation for the parent attribute, the ClassMeta objects describe a java inheritance tree, but it is not quite the same as the real java inheritance hierarchy for the annotated java classes. The ClassMeta data omits any classes in the hierarchy that are not annotated, as they are not relevant for the purposes of metadata inheritance.
Constructor Summary | |
---|---|
protected |
ClassMeta(String xmlElementName)
Constructor. |
Method Summary | |
---|---|
void |
addInterfaceClassName(String name)
|
static void |
addXmlRules(org.apache.commons.digester.Digester digester,
String prefix)
Add digester rules to repopulate an instance of this type from an xml file. |
String |
getClassName()
The fully-qualified name of the JSF entity class, ie the class that actually implements a Component, Converter, Validator, Renderer, etc. |
List |
getInterfaceClassNames()
The list of relevant interface classes. |
String |
getModelId()
Indicates which "group" of metadata this class belongs to. |
String |
getPackageName()
Utility method to return just the packagename part of the className attribute. |
String |
getParentClassName()
The nearest relevant (annotated) ancestor class of the class that this metadata was extracted from. |
String |
getSourceClassName()
Return the className of the real java class from which this metadata was gathered. |
String |
getSourceClassParentClassName()
|
protected void |
merge(ClassMeta other)
Merge any inheritable data from the specified "other" instance into the metadata held by this instance. |
void |
setClassName(String className)
|
void |
setInterfaceClassNames(List classNames)
|
void |
setModelId(String modelId)
|
void |
setParentClassName(String className)
|
void |
setSourceClassName(String sourceClassName)
|
void |
setSourceClassParentClassName(String sourceClassParentClassName)
Return the real java parent class of the class from which this metadata was gathered (see classSource property). |
protected void |
writeXml(XmlWriter out)
Write the properties of this instance out as xml. |
protected void |
writeXmlComplex(XmlWriter out)
See documentation for writeXml and writeXmlSimple methods. |
protected void |
writeXmlSimple(XmlWriter out)
Write this model out as xml. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ClassMeta(String xmlElementName)
Method Detail |
---|
public static void addXmlRules(org.apache.commons.digester.Digester digester, String prefix)
protected void writeXml(XmlWriter out)
The name of the xml element that is created to hold the properties was specified when the constructor was called.
Subclasses that want to output their own properties should not override this method. Instead, they should override writeXmlSimple (and in rare cases writeXmlComplex).
Having two write methods (writeXmlSimple/writeXmlComplex) gives some basic control over the order in which data is written to xml, in order to make the generated xml look nice. Any properties written in writeXmlSimple will appear in the output file before properties written by writeXmlComplex. Therefore, properties which are "easily read" should be written out in a writeXmlSimple method. Data which has large CDATA blocks, or complicated nested structure should be written out in a writeXmlComplex method so that the "simple" stuff can be easily read and is not buried in the middle of the harder-to-read output.
protected void writeXmlSimple(XmlWriter out)
Subclasses that wish to write out properties as xml should override this method, call the super implementation, then call methods on the XmlWriter object to output their data.
protected void writeXmlComplex(XmlWriter out)
protected void merge(ClassMeta other)
public String getModelId()
Projects can inherit metadata from other projects, in which case all the ClassMeta objects end up in one big collection. But for some purposes it is necessary to iterate over the objects belonging to only one project (eg when generating components). This return value can be tested to check which "group" (project) a particular instance belongs to.
public void setModelId(String modelId)
public String getClassName()
The specified class may be a hand-written one, or one created via code generation.
public void setClassName(String className)
public String getPackageName()
public String getParentClassName()
For example, when a class is marked as a Component class, then this will refer to the nearest ancestor class that is also marked as a Component class. Note that this is "consistent with" the actual Java class hierarchy for annotated classes that were used to create this data, but skips java classes that were not annotated (and are therefore irrelevant for metadata purposes).
The value of this attribute will match the className attribute of another ClassMeta object. Following the chain of ParentClassName links (plus Interface links) gives all the ClassMeta objects needed to determine the set of metadata properties for a JSF entity.
public void setParentClassName(String className)
public List getInterfaceClassNames()
For example, when a class is marked as a Component class, then this will refer to the list of interfaces which that class implements that are also marked as a component.
public void setInterfaceClassNames(List classNames)
public void addInterfaceClassName(String name)
public String getSourceClassName()
This is mostly used for documentation. However when generating code in "template mode", this is used to locate the original class in order to find the source code to copy. It is also used for some reason in MakeComponentsMojo when determining whether to generate a class or not - this is probably wrong.
public void setSourceClassName(String sourceClassName)
public void setSourceClassParentClassName(String sourceClassParentClassName)
This value is usually the same as property parentClassName. However if the parent of the annotated class is not itself annotated, then this property still points to the real java parent (which will not have a ClassMeta object representing it) while property parentClass will point to the nearest superclass that does have an annotation (and does have a corresponding ClassMeta object).
This information is needed for code generation.
public String getSourceClassParentClassName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |