Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/entity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26289
Modified Files:
PrimaryKeyClassPlugin.java PrimaryKeyClassPlugin.vm
Added Files:
PkMetadata.java
Log Message:
no message
Index: PrimaryKeyClassPlugin.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/entity/PrimaryKeyClassPlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PrimaryKeyClassPlugin.java 13 Sep 2005 02:22:32 -0000 1.3
--- PrimaryKeyClassPlugin.java 6 Oct 2005 13:46:23 -0000 1.4
***************
*** 1,88 ****
! /*
! * Copyright (c) 2005
! * XDoclet Team
! * All rights reserved.
! */
! package org.xdoclet.plugin.ejb.entity;
!
! import java.text.MessageFormat;
!
! import org.generama.QDoxCapableMetadataProvider;
! import org.generama.TemplateEngine;
! import org.generama.WriterMapper;
!
! import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbJavaGeneratingPlugin;
! import org.xdoclet.plugin.ejb.EjbRuntime;
! import org.xdoclet.plugin.ejb.EjbUtils;
! import org.xdoclet.plugin.ejb.qtags.EjbPkTag;
! import org.xdoclet.plugin.ejb.qtags.TagLibrary;
!
! import com.thoughtworks.qdox.model.JavaClass;
!
! /**
! * Primary key class plugin
! *
! * @author Diogo Quintela
! * @version $Revision$
! */
! public class PrimaryKeyClassPlugin extends EjbJavaGeneratingPlugin {
! private EjbUtils ejbUtils;
!
! public PrimaryKeyClassPlugin(TemplateEngine templateEngine,
QDoxCapableMetadataProvider metadataProvider,
! WriterMapper writerMapper, EjbConfig config) throws
ClassNotFoundException {
! super(templateEngine, metadataProvider, writerMapper);
!
! EjbRuntime.setPlugin(this);
!
! setPackageregex("beans");
! setPackagereplace("util");
! setFileregex(config.getEjbReplaceRegex());
! setFilereplace("PK");
! setMultioutput(true);
!
! this.ejbUtils = new EjbUtils();
!
! new TagLibrary(metadataProvider);
! }
!
! public EjbConfig getConfig() {
! return EjbRuntime.getConfig();
! }
!
! public EjbUtils getEjbUtils() {
! return this.ejbUtils;
! }
!
!
! public boolean shouldGenerate(Object metadata) {
! JavaClass javaClass = (JavaClass) metadata;
! boolean generate = ejbUtils.shouldGenerate(javaClass);
! generate &= ejbUtils.isEntityBean(javaClass);
! EjbPkTag pkTag = (EjbPkTag) javaClass.getTagByName("ejb.pk");
!
! if (pkTag != null) {
! generate &= pkTag.isGenerate();
! // TODO: We should only generate if there is at least
! // one @ejb.pk-field i guess
! }
!
! return generate;
! }
!
! protected String getLocalyDefinedFullClassName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null) ? pkTag.getClass_() : null;
! }
!
! protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null && pkTag.getPattern() != null)
! ? MessageFormat.format(pkTag.getPattern(), new String[]
{ejbUtils.getEjbName(clazz)}) : null;
! }
!
! protected String getLocalyDefinedPackageName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null) ? pkTag.getPackage() : null;
! }
}
\ No newline at end of file
--- 1,423 ----
! /*
! * Copyright (c) 2005
! * XDoclet Team
! * All rights reserved.
! */
! package org.xdoclet.plugin.ejb.entity;
!
! import java.text.MessageFormat;
!
! import java.util.ArrayList;
! import java.util.Arrays;
! import java.util.Collection;
! import java.util.Collections;
! import java.util.HashMap;
! import java.util.Iterator;
! import java.util.List;
! import java.util.Map;
!
! import org.generama.QDoxCapableMetadataProvider;
! import org.generama.VelocityTemplateEngine;
! import org.generama.WriterMapper;
!
! import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbJavaGeneratingPlugin;
! import org.xdoclet.plugin.ejb.EjbJavaType;
! import org.xdoclet.plugin.ejb.EjbRuntime;
! import org.xdoclet.plugin.ejb.EjbUtils;
! import org.xdoclet.plugin.ejb.qtags.EjbBeanTag;
! import org.xdoclet.plugin.ejb.qtags.EjbPkFieldTag;
! import org.xdoclet.plugin.ejb.qtags.EjbPkTag;
! import org.xdoclet.plugin.ejb.qtags.TagLibrary;
!
! import com.thoughtworks.qdox.model.BeanProperty;
! import com.thoughtworks.qdox.model.JavaClass;
! import com.thoughtworks.qdox.model.JavaMethod;
! import com.thoughtworks.qdox.model.Type;
!
! /**
! * Primary key class plugin
! *
! * @author Diogo Quintela
! * @version $Revision$
! */
! public class PrimaryKeyClassPlugin extends EjbJavaGeneratingPlugin {
! private EjbUtils ejbUtils;
!
! /** Cache for hierarchy resolver */
! private Map pkHierarchyCache = new HashMap();
!
! public PrimaryKeyClassPlugin(VelocityTemplateEngine templateEngine,
! QDoxCapableMetadataProvider metadataProvider, WriterMapper
writerMapper, EjbConfig config)
! throws ClassNotFoundException {
! super(templateEngine, metadataProvider, writerMapper);
! EjbRuntime.setPlugin(this);
! setPackageregex("beans");
! setPackagereplace("util");
! setFileregex(config.getEjbReplaceRegex());
! setFilereplace("PK");
! setMultioutput(true);
! this.ejbUtils = new EjbUtils();
! new TagLibrary(metadataProvider);
! }
!
! public EjbConfig getConfig() {
! return EjbRuntime.getConfig();
! }
!
! public EjbUtils getEjbUtils() {
! return this.ejbUtils;
! }
!
! public String getExtends(JavaClass javaClass) {
! PkMetadata pkHierarchy = getMetaPk(javaClass);
!
! // We'll go up twice, as the first above is the metadata from the
class being generated
! pkHierarchy = (pkHierarchy != null) ? pkHierarchy.getParent() : null;
! return (pkHierarchy != null) ? pkHierarchy.getType().toString() :
"java.lang.Object";
! }
!
! public String[] getImplements(JavaClass javaClass) {
! Collection implementsLst = new ArrayList();
! PkMetadata pkHierarchy = getMetaPk(javaClass);
! implementsLst.addAll(Arrays.asList(pkHierarchy.getImplements()));
!
! if (!implementsLst.contains("java.io.Serializable")) {
! implementsLst.add("java.io.Serializable");
! }
!
! return (String[]) implementsLst.toArray(new String[0]);
! }
!
! public boolean shouldGenerate(Object metadata) {
! JavaClass javaClass = (JavaClass) metadata;
! boolean generate = false;
! PkMetadata pkHierarchy = getMetaPk(javaClass);
!
! if (pkHierarchy != null) {
! generate =
pkHierarchy.getType().equals(getVirtualType(javaClass));
! }
!
! return generate;
! }
!
! public PkMetadata getMetaPk(JavaClass javaClass) {
! PkMetadata pkHierarchy = collectPkHierarchy(javaClass);
!
! if (pkHierarchy.isEmptyWithParent()) {
! return pkHierarchy.getParent();
! }
!
! return null;
! }
!
! public List getHierarchy(JavaClass javaClass) {
! List hierarchyLst = new ArrayList();
! hierarchyLst.add(javaClass);
!
! while ((javaClass = javaClass.getSuperJavaClass()) != null) {
! hierarchyLst.add(javaClass);
! }
!
! return hierarchyLst;
! }
!
! private BeanProperty[] getPkProperties(JavaClass javaClass) {
! Collection propList = new ArrayList();
! EjbBeanTag beanTag = (EjbBeanTag) javaClass.getTagByName("ejb.bean");
!
! if (beanTag != null && beanTag.getPrimkeyField() != null) {
! BeanProperty prop =
javaClass.getBeanProperty(beanTag.getPrimkeyField());
!
! if (prop == null || prop.getAccessor() == null) {
! throw ejbUtils.getErrorWithTagLocation(beanTag,
! "Could not find getter for prim-key-field: " +
beanTag.getPrimkeyField());
! }
!
! propList.add(prop);
! } else {
! JavaMethod[] methods = javaClass.getMethods();
! JavaMethod method;
! EjbPkFieldTag tag;
!
! for (int i = 0; i < methods.length; i++) {
! method = methods[i];
!
! if ((tag = (EjbPkFieldTag)
method.getTagByName("ejb.pk-field")) != null) {
! // method must be a property acessor
! if (!method.isPropertyAccessor()) {
! throw ejbUtils.getErrorWithTagLocation(tag, "Tag must
be used on a property getter");
! }
!
!
propList.add(javaClass.getBeanProperty(method.getPropertyName()));
! }
! }
! }
!
! return (BeanProperty[]) propList.toArray(new BeanProperty[0]);
! }
!
! public PkMetadata collectPkHierarchy(JavaClass javaClass) {
! PkMetadata retVal = null;
!
! if (pkHierarchyCache.containsKey(javaClass)) {
! retVal = (PkMetadata) pkHierarchyCache.get(javaClass);
! } else {
! List hierarchyLst = getHierarchy(javaClass);
! Collections.reverse(hierarchyLst); // Top down scan
! PkClass current = new PkClass();
! EjbPkTag pkTag;
!
! for (Iterator iter = hierarchyLst.iterator(); iter.hasNext();) {
! JavaClass clazz = (JavaClass) iter.next();
! pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
!
! if (pkTag != null) {
! String pkExtends = pkTag.getExtends();
!
! if (pkExtends != null) {
! // We need to test if so far we haven't collected any
properties to allow to set top class
! // If we don't check this, we could be loosing
primary key's properties
! // NOTE: xdoclet1 allowed this, although it generates
non compiling class
! if (current.isEmpty() && current.getParent() == null)
{
! current.setType(new EjbJavaType(pkExtends));
! current = new PkClass(current);
! } else {
! throw ejbUtils.getErrorWithTagLocation(pkTag,
! "Can't set \"extends\" property without
loosing current primary key properties: " +
! current);
! }
! }
!
! String[] implementz = pkTag.getImplements();
!
! if (implementz != null) {
! current.addImplements(implementz);
! }
! }
!
! current.addProperties(getPkProperties(clazz));
!
! if (!current.isSimpleProperty() && !current.isEmpty() &&
((pkTag == null) || pkTag.isGenerate())) {
! current.setType(getVirtualType(clazz));
! current = new PkClass(current);
! }
! }
!
! // Set into cache
! pkHierarchyCache.put(javaClass, current);
!
! // Set return value
! retVal = current;
! }
!
! return retVal;
! }
!
! public String getPad(int depth) {
! StringBuffer retBuf = new StringBuffer();
!
! while (depth-- > 1) {
! retBuf.append(" ");
! }
!
! return retBuf.toString();
! }
!
! public String getSetterName(BeanProperty prop) {
! StringBuffer retBuf = new StringBuffer(prop.getName());
! retBuf.setCharAt(0, Character.toUpperCase(retBuf.charAt(0)));
! retBuf.insert(0, "set");
! return retBuf.toString();
! }
!
! public String getGetterName(BeanProperty prop) {
! StringBuffer retBuf = new StringBuffer(prop.getName());
! retBuf.setCharAt(0, Character.toUpperCase(retBuf.charAt(0)));
!
! if (prop.getType().isA(new Type("boolean")) || prop.getType().isA(new
Type("java.lang.Boolean"))) {
! retBuf.insert(0, "is");
! } else {
! retBuf.insert(0, "get");
! }
!
! return retBuf.toString();
! }
!
! /**
! * Gets primary key field name if exists
! *
! * @param javaClass Entity bean
! *
! * @return The field name if exists
! */
! public String pkField(JavaClass javaClass) {
! PkMetadata pkClassHierarchy = collectPkHierarchy(javaClass);
!
! if (pkClassHierarchy.isSimpleProperty()) {
! return pkClassHierarchy.getProperties()[0].getName();
! }
!
! return null;
! }
!
! /**
! * Get the primary key class specified for a given class. If a primary
key field has been specified, using the
! * <code>primkey-field</code> parameter on the <code>ejb.bean</code> tag,
this will be the return type of that
! * field's getter method.
! * Otherwise, it will be determined by the various parameters of the
<code>ejb.pk</code> tag
! * and the subtask's settings for default pattern, packageSubstitution,
etc.
! *
! * @param javaClass Entity bean
! *
! * @return The primary key for the entity
! * @throws ClassNotFoundException
! */
! public String pkClass(JavaClass javaClass) {
! PkMetadata pkClassHierarchy = collectPkHierarchy(javaClass);
!
! if (pkClassHierarchy.isSimpleProperty()) {
! return pkClassHierarchy.getProperties()[0].getType().toString();
! } else {
! if (pkClassHierarchy.isEmptyWithParent()) {
! pkClassHierarchy = pkClassHierarchy.getParent();
! return pkClassHierarchy.getType().toString();
! } else {
! throw new Error("Cannot resolve primary key class name (" +
javaClass.getFullyQualifiedName() +
! "). Have you forgot to set @ejb.bean \"primkey-field\" or
@ejb.pk-field ? (" + pkClassHierarchy +
! ")");
! }
! }
! }
!
! protected String getLocalyDefinedFullClassName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null) ? pkTag.getClass_() : null;
! }
!
! protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null && pkTag.getPattern() != null)
! ? MessageFormat.format(pkTag.getPattern(), new String[]
{ejbUtils.getEjbName(clazz)}) : null;
! }
!
! protected String getLocalyDefinedPackageName(JavaClass clazz) {
! EjbPkTag pkTag = (EjbPkTag) clazz.getTagByName("ejb.pk");
! return (pkTag != null) ? pkTag.getPackage() : null;
! }
!
! public final static class PkClass implements PkMetadata {
! private EjbJavaType type;
! private List propertiesLst = new ArrayList();
! private List implementsLst = new ArrayList();
! private PkClass parent;
!
! public PkClass(PkClass parent) {
! this.parent = parent;
! }
!
! public PkClass() {
! // no parent
! }
!
! public void addImplements(String[] implementz) {
! implementsLst.addAll(Arrays.asList(implementz));
! }
!
! public String[] getImplements() {
! return (String[]) implementsLst.toArray(new String[0]);
! }
!
! public void addProperty(BeanProperty prop) {
! propertiesLst.add(prop);
! }
!
! public void addProperties(BeanProperty[] prop) {
! propertiesLst.addAll(Arrays.asList(prop));
! }
!
! public BeanProperty[] getProperties() {
! return (BeanProperty[]) propertiesLst.toArray(new
BeanProperty[0]);
! }
!
! public BeanProperty[] getParentProperties() {
! List retVal = new ArrayList();
!
! if (parent != null) {
! retVal.addAll(Arrays.asList(parent.getProperties()));
! retVal.addAll(Arrays.asList(parent.getParentProperties()));
! }
!
! return (BeanProperty[]) retVal.toArray(new BeanProperty[0]);
! }
!
! public EjbJavaType getType() {
! return type;
! }
!
! public PkMetadata getParent() {
! return this.parent;
! }
!
! public void setParent(PkClass parent) {
! this.parent = parent;
! }
!
! public void setType(EjbJavaType type) {
! this.type = type;
! }
!
! public boolean isSimpleProperty() {
! return !hasParent() && (propertiesLst.size() == 1) &&
(implementsLst.size() == 0);
! }
!
! public boolean isEmpty() {
! return (type == null) && (propertiesLst.size() == 0) &&
(implementsLst.size() == 0);
! }
!
! public boolean hasParent() {
! return (parent != null);
! }
!
! public boolean isEmptyWithParent() {
! return isEmpty() && hasParent();
! }
!
! public String toString() {
! StringBuffer retBuf = new StringBuffer();
! retBuf.append('[');
! retBuf.append("type=");
! retBuf.append(type);
! retBuf.append(", properties=");
! retBuf.append('{');
!
! for (Iterator iter = propertiesLst.iterator(); iter.hasNext();) {
! BeanProperty prop = (BeanProperty) iter.next();
! retBuf.append(prop.getName());
!
! if (iter.hasNext()) {
! retBuf.append(',');
! }
! }
!
! retBuf.append('}');
! retBuf.append(", implements=");
! retBuf.append('{');
!
! for (Iterator iter = implementsLst.iterator(); iter.hasNext();) {
! String implementz = (String) iter.next();
! retBuf.append(implementz);
!
! if (iter.hasNext()) {
! retBuf.append(',');
! }
! }
!
! retBuf.append('}');
! retBuf.append(", parent=");
! retBuf.append(parent);
! retBuf.append(']');
! return retBuf.toString();
! }
! }
}
\ No newline at end of file
Index: PrimaryKeyClassPlugin.vm
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/entity/PrimaryKeyClassPlugin.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PrimaryKeyClassPlugin.vm 26 Aug 2005 17:52:30 -0000 1.1
--- PrimaryKeyClassPlugin.vm 6 Oct 2005 13:46:23 -0000 1.2
***************
*** 1,8 ****
! #set( $class = $metadata )
! // ${dontedit}
! // Generated by $plugin.class.name from $class.fullyQualifiedName
! package ${plugin.getDestinationPackage($class)};
!
! public class ${plugin.getDestinationClassname($class)} {
! // TODO:
! }
--- 1,156 ----
! #set( $class = $metadata )
! #set( $metaPk = $plugin.getMetaPk($class) )
! // ${dontedit}
! // Generated by $plugin.class.name from $class.fullyQualifiedName
! package ${plugin.getDestinationPackage($class)};
!
! /*
! * Meta-class hierarchy dump:
! * $metaPk
! */
! public class ${plugin.getDestinationClassname($class)}
! extends $plugin.getExtends($class)
! implements #foreach($interface in $plugin.getImplements($class)
)#if($velocityCount > 1), #end$interface#end {
! #foreach($property in $metaPk.getProperties())
! public $property.type $property.name;
! #end
!
! public ${plugin.getDestinationClassname($class)}() {
! }
!
! #if( !$plugin.isEmpty($metaPk.properties) ||
!$plugin.isEmpty($metaPk.parentProperties) )
! public ${plugin.getDestinationClassname($class)}(#foreach($property in
$metaPk.properties)#if($velocityCount > 1), #end$property.type
$property.name#end#foreach($property in
$metaPk.parentProperties)#if(($velocityCount > 1) ||
!$plugin.isEmpty($metaPk.properties)), #end$property.type $property.name#end) {
! #if( !$plugin.isEmpty($metaPk.parentProperties) )
! super(#foreach($property in
$metaPk.parentProperties)#if($velocityCount > 1), #end$property.name#end);
! #end
! #foreach($property in $metaPk.properties)
! this.$property.name = $property.name;
! #end
! }
! #end
! #foreach($property in $metaPk.properties)
!
! public void $plugin.getSetterName($property)($property.type
$property.name) {
! this.$property.name = $property.name;
! }
!
! public $property.type $plugin.getGetterName($property)() {
! return this.$property.name;
! }
! #end
!
! public int hashCode() {
! int _hashCode =#if( !$plugin.isEmpty($metaPk.parentProperties) )
super.hashCode()#else 0#end;
! #foreach($property in $metaPk.properties)
! #if( $property.type.isArray() )
! #set( $prop = "this.${property.name}")
! #foreach ( $idx in [1..${property.type.dimensions}] )
! ${plugin.getPad($idx)}for (int i$idx = 0; ($prop != null) &&
(i$idx < ${prop}.length); i$idx++)
! #set( $prop = "${prop}[i$idx]")
! #if( $idx == ${property.type.dimensions})
! #if( $property.type.isPrimitive() )
! #if( $property.type == "boolean" )
! ${plugin.getPad($idx)}_hashCode += ${prop} ? 1 : 0;
! #else
! ${plugin.getPad($idx)}_hashCode += (int)${prop};
! #end## end of is "boolean"
! #else
! ${plugin.getPad($idx)}_hashCode += (${prop} != null) ?
${prop}.hashCode() : 0;
! #end## end of isPrimitive
! #end## end of idx == type.dimensions
! #end## end of foreach
! #else## else of isArray
! #if( $property.type.isPrimitive() )
! #if( $property.type == "boolean" )
! _hashCode += this.${property.name} ? 1 : 0;
! #else
! _hashCode += (int)this.${property.name};
! #end## end of is "boolean"
! #else
! _hashCode += (this.${property.name} != null) ?
this.${property.name}.hashCode() : 0;
! #end## end of isPrimitive
! #end## end of isArray
! #end## end of foreach metaPk.properties
! return _hashCode;
! }
!
! public boolean equals(Object other) {
! if (other == null || !(other instanceof
${plugin.getDestinationClassname($class)})) {
! return false;
! }
! ${plugin.getDestinationClassname($class)} otherPk =
(${plugin.getDestinationClassname($class)})other;
! boolean equals =#if( !$plugin.isEmpty($metaPk.parentProperties) )
super.equals(other)#else true#end;
! #foreach($property in $metaPk.properties)
! #if( $property.type.isArray() )
! equals &= (this.${property.name} != null) ?
(otherPk.${property.name} != null) : (otherPk.${property.name} == null);
! #set( $prop = "${property.name}")
! #foreach ( $idx in [1..${property.type.dimensions}] )
! ${plugin.getPad($idx)}for (int i$idx = 0; equals && ($prop !=
null) && (i$idx < ${prop}.length); i$idx++) {
! #set( $prop = "${prop}[i$idx]")
! #if( $idx == ${property.type.dimensions})
! #if( $property.type.isPrimitive() )
! ${plugin.getPad($idx)}equals &= (this.${prop} ==
otherPk.${prop});
! #else
! ${plugin.getPad($idx)}equals &= (this.${prop} != null)
? (this.${prop}.equals(otherPk.${prop})) : (otherPk.${prop} == null);
! #end
! #else
! ${plugin.getPad($idx)}equals &= (this.${prop} != null)
? (otherPk.${prop} != null) : (otherPk.${prop} == null);
! #end
! #end## end of foreach
! #foreach ( $idx in [${property.type.dimensions}..1] )
! ${plugin.getPad($idx)}}
! #end
! #else
! #if( $property.type.isPrimitive() )
! equals &= (this.${property.name} == otherPk.${property.name});
! #else
! equals &= (this.${property.name} != null) ?
this.${property.name}.equals(otherPk.${property.name}) :
(otherPk.${property.name} == null);
! #end
! #end
! #end
! return equals;
! }
!
! public String toString() {
! StringBuffer retBuf = new StringBuffer();
! #if( !$plugin.isEmpty($metaPk.parentProperties) )
! retBuf.append(super.toString());
! #end
! #foreach($property in $metaPk.properties)
! #if(($velocityCount > 1) || !$plugin.isEmpty($metaPk.parentProperties))
! retBuf.append(',');
! #end
! #if( $property.type.isArray() )
! retBuf.append("${property.name}={");
! #set( $prop = "this.${property.name}")
! #set( $cond = "false")
! #set( $desc = "")
! #foreach ( $idx in [1..${property.type.dimensions}] )
! ${plugin.getPad($idx)}for (int i$idx = 0; ($prop != null) && (i$idx <
${prop}.length); i$idx++)
! #set( $prop = "${prop}[i$idx]")
! #set( $cond = "(i$idx > 0) || ${cond}")
! #set( $desc = "${desc}append(i$idx).")
! #if( $idx == ${property.type.dimensions})
! ${plugin.getPad($idx)}{
! ${plugin.getPad($idx)} if ($cond) retBuf.append(',');
! ${plugin.getPad($idx)} retBuf.${desc}append('=').append(${prop});
! ${plugin.getPad($idx)}}
! #end
! #set( $desc = "${desc}append(';').")
! #end
! retBuf.append("}");
! #else
! retBuf.append("${property.name}=").append(this.${property.name});
! #end
! #end
! return retBuf.toString();
! }
! #if($plugin.getMergeFile("entitypk-custom.vm").exists())
! #parse("entitypk-custom.vm")
! #else
! // ----------------------------------------------------------------
! // Define your custom append code in a file called entitypk-custom.vm
! // and place it in your merge directory.
! // ----------------------------------------------------------------
! #end
! }
--- NEW FILE: PkMetadata.java ---
/*
* Copyright (c) 2005
* XDoclet Team
* All rights reserved.
*/
package org.xdoclet.plugin.ejb.entity;
import org.xdoclet.plugin.ejb.EjbJavaType;
import com.thoughtworks.qdox.model.BeanProperty;
/**
* Metadata for a primary key class
*
* @author Diogo Quintela
*/
public interface PkMetadata {
/**
* Returns implementation list for this meta-class
*/
public String[] getImplements();
/**
* Returns the properties that this meta-class contains
*/
public BeanProperty[] getProperties();
/**
* Returns the properties that this meta-class parent
* hierarchy contains
*/
public BeanProperty[] getParentProperties();
/**
* The type of this meta-class
*/
public EjbJavaType getType();
/**
* The meta-class parent
*/
public PkMetadata getParent();
/**
* Is this a simple meta-class with a single property ?
* If so we could use just the single property itself.
*/
public boolean isSimpleProperty();
/**
* Is this a empty meta-class
*/
public boolean isEmpty();
/**
* Is this a leaf, does it have a parent
*/
public boolean hasParent();
/**
* Is this a empty meta-class that extends other ?
* If so, it's parent it's the meta-class to use
*/
public boolean isEmptyWithParent();
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits