diff --git a/ant/.classpath b/ant/.classpath
new file mode 100644
index 00000000..bc5aeac5
--- /dev/null
+++ b/ant/.classpath
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basics/tags/0.6.4/ant/.project b/ant/.project
similarity index 100%
rename from basics/tags/0.6.4/ant/.project
rename to ant/.project
diff --git a/basics/trunk/ant/pom.xml b/ant/pom.xml
similarity index 100%
rename from basics/trunk/ant/pom.xml
rename to ant/pom.xml
diff --git a/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java b/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java
new file mode 100644
index 00000000..e332bcdb
--- /dev/null
+++ b/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java
@@ -0,0 +1,34 @@
+package org.jvnet.jaxb2_commons.xjc;
+
+import java.io.File;
+import java.lang.reflect.Field;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+
+public class XJC2Task extends com.sun.tools.xjc.XJC2Task {
+
+ @Override
+ public void execute() throws BuildException {
+
+ hack();
+ super.execute();
+ }
+
+ protected void hack() {
+ try {
+ final Field declaredField = getClass().getSuperclass()
+ .getDeclaredField("classpath");
+ declaredField.setAccessible(true);
+ final Path path = (Path) declaredField.get(this);
+ if (path != null) {
+ for (String pathElement : path.list()) {
+ options.classpaths.add(new File(pathElement).toURI()
+ .toURL());
+ }
+ }
+ } catch (Exception ex) {
+ throw new BuildException(ex);
+ }
+ }
+}
diff --git a/basic/.classpath b/basic/.classpath
new file mode 100644
index 00000000..ecf83840
--- /dev/null
+++ b/basic/.classpath
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basics/tags/0.6.4/basic/.project b/basic/.project
similarity index 100%
rename from basics/tags/0.6.4/basic/.project
rename to basic/.project
diff --git a/basics/trunk/basic/pom.xml b/basic/pom.xml
similarity index 100%
rename from basics/trunk/basic/pom.xml
rename to basic/pom.xml
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java
new file mode 100644
index 00000000..a9860669
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java
@@ -0,0 +1,15 @@
+package org.jvnet.jaxb2_commons.plugin;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic";
+
+ public static QName GENERATED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "generated");
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java
new file mode 100644
index 00000000..3a0ee95a
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java
@@ -0,0 +1,80 @@
+package org.jvnet.jaxb2_commons.plugin;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.util.CustomizationUtils;
+
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CEnumLeafInfo;
+import com.sun.tools.xjc.model.CPropertyInfo;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.EnumOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+
+public class CustomizedIgnoring implements Ignoring {
+
+ private final QName[] ignoredCustomizationElementNames;
+
+ public CustomizedIgnoring(QName... names) {
+ this.ignoredCustomizationElementNames = names;
+ }
+
+ public QName[] getIgnoredCustomizationElementNames() {
+ return ignoredCustomizationElementNames;
+ }
+
+ public boolean isIgnored(ClassOutline classOutline) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(classOutline, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnored(EnumOutline enumOutline) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(enumOutline, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnored(FieldOutline fieldOutline) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(fieldOutline, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnored(CClassInfo classInfo) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(classInfo, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnored(CEnumLeafInfo enumLeafInfo) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(enumLeafInfo, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isIgnored(CPropertyInfo propertyInfo) {
+ for (QName name : getIgnoredCustomizationElementNames()) {
+ if (CustomizationUtils.containsCustomization(propertyInfo, name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java
new file mode 100644
index 00000000..d5ae14f6
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java
@@ -0,0 +1,24 @@
+package org.jvnet.jaxb2_commons.plugin;
+
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CEnumLeafInfo;
+import com.sun.tools.xjc.model.CPropertyInfo;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.EnumOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+
+public interface Ignoring {
+
+ public boolean isIgnored(ClassOutline classOutline);
+
+ public boolean isIgnored(EnumOutline enumOutline);
+
+ public boolean isIgnored(FieldOutline fieldOutline);
+
+ public boolean isIgnored(CClassInfo classInfo);
+
+ public boolean isIgnored(CEnumLeafInfo enumLeafInfo);
+
+ public boolean isIgnored(CPropertyInfo propertyInfo);
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java
new file mode 100644
index 00000000..2754259e
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java
@@ -0,0 +1,141 @@
+package org.jvnet.jaxb2_commons.plugin.autoinheritance;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.model.CElementInfo;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.ElementOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class AutoInheritancePlugin extends AbstractParameterizablePlugin {
+
+ private String xmlRootElementsExtend = null;
+ private List xmlRootElementsImplement = new LinkedList();
+
+ private String xmlTypesExtend = null;
+ private List xmlTypesImplement = new LinkedList();
+
+ private List jaxbElementsImplement = new LinkedList();
+
+ public String getXmlRootElementsExtend() {
+ return xmlRootElementsExtend;
+ }
+
+ public void setXmlRootElementsExtend(String globalElementsExtend) {
+ this.xmlRootElementsExtend = globalElementsExtend;
+ }
+
+ public String getXmlRootElementsImplement() {
+ return xmlRootElementsImplement.toString();
+ }
+
+ public void setXmlRootElementsImplement(String xmlRootElementsImplement) {
+ this.xmlRootElementsImplement.add(xmlRootElementsImplement);
+ }
+
+ public String getXmlTypesExtend() {
+ return xmlTypesExtend;
+ }
+
+ public void setXmlTypesExtend(String globalComplexTypesExtend) {
+ this.xmlTypesExtend = globalComplexTypesExtend;
+ }
+
+ public String getXmlTypesImplement() {
+ return xmlTypesImplement.toString();
+ }
+
+ public void setXmlTypesImplement(String xmlTypesImplement) {
+ this.xmlTypesImplement.add(xmlTypesImplement);
+ }
+
+ public String getJaxbElementsImplement() {
+ return jaxbElementsImplement.toString();
+ }
+
+ public void setJaxbElementsImplement(String jaxbElementsImplement) {
+ this.jaxbElementsImplement.add(jaxbElementsImplement);
+ }
+
+ @Override
+ public String getOptionName() {
+ return "XautoInheritance";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses()) {
+ if (classOutline.target.getElementName() != null) {
+ processGlobalElement(classOutline);
+ } else {
+ processGlobalComplexType(classOutline);
+ }
+ }
+ for (final CElementInfo elementInfo : outline.getModel()
+ .getAllElements()) {
+ final ElementOutline elementOutline = outline
+ .getElement(elementInfo);
+ if (elementOutline != null) {
+ processGlobalJAXBElement(elementOutline);
+ }
+ }
+ return true;
+ }
+
+ protected void processGlobalElement(ClassOutline classOutline) {
+
+ generateExtends(classOutline.implClass, xmlRootElementsExtend);
+ generateImplements(classOutline.implClass, xmlRootElementsImplement);
+
+ }
+
+ protected void processGlobalJAXBElement(ElementOutline elementOutline) {
+
+ generateImplements(elementOutline.implClass, jaxbElementsImplement);
+
+ }
+
+ protected void processGlobalComplexType(ClassOutline classOutline) {
+
+ generateExtends(classOutline.implClass, xmlTypesExtend);
+ generateImplements(classOutline.implClass, xmlTypesImplement);
+
+ }
+
+ private void generateExtends(JDefinedClass theClass, String name) {
+ if (name != null) {
+ final JClass targetClass = theClass.owner().ref(name);
+ if (theClass._extends() == theClass.owner().ref(Object.class)) {
+ theClass._extends(targetClass);
+ }
+ }
+ }
+
+ private void generateImplements(JDefinedClass theClass, String name) {
+ if (name != null) {
+ final JClass targetClass = theClass.owner().ref(name);
+ theClass._implements(targetClass);
+ }
+ }
+
+ private void generateImplements(JDefinedClass theClass, List names) {
+ if (names != null && !names.isEmpty()) {
+ for (String name : names) {
+ generateImplements(theClass, name);
+ }
+ }
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java
new file mode 100644
index 00000000..7f4aff8c
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java
@@ -0,0 +1,335 @@
+package org.jvnet.jaxb2_commons.plugin.copyable;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.CopyStrategy;
+import org.jvnet.jaxb2_commons.lang.CopyTo;
+import org.jvnet.jaxb2_commons.lang.JAXBCopyStrategy;
+import org.jvnet.jaxb2_commons.locator.ObjectLocator;
+import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
+import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JConditional;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JOp;
+import com.sun.codemodel.JType;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class CopyablePlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xcopyable";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
+
+ public FieldAccessorFactory getFieldAccessorFactory() {
+ return fieldAccessorFactory;
+ }
+
+ public void setFieldAccessorFactory(
+ FieldAccessorFactory fieldAccessorFactory) {
+ this.fieldAccessorFactory = fieldAccessorFactory;
+ }
+
+ private String copyStrategyClass = JAXBCopyStrategy.class.getName();
+
+ public void setCopyStrategyClass(final String copyStrategy) {
+ this.copyStrategyClass = copyStrategy;
+ }
+
+ public String getCopyStrategyClass() {
+ return copyStrategyClass;
+ }
+
+ public JExpression createCopyStrategy(JCodeModel codeModel) {
+ return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
+ CopyStrategy.class, getCopyStrategyClass());
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.copyable.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.copyable.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses())
+ if (!getIgnoring().isIgnored(classOutline)) {
+
+ processClassOutline(classOutline);
+ }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+
+ ClassUtils._implements(theClass, theClass.owner().ref(Cloneable.class));
+ @SuppressWarnings("unused")
+ final JMethod object$clone = generateObject$clone(classOutline,
+ theClass);
+ ClassUtils._implements(theClass, theClass.owner().ref(CopyTo.class));
+
+ @SuppressWarnings("unused")
+ final JMethod copyTo$copyTo = generateCopyTo$copyTo(classOutline,
+ theClass);
+ @SuppressWarnings("unused")
+ final JMethod copyTo$copyTo1 = generateCopyTo$copyTo1(classOutline,
+ theClass);
+ // @SuppressWarnings("unused")
+ // final JMethod copyable$copyTo = generateCopyable$CopyTo(classOutline,
+ // theClass);
+ // @SuppressWarnings("unused")
+ // final JMethod copyable$copyTo1 =
+ // generateCopyable$CopyTo1(classOutline,
+ // theClass);
+
+ // @SuppressWarnings("unused")
+ // final JMethod copyFrom$copyFrom = generateCopyFrom$CopyFrom(
+ // classOutline, theClass);
+ // @SuppressWarnings("unused")
+ // final JMethod copyable$copyFrom = generateCopyable$CopyFrom(
+ // classOutline, theClass);
+ if (!classOutline.target.isAbstract()) {
+ @SuppressWarnings("unused")
+ final JMethod createCopy = generateCopyTo$createNewInstance(
+ classOutline, theClass);
+
+ }
+ }
+
+ protected JMethod generateCopyTo$createNewInstance(
+ final ClassOutline classOutline, final JDefinedClass theClass) {
+
+ final JMethod existingMethod = theClass.getMethod("createNewInstance",
+ new JType[0]);
+ if (existingMethod == null) {
+
+ final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass
+ .owner().ref(Object.class), "createNewInstance");
+ {
+ final JBlock body = newMethod.body();
+ body._return(JExpr._new(theClass));
+ }
+ return newMethod;
+ } else {
+ return existingMethod;
+ }
+ }
+
+ protected JMethod generateObject$clone(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+
+ final JMethod clone = theClass.method(JMod.PUBLIC, theClass.owner()
+ .ref(Object.class), "clone");
+ {
+ final JBlock body = clone.body();
+ body._return(JExpr.invoke("copyTo").arg(
+ JExpr.invoke("createNewInstance")));
+ }
+ return clone;
+ }
+
+ protected JMethod generateCopyTo$copyTo(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+
+ final JCodeModel codeModel = theClass.owner();
+ final JMethod copyTo$copyTo = theClass.method(JMod.PUBLIC,
+ codeModel.ref(Object.class), "copyTo");
+ {
+ final JVar target = copyTo$copyTo.param(Object.class, "target");
+
+ final JBlock body = copyTo$copyTo.body();
+ final JVar copyStrategy = body.decl(JMod.FINAL,
+ codeModel.ref(CopyStrategy.class), "strategy",
+ createCopyStrategy(codeModel));
+
+ body._return(JExpr.invoke("copyTo").arg(JExpr._null()).arg(target)
+ .arg(copyStrategy));
+ }
+ return copyTo$copyTo;
+ }
+
+ protected JMethod generateCopyTo$copyTo1(ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ ClassUtils._implements(theClass, theClass.owner().ref(CopyTo.class));
+
+ final JMethod copyTo = theClass.method(JMod.PUBLIC, theClass.owner()
+ .ref(Object.class), "copyTo");
+ {
+ final JVar locator = copyTo.param(ObjectLocator.class, "locator");
+ final JVar target = copyTo.param(Object.class, "target");
+ final JVar copyStrategy = copyTo.param(CopyStrategy.class,
+ "strategy");
+
+ final JBlock body = copyTo.body();
+
+ final JVar draftCopy;
+ if (!classOutline.target.isAbstract()) {
+ draftCopy = body.decl(
+ JMod.FINAL,
+ theClass.owner().ref(Object.class),
+ "draftCopy",
+
+ JOp.cond(JOp.eq(target, JExpr._null()),
+ JExpr.invoke("createNewInstance"), target));
+ } else {
+ body._if(JExpr._null().eq(target))
+ ._then()
+ ._throw(JExpr
+ ._new(theClass.owner().ref(
+ IllegalArgumentException.class))
+ .arg("Target argument must not be null for abstract copyable classes."));
+ draftCopy = target;
+ }
+
+ Boolean superClassImplementsCopyTo = StrategyClassUtils
+ .superClassImplements(classOutline, getIgnoring(),
+ CopyTo.class);
+
+ if (superClassImplementsCopyTo == null) {
+
+ } else if (superClassImplementsCopyTo.booleanValue()) {
+ body.invoke(JExpr._super(), "copyTo").arg(locator)
+ .arg(draftCopy).arg(copyStrategy);
+
+ } else {
+
+ }
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ if (declaredFields.length > 0) {
+
+ final JBlock bl = body._if(draftCopy._instanceof(theClass))
+ ._then();
+
+ final JVar copy = bl.decl(JMod.FINAL, theClass, "copy",
+ JExpr.cast(theClass, draftCopy));
+
+ for (final FieldOutline fieldOutline : declaredFields) {
+
+ final FieldAccessorEx sourceFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, JExpr._this());
+ final FieldAccessorEx copyFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, copy);
+
+ if (sourceFieldAccessor.isConstant()) {
+ continue;
+ }
+
+ final JBlock block = bl.block();
+
+ final JBlock setValueBlock;
+ final JBlock unsetValueBlock;
+
+ final JExpression valueIsSet = sourceFieldAccessor
+ .hasSetValue();
+
+ if (!sourceFieldAccessor.isAlwaysSet()
+ && valueIsSet != null) {
+ final JConditional ifValueIsSet = block._if(valueIsSet);
+ setValueBlock = ifValueIsSet._then();
+ unsetValueBlock = ifValueIsSet._else();
+ } else {
+ setValueBlock = block;
+ unsetValueBlock = null;
+ }
+
+ if (setValueBlock != null) {
+
+ final JType copyFieldType = sourceFieldAccessor
+ .getType();
+ final JVar sourceField = setValueBlock.decl(
+ copyFieldType, "source"
+ + fieldOutline.getPropertyInfo()
+ .getName(true));
+ sourceFieldAccessor.toRawValue(setValueBlock,
+ sourceField);
+ final JExpression builtCopy = JExpr
+ .invoke(copyStrategy, "copy")
+ .arg(theClass
+ .owner()
+ .ref(LocatorUtils.class)
+ .staticInvoke("property")
+ .arg(locator)
+ .arg(fieldOutline.getPropertyInfo()
+ .getName(false))
+ .arg(sourceField)).arg(sourceField);
+ final JVar copyField = setValueBlock.decl(
+ copyFieldType, "copy"
+ + fieldOutline.getPropertyInfo()
+ .getName(true),
+ copyFieldType.isPrimitive() ? builtCopy :
+
+ JExpr.cast(copyFieldType, builtCopy));
+ if (copyFieldType instanceof JClass
+ && ((JClass) copyFieldType).isParameterized()) {
+ copyField.annotate(SuppressWarnings.class).param(
+ "value", "unchecked");
+ }
+ copyFieldAccessor.fromRawValue(setValueBlock, "unique"
+ + fieldOutline.getPropertyInfo().getName(true),
+ copyField);
+ }
+ if (unsetValueBlock != null) {
+ copyFieldAccessor.unsetValues(unsetValueBlock);
+
+ }
+ }
+ }
+
+ body._return(draftCopy);
+ }
+ return copyTo;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java
new file mode 100644
index 00000000..9ee7f781
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.copyable;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/copyable";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java
new file mode 100644
index 00000000..9a9ed3b8
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.elementwrapper;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/elementWrapper";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java
new file mode 100644
index 00000000..5a4e6ec1
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java
@@ -0,0 +1,286 @@
+package org.jvnet.jaxb2_commons.plugin.elementwrapper;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.model.AbstractModelPlugin;
+import org.jvnet.jaxb2_commons.xjc.model.concrete.origin.DummyPropertyInfoOrigin;
+import org.jvnet.jaxb2_commons.xml.bind.model.MClassInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MElementPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MElementRefPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MElementRefsPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MElementsPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.MPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementRefPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementRefsPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementsPropertyInfo;
+import org.jvnet.jaxb2_commons.xml.bind.model.util.DefaultPropertyInfoVisitor;
+import org.jvnet.jaxb2_commons.xml.bind.model.util.DefaultTypeInfoVisitor;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.tools.xjc.model.Model;
+import com.sun.tools.xjc.model.nav.NClass;
+import com.sun.tools.xjc.model.nav.NType;
+
+public class ElementWrapperPlugin extends AbstractModelPlugin {
+
+ @Override
+ public String getOptionName() {
+ return "XelementWrapper";
+ }
+
+ @Override
+ public String getUsage() {
+ return "Generates @XmlElementWrapper annotations.";
+ }
+
+ @Override
+ protected void postProcessModel(Model model,
+ final MModelInfo mmodel, ErrorHandler errorHandler) {
+
+ final Collection> classInfos = new ArrayList>(
+ mmodel.getClassInfos());
+ for (final MClassInfo rootClassInfo : classInfos) {
+ if (/*
+ * TODO !getIgnoring().isIgnored(classInfo) &&
+ */true) {
+ List> properties = new ArrayList>(
+ rootClassInfo.getProperties());
+ for (MPropertyInfo propertyInfo0 : properties) {
+
+ propertyInfo0
+ .acceptPropertyInfoVisitor(new DefaultPropertyInfoVisitor() {
+
+ @Override
+ public Void visitElementPropertyInfo(
+ final MElementPropertyInfo wrapperPropertyInfo) {
+
+ processWrapperElementPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo);
+ return null;
+
+ }
+ });
+ }
+ }
+ }
+
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.elementwrapper.Customizations.IGNORED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.elementwrapper.Customizations.IGNORED_ELEMENT_NAME);
+ }
+
+ protected void processWrapperElementPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo) {
+ wrapperPropertyInfo.getTypeInfo().acceptTypeInfoVisitor(
+ new DefaultTypeInfoVisitor() {
+ @Override
+ public Void visitClassInfo(
+ final MClassInfo wrapperClassInfo) {
+ if (/*
+ * TODO !getIgnoring ( ).isIgnored ( classInfo ) &&
+ */wrapperClassInfo.getProperties().size() == 1) {
+ final MPropertyInfo wrappedPropertyInfo = wrapperClassInfo
+ .getProperties().get(0);
+
+ if (wrappedPropertyInfo.isCollection()) {
+ processWrappedPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo,
+ wrapperClassInfo, wrappedPropertyInfo);
+ }
+ }
+ return null;
+ }
+ });
+ }
+
+ protected void processWrappedPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo,
+ final MClassInfo wrapperClassInfo,
+ final MPropertyInfo wrappedPropertyInfo) {
+ wrappedPropertyInfo
+ .acceptPropertyInfoVisitor(new DefaultPropertyInfoVisitor() {
+
+ @Override
+ public Void visitElementPropertyInfo(
+ final MElementPropertyInfo wrappedPropertyInfo) {
+ processWrappedElementPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo,
+ wrapperClassInfo, wrappedPropertyInfo);
+ return null;
+ }
+
+ @Override
+ public Void visitElementsPropertyInfo(
+ MElementsPropertyInfo wrappedPropertyInfo) {
+ processWrappedElementsPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo,
+ wrapperClassInfo, wrappedPropertyInfo);
+ return null;
+ }
+
+ @Override
+ public Void visitElementRefPropertyInfo(
+ final MElementRefPropertyInfo wrappedPropertyInfo) {
+ processWrappedElementRefPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo,
+ wrapperClassInfo, wrappedPropertyInfo);
+ return null;
+ }
+
+ @Override
+ public Void visitElementRefsPropertyInfo(
+ MElementRefsPropertyInfo wrappedPropertyInfo) {
+ processWrappedElementRefsPropertyInfo(mmodel,
+ rootClassInfo, wrapperPropertyInfo,
+ wrapperClassInfo, wrappedPropertyInfo);
+ return null;
+ }
+ });
+ }
+
+ protected void processWrappedElementPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo,
+ final MClassInfo wrapperClassInfo,
+ final MElementPropertyInfo wrappedPropertyInfo) {
+ System.out.println("Class info:" + rootClassInfo.getName());
+ System.out.println("Wrapper property info:"
+ + wrapperPropertyInfo.getPrivateName());
+ System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
+ System.out.println("Wrapped property info:"
+ + wrappedPropertyInfo.getPrivateName());
+
+ final MPropertyInfo propertyInfo = new CMElementPropertyInfo(
+ new DummyPropertyInfoOrigin(), wrapperClassInfo,
+ wrapperPropertyInfo.getPrivateName(),
+ wrappedPropertyInfo.isCollection(),
+ wrappedPropertyInfo.getTypeInfo(),
+ wrappedPropertyInfo.getElementName(),
+ wrapperPropertyInfo.getElementName());
+
+ rootClassInfo.addProperty(propertyInfo);
+
+ // TODO
+ rootClassInfo.removeProperty(wrapperPropertyInfo);
+ mmodel.removeClassInfo(wrapperClassInfo);
+ }
+
+ protected void processWrappedElementsPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo,
+ final MClassInfo wrapperClassInfo,
+ final MElementsPropertyInfo wrappedPropertyInfo) {
+ System.out.println("Class info:" + rootClassInfo.getName());
+ System.out.println("Wrapper property info:"
+ + wrapperPropertyInfo.getPrivateName());
+ System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
+ System.out.println("Wrapped property info:"
+ + wrappedPropertyInfo.getPrivateName());
+
+ final MPropertyInfo propertyInfo = new CMElementsPropertyInfo(
+ new DummyPropertyInfoOrigin(), wrapperClassInfo,
+ wrapperPropertyInfo.getPrivateName(),
+ wrappedPropertyInfo.isCollection(),
+
+ wrappedPropertyInfo.getElementTypeInfos(),
+ wrapperPropertyInfo.getElementName());
+
+ rootClassInfo.addProperty(propertyInfo);
+
+ // TODO
+ rootClassInfo.removeProperty(wrapperPropertyInfo);
+ mmodel.removeClassInfo(wrapperClassInfo);
+ }
+
+ protected void processWrappedElementRefPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo,
+ final MClassInfo wrapperClassInfo,
+ final MElementRefPropertyInfo wrappedPropertyInfo) {
+ System.out.println("Class info:" + rootClassInfo.getName());
+ System.out.println("Wrapper property info:"
+ + wrapperPropertyInfo.getPrivateName());
+ System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
+ System.out.println("Wrapped property info:"
+ + wrappedPropertyInfo.getPrivateName());
+
+ final MPropertyInfo propertyInfo = new CMElementRefPropertyInfo(
+ new DummyPropertyInfoOrigin(), wrapperClassInfo,
+ wrapperPropertyInfo.getPrivateName(),
+ wrappedPropertyInfo.isCollection(),
+ wrappedPropertyInfo.getTypeInfo(),
+ wrappedPropertyInfo.getElementName(),
+ wrapperPropertyInfo.getElementName(),
+ wrappedPropertyInfo.isMixed(),
+ wrappedPropertyInfo.isDomAllowed(),
+ wrappedPropertyInfo.isTypedObjectAllowed());
+
+ rootClassInfo.addProperty(propertyInfo);
+
+ // TODO
+ rootClassInfo.removeProperty(wrapperPropertyInfo);
+ mmodel.removeClassInfo(wrapperClassInfo);
+ }
+
+ protected void processWrappedElementRefsPropertyInfo(
+ final MModelInfo mmodel,
+ final MClassInfo rootClassInfo,
+ final MElementPropertyInfo wrapperPropertyInfo,
+ final MClassInfo wrapperClassInfo,
+ final MElementRefsPropertyInfo wrappedPropertyInfo) {
+ System.out.println("Class info:" + rootClassInfo.getName());
+ System.out.println("Wrapper property info:"
+ + wrapperPropertyInfo.getPrivateName());
+ System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
+ System.out.println("Wrapped property info:"
+ + wrappedPropertyInfo.getPrivateName());
+
+ final MPropertyInfo propertyInfo = new CMElementRefsPropertyInfo(
+ new DummyPropertyInfoOrigin(), wrapperClassInfo,
+ wrapperPropertyInfo.getPrivateName(),
+ wrappedPropertyInfo.isCollection(),
+
+ wrappedPropertyInfo.getElementTypeInfos(),
+ wrapperPropertyInfo.getElementName(),
+ wrappedPropertyInfo.isMixed(),
+ wrappedPropertyInfo.isDomAllowed(),
+ wrappedPropertyInfo.isTypedObjectAllowed());
+
+ rootClassInfo.addProperty(propertyInfo);
+
+ // TODO
+ rootClassInfo.removeProperty(wrapperPropertyInfo);
+ mmodel.removeClassInfo(wrapperClassInfo);
+ }
+
+}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin1.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin1.java
similarity index 100%
rename from basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin1.java
rename to basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin1.java
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/Customizations.java
new file mode 100644
index 00000000..8710a1ec
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.enumvalue;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/enumvalue";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/EnumValuePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/EnumValuePlugin.java
new file mode 100644
index 00000000..e3bbade8
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/enumvalue/EnumValuePlugin.java
@@ -0,0 +1,84 @@
+package org.jvnet.jaxb2_commons.plugin.enumvalue;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.EnumValue;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.model.CEnumLeafInfo;
+import com.sun.tools.xjc.outline.Aspect;
+import com.sun.tools.xjc.outline.EnumOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class EnumValuePlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "XenumValue";
+ }
+
+ @Override
+ public String getUsage() {
+ return "Forces generated @XmlEnums implement the org.jvnet.jaxb2_commons.lang.EnumValue interface.";
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final EnumOutline enumOutline : outline.getEnums()) {
+ if (!getIgnoring().isIgnored(enumOutline)) {
+ processEnumOutline(enumOutline);
+ }
+ }
+ return true;
+ }
+
+ protected void processEnumOutline(EnumOutline enumOutline) {
+ CEnumLeafInfo enumLeafInfo = enumOutline.target;
+ JClass enumType = enumLeafInfo.base.toType(enumOutline.parent(),
+ Aspect.EXPOSED).boxify();
+
+ final JDefinedClass theClass = enumOutline.clazz;
+
+ ClassUtils._implements(theClass, theClass.owner().ref(EnumValue.class)
+ .narrow(enumType));
+
+ final JMethod enumValue$enumValue = theClass.method(JMod.PUBLIC,
+ enumType, "enumValue");
+ enumValue$enumValue.body()._return(JExpr._this().invoke("value"));
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java
new file mode 100644
index 00000000..d4a2d62f
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.equals;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/equals";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java
new file mode 100644
index 00000000..4dbf44ca
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java
@@ -0,0 +1,299 @@
+package org.jvnet.jaxb2_commons.plugin.equals;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.Equals;
+import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
+import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
+import org.jvnet.jaxb2_commons.locator.ObjectLocator;
+import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
+import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JConditional;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JOp;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class EqualsPlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xequals";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
+
+ public FieldAccessorFactory getFieldAccessorFactory() {
+ return fieldAccessorFactory;
+ }
+
+ public void setFieldAccessorFactory(
+ FieldAccessorFactory fieldAccessorFactory) {
+ this.fieldAccessorFactory = fieldAccessorFactory;
+ }
+
+ private String equalsStrategyClass = JAXBEqualsStrategy.class.getName();
+
+ public void setEqualsStrategyClass(String equalsStrategyClass) {
+ this.equalsStrategyClass = equalsStrategyClass;
+ }
+
+ public String getEqualsStrategyClass() {
+ return equalsStrategyClass;
+ }
+
+ public JExpression createEqualsStrategy(JCodeModel codeModel) {
+ return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
+ EqualsStrategy.class, getEqualsStrategyClass());
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses()) {
+ if (!getIgnoring().isIgnored(classOutline)) {
+ processClassOutline(classOutline);
+ }
+ }
+ // for (final EnumOutline enumOutline : outline.getEnums()) {
+ // if (!getIgnoring().isIgnored(enumOutline)) {
+ // processEnumOutline(enumOutline);
+ // }
+ // }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+ ClassUtils._implements(theClass, theClass.owner().ref(Equals.class));
+
+ // @SuppressWarnings("unused")
+ // final JMethod equals0 = generateEquals$Equals0(classOutline,
+ // theClass);
+ @SuppressWarnings("unused")
+ final JMethod equals = generateEquals$equals(classOutline, theClass);
+ @SuppressWarnings("unused")
+ final JMethod objectEquals = generateObject$equals(classOutline,
+ theClass);
+ }
+
+ // protected void processEnumOutline(EnumOutline enumOutline) {
+ // final JDefinedClass theClass = enumOutline.clazz;
+ // ClassUtils._implements(theClass, theClass.owner().ref(Equals.class));
+ //
+ // @SuppressWarnings("unused")
+ // final JMethod equals$equals = generateEquals$equals(enumOutline,
+ // theClass);
+ // }
+
+ protected JMethod generateObject$equals(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ final JCodeModel codeModel = theClass.owner();
+ final JMethod objectEquals = theClass.method(JMod.PUBLIC,
+ codeModel.BOOLEAN, "equals");
+ {
+ final JVar object = objectEquals.param(Object.class, "object");
+ final JBlock body = objectEquals.body();
+ final JVar equalsStrategy = body.decl(JMod.FINAL,
+ codeModel.ref(EqualsStrategy.class), "strategy",
+ createEqualsStrategy(codeModel));
+ body._return(JExpr.invoke("equals").arg(JExpr._null())
+ .arg(JExpr._null()).arg(object).arg(equalsStrategy));
+ }
+ return objectEquals;
+ }
+
+ // protected JMethod generateEquals$Equals0(final ClassOutline classOutline,
+ // final JDefinedClass theClass) {
+ // final JMethod equalsEquals0 = theClass.method(JMod.PUBLIC, theClass
+ // .owner().BOOLEAN, "equals");
+ // {
+ // final JVar object = equalsEquals0.param(Object.class, "object");
+ // final JVar equalsStrategy = equalsEquals0.param(
+ // EqualsStrategy.class, "strategy");
+ // final JBlock body = equalsEquals0.body();
+ //
+ // body._return(JExpr.invoke("equals").arg(JExpr._null()).arg(
+ // JExpr._null()).arg(object).arg(equalsStrategy));
+ // }
+ // return equalsEquals0;
+ // }
+
+ protected JMethod generateEquals$equals(ClassOutline classOutline,
+ final JDefinedClass theClass) {
+
+ final JCodeModel codeModel = theClass.owner();
+ final JMethod equals = theClass.method(JMod.PUBLIC, codeModel.BOOLEAN,
+ "equals");
+ {
+ final JBlock body = equals.body();
+ final JVar leftLocator = equals.param(ObjectLocator.class,
+ "thisLocator");
+ final JVar rightLocator = equals.param(ObjectLocator.class,
+ "thatLocator");
+ final JVar object = equals.param(Object.class, "object");
+ final JVar equalsStrategy = equals.param(EqualsStrategy.class,
+ "strategy");
+
+ final JConditional ifNotInstanceof = body._if(JOp.not(object
+ ._instanceof(theClass)));
+ ifNotInstanceof._then()._return(JExpr.FALSE);
+
+ //
+ body._if(JExpr._this().eq(object))._then()._return(JExpr.TRUE);
+
+ final Boolean superClassImplementsEquals = StrategyClassUtils
+ .superClassImplements(classOutline, getIgnoring(),
+ Equals.class);
+
+ if (superClassImplementsEquals == null) {
+ // No superclass
+ } else if (superClassImplementsEquals.booleanValue()) {
+ body._if(
+ JOp.not(JExpr._super().invoke("equals")
+ .arg(leftLocator).arg(rightLocator).arg(object)
+ .arg(equalsStrategy)))._then()
+ ._return(JExpr.FALSE);
+
+ } else {
+ body._if(JOp.not(JExpr._super().invoke("equals").arg(object)))
+ ._then()._return(JExpr.FALSE);
+ }
+
+ final JExpression _this = JExpr._this();
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ if (declaredFields.length > 0) {
+
+ final JVar _that = body.decl(JMod.FINAL, theClass, "that",
+ JExpr.cast(theClass, object));
+
+ for (final FieldOutline fieldOutline : declaredFields) {
+
+ final FieldAccessorEx leftFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, _this);
+ final FieldAccessorEx rightFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, _that);
+
+ if (leftFieldAccessor.isConstant()
+ || rightFieldAccessor.isConstant()) {
+ continue;
+ }
+
+ final JBlock block = body.block();
+
+ final String name = fieldOutline.getPropertyInfo().getName(
+ true);
+
+ final JVar lhsValue = block.decl(
+ leftFieldAccessor.getType(), "lhs" + name);
+ leftFieldAccessor.toRawValue(block, lhsValue);
+
+ final JVar rhsValue = block.decl(
+ rightFieldAccessor.getType(), "rhs" + name);
+ rightFieldAccessor.toRawValue(block, rhsValue);
+
+ final JExpression leftFieldLocator = codeModel
+ .ref(LocatorUtils.class).staticInvoke("property")
+ .arg(leftLocator)
+ .arg(fieldOutline.getPropertyInfo().getName(false))
+ .arg(lhsValue);
+ final JExpression rightFieldLocator = codeModel
+ .ref(LocatorUtils.class).staticInvoke("property")
+ .arg(rightLocator)
+ .arg(fieldOutline.getPropertyInfo().getName(false))
+ .arg(rhsValue);
+ block._if(
+ JOp.not(JExpr.invoke(equalsStrategy, "equals")
+ .arg(leftFieldLocator)
+ .arg(rightFieldLocator).arg(lhsValue)
+ .arg(rhsValue)))._then()
+ ._return(JExpr.FALSE);
+ }
+ }
+ body._return(JExpr.TRUE);
+ }
+ return equals;
+ }
+
+ // protected JMethod generateEquals$equals(EnumOutline enumOutline,
+ // final JDefinedClass theClass) {
+ //
+ // final JCodeModel codeModel = theClass.owner();
+ // final JMethod equals = theClass.method(JMod.PUBLIC, codeModel.BOOLEAN,
+ // "equals");
+ //
+ // {
+ // final JBlock body = equals.body();
+ // final JVar leftLocator = equals.param(ObjectLocator.class,
+ // "thisLocator");
+ // final JVar rightLocator = equals.param(ObjectLocator.class,
+ // "thatLocator");
+ // final JVar object = equals.param(Object.class, "object");
+ // final JVar equalsStrategy = equals.param(EqualsStrategy.class,
+ // "strategy");
+ //
+ // body._return(equalsStrategy
+ // .invoke("equals")
+ // .arg(codeModel.ref(LocatorUtils.class)
+ // .staticInvoke("property").arg(leftLocator)
+ // .arg("value").arg(JExpr._this().ref("value")))
+ // .arg(codeModel.ref(LocatorUtils.class)
+ // .staticInvoke("property").arg(rightLocator)
+ // .arg("value").arg(object.ref("value")))
+ // .arg(JExpr._this().ref("value")).arg(object.ref("value")));
+ //
+ // }
+ // return equals;
+ // }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java
new file mode 100644
index 00000000..8ac13732
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.hashcode;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/hashCode";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java
new file mode 100644
index 00000000..98707ed5
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java
@@ -0,0 +1,258 @@
+package org.jvnet.jaxb2_commons.plugin.hashcode;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.HashCode;
+import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
+import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
+import org.jvnet.jaxb2_commons.locator.ObjectLocator;
+import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
+import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class HashCodePlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "XhashCode";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
+
+ public FieldAccessorFactory getFieldAccessorFactory() {
+ return fieldAccessorFactory;
+ }
+
+ public void setFieldAccessorFactory(
+ FieldAccessorFactory fieldAccessorFactory) {
+ this.fieldAccessorFactory = fieldAccessorFactory;
+ }
+
+ private String hashCodeStrategyClass = JAXBHashCodeStrategy.class.getName();
+
+ public void setHashCodeStrategyClass(String hashCodeStrategy) {
+ this.hashCodeStrategyClass = hashCodeStrategy;
+ }
+
+ public String getHashCodeStrategyClass() {
+ return hashCodeStrategyClass;
+ }
+
+ public JExpression createHashCodeStrategy(JCodeModel codeModel) {
+ return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
+ HashCodeStrategy.class, getHashCodeStrategyClass());
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.hashcode.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.hashcode.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses()) {
+ if (!getIgnoring().isIgnored(classOutline)) {
+ processClassOutline(classOutline);
+ }
+ }
+ // for (final EnumOutline enumOutline : outline.getEnums()) {
+ // if (!getIgnoring().isIgnored(enumOutline)) {
+ // processEnumOutline(enumOutline);
+ // }
+ // }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+ ClassUtils._implements(theClass, theClass.owner().ref(HashCode.class));
+
+ // @SuppressWarnings("unused")
+ // final JMethod hashCode$hashCode0 = generateHashCode$hashCode0(
+ // classOutline, theClass);
+ @SuppressWarnings("unused")
+ final JMethod hashCode$hashCode = generateHashCode$hashCode(
+ classOutline, theClass);
+ @SuppressWarnings("unused")
+ final JMethod object$hashCode = generateObject$hashCode(classOutline,
+ theClass);
+ }
+
+ // protected void processEnumOutline(EnumOutline enumOutline) {
+ // final JDefinedClass theClass = enumOutline.clazz;
+ // ClassUtils._implements(theClass, theClass.owner().ref(HashCode.class));
+ //
+ // // @SuppressWarnings("unused")
+ // // final JMethod hashCode$hashCode0 = generateHashCode$hashCode0(
+ // // classOutline, theClass);
+ // @SuppressWarnings("unused")
+ // final JMethod hashCode$hashCode = generateHashCode$hashCode(
+ // enumOutline, theClass);
+ // // @SuppressWarnings("unused")
+ // // final JMethod object$hashCode = generateObject$hashCode(enumOutline,
+ // // theClass);
+ // }
+
+ protected JMethod generateObject$hashCode(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ return generateObject$hashCode(theClass);
+ }
+
+ // protected JMethod generateObject$hashCode(final EnumOutline enumOutline,
+ // final JDefinedClass theClass) {
+ // return generateObject$hashCode(theClass);
+ // }
+
+ private JMethod generateObject$hashCode(final JDefinedClass theClass) {
+ final JMethod object$hashCode = theClass.method(JMod.PUBLIC,
+ theClass.owner().INT, "hashCode");
+ {
+ final JBlock body = object$hashCode.body();
+ final JVar hashCodeStrategy = body.decl(JMod.FINAL, theClass
+ .owner().ref(HashCodeStrategy.class), "strategy",
+ createHashCodeStrategy(theClass.owner()));
+ body._return(JExpr._this().invoke("hashCode").arg(JExpr._null())
+ .arg(hashCodeStrategy));
+ }
+ return object$hashCode;
+ }
+
+ protected JMethod generateHashCode$hashCode(ClassOutline classOutline,
+ final JDefinedClass theClass) {
+
+ JCodeModel codeModel = theClass.owner();
+ final JMethod hashCode$hashCode = theClass.method(JMod.PUBLIC,
+ codeModel.INT, "hashCode");
+ {
+ final JVar locator = hashCode$hashCode.param(ObjectLocator.class,
+ "locator");
+ final JVar hashCodeStrategy = hashCode$hashCode.param(
+ HashCodeStrategy.class, "strategy");
+ final JBlock body = hashCode$hashCode.body();
+
+ final JExpression currentHashCodeExpression;
+
+ final Boolean superClassImplementsHashCode = StrategyClassUtils
+ .superClassImplements(classOutline, ignoring,
+ HashCode.class);
+
+ if (superClassImplementsHashCode == null) {
+ currentHashCodeExpression = JExpr.lit(1);
+ } else if (superClassImplementsHashCode.booleanValue()) {
+ currentHashCodeExpression = JExpr._super().invoke("hashCode")
+ .arg(locator).arg(hashCodeStrategy);
+ } else {
+ currentHashCodeExpression = JExpr._super().invoke("hashCode");
+ }
+
+ final JVar currentHashCode = body.decl(codeModel.INT,
+ "currentHashCode", currentHashCodeExpression);
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ if (declaredFields.length > 0) {
+
+ for (final FieldOutline fieldOutline : declaredFields) {
+ final FieldAccessorEx fieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, JExpr._this());
+ if (fieldAccessor.isConstant()) {
+ continue;
+ }
+ final JBlock block = body.block();
+
+ final JVar theValue = block.decl(
+ fieldAccessor.getType(),
+ "the"
+ + fieldOutline.getPropertyInfo().getName(
+ true));
+
+ fieldAccessor.toRawValue(block, theValue);
+
+ block.assign(
+ currentHashCode,
+ hashCodeStrategy
+ .invoke("hashCode")
+ .arg(codeModel
+ .ref(LocatorUtils.class)
+ .staticInvoke("property")
+ .arg(locator)
+ .arg(fieldOutline.getPropertyInfo()
+ .getName(false))
+ .arg(theValue))
+ .arg(currentHashCode).arg(theValue));
+ }
+ }
+ body._return(currentHashCode);
+ }
+ return hashCode$hashCode;
+ }
+
+ // protected JMethod generateHashCode$hashCode(EnumOutline enumOutline,
+ // final JDefinedClass theClass) {
+ //
+ // JCodeModel codeModel = theClass.owner();
+ // final JMethod hashCode$hashCode = theClass.method(JMod.PUBLIC,
+ // codeModel.INT, "hashCode");
+ // final JVar locator = hashCode$hashCode.param(ObjectLocator.class,
+ // "locator");
+ // final JVar hashCodeStrategy = hashCode$hashCode.param(
+ // HashCodeStrategy.class, "strategy");
+ // final JBlock body = hashCode$hashCode.body();
+ //
+ // body._return(hashCodeStrategy
+ // .invoke("hashCode")
+ // .arg(codeModel.ref(LocatorUtils.class).staticInvoke("property")
+ // .arg(locator).arg("value")
+ // .arg(JExpr._this().ref("value"))).arg(JExpr.lit(1))
+ // .arg(JExpr._this().ref("value")));
+ //
+ // return hashCode$hashCode;
+ // }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java
new file mode 100644
index 00000000..e04c9713
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java
@@ -0,0 +1,65 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.util.CustomizationUtils;
+
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CPluginCustomization;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/inheritance";
+
+ public static QName OBJECT_FACTORY_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "objectFactory");
+
+ public static QName EXTENDS_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "extends");
+
+ public static QName IMPLEMENTS_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "implements");
+
+ private static final JAXBContext context;
+ static {
+ try {
+ context = JAXBContext.newInstance(ObjectFactory.class.getPackage()
+ .getName(), ObjectFactory.class.getClassLoader());
+ } catch (JAXBException e) {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ public static JAXBContext getContext() {
+ return context;
+ }
+
+ public static void _extends(CClassInfo classInfo, String className) {
+ final ExtendsClass extendsClass = new ExtendsClass();
+ extendsClass.setClassName(className);
+ final CPluginCustomization customization = CustomizationUtils
+ .marshal(getContext(), Customizations.EXTENDS_ELEMENT_NAME,
+ extendsClass);
+ classInfo.getCustomizations().add(customization);
+ customization.markAsAcknowledged();
+
+ }
+
+ public static void _implements(CClassInfo classInfo,
+ String... interfaceNames) {
+ for (String interfaceName : interfaceNames) {
+ final ImplementsInterface implementsInterface = new ImplementsInterface();
+ implementsInterface.setInterfaceName(interfaceName);
+ final CPluginCustomization customization = CustomizationUtils
+ .marshal(getContext(),
+ Customizations.IMPLEMENTS_ELEMENT_NAME,
+ implementsInterface);
+ customization.markAsAcknowledged();
+ classInfo.getCustomizations().add(customization);
+ }
+
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java
new file mode 100644
index 00000000..54ca235a
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java
@@ -0,0 +1,26 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlRootElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "extends")
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class ExtendsClass {
+
+ private String className;
+
+ @XmlValue
+ @XmlJavaTypeAdapter(value = CollapsedStringAdapter.class)
+ String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java
new file mode 100644
index 00000000..854a4d5f
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java
@@ -0,0 +1,26 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlRootElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "implements")
+@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
+public class ImplementsInterface {
+
+ private String interfaceName;
+
+ @XmlValue
+ @XmlJavaTypeAdapter(value = CollapsedStringAdapter.class)
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java
new file mode 100644
index 00000000..95d25294
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java
@@ -0,0 +1,299 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.inheritance.util.JavaTypeParser;
+import org.jvnet.jaxb2_commons.util.CustomizationUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CClassRef;
+import com.sun.tools.xjc.model.CCustomizations;
+import com.sun.tools.xjc.model.CElementInfo;
+import com.sun.tools.xjc.model.CPluginCustomization;
+import com.sun.tools.xjc.model.Model;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.ElementOutline;
+import com.sun.tools.xjc.outline.EnumOutline;
+import com.sun.tools.xjc.outline.Outline;
+import com.sun.tools.xjc.outline.PackageOutline;
+import com.sun.tools.xjc.reader.xmlschema.bindinfo.BIEnum;
+
+public class InheritancePlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xinheritance";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays.asList(Customizations.EXTENDS_ELEMENT_NAME,
+ Customizations.IMPLEMENTS_ELEMENT_NAME,
+ Customizations.OBJECT_FACTORY_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ final Map knownClasses = new HashMap();
+ final Map knownClassInfos = new IdentityHashMap();
+
+ for (final ClassOutline classOutline : outline.getClasses()) {
+ knownClasses.put(classOutline.implClass.fullName(),
+ classOutline.implClass);
+ knownClassInfos.put(classOutline.implClass, classOutline.target);
+ }
+ for (final ClassOutline classOutline : outline.getClasses()) {
+ processClassOutline(classOutline, knownClasses, knownClassInfos);
+ }
+ for (final EnumOutline enumOutline : outline.getEnums()) {
+ processEnumOutline(enumOutline, knownClasses);
+ }
+ for (final CElementInfo elementInfo : outline.getModel()
+ .getAllElements()) {
+ final ElementOutline elementOutline = outline
+ .getElement(elementInfo);
+ if (elementOutline != null) {
+ processElementOutline(elementOutline, knownClasses);
+ }
+ }
+ processPackageOutlines(outline, knownClasses);
+ return true;
+ }
+
+ private void processClassOutline(ClassOutline classOutline,
+ Map knownClasses,
+ Map knownClassInfos) {
+
+ generateExtends(classOutline, knownClasses, knownClassInfos);
+ generateImplements(classOutline, knownClasses);
+
+ }
+
+ private void processEnumOutline(EnumOutline enumOutline,
+ Map knownClasses) {
+
+ generateExtends(enumOutline, knownClasses);
+ generateImplements(enumOutline, knownClasses);
+
+ }
+
+ private void processElementOutline(ElementOutline elementOutline,
+ Map knownClasses) {
+
+ generateExtends(elementOutline, knownClasses);
+ generateImplements(elementOutline, knownClasses);
+
+ }
+
+ private void processPackageOutlines(Outline outline,
+ Map knownClasses) {
+ List customizations = CustomizationUtils
+ .findCustomizations(outline,
+ Customizations.OBJECT_FACTORY_ELEMENT_NAME);
+
+ for (CPluginCustomization customization : customizations) {
+ final ObjectFactoryCustomization objectFactoryCustomization = (ObjectFactoryCustomization) CustomizationUtils
+ .unmarshall(Customizations.getContext(), customization);
+
+ final String packageName = objectFactoryCustomization
+ .getPackageName();
+
+ if (packageName != null) {
+ for (PackageOutline packageOutline : outline
+ .getAllPackageContexts()) {
+ final JDefinedClass theClass = packageOutline
+ .objectFactory();
+ if (packageName.equals(packageOutline._package().name())) {
+ ExtendsClass extendsClass = objectFactoryCustomization
+ .getExtendsClass();
+ if (extendsClass != null) {
+ generateExtends(theClass, extendsClass,
+ knownClasses);
+ }
+ List implementsInterfaces = objectFactoryCustomization
+ .getImplementsInterface();
+ if (implementsInterfaces != null) {
+ for (ImplementsInterface implementsInterface : implementsInterfaces) {
+ if (implementsInterface != null) {
+ generateImplements(theClass,
+ implementsInterface, knownClasses);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private JClass generateExtends(ClassOutline classOutline,
+ Map knownClasses,
+ Map knownClassInfos) {
+ final JDefinedClass theClass = classOutline.implClass;
+ final CPluginCustomization extendsClassCustomization = CustomizationUtils
+ .findCustomization(classOutline,
+ Customizations.EXTENDS_ELEMENT_NAME);
+ JClass targetClass = generateExtends(theClass,
+ extendsClassCustomization, knownClasses);
+
+ final CClassInfo classInfo = classOutline.target;
+ if (targetClass != null && classInfo.getBaseClass() == null
+ && classInfo.getRefBaseClass() == null) {
+ final CClassInfo targetClassInfo = knownClassInfos.get(targetClass);
+ if (targetClassInfo == null && classInfo.getRefBaseClass() == null) {
+ final Model model = classInfo.model;
+ // BIEnum as BIClass is protected too much
+ final BIEnum decl = new BIEnum();
+ decl.ref = targetClass.fullName();
+ final CClassRef baseClass = new CClassRef(model,
+ classInfo.getSchemaComponent(), decl,
+ new CCustomizations());
+ classInfo.setBaseClass(baseClass);
+ } else if (targetClassInfo != null
+ && classInfo.getBaseClass() == null) {
+ classInfo.setBaseClass(targetClassInfo);
+ }
+ }
+ return targetClass;
+ }
+
+ private JClass generateExtends(EnumOutline enumOutline,
+ Map knownClasses) {
+ final JDefinedClass theClass = enumOutline.clazz;
+ final CPluginCustomization extendsClassCustomization = CustomizationUtils
+ .findCustomization(enumOutline,
+ Customizations.EXTENDS_ELEMENT_NAME);
+ return generateExtends(theClass, extendsClassCustomization,
+ knownClasses);
+ }
+
+ private JClass generateExtends(ElementOutline elementOutline,
+ Map knownClasses) {
+ final JDefinedClass theClass = elementOutline.implClass;
+ final CPluginCustomization extendsClassCustomization = CustomizationUtils
+ .findCustomization(elementOutline,
+ Customizations.EXTENDS_ELEMENT_NAME);
+ return generateExtends(theClass, extendsClassCustomization,
+ knownClasses);
+ }
+
+ private JClass generateExtends(final JDefinedClass theClass,
+ final CPluginCustomization extendsClassCustomization,
+ Map knownClasses) throws AssertionError {
+ if (extendsClassCustomization != null) {
+
+ final ExtendsClass extendsClass = (ExtendsClass) CustomizationUtils
+ .unmarshall(Customizations.getContext(),
+ extendsClassCustomization);
+
+ return generateExtends(theClass, extendsClass, knownClasses);
+ } else {
+ return null;
+ }
+ }
+
+ private JClass generateExtends(final JDefinedClass theClass,
+ final ExtendsClass extendsClass, Map knownClasses) {
+ if (extendsClass.getClassName() != null) {
+ final String _class = extendsClass.getClassName();
+ final JClass targetClass = parseClass(_class, theClass.owner(),
+ knownClasses);
+ theClass._extends(targetClass);
+ return targetClass;
+ } else {
+ return null;
+ }
+ }
+
+ private List generateImplements(ClassOutline classOutline,
+ Map knownClasses) {
+ final JDefinedClass theClass = classOutline.implClass;
+ final List implementsInterfaceCustomizations = CustomizationUtils
+ .findCustomizations(classOutline,
+ Customizations.IMPLEMENTS_ELEMENT_NAME);
+ return generateImplements(theClass, implementsInterfaceCustomizations,
+ knownClasses);
+ }
+
+ private List generateImplements(EnumOutline enumOutline,
+ Map knownClasses) {
+ final JDefinedClass theClass = enumOutline.clazz;
+ final List implementsInterfaceCustomizations = CustomizationUtils
+ .findCustomizations(enumOutline,
+ Customizations.IMPLEMENTS_ELEMENT_NAME);
+ return generateImplements(theClass, implementsInterfaceCustomizations,
+ knownClasses);
+ }
+
+ private List generateImplements(ElementOutline elementOutline,
+ Map knownClasses) {
+ final JDefinedClass theClass = elementOutline.implClass;
+ final List implementsInterfaceCustomizations = CustomizationUtils
+ .findCustomizations(elementOutline,
+ Customizations.IMPLEMENTS_ELEMENT_NAME);
+ return generateImplements(theClass, implementsInterfaceCustomizations,
+ knownClasses);
+ }
+
+ private List generateImplements(final JDefinedClass theClass,
+ final List implementsInterfaceCustomizations,
+ Map knownClasses) throws AssertionError {
+ final List implementedInterfaces = new ArrayList(
+ implementsInterfaceCustomizations.size());
+ for (final CPluginCustomization implementsInterfaceCustomization : implementsInterfaceCustomizations) {
+ if (implementsInterfaceCustomization != null) {
+
+ final ImplementsInterface implementsInterface = (ImplementsInterface) org.jvnet.jaxb2_commons.util.CustomizationUtils
+ .unmarshall(Customizations.getContext(),
+ implementsInterfaceCustomization);
+
+ final JClass implementedInterface = generateImplements(
+ theClass, implementsInterface, knownClasses);
+ if (implementedInterface != null) {
+ implementedInterfaces.add(implementedInterface);
+ }
+ }
+ }
+ return implementedInterfaces;
+ }
+
+ private JClass generateImplements(final JDefinedClass theClass,
+ final ImplementsInterface implementsInterface,
+ Map knownClasses) {
+
+ String _interface = implementsInterface.getInterfaceName();
+ if (_interface != null) {
+ final JClass targetClass = parseClass(_interface, theClass.owner(),
+ knownClasses);
+ theClass._implements(targetClass);
+ return targetClass;
+ } else {
+ return null;
+ }
+ }
+
+ private JClass parseClass(String _class, JCodeModel codeModel,
+ Map knownClasses) {
+ return new JavaTypeParser(knownClasses).parseClass(_class, codeModel);
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java
new file mode 100644
index 00000000..98b29f2a
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java
@@ -0,0 +1,20 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+@XmlRegistry
+public class ObjectFactory {
+
+ public ExtendsClass createExtendsClass() {
+ return new ExtendsClass();
+ }
+
+ public ImplementsInterface createImplementsInterface() {
+ return new ImplementsInterface();
+ }
+
+ public ObjectFactoryCustomization createObjectFactoryCustomization() {
+ return new ObjectFactoryCustomization();
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactoryCustomization.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactoryCustomization.java
new file mode 100644
index 00000000..a4a34530
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactoryCustomization.java
@@ -0,0 +1,52 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "objectFactory")
+@XmlType(propOrder = { "extendsClass", "implementsInterface" })
+@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
+public class ObjectFactoryCustomization {
+
+ private String packageName;
+
+ @XmlAttribute
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ private ExtendsClass extendsClass;
+
+ @XmlElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "extends")
+ public ExtendsClass getExtendsClass() {
+ return extendsClass;
+ }
+
+ public void setExtendsClass(ExtendsClass extendsClass) {
+ this.extendsClass = extendsClass;
+ }
+
+ private List implementsInterface = new ArrayList();
+
+ @XmlElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "implements")
+ public List getImplementsInterface() {
+ return implementsInterface;
+ }
+
+ public void setImplementsInterface(
+ List implementsInterface) {
+ this.implementsInterface = implementsInterface;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java
new file mode 100644
index 00000000..2d5d07a6
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java
@@ -0,0 +1,73 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance.util;
+
+import japa.parser.JavaParser;
+import japa.parser.ParseException;
+import japa.parser.ast.CompilationUnit;
+import japa.parser.ast.body.ClassOrInterfaceDeclaration;
+import japa.parser.ast.body.TypeDeclaration;
+import japa.parser.ast.type.ClassOrInterfaceType;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JType;
+
+public class JavaTypeParser {
+
+ static {
+// JavaParser.setCacheParser(false);
+ }
+
+ private final TypeToJTypeConvertingVisitor typeToJTypeConvertingVisitor;
+
+ public JavaTypeParser() {
+ this(Collections. emptyMap());
+ }
+
+ public JavaTypeParser(Map knownClasses) {
+ Validate.notNull(knownClasses);
+ this.typeToJTypeConvertingVisitor = new TypeToJTypeConvertingVisitor(
+ knownClasses);
+
+ }
+
+ public JClass parseClass(String _class, JCodeModel codeModel) {
+ JType type = parseType(_class, codeModel);
+ if (type instanceof JClass) {
+ return (JClass) type;
+ } else {
+ throw new IllegalArgumentException("Type [" + _class
+ + "] is not a class.");
+ }
+ }
+
+ private JType parseType(String type, JCodeModel codeModel) {
+ final String text = "public class Ignored extends " + type + " {}";
+ try {
+ CompilationUnit compilationUnit = JavaParser.parse(
+ new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8");
+ final List typeDeclarations = compilationUnit
+ .getTypes();
+ final TypeDeclaration typeDeclaration = typeDeclarations.get(0);
+ final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration;
+ final List _extended = classDeclaration
+ .getExtends();
+ final ClassOrInterfaceType classOrInterfaceType = _extended.get(0);
+
+ return classOrInterfaceType.accept(
+ this.typeToJTypeConvertingVisitor, codeModel);
+ } catch (ParseException pex) {
+ throw new IllegalArgumentException(
+ "Could not parse the type definition [" + type + "].", pex);
+ } catch (UnsupportedEncodingException uex) {
+ throw new UnsupportedOperationException(uex);
+ }
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java
new file mode 100644
index 00000000..5b8a4b7d
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java
@@ -0,0 +1,130 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance.util;
+
+import japa.parser.ast.type.ClassOrInterfaceType;
+import japa.parser.ast.type.PrimitiveType;
+import japa.parser.ast.type.ReferenceType;
+import japa.parser.ast.type.Type;
+import japa.parser.ast.type.VoidType;
+import japa.parser.ast.type.WildcardType;
+import japa.parser.ast.visitor.GenericVisitorAdapter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JType;
+
+public class TypeToJTypeConvertingVisitor extends
+ GenericVisitorAdapter {
+
+ private final Map knownClasses;
+
+ public TypeToJTypeConvertingVisitor(Map knownClasses) {
+ Validate.notNull(knownClasses);
+ this.knownClasses = knownClasses;
+ }
+
+ @Override
+ public JType visit(VoidType type, JCodeModel codeModel) {
+ return codeModel.VOID;
+ }
+
+ @Override
+ public JType visit(PrimitiveType type, JCodeModel codeModel) {
+ switch (type.getType()) {
+ case Boolean:
+ return codeModel.BOOLEAN;
+ case Char:
+ return codeModel.CHAR;
+ case Byte:
+ return codeModel.BYTE;
+ case Short:
+ return codeModel.SHORT;
+ case Int:
+ return codeModel.INT;
+ case Long:
+ return codeModel.LONG;
+ case Float:
+ return codeModel.FLOAT;
+ case Double:
+ return codeModel.DOUBLE;
+ default:
+ throw new AssertionError("Unknown primitive type ["
+ + type.getType() + "]");
+ }
+ }
+
+ @Override
+ public JType visit(ReferenceType type, JCodeModel codeModel) {
+ final JType referencedType = type.getType().accept(this, codeModel);
+
+ JType referencedTypeArray = referencedType;
+ for (int index = 0; index < type.getArrayCount(); index++) {
+ referencedTypeArray = referencedTypeArray.array();
+ }
+ return referencedTypeArray;
+ }
+
+ @Override
+ public JType visit(WildcardType type, JCodeModel codeModel) {
+
+ if (type.getExtends() != null) {
+ final ReferenceType _extends = type.getExtends();
+ final JType boundType = _extends.accept(this, codeModel);
+
+ if (!(boundType instanceof JClass)) {
+ throw new IllegalArgumentException("Bound type [" + _extends
+ + "]in the wildcard type must be class.");
+ }
+
+ final JClass boundClass = (JClass) boundType;
+ return boundClass.wildcard();
+ } else if (type.getSuper() != null) {
+ // TODO
+ throw new IllegalArgumentException(
+ "Wildcard types with super clause are not supported at the moment.");
+ } else {
+ throw new IllegalArgumentException(
+ "Wildcard type must have either extends or super clause.");
+ }
+ }
+
+ @Override
+ public JType visit(ClassOrInterfaceType type, JCodeModel codeModel) {
+ final String name = getName(type);
+ final JClass knownClass = this.knownClasses.get(name);
+ final JClass jclass = knownClass != null ? knownClass : codeModel
+ .ref(name);
+ final List typeArgs = type.getTypeArgs();
+ if (typeArgs == null || typeArgs.isEmpty()) {
+ return jclass;
+ } else {
+ final List jtypeArgs = new ArrayList(
+ typeArgs.size());
+ for (Type typeArg : typeArgs) {
+ final JType jtype = typeArg.accept(this, codeModel);
+ if (!(jtype instanceof JClass)) {
+ throw new IllegalArgumentException("Type argument ["
+ + typeArg.toString() + "] is not a class.");
+ } else {
+ jtypeArgs.add((JClass) jtype);
+ }
+ }
+ return jclass.narrow(jtypeArgs);
+ }
+ }
+
+ private String getName(ClassOrInterfaceType type) {
+ final String name = type.getName();
+ final ClassOrInterfaceType scope = type.getScope();
+ if (scope == null) {
+ return name;
+ } else {
+ return getName(scope) + "." + name;
+ }
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java
new file mode 100644
index 00000000..7963b722
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java
@@ -0,0 +1,39 @@
+package org.jvnet.jaxb2_commons.plugin.jaxbindex;
+
+import org.jvnet.jaxb2_commons.util.CodeModelUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.fmt.JTextFile;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.Outline;
+import com.sun.tools.xjc.outline.PackageOutline;
+
+public class JaxbIndexPlugin extends com.sun.tools.xjc.Plugin {
+
+ public String getOptionName() {
+ return "Xjaxbindex";
+ }
+
+ public String getUsage() {
+ return "-Xjaxbindex: generate per-package jaxb.index file";
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+
+ for (final PackageOutline packageOutline : outline
+ .getAllPackageContexts()) {
+ final StringBuilder sb = new StringBuilder();
+ for (final ClassOutline classOutline : packageOutline.getClasses()) {
+ sb.append(CodeModelUtils.getLocalClassName(classOutline.ref));
+ sb.append("\n");
+ }
+
+ final JTextFile indexFile = new JTextFile("jaxb.index");
+ indexFile.setContents(sb.toString());
+ packageOutline._package().addResourceFile(indexFile);
+ }
+ return true;
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java
new file mode 100644
index 00000000..72fad319
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.mergeable;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/mergeable";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java
new file mode 100644
index 00000000..8ca10789
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java
@@ -0,0 +1,272 @@
+package org.jvnet.jaxb2_commons.plugin.mergeable;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy;
+import org.jvnet.jaxb2_commons.lang.MergeFrom;
+import org.jvnet.jaxb2_commons.lang.MergeStrategy;
+import org.jvnet.jaxb2_commons.locator.ObjectLocator;
+import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
+import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JType;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class MergeablePlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xmergeable";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
+
+ public FieldAccessorFactory getFieldAccessorFactory() {
+ return fieldAccessorFactory;
+ }
+
+ public void setFieldAccessorFactory(
+ FieldAccessorFactory fieldAccessorFactory) {
+ this.fieldAccessorFactory = fieldAccessorFactory;
+ }
+
+ private String mergeStrategyClass = JAXBMergeStrategy.class.getName();
+
+ public void setMergeStrategyClass(
+ final String mergeStrategyClass) {
+ this.mergeStrategyClass = mergeStrategyClass;
+ }
+
+ public String getMergeStrategyClass() {
+ return mergeStrategyClass;
+ }
+
+ public JExpression createMergeStrategy(JCodeModel codeModel) {
+ return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
+ MergeStrategy.class, getMergeStrategyClass());
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses())
+ if (!getIgnoring().isIgnored(classOutline)) {
+ processClassOutline(classOutline);
+ }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+ ClassUtils._implements(theClass, theClass.owner().ref(MergeFrom.class));
+
+ @SuppressWarnings("unused")
+ final JMethod mergeFrom$mergeFrom0 = generateMergeFrom$mergeFrom0(
+ classOutline, theClass);
+ @SuppressWarnings("unused")
+ final JMethod mergeFrom$mergeFrom = generateMergeFrom$mergeFrom(
+ classOutline, theClass);
+
+ if (!classOutline.target.isAbstract()) {
+ @SuppressWarnings("unused")
+ final JMethod createCopy = generateMergeFrom$createNewInstance(
+ classOutline, theClass);
+
+ }
+ }
+
+ protected JMethod generateMergeFrom$mergeFrom0(
+ final ClassOutline classOutline, final JDefinedClass theClass) {
+
+ JCodeModel codeModel = theClass.owner();
+ final JMethod mergeFrom$mergeFrom = theClass.method(JMod.PUBLIC,
+ codeModel.VOID, "mergeFrom");
+ {
+ final JVar left = mergeFrom$mergeFrom.param(Object.class, "left");
+ final JVar right = mergeFrom$mergeFrom.param(Object.class, "right");
+ final JBlock body = mergeFrom$mergeFrom.body();
+
+ final JVar mergeStrategy = body.decl(JMod.FINAL,
+ codeModel.ref(MergeStrategy.class), "strategy",
+ createMergeStrategy(codeModel));
+
+ body.invoke("mergeFrom").arg(JExpr._null()).arg(JExpr._null())
+ .arg(left).arg(right).arg(mergeStrategy);
+ }
+ return mergeFrom$mergeFrom;
+ }
+
+ protected JMethod generateMergeFrom$mergeFrom(ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ final JCodeModel codeModel = theClass.owner();
+
+ final JMethod mergeFrom = theClass.method(JMod.PUBLIC, codeModel.VOID,
+ "mergeFrom");
+ {
+ final JVar leftLocator = mergeFrom.param(ObjectLocator.class,
+ "leftLocator");
+ final JVar rightLocator = mergeFrom.param(ObjectLocator.class,
+ "rightLocator");
+ final JVar left = mergeFrom.param(Object.class, "left");
+ final JVar right = mergeFrom.param(Object.class, "right");
+
+ final JVar mergeStrategy = mergeFrom.param(MergeStrategy.class,
+ "strategy");
+
+ final JBlock methodBody = mergeFrom.body();
+
+ Boolean superClassImplementsMergeFrom = StrategyClassUtils
+ .superClassImplements(classOutline, getIgnoring(),
+ MergeFrom.class);
+
+ if (superClassImplementsMergeFrom == null) {
+
+ } else if (superClassImplementsMergeFrom.booleanValue()) {
+ methodBody.invoke(JExpr._super(), "mergeFrom").arg(leftLocator)
+ .arg(rightLocator).arg(left).arg(right)
+ .arg(mergeStrategy);
+ } else {
+
+ }
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ if (declaredFields.length > 0) {
+
+ final JBlock body = methodBody._if(right._instanceof(theClass))
+ ._then();
+
+ JVar target = body.decl(JMod.FINAL, theClass, "target",
+ JExpr._this());
+ JVar leftObject = body.decl(JMod.FINAL, theClass, "leftObject",
+ JExpr.cast(theClass, left));
+ JVar rightObject = body.decl(JMod.FINAL, theClass,
+ "rightObject", JExpr.cast(theClass, right));
+ for (final FieldOutline fieldOutline : declaredFields) {
+ final FieldAccessorEx leftFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, leftObject);
+ final FieldAccessorEx rightFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, rightObject);
+ if (leftFieldAccessor.isConstant()
+ || rightFieldAccessor.isConstant()) {
+ continue;
+ }
+ final JBlock block = body.block();
+ final JVar leftField = block.decl(
+ leftFieldAccessor.getType(),
+ "lhs"
+ + fieldOutline.getPropertyInfo().getName(
+ true));
+ leftFieldAccessor.toRawValue(block, leftField);
+ final JVar rightField = block.decl(
+ rightFieldAccessor.getType(),
+ "rhs"
+ + fieldOutline.getPropertyInfo().getName(
+ true));
+
+ rightFieldAccessor.toRawValue(block, rightField);
+
+ final JExpression leftFieldLocator = codeModel
+ .ref(LocatorUtils.class).staticInvoke("property")
+ .arg(leftLocator)
+ .arg(fieldOutline.getPropertyInfo().getName(false))
+ .arg(leftField);
+ final JExpression rightFieldLocator = codeModel
+ .ref(LocatorUtils.class).staticInvoke("property")
+ .arg(rightLocator)
+ .arg(fieldOutline.getPropertyInfo().getName(false))
+ .arg(rightField);
+
+ final FieldAccessorEx targetFieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, target);
+ final JExpression mergedValue = JExpr.cast(
+ targetFieldAccessor.getType(),
+ mergeStrategy.invoke("merge").arg(leftFieldLocator)
+ .arg(rightFieldLocator).arg(leftField)
+ .arg(rightField));
+
+ final JVar merged = block.decl(
+ rightFieldAccessor.getType(),
+ "merged"
+ + fieldOutline.getPropertyInfo().getName(
+ true), mergedValue);
+
+ targetFieldAccessor.fromRawValue(block, "unique"
+ + fieldOutline.getPropertyInfo().getName(true),
+
+ merged);
+ }
+ }
+ }
+ return mergeFrom;
+ }
+
+ protected JMethod generateMergeFrom$createNewInstance(
+ final ClassOutline classOutline, final JDefinedClass theClass) {
+
+ final JMethod existingMethod = theClass.getMethod("createNewInstance",
+ new JType[0]);
+ if (existingMethod == null) {
+
+ final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass
+ .owner().ref(Object.class), "createNewInstance");
+ {
+ final JBlock body = newMethod.body();
+ body._return(JExpr._new(theClass));
+ }
+ return newMethod;
+ } else {
+ return existingMethod;
+ }
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java
new file mode 100644
index 00000000..986a34b7
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java
@@ -0,0 +1,80 @@
+package org.jvnet.jaxb2_commons.plugin.model;
+
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.xjc.generator.MModelOutlineGenerator;
+import org.jvnet.jaxb2_commons.xjc.generator.concrete.ModelOutlineGeneratorFactory;
+import org.jvnet.jaxb2_commons.xjc.model.concrete.XJCCMInfoFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.MModelOutline;
+import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.model.Model;
+import com.sun.tools.xjc.model.nav.NClass;
+import com.sun.tools.xjc.model.nav.NType;
+import com.sun.tools.xjc.outline.Outline;
+import com.sun.tools.xjc.reader.Ring;
+
+public abstract class AbstractModelPlugin extends AbstractParameterizablePlugin {
+
+ protected MModelInfo getModel(Model model) {
+ try {
+ @SuppressWarnings("unchecked")
+ final MModelInfo modelInfo = (MModelInfo) Ring
+ .get(MModelInfo.class);
+ return modelInfo;
+ } catch (Throwable t) {
+ final MModelInfo mmodel = new XJCCMInfoFactory(model)
+ .createModel();
+ Ring.add(MModelInfo.class, mmodel);
+ return mmodel;
+ }
+ }
+
+ protected MModelOutline getModelOutline(
+ MModelInfo modelInfo, Outline outline,
+ Options options) {
+ try {
+ final MModelOutline modelOutline = (MModelOutline) Ring
+ .get(MModelOutline.class);
+ return modelOutline;
+ } catch (Throwable t) {
+ if (modelInfo.getOrigin() instanceof ModelOutlineGeneratorFactory) {
+ MModelOutlineGenerator generator = ((ModelOutlineGeneratorFactory) modelInfo
+ .getOrigin()).createGenerator(outline);
+ MModelOutline modelOutline = generator.generate(modelInfo);
+ Ring.add(MModelOutline.class, modelOutline);
+ return modelOutline;
+ } else {
+ throw new AssertionError("Model is expected to be generateable");
+ }
+ }
+ }
+
+ private MModelInfo modelInfo;
+
+ @Override
+ public void postProcessModel(Model model, ErrorHandler errorHandler) {
+ this.modelInfo = getModel(model);
+ postProcessModel(model, modelInfo, errorHandler);
+ }
+
+ protected void postProcessModel(Model model,
+ MModelInfo modelInfo, ErrorHandler errorHandler) {
+ // Template method to be overridden by classes
+ }
+
+ @Override
+ protected boolean run(Outline outline, Options options) throws Exception {
+ if (modelInfo.getOrigin() instanceof ModelOutlineGeneratorFactory) {
+ MModelOutlineGenerator generator = ((ModelOutlineGeneratorFactory) modelInfo
+ .getOrigin()).createGenerator(outline);
+ MModelOutline modelOutline = generator.generate(modelInfo);
+ Ring.add(MModelOutline.class, modelOutline);
+ } else {
+ throw new AssertionError("Model is expected to be generateable");
+ }
+ return true;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java
new file mode 100644
index 00000000..104e1c22
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.setters;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/collectionsetters";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java
new file mode 100644
index 00000000..fce14ff8
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java
@@ -0,0 +1,168 @@
+package org.jvnet.jaxb2_commons.plugin.setters;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.lang3.Validate;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JFieldVar;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JType;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldAccessor;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class SettersPlugin extends AbstractParameterizablePlugin {
+
+ private static final JType[] ABSENT = new JType[0];
+
+ @Override
+ public String getOptionName() {
+ return "Xsetters";
+ }
+
+ @Override
+ public String getUsage() {
+ return "Generates setters for collections.";
+ }
+
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses())
+ if (!getIgnoring().isIgnored(classOutline)) {
+
+ processClassOutline(classOutline);
+ }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+
+ generateSetters(classOutline, theClass);
+
+ }
+
+ public static enum Mode {
+
+ accessor {
+
+ @Override
+ public void generateSetter(FieldOutline fieldOutline,
+ JDefinedClass theClass, JMethod setter, JVar value) {
+ final FieldAccessor accessor = fieldOutline.create(JExpr
+ ._this());
+ accessor.unsetValues(setter.body());
+ accessor.fromRawValue(setter.body(), "draft", value);
+ }
+ },
+ direct {
+ @Override
+ public void generateSetter(FieldOutline fieldOutline,
+ JDefinedClass theClass, JMethod setter, JVar value) {
+
+ final JFieldVar field = theClass.fields().get(
+ fieldOutline.getPropertyInfo().getName(false));
+
+ if (field != null) {
+ setter.body().assign(JExpr._this().ref(field), value);
+ } else {
+ // Fallback to the accessor
+ Mode.accessor.generateSetter(fieldOutline, theClass,
+ setter, value);
+ }
+ }
+ };
+ public abstract void generateSetter(FieldOutline fieldOutline,
+ JDefinedClass theClass, JMethod setter, JVar value);
+ }
+
+ private Mode mode = Mode.accessor;
+
+ public String getMode() {
+ return mode.name();
+
+ }
+
+ public void setMode(String mode) {
+ Validate.notNull(mode);
+ try {
+ this.mode = Mode.valueOf(mode);
+ } catch (IllegalArgumentException iaex) {
+ throw new IllegalArgumentException(
+ "Unsupported mode ["
+ + mode
+ + "]."
+ + " Supported modes are [accessor] (uses JAXB-generated accessors, default)"
+ + " and [direct] (assigns the value to the field directly).");
+ }
+ }
+
+ private void generateSetters(ClassOutline classOutline,
+ JDefinedClass theClass) {
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ for (final FieldOutline fieldOutline : declaredFields) {
+
+ final String publicName = fieldOutline.getPropertyInfo().getName(
+ true);
+
+ final String getterName = "get" + publicName;
+
+ final JMethod getter = theClass.getMethod(getterName, ABSENT);
+
+ if (getter != null) {
+ final JType type = getter.type();
+ final JType rawType = fieldOutline.getRawType();
+ final String setterName = "set" + publicName;
+ final JMethod boxifiedSetter = theClass.getMethod(setterName,
+ new JType[] { rawType.boxify() });
+ final JMethod unboxifiedSetter = theClass.getMethod(setterName,
+ new JType[] { rawType.unboxify() });
+ final JMethod setter = boxifiedSetter != null ? boxifiedSetter
+ : unboxifiedSetter;
+
+ if (setter == null) {
+ final JMethod generatedSetter = theClass.method(
+ JMod.PUBLIC, theClass.owner().VOID, setterName);
+ final JVar value = generatedSetter.param(type, "value");
+
+ mode.generateSetter(fieldOutline, theClass,
+ generatedSetter, value);
+ }
+ }
+ }
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.setters.Customizations.IGNORED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.setters.Customizations.IGNORED_ELEMENT_NAME);
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/Customizations.java
new file mode 100644
index 00000000..0afdde9f
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/Customizations.java
@@ -0,0 +1,18 @@
+package org.jvnet.jaxb2_commons.plugin.simplify;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/simplify";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+ public static QName AS_ELEMENT_PROPERTY_ELEMENT_NAME = new QName(
+ NAMESPACE_URI, "as-element-property");
+
+ public static QName AS_REFERENCE_PROPERTY_ELEMENT_NAME = new QName(
+ NAMESPACE_URI, "as-reference-property");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java
new file mode 100644
index 00000000..2602700e
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/simplify/SimplifyPlugin.java
@@ -0,0 +1,278 @@
+package org.jvnet.jaxb2_commons.plugin.simplify;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.util.CustomizationUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.tools.xjc.model.CAttributePropertyInfo;
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CClassRef;
+import com.sun.tools.xjc.model.CElement;
+import com.sun.tools.xjc.model.CElementInfo;
+import com.sun.tools.xjc.model.CElementPropertyInfo;
+import com.sun.tools.xjc.model.CElementPropertyInfo.CollectionMode;
+import com.sun.tools.xjc.model.CPropertyInfo;
+import com.sun.tools.xjc.model.CPropertyVisitor;
+import com.sun.tools.xjc.model.CReferencePropertyInfo;
+import com.sun.tools.xjc.model.CTypeRef;
+import com.sun.tools.xjc.model.CValuePropertyInfo;
+import com.sun.tools.xjc.model.Model;
+import com.sun.xml.bind.v2.model.core.ID;
+
+public class SimplifyPlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xsimplify";
+ }
+
+ @Override
+ public String getUsage() {
+ return "This plugin allows simplifying \"complex\" properties"
+ + " (ex. aOrBOrC generated from repeatable choices)"
+ + " into several \"simple\" properties (ex. a, b, c).\n"
+ + " Please visit http://confluence.highsource.org/display/J2B/Simplify+Plugin"
+ + " for plugin documentation.";
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_ELEMENT_PROPERTY_ELEMENT_NAME,
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_REFERENCE_PROPERTY_ELEMENT_NAME,
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public void postProcessModel(final Model model, ErrorHandler errorHandler) {
+
+ for (final CClassInfo classInfo : model.beans().values()) {
+ postProcessClassInfo(model, classInfo);
+ }
+ }
+
+ private void postProcessClassInfo(final Model model,
+ final CClassInfo classInfo) {
+ final List properties = new ArrayList(
+ classInfo.getProperties());
+ for (CPropertyInfo property : properties) {
+ property.accept(new CPropertyVisitor() {
+
+ public Void onElement(CElementPropertyInfo elementProperty) {
+ postProcessElementPropertyInfo(model, classInfo,
+ elementProperty);
+ return null;
+ }
+
+ public Void onAttribute(CAttributePropertyInfo attributeProperty) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Void onValue(CValuePropertyInfo valueProperty) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Void onReference(CReferencePropertyInfo p) {
+ postProcessReferencePropertyInfo(model, classInfo, p);
+ return null;
+ }
+
+ });
+ }
+ }
+
+ private void postProcessElementPropertyInfo(final Model model,
+ final CClassInfo classInfo, CElementPropertyInfo property) {
+ if (property.isCollection() && property.getTypes().size() > 1) {
+ if (CustomizationUtils
+ .containsCustomization(
+ property,
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_ELEMENT_PROPERTY_ELEMENT_NAME)) {
+ simplifyElementPropertyInfoAsElementPropertyInfo(model,
+ classInfo, property);
+ }
+ }
+ }
+
+ private void postProcessReferencePropertyInfo(final Model model,
+ final CClassInfo classInfo, CReferencePropertyInfo property) {
+ if (property.isCollection() && property.getElements().size() > 1) {
+ if (CustomizationUtils
+ .containsCustomization(
+ property,
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_ELEMENT_PROPERTY_ELEMENT_NAME)) {
+ simplifyReferencePropertyInfoAsElementPropertyInfo(model,
+ classInfo, property);
+ } else if (CustomizationUtils
+ .containsCustomization(
+ property,
+ org.jvnet.jaxb2_commons.plugin.simplify.Customizations.AS_REFERENCE_PROPERTY_ELEMENT_NAME)) {
+ simplifyReferencePropertyInfoAsReferencePropertyInfo(model,
+ classInfo, property);
+ }
+ }
+ }
+
+ private void simplifyElementPropertyInfoAsElementPropertyInfo(
+ final Model model, final CClassInfo classInfo,
+ CElementPropertyInfo property) {
+ int index = classInfo.getProperties().indexOf(property);
+ for (CTypeRef typeRef : property.getTypes()) {
+ final CElementPropertyInfo elementPropertyInfo = createElementPropertyInfo(
+ model, property, typeRef);
+ classInfo.getProperties().add(index++, elementPropertyInfo);
+ }
+ classInfo.getProperties().remove(property);
+ }
+
+ private void simplifyReferencePropertyInfoAsReferencePropertyInfo(
+ final Model model, final CClassInfo classInfo,
+ CReferencePropertyInfo property) {
+ int index = classInfo.getProperties().indexOf(property);
+ for (CElement element : property.getElements()) {
+ final CReferencePropertyInfo referencePropertyInfo = createReferencePropertyInfo(
+ model, property, element);
+ classInfo.getProperties().add(index++, referencePropertyInfo);
+ }
+ classInfo.getProperties().remove(property);
+ }
+
+ private void simplifyReferencePropertyInfoAsElementPropertyInfo(
+ final Model model, final CClassInfo classInfo,
+ CReferencePropertyInfo property) {
+ int index = classInfo.getProperties().indexOf(property);
+ for (CElement element : property.getElements()) {
+ final CElementPropertyInfo elementPropertyInfo;
+ if (element instanceof CElementInfo) {
+ elementPropertyInfo = createElementPropertyInfo(model, element,
+ (CElementInfo) element);
+ } else if (element instanceof CClassInfo) {
+ elementPropertyInfo = createElementPropertyInfo(model, element,
+ (CClassInfo) element);
+
+ } else if (element instanceof CClassRef) {
+ // elementPropertyInfo = createElementPropertyInfo(model,
+ // element,
+ // (CClassRef) element);
+ elementPropertyInfo = null;
+ // TODO WARN
+
+ } else {
+ // TODO WARN
+ elementPropertyInfo = null;
+ }
+ if (elementPropertyInfo != null) {
+ classInfo.getProperties().add(index++, elementPropertyInfo);
+ }
+ }
+ classInfo.getProperties().remove(property);
+ }
+
+ private CElementPropertyInfo createElementPropertyInfo(final Model model,
+ CElement element, final CElementInfo elementInfo) {
+ final CElementPropertyInfo elementPropertyInfo;
+ final String propertyName = createPropertyName(model, element);
+ elementPropertyInfo = new CElementPropertyInfo(propertyName,
+ CollectionMode.REPEATED_ELEMENT, ID.NONE, null,
+ element.getSchemaComponent(), element.getCustomizations(),
+ element.getLocator(), false);
+ elementPropertyInfo.getTypes().add(
+ new CTypeRef(elementInfo.getContentType(), element
+ .getElementName(), elementInfo.getContentType()
+ .getTypeName(), false, null));
+ return elementPropertyInfo;
+ }
+
+ private CElementPropertyInfo createElementPropertyInfo(final Model model,
+ CElement element, final CClassInfo classInfo) {
+ final CElementPropertyInfo elementPropertyInfo;
+ final String propertyName = createPropertyName(model, element);
+ elementPropertyInfo = new CElementPropertyInfo(propertyName,
+ CollectionMode.REPEATED_ELEMENT, ID.NONE, null,
+ element.getSchemaComponent(), element.getCustomizations(),
+ element.getLocator(), false);
+ elementPropertyInfo.getTypes().add(
+ new CTypeRef(classInfo, element.getElementName(), classInfo
+ .getTypeName(), false, null));
+ return elementPropertyInfo;
+ }
+
+ // private CElementPropertyInfo createElementPropertyInfo(final Model model,
+ // CElement element, final CClassRef cr) {
+ // final CElementPropertyInfo elementPropertyInfo;
+ // final String propertyName = createPropertyName(model, element);
+ // elementPropertyInfo = new CElementPropertyInfo(propertyName,
+ // CollectionMode.REPEATED_ELEMENT, ID.NONE, null,
+ // element.getSchemaComponent(), element.getCustomizations(),
+ // element.getLocator(), false);
+ // elementPropertyInfo.getTypes().add(
+ // new CTypeRef(cr, element.getElementName(), cr.getTypeName(),
+ // false, null));
+ // return elementPropertyInfo;
+ // }
+
+ private CReferencePropertyInfo createReferencePropertyInfo(
+ final Model model, CReferencePropertyInfo property, CElement element) {
+ final String propertyName = createPropertyName(model, element);
+ final CReferencePropertyInfo referencePropertyInfo = new CReferencePropertyInfo(
+ propertyName, true, false, property.isMixed(),
+ element.getSchemaComponent(), element.getCustomizations(),
+ element.getLocator(), property.isDummy(), property.isContent(),
+ property.isMixedExtendedCust());
+ referencePropertyInfo.getElements().add(element);
+ return referencePropertyInfo;
+ }
+
+ private CElementPropertyInfo createElementPropertyInfo(final Model model,
+ CElementPropertyInfo property, CTypeRef typeRef) {
+ final String propertyName = createPropertyName(model, typeRef);
+ boolean required = false;
+ final CElementPropertyInfo elementPropertyInfo = new CElementPropertyInfo(
+ propertyName, CollectionMode.REPEATED_ELEMENT, typeRef
+ .getTarget().idUse(), typeRef.getTarget()
+ .getExpectedMimeType(), property.getSchemaComponent(),
+ property.getCustomizations(), property.getLocator(), required);
+ elementPropertyInfo.getTypes().add(typeRef);
+ return elementPropertyInfo;
+ }
+
+ private String createPropertyName(final Model model, CElement element) {
+ final String propertyName = model.getNameConverter().toPropertyName(
+ element.getElementName().getLocalPart());
+ return propertyName;
+ }
+
+ private String createPropertyName(final Model model, CTypeRef element) {
+ final String propertyName = model.getNameConverter().toPropertyName(
+ element.getTagName().getLocalPart());
+ return propertyName;
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java
new file mode 100644
index 00000000..007c7d4e
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java
@@ -0,0 +1,12 @@
+package org.jvnet.jaxb2_commons.plugin.tostring;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/toString";
+
+ public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
+ "ignored");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java
new file mode 100644
index 00000000..e5dc1b9b
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java
@@ -0,0 +1,228 @@
+package org.jvnet.jaxb2_commons.plugin.tostring;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
+import org.jvnet.jaxb2_commons.lang.ToString;
+import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
+import org.jvnet.jaxb2_commons.locator.ObjectLocator;
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.plugin.Customizations;
+import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
+import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
+import org.jvnet.jaxb2_commons.util.ClassUtils;
+import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
+import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
+import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.codemodel.JBlock;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JDefinedClass;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.codemodel.JMethod;
+import com.sun.codemodel.JMod;
+import com.sun.codemodel.JVar;
+import com.sun.tools.xjc.Options;
+import com.sun.tools.xjc.outline.ClassOutline;
+import com.sun.tools.xjc.outline.FieldOutline;
+import com.sun.tools.xjc.outline.Outline;
+
+public class ToStringPlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "XtoString";
+ }
+
+ @Override
+ public String getUsage() {
+ return "TBD";
+ }
+
+ private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
+
+ public FieldAccessorFactory getFieldAccessorFactory() {
+ return fieldAccessorFactory;
+ }
+
+ public void setFieldAccessorFactory(
+ FieldAccessorFactory fieldAccessorFactory) {
+ this.fieldAccessorFactory = fieldAccessorFactory;
+ }
+
+
+ private String toStringStrategyClass = JAXBToStringStrategy.class.getName();
+
+ public void setToStringStrategyClass(
+ String toStringStrategy) {
+ this.toStringStrategyClass = toStringStrategy;
+ }
+
+ public String getToStringStrategyClass() {
+ return toStringStrategyClass;
+ }
+
+ public JExpression createToStringStrategy(JCodeModel codeModel) {
+ return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
+ ToStringStrategy.class, getToStringStrategyClass());
+ }
+
+ private Ignoring ignoring = new CustomizedIgnoring(
+ org.jvnet.jaxb2_commons.plugin.tostring.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+
+ public Ignoring getIgnoring() {
+ return ignoring;
+ }
+
+ public void setIgnoring(Ignoring ignoring) {
+ this.ignoring = ignoring;
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(
+ org.jvnet.jaxb2_commons.plugin.tostring.Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.IGNORED_ELEMENT_NAME,
+ Customizations.GENERATED_ELEMENT_NAME);
+ }
+
+ @Override
+ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
+ for (final ClassOutline classOutline : outline.getClasses())
+ if (!getIgnoring().isIgnored(classOutline)) {
+ processClassOutline(classOutline);
+ }
+ return true;
+ }
+
+ protected void processClassOutline(ClassOutline classOutline) {
+ final JDefinedClass theClass = classOutline.implClass;
+ ClassUtils._implements(theClass, theClass.owner().ref(ToString.class));
+
+ @SuppressWarnings("unused")
+ final JMethod object$toString = generateObject$toString(classOutline,
+ theClass);
+ @SuppressWarnings("unused")
+ final JMethod toString$append = generateToString$append(classOutline,
+ theClass);
+ @SuppressWarnings("unused")
+ final JMethod toString$appendFields = generateToString$appendFields(
+ classOutline, theClass);
+ }
+
+ protected JMethod generateObject$toString(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ final JCodeModel codeModel = theClass.owner();
+ final JMethod object$toString = theClass.method(JMod.PUBLIC, codeModel
+ .ref(String.class), "toString");
+ {
+ final JBlock body = object$toString.body();
+
+ final JVar toStringStrategy =
+
+ body.decl(JMod.FINAL, codeModel.ref(ToStringStrategy.class),
+ "strategy", createToStringStrategy(codeModel));
+
+ final JVar buffer = body.decl(JMod.FINAL, codeModel
+ .ref(StringBuilder.class), "buffer", JExpr._new(codeModel
+ .ref(StringBuilder.class)));
+ body.invoke("append").arg(JExpr._null()).arg(buffer).arg(
+ toStringStrategy);
+ body._return(buffer.invoke("toString"));
+ }
+ return object$toString;
+ }
+
+ protected JMethod generateToString$append(final ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ final JCodeModel codeModel = theClass.owner();
+ final JMethod toString$append = theClass.method(JMod.PUBLIC, codeModel
+ .ref(StringBuilder.class), "append");
+ {
+
+ final JVar locator = toString$append.param(ObjectLocator.class,
+ "locator");
+ final JVar buffer = toString$append.param(StringBuilder.class,
+ "buffer");
+ final JVar toStringStrategy = toString$append.param(
+ ToStringStrategy.class, "strategy");
+
+ final JBlock body = toString$append.body();
+
+ body.invoke(toStringStrategy, "appendStart").arg(locator).arg(
+ JExpr._this()).arg(buffer);
+ body.invoke("appendFields").arg(locator).arg(buffer).arg(
+ toStringStrategy);
+ body.invoke(toStringStrategy, "appendEnd").arg(locator).arg(
+ JExpr._this()).arg(buffer);
+ body._return(buffer);
+ }
+ return toString$append;
+ }
+
+ protected JMethod generateToString$appendFields(ClassOutline classOutline,
+ final JDefinedClass theClass) {
+ final JCodeModel codeModel = theClass.owner();
+
+ final JMethod toString$appendFields = theClass.method(JMod.PUBLIC,
+ codeModel.ref(StringBuilder.class), "appendFields");
+ {
+ final JVar locator = toString$appendFields.param(
+ ObjectLocator.class, "locator");
+ final JVar buffer = toString$appendFields.param(
+ StringBuilder.class, "buffer");
+ final JVar toStringStrategy = toString$appendFields.param(
+ ToStringStrategy.class, "strategy");
+ final JBlock body = toString$appendFields.body();
+
+ final Boolean superClassImplementsToString = StrategyClassUtils
+ .superClassImplements(classOutline, ignoring,
+ ToString.class);
+
+ if (superClassImplementsToString == null) {
+ // No superclass
+ } else if (superClassImplementsToString.booleanValue()) {
+ body.invoke(JExpr._super(), "appendFields").arg(locator).arg(
+ buffer).arg(toStringStrategy);
+ } else {
+ // Superclass does not implement ToString
+ }
+
+ final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
+ classOutline.getDeclaredFields(), getIgnoring());
+
+ if (declaredFields.length > 0) {
+
+ for (final FieldOutline fieldOutline : declaredFields) {
+ final JBlock block = body.block();
+ final FieldAccessorEx fieldAccessor = getFieldAccessorFactory()
+ .createFieldAccessor(fieldOutline, JExpr._this());
+ final JVar theValue = block.decl(fieldAccessor.getType(),
+ "the"
+ + fieldOutline.getPropertyInfo().getName(
+ true));
+ fieldAccessor.toRawValue(block, theValue);
+
+ block.invoke(toStringStrategy, "appendField").arg(locator)
+ .arg(JExpr._this()).arg(
+ JExpr.lit(fieldOutline.getPropertyInfo()
+ .getName(false))).arg(buffer).arg(
+ theValue);
+ }
+ }
+ body._return(buffer);
+ }
+ return toString$appendFields;
+ }
+
+}
\ No newline at end of file
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java
new file mode 100644
index 00000000..d1f00231
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java
@@ -0,0 +1,32 @@
+package org.jvnet.jaxb2_commons.plugin.util;
+
+import java.lang.reflect.Array;
+import java.util.LinkedList;
+import java.util.List;
+
+public class ArrayUtils {
+
+ private ArrayUtils() {
+
+ }
+
+ public static T[] filter(T[] array, Predicate predicate,
+ Class extends T> theClass) {
+
+ if (array == null) {
+ return null;
+ } else {
+ final List list = new LinkedList();
+ for (T item : array) {
+ if (predicate.evaluate(item)) {
+ list.add(item);
+ }
+ }
+ @SuppressWarnings("unchecked")
+ final T[] newArray = (T[]) Array.newInstance(theClass, list.size());
+ return list.toArray(newArray);
+ }
+
+ }
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java
new file mode 100644
index 00000000..b7b67ada
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java
@@ -0,0 +1,22 @@
+package org.jvnet.jaxb2_commons.plugin.util;
+
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+
+import com.sun.tools.xjc.outline.FieldOutline;
+
+public class FieldOutlineUtils {
+
+ private FieldOutlineUtils() {
+
+ }
+
+ public static FieldOutline[] filter(final FieldOutline[] fieldOutlines,
+ final Ignoring ignoring) {
+ return ArrayUtils.filter(fieldOutlines, new Predicate() {
+ public boolean evaluate(FieldOutline fieldOutline) {
+ return !ignoring.isIgnored(fieldOutline);
+
+ }
+ }, FieldOutline.class);
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java
new file mode 100644
index 00000000..0c38cf47
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java
@@ -0,0 +1,7 @@
+package org.jvnet.jaxb2_commons.plugin.util;
+
+public interface Predicate {
+
+ public boolean evaluate(T object);
+
+}
\ No newline at end of file
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java
new file mode 100644
index 00000000..da6ed089
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java
@@ -0,0 +1,82 @@
+package org.jvnet.jaxb2_commons.plugin.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.jvnet.jaxb2_commons.plugin.Ignoring;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+import com.sun.codemodel.JExpr;
+import com.sun.codemodel.JExpression;
+import com.sun.tools.xjc.outline.ClassOutline;
+
+public class StrategyClassUtils {
+ public static JExpression createStrategyInstanceExpression(
+ JCodeModel codeModel, final Class extends T> strategyInterface,
+ final String strategyClassName) {
+
+ try {
+ final Class> strategyClass = Class.forName(strategyClassName);
+ final JClass strategyJClass = codeModel.ref(strategyClass);
+ try {
+ final Method getInstanceMethod = strategyClass.getMethod(
+ "getInstance", new Class>[0]);
+ if (getInstanceMethod != null
+ && strategyInterface.isAssignableFrom(getInstanceMethod
+ .getReturnType())
+ && Modifier.isStatic(getInstanceMethod.getModifiers())
+ && Modifier.isPublic(getInstanceMethod.getModifiers())) {
+ return strategyJClass.staticInvoke("getInstance");
+ }
+
+ } catch (Exception ignored) {
+ // Nothing to do
+ }
+ try {
+ final Field instanceField = strategyClass.getField("INSTANCE");
+ if (instanceField != null
+ && strategyInterface.isAssignableFrom(instanceField
+ .getType())
+ && Modifier.isStatic(instanceField.getModifiers())
+ && Modifier.isPublic(instanceField.getModifiers())) {
+ return strategyJClass.staticRef("INSTANCE");
+ }
+ } catch (Exception ignored) {
+ // Nothing to do
+ }
+ return JExpr._new(strategyJClass);
+ } catch (ClassNotFoundException cnfex) {
+ final JClass strategyJClass = codeModel.ref(strategyClassName);
+ return JExpr._new(strategyJClass);
+ }
+ }
+
+ public static Boolean superClassImplements(ClassOutline classOutline,
+ Ignoring ignoring, Class extends T> theInterface) {
+ if (classOutline.target.getBaseClass() != null) {
+ if (!ignoring.isIgnored(classOutline.parent().getClazz(
+ classOutline.target.getBaseClass()))) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ } else if (classOutline.target.getRefBaseClass() != null) {
+ try {
+ if (theInterface.isAssignableFrom(Class
+ .forName(classOutline.target.getRefBaseClass()
+ .fullName()))) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ } catch (ClassNotFoundException ignored) {
+ // We'll assume it does implement
+ return Boolean.TRUE;
+ }
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java
new file mode 100644
index 00000000..ea32d362
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java
@@ -0,0 +1,13 @@
+package org.jvnet.jaxb2_commons.plugin.wildcard;
+
+import javax.xml.namespace.QName;
+
+public class Customizations {
+
+ public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/wildcard";
+
+ public static QName LAX_ELEMENT_NAME = new QName(NAMESPACE_URI, "lax");
+ public static QName STRICT_ELEMENT_NAME = new QName(NAMESPACE_URI, "strict");
+ public static QName SKIP_ELEMENT_NAME = new QName(NAMESPACE_URI, "skip");
+
+}
diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java
new file mode 100644
index 00000000..33839b93
--- /dev/null
+++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java
@@ -0,0 +1,97 @@
+package org.jvnet.jaxb2_commons.plugin.wildcard;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
+import org.jvnet.jaxb2_commons.util.CustomizationUtils;
+import org.xml.sax.ErrorHandler;
+
+import com.sun.tools.xjc.model.CClassInfo;
+import com.sun.tools.xjc.model.CPropertyInfo;
+import com.sun.tools.xjc.model.CReferencePropertyInfo;
+import com.sun.tools.xjc.model.Model;
+import com.sun.xml.bind.v2.model.core.WildcardMode;
+
+public class WildcardPlugin extends AbstractParameterizablePlugin {
+
+ @Override
+ public String getOptionName() {
+ return "Xwildcard";
+ }
+
+ @Override
+ public String getUsage() {
+ return "Allows specifying the wildcard mode in wildcard properties.";
+ }
+
+ @Override
+ public void postProcessModel(Model model, ErrorHandler errorHandler) {
+ final boolean laxModel = CustomizationUtils.containsCustomization(
+ model, Customizations.LAX_ELEMENT_NAME);
+ final boolean skipModel = CustomizationUtils.containsCustomization(
+ model, Customizations.SKIP_ELEMENT_NAME);
+ final boolean strictModel = CustomizationUtils.containsCustomization(
+ model, Customizations.STRICT_ELEMENT_NAME);
+ for (CClassInfo classInfo : model.beans().values()) {
+ final boolean laxClassInfo = CustomizationUtils
+ .containsCustomization(classInfo,
+ Customizations.LAX_ELEMENT_NAME);
+ final boolean skipClassInfo = CustomizationUtils
+ .containsCustomization(classInfo,
+ Customizations.SKIP_ELEMENT_NAME);
+ final boolean strictClassInfo = CustomizationUtils
+ .containsCustomization(classInfo,
+ Customizations.STRICT_ELEMENT_NAME);
+ for (CPropertyInfo propertyInfo : classInfo.getProperties()) {
+ if (propertyInfo instanceof CReferencePropertyInfo) {
+ final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) propertyInfo;
+ final boolean laxPropertyInfo = CustomizationUtils
+ .containsCustomization(referencePropertyInfo,
+ Customizations.LAX_ELEMENT_NAME);
+ final boolean skipPropertyInfo = CustomizationUtils
+ .containsCustomization(referencePropertyInfo,
+ Customizations.SKIP_ELEMENT_NAME);
+ final boolean strictPropertyInfo = CustomizationUtils
+ .containsCustomization(referencePropertyInfo,
+ Customizations.STRICT_ELEMENT_NAME);
+
+ if (laxModel) {
+ referencePropertyInfo.setWildcard(WildcardMode.LAX);
+ } else if (skipModel) {
+ referencePropertyInfo.setWildcard(WildcardMode.SKIP);
+ } else if (strictModel) {
+ referencePropertyInfo.setWildcard(WildcardMode.STRICT);
+ }
+
+ if (laxClassInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.LAX);
+ } else if (skipClassInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.SKIP);
+ } else if (strictClassInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.STRICT);
+ }
+
+ if (laxPropertyInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.LAX);
+ } else if (skipPropertyInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.SKIP);
+ } else if (strictPropertyInfo) {
+ referencePropertyInfo.setWildcard(WildcardMode.STRICT);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public Collection getCustomizationElementNames() {
+ return Arrays
+ .asList(org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.LAX_ELEMENT_NAME,
+ org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.SKIP_ELEMENT_NAME,
+ org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.STRICT_ELEMENT_NAME);
+ }
+
+}
diff --git a/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin b/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
new file mode 100644
index 00000000..d62ace6e
--- /dev/null
+++ b/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
@@ -0,0 +1,13 @@
+org.jvnet.jaxb2_commons.plugin.jaxbindex.JaxbIndexPlugin
+org.jvnet.jaxb2_commons.plugin.tostring.ToStringPlugin
+org.jvnet.jaxb2_commons.plugin.equals.EqualsPlugin
+org.jvnet.jaxb2_commons.plugin.hashcode.HashCodePlugin
+org.jvnet.jaxb2_commons.plugin.copyable.CopyablePlugin
+org.jvnet.jaxb2_commons.plugin.mergeable.MergeablePlugin
+org.jvnet.jaxb2_commons.plugin.inheritance.InheritancePlugin
+org.jvnet.jaxb2_commons.plugin.setters.SettersPlugin
+org.jvnet.jaxb2_commons.plugin.wildcard.WildcardPlugin
+org.jvnet.jaxb2_commons.plugin.autoinheritance.AutoInheritancePlugin
+org.jvnet.jaxb2_commons.plugin.elementwrapper.ElementWrapperPlugin
+org.jvnet.jaxb2_commons.plugin.simplify.SimplifyPlugin
+org.jvnet.jaxb2_commons.plugin.enumvalue.EnumValuePlugin
\ No newline at end of file
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java
new file mode 100644
index 00000000..c3ceb73b
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java
@@ -0,0 +1,30 @@
+package org.jvnet.jaxb2_commons.plugin.copyable.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
+import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
+
+public class RunCopyablePlugin extends RunXJC2Mojo {
+
+ @Override
+ public File getSchemaDirectory() {
+ return new File(getBaseDir(), "src/test/resources");
+ }
+
+ @Override
+ protected void configureMojo(AbstractXJC2Mojo mojo) {
+ super.configureMojo(mojo);
+ mojo.setForceRegenerate(true);
+ }
+
+ @Override
+ public List getArgs() {
+ final List args = new ArrayList(super.getArgs());
+ args.add("-Xcopyable");
+ return args;
+ }
+
+}
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java
new file mode 100644
index 00000000..b29251cc
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java
@@ -0,0 +1,30 @@
+package org.jvnet.jaxb2_commons.plugin.equals.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
+import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
+
+public class RunEqualsPlugin extends RunXJC2Mojo {
+
+ @Override
+ public File getSchemaDirectory() {
+ return new File(getBaseDir(), "src/test/resources");
+ }
+
+ @Override
+ protected void configureMojo(AbstractXJC2Mojo mojo) {
+ super.configureMojo(mojo);
+ mojo.setForceRegenerate(true);
+ }
+
+ @Override
+ public List getArgs() {
+ final List args = new ArrayList(super.getArgs());
+ args.add("-Xequals");
+ return args;
+ }
+
+}
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaParserTest.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaParserTest.java
new file mode 100644
index 00000000..bd7ca4a8
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaParserTest.java
@@ -0,0 +1,28 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance.tests;
+
+import junit.framework.TestCase;
+
+import org.jvnet.jaxb2_commons.plugin.inheritance.util.JavaTypeParser;
+
+import com.sun.codemodel.JClass;
+import com.sun.codemodel.JCodeModel;
+
+public class JavaParserTest extends TestCase {
+
+ public void testParse() throws Exception {
+
+ final String text = "public class Dummy implements java.util.Comparator{}";
+
+ final JavaTypeParser javaTypeParser = new JavaTypeParser();
+ final JCodeModel codeModel = new JCodeModel();
+ JClass comparator = javaTypeParser.parseClass("java.util.Comparator",
+ codeModel);
+ assertNotNull(comparator);
+ JClass integerComparator = javaTypeParser.parseClass(
+ "java.util.Comparator", codeModel);
+ assertNotNull(integerComparator);
+ JClass wildcardIntegerComparator = javaTypeParser.parseClass(
+ "java.util.Comparator extends java.lang.Integer>", codeModel);
+ assertNotNull(wildcardIntegerComparator);
+ }
+}
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java
new file mode 100644
index 00000000..8566557b
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java
@@ -0,0 +1,48 @@
+package org.jvnet.jaxb2_commons.plugin.inheritance.tests;
+
+import japa.parser.JavaParser;
+import japa.parser.ast.CompilationUnit;
+import japa.parser.ast.body.ClassOrInterfaceDeclaration;
+import japa.parser.ast.body.TypeDeclaration;
+import japa.parser.ast.type.ClassOrInterfaceType;
+import japa.parser.ast.type.ReferenceType;
+import japa.parser.ast.type.Type;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class JavaTypeParserTest extends TestCase {
+
+ public void testParse() throws Exception {
+
+ final String text = "public class Dummy implements java.util.Comparator{}";
+
+ final CompilationUnit compilationUnit = JavaParser.parse(
+ new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8");
+ final List typeDeclarations = compilationUnit
+ .getTypes();
+ assertEquals(1, typeDeclarations.size());
+ final TypeDeclaration typeDeclaration = typeDeclarations.get(0);
+ assertTrue(typeDeclaration instanceof ClassOrInterfaceDeclaration);
+ final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration;
+ assertEquals("Dummy", classDeclaration.getName());
+ final List implementedInterfaces = classDeclaration
+ .getImplements();
+ assertEquals(1, implementedInterfaces.size());
+ final ClassOrInterfaceType implementedInterface = implementedInterfaces
+ .get(0);
+ assertEquals("Comparator", implementedInterface.getName());
+ final List typeArgs = implementedInterface.getTypeArgs();
+ assertEquals(1, typeArgs.size());
+ final Type typeArg = typeArgs.get(0);
+ assertTrue(typeArg instanceof ReferenceType);
+ final ReferenceType referenceTypeArg = (ReferenceType) typeArg;
+ final Type referencedType = referenceTypeArg.getType();
+ assertTrue(referencedType instanceof ClassOrInterfaceType);
+ final ClassOrInterfaceType typeArgType = (ClassOrInterfaceType) referencedType;
+ assertEquals("Integer", typeArgType.getName());
+
+ }
+}
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/mergeable/tests/RunMergeablePlugin.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/mergeable/tests/RunMergeablePlugin.java
new file mode 100644
index 00000000..8faa3469
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/mergeable/tests/RunMergeablePlugin.java
@@ -0,0 +1,30 @@
+package org.jvnet.jaxb2_commons.plugin.mergeable.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
+import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
+
+public class RunMergeablePlugin extends RunXJC2Mojo {
+
+ @Override
+ public File getSchemaDirectory() {
+ return new File(getBaseDir(), "src/test/resources");
+ }
+
+ @Override
+ protected void configureMojo(AbstractXJC2Mojo mojo) {
+ super.configureMojo(mojo);
+ mojo.setForceRegenerate(true);
+ }
+
+ @Override
+ public List getArgs() {
+ final List args = new ArrayList(super.getArgs());
+ args.add("-Xmergeable");
+ return args;
+ }
+
+}
diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/tostring/tests/RunToStringPlugin.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/tostring/tests/RunToStringPlugin.java
new file mode 100644
index 00000000..1d435a9e
--- /dev/null
+++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/tostring/tests/RunToStringPlugin.java
@@ -0,0 +1,33 @@
+package org.jvnet.jaxb2_commons.plugin.tostring.tests;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
+import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
+import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
+
+public class RunToStringPlugin extends RunXJC2Mojo {
+
+ @Override
+ public File getSchemaDirectory() {
+ return new File(getBaseDir(), "src/test/resources");
+ }
+
+ @Override
+ protected void configureMojo(AbstractXJC2Mojo mojo) {
+ super.configureMojo(mojo);
+ mojo.setForceRegenerate(true);
+ }
+
+ @Override
+ public List getArgs() {
+ final List args = new ArrayList(super.getArgs());
+ args.add("-XtoString");
+ args.add("-XtoString-toStringStrategy="
+ + JAXBToStringStrategy.class.getName());
+ return args;
+ }
+
+}
diff --git a/basic/src/test/resources/schema.xsd b/basic/src/test/resources/schema.xsd
new file mode 100644
index 00000000..29a52962
--- /dev/null
+++ b/basic/src/test/resources/schema.xsd
@@ -0,0 +1,260 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/.classpath b/basics/tags/0.6.1/annotate/.classpath
deleted file mode 100644
index 2daddec3..00000000
--- a/basics/tags/0.6.1/annotate/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/basics/tags/0.6.1/annotate/.project b/basics/tags/0.6.1/annotate/.project
deleted file mode 100644
index 10d88fcb..00000000
--- a/basics/tags/0.6.1/annotate/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- jaxb2-basics-annotate
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.maven.ide.eclipse.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.maven.ide.eclipse.maven2Nature
-
-
diff --git a/basics/tags/0.6.1/annotate/pom.xml b/basics/tags/0.6.1/annotate/pom.xml
deleted file mode 100644
index 22f942b7..00000000
--- a/basics/tags/0.6.1/annotate/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
- 4.0.0
- org.jvnet.jaxb2_commons
- jaxb2-basics-annotate
- jar
- JAXB2 Basics - Annotate Plugin
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-project
- 0.6.1
- ../pom.xml
-
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-tools
-
-
- commons-lang
- commons-lang
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-runtime
-
-
-
-
- com.sun.xml.bind
- jaxb-impl
- provided
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-jaxb-xjc
- provided
-
-
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin-testing
- test
-
-
-
- org.jvnet.annox
- annox
-
-
-
- install
-
-
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/AnnotatePlugin.java b/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/AnnotatePlugin.java
deleted file mode 100644
index 86d346d9..00000000
--- a/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/AnnotatePlugin.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.annotate;
-
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.annox.Constants;
-import org.jvnet.annox.model.XAnnotation;
-import org.jvnet.annox.parser.XAnnotationParser;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.util.CustomizationUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorUtils;
-import org.jvnet.jaxb2_commons.util.OutlineUtils;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import com.sun.codemodel.JAnnotatable;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JFieldVar;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.model.CCustomizations;
-import com.sun.tools.xjc.model.CElementInfo;
-import com.sun.tools.xjc.model.CPluginCustomization;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.ElementOutline;
-import com.sun.tools.xjc.outline.EnumConstantOutline;
-import com.sun.tools.xjc.outline.EnumOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class AnnotatePlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xannotate";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private String defaultFieldTarget = "getter";
-
- public String getDefaultFieldTarget() {
- return defaultFieldTarget;
- }
-
- public void setDefaultFieldTarget(String defaultFieldTarget) {
- if ("getter".equals(defaultFieldTarget)
- || "setter".equals(defaultFieldTarget)
- || "setter-parameter".equals(defaultFieldTarget)
- || "field".equals(defaultFieldTarget)) {
- this.defaultFieldTarget = defaultFieldTarget;
- } else {
- throw new IllegalArgumentException("Invalid default field target.");
- }
- }
-
- private XAnnotationParser annotationParser = XAnnotationParser.GENERIC;
-
- public XAnnotationParser getAnnotationParser() {
- return annotationParser;
- }
-
- public void setAnnotationParser(XAnnotationParser annotationParser) {
- this.annotationParser = annotationParser;
- }
-
- private Annotator annotator = new Annotator();
-
- public Annotator getAnnotator() {
- return annotator;
- }
-
- public void setAnnotator(Annotator annotator) {
- this.annotator = annotator;
- }
-
- @Override
- public boolean run(Outline outline, Options options,
- ErrorHandler errorHandler) {
-
- for (final CElementInfo elementInfo : outline.getModel()
- .getAllElements()) {
- final ElementOutline elementOutline = outline
- .getElement(elementInfo);
- if (elementOutline != null) {
- processElementOutline(elementOutline, options, errorHandler);
- }
- }
-
- for (final ClassOutline classOutline : outline.getClasses()) {
- processClassOutline(classOutline, options, errorHandler);
- }
- for (final EnumOutline enumOutline : outline.getEnums()) {
- processEnumOutline(enumOutline, options, errorHandler);
- }
- return true;
- }
-
- protected void processElementOutline(ElementOutline elementOutline,
- Options options, ErrorHandler errorHandler) {
-
- final CCustomizations customizations = CustomizationUtils
- .getCustomizations(elementOutline);
-
- annotateElementOutline(elementOutline.implClass.owner(), elementOutline,
- customizations, errorHandler);
- }
-
- protected void processEnumOutline(EnumOutline enumOutline, Options options,
- ErrorHandler errorHandler) {
- final CCustomizations customizations = CustomizationUtils
- .getCustomizations(enumOutline);
- annotateEnumOutline(enumOutline.clazz.owner(), enumOutline,
- customizations, errorHandler);
-
- for (final EnumConstantOutline enumConstantOutline : enumOutline.constants) {
- processEnumConstantOutline(enumOutline, enumConstantOutline,
- options, errorHandler);
- }
-
- }
-
- protected void processClassOutline(ClassOutline classOutline,
- Options options, ErrorHandler errorHandler) {
-
- final CCustomizations customizations = CustomizationUtils
- .getCustomizations(classOutline);
-
- annotateClassOutline(classOutline.ref.owner(), classOutline,
- customizations, errorHandler);
-
- for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) {
- processFieldOutline(classOutline, fieldOutline, options,
- errorHandler);
- }
-
- }
-
- private void processFieldOutline(ClassOutline classOutline,
- FieldOutline fieldOutline, Options options,
- ErrorHandler errorHandler) {
-
- final CCustomizations customizations =
-// fieldOutline.getPropertyInfo().getCustomizations();
- CustomizationUtils.getCustomizations(fieldOutline);
- annotate(fieldOutline.parent().ref.owner(), fieldOutline,
- customizations, errorHandler);
- }
-
- private void processEnumConstantOutline(EnumOutline enumOutline,
- EnumConstantOutline enumConstantOutline, Options options,
- ErrorHandler errorHandler) {
-
- final CCustomizations customizations = CustomizationUtils
- .getCustomizations(enumConstantOutline);
-
- annotateEnumConstantOutline(enumOutline.parent().getCodeModel(),
- enumConstantOutline, customizations, errorHandler);
- }
-
- protected void annotateElementOutline(final JCodeModel codeModel,
- final ElementOutline elementOutline,
- final CCustomizations customizations,
- final ErrorHandler errorHandler) {
- for (final CPluginCustomization customization : customizations) {
- final Element element = customization.element;
- final String namespaceURI = element.getNamespaceURI();
- if (Constants.NAMESPACE_URI.equals(namespaceURI)) {
- customization.markAsAcknowledged();
-
- final JAnnotatable annotatable = elementOutline.implClass;
-
- annotate(codeModel, errorHandler, customization, element,
- annotatable);
- }
- }
- }
-
- protected void annotateEnumOutline(final JCodeModel codeModel,
- final EnumOutline enumOutline,
- final CCustomizations customizations,
- final ErrorHandler errorHandler) {
- for (final CPluginCustomization customization : customizations) {
- final Element element = customization.element;
- final String namespaceURI = element.getNamespaceURI();
- if (Constants.NAMESPACE_URI.equals(namespaceURI)) {
- customization.markAsAcknowledged();
-
- final JAnnotatable annotatable = enumOutline.clazz;
-
- annotate(codeModel, errorHandler, customization, element,
- annotatable);
- }
- }
- }
-
- protected void annotateEnumConstantOutline(final JCodeModel codeModel,
- final EnumConstantOutline enumConstantOutline,
- final CCustomizations customizations,
- final ErrorHandler errorHandler) {
- for (final CPluginCustomization customization : customizations) {
- final Element element = customization.element;
- final String namespaceURI = element.getNamespaceURI();
- if (Constants.NAMESPACE_URI.equals(namespaceURI)) {
- customization.markAsAcknowledged();
-
- final JAnnotatable annotatable = enumConstantOutline.constRef;
-
- annotate(codeModel, errorHandler, customization, element,
- annotatable);
- }
- }
- }
-
- protected void annotateClassOutline(final JCodeModel codeModel,
- final ClassOutline classOutline,
- final CCustomizations customizations, ErrorHandler errorHandler) {
- for (final CPluginCustomization customization : customizations) {
- final Element element = customization.element;
- final String namespaceURI = element.getNamespaceURI();
- if (Constants.NAMESPACE_URI.equals(namespaceURI)) {
- customization.markAsAcknowledged();
-
- final JAnnotatable annotatable = classOutline.ref;
-
- annotate(codeModel, errorHandler, customization, element,
- annotatable);
- }
- }
- }
-
- protected void annotate(final JCodeModel codeModel,
- final FieldOutline fieldOutline,
- final CCustomizations customizations, ErrorHandler errorHandler) {
- for (final CPluginCustomization customization : customizations) {
- final Element element = customization.element;
- final String namespaceURI = element.getNamespaceURI();
- if (Constants.NAMESPACE_URI.equals(namespaceURI)) {
- customization.markAsAcknowledged();
-
- final JAnnotatable annotatable;
-
- final String draftTarget = element.getAttribute("target");
-
- final String target;
-
- if (draftTarget == null || "".equals(draftTarget)) {
- target = getDefaultFieldTarget();
- } else {
- target = draftTarget;
- }
-
- if ("class".equals(target)) {
- annotatable = fieldOutline.parent().ref;
- } else if ("getter".equals(target)) {
- final JMethod _getter = FieldAccessorUtils
- .getter(fieldOutline);
- if (_getter == null) {
- logger
- .error(MessageFormat
- .format(
- "Could not annotate the getter of the field outline [{0}], getter method could not be found.",
-
- OutlineUtils
- .getFieldName(fieldOutline)));
-
- }
- annotatable = _getter;
- } else if ("setter".equals(target)) {
- final JMethod _setter = FieldAccessorUtils
- .setter(fieldOutline);
- if (_setter == null) {
- logger
- .error(MessageFormat
- .format(
- "Could not annotate the setter of the field outline [{0}], setter method could not be found.",
-
- OutlineUtils
- .getFieldName(fieldOutline)));
- }
- annotatable = _setter;
- } else if ("setter-parameter".equals(target)) {
- final JMethod _setter = FieldAccessorUtils
- .setter(fieldOutline);
-
- if (_setter == null) {
- logger
- .error(MessageFormat
- .format(
- "Could not annotate the setter parameter of the field outline [{0}], setter method could not be found.",
-
- OutlineUtils
- .getFieldName(fieldOutline)));
- annotatable = null;
- } else {
- final JVar[] params = _setter.listParams();
- if (params.length != 1) {
- logger
- .error(MessageFormat
- .format(
- "Could not annotate the setter parameter of the field outline [{0}], setter method must have a single parameter(this setter has {1}).",
-
- OutlineUtils
- .getFieldName(fieldOutline),
- params.length));
- annotatable = null;
- } else {
- annotatable = FieldAccessorUtils.setter(
- fieldOutline).listParams()[0];
- }
- }
- } else if ("field".equals(target)) {
- // Ok
- final JFieldVar _field = FieldAccessorUtils
- .field(fieldOutline);
- if (_field == null) {
- logger
- .error(MessageFormat
- .format(
- "Could not annotate the field of the field outline [{0}] since it could not be found.",
-
- OutlineUtils
- .getFieldName(fieldOutline)));
- }
- annotatable = _field;
-
- } else {
- logger.error("Invalid annotation target [" + target + "].");
- annotatable = null;
- }
-
- if (annotatable != null) {
-
- annotate(codeModel, errorHandler, customization, element,
- annotatable);
- }
- }
- }
- }
-
- private void annotate(final JCodeModel codeModel,
- ErrorHandler errorHandler,
- final CPluginCustomization customization, final Element element,
- final JAnnotatable annotatable) {
- final NodeList elements = element.getChildNodes();
- for (int index = 0; index < elements.getLength(); index++) {
- final Node node = elements.item(index);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- final Element child = (Element) node;
-
- try {
- final XAnnotation annotation = getAnnotationParser().parse(
- child);
- getAnnotator().annotate(codeModel, annotatable, annotation);
- } catch (Exception ex) {
- try {
- errorHandler.error(new SAXParseException(
- "Error parsing annotation.",
- customization.locator, ex));
- } catch (SAXException ignored) {
- // Nothing to do
- }
- }
- }
- }
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays.asList(new QName(Constants.NAMESPACE_URI, "annotate"));
- }
-
-}
diff --git a/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/Annotator.java b/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/Annotator.java
deleted file mode 100644
index 92891492..00000000
--- a/basics/tags/0.6.1/annotate/src/main/java/org/jvnet/jaxb2_commons/plugin/annotate/Annotator.java
+++ /dev/null
@@ -1,304 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.annotate;
-
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.List;
-
-import org.jvnet.annox.model.XAnnotation;
-import org.jvnet.annox.model.XAnnotationField;
-import org.jvnet.annox.model.XAnnotationVisitor;
-import org.jvnet.annox.model.XAnnotationField.XAnnotationArray;
-import org.jvnet.annox.model.XAnnotationField.XBoolean;
-import org.jvnet.annox.model.XAnnotationField.XBooleanArray;
-import org.jvnet.annox.model.XAnnotationField.XByte;
-import org.jvnet.annox.model.XAnnotationField.XByteArray;
-import org.jvnet.annox.model.XAnnotationField.XChar;
-import org.jvnet.annox.model.XAnnotationField.XCharArray;
-import org.jvnet.annox.model.XAnnotationField.XClass;
-import org.jvnet.annox.model.XAnnotationField.XClassArray;
-import org.jvnet.annox.model.XAnnotationField.XDouble;
-import org.jvnet.annox.model.XAnnotationField.XDoubleArray;
-import org.jvnet.annox.model.XAnnotationField.XEnum;
-import org.jvnet.annox.model.XAnnotationField.XEnumArray;
-import org.jvnet.annox.model.XAnnotationField.XFloat;
-import org.jvnet.annox.model.XAnnotationField.XFloatArray;
-import org.jvnet.annox.model.XAnnotationField.XInt;
-import org.jvnet.annox.model.XAnnotationField.XIntArray;
-import org.jvnet.annox.model.XAnnotationField.XLong;
-import org.jvnet.annox.model.XAnnotationField.XLongArray;
-import org.jvnet.annox.model.XAnnotationField.XShort;
-import org.jvnet.annox.model.XAnnotationField.XShortArray;
-import org.jvnet.annox.model.XAnnotationField.XString;
-import org.jvnet.annox.model.XAnnotationField.XStringArray;
-import org.jvnet.jaxb2_commons.util.CodeModelUtils;
-
-import com.sun.codemodel.JAnnotatable;
-import com.sun.codemodel.JAnnotationArrayMember;
-import com.sun.codemodel.JAnnotationUse;
-import com.sun.codemodel.JAnnotationValue;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JFormatter;
-import com.sun.codemodel.JType;
-
-public class Annotator {
-
- public static final Annotator INSTANCE = new Annotator();
-
- public void annotate(JCodeModel codeModel, JAnnotatable annotatable,
- Collection xannotations) {
- for (final XAnnotation xannotation : xannotations) {
- if (xannotation != null) {
- annotate(codeModel, annotatable, xannotation);
- }
- }
- }
-
- public void annotate(JCodeModel codeModel, JAnnotatable annotatable,
- XAnnotation xannotation) {
- final JAnnotationUse annotationUse = annotatable.annotate(xannotation
- .getAnnotationClass());
- final XAnnotationVisitor visitor = createAnnotationFieldVisitor(
- codeModel, annotationUse);
- xannotation.accept(visitor);
-
- }
-
- protected XAnnotationVisitor createAnnotationFieldVisitor(
- JCodeModel codeModel, final JAnnotationUse annotationUse) {
- final XAnnotationVisitor visitor = new AnnotatingFieldVisitor(
- codeModel, annotationUse);
- return visitor;
- }
-
- public static class AnnotatingFieldVisitor implements
- XAnnotationVisitor {
-
- protected final JCodeModel codeModel;
-
- protected final JAnnotationUse use;
-
- public AnnotatingFieldVisitor(final JCodeModel codeModel,
- final JAnnotationUse use) {
- this.codeModel = codeModel;
- this.use = use;
- }
-
- public JAnnotationUse visitAnnotation(XAnnotation annotation) {
- for (final XAnnotationField> field : annotation.getFieldsList()) {
- field.accept(this);
- }
- return use;
- }
-
- public JAnnotationUse visitBooleanField(XBoolean field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitByteField(XByte field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitCharField(XChar field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitClassField(XClass field) {
- JType type = CodeModelUtils.ref(codeModel, field.getClassName());
- return use.param(field.getName(), type);
- }
-
- public JAnnotationUse visitDoubleField(XDouble field) {
- // TODO: patch code model
- return use.param(field.getName(), field.getValue().intValue());
- }
-
- public JAnnotationUse visitEnumField(XEnum field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitFloatField(XFloat field) {
- // TODO: patch code model
- return use.param(field.getName(), field.getValue().intValue());
- }
-
- public JAnnotationUse visitIntField(XInt field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitLongField(XLong field) {
- return use.param(field.getName(), field.getValue().intValue());
- }
-
- public JAnnotationUse visitShortField(XShort field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitStringField(XString field) {
- return use.param(field.getName(), field.getValue());
- }
-
- public JAnnotationUse visitBooleanArrayField(XBooleanArray field) {
-
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final Boolean value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitByteArrayField(XByteArray field) {
-
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final Byte value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitCharArrayField(XCharArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final Character value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitClassArrayField(XClassArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final String className : field.getClassNames()) {
- final JType type = CodeModelUtils.ref(codeModel, className);
- array.param(type);
- }
- return use;
- }
-
- public JAnnotationUse visitDoubleArrayField(XDoubleArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final Double value : field.getValue()) {
- // TODO
- array.param(value.intValue());
- }
- return use;
- }
-
- public JAnnotationUse visitEnumArrayField(XEnumArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- for (final Enum> value : field.getValue()) {
-
- final JAnnotationValue annotationValue = new JAnnotationValue() {
- public void generate(JFormatter f) {
- f.t(codeModel.ref(value.getDeclaringClass())).p('.').p(
- value.name());
- }
- };
-
- addParam(array, annotationValue);
- }
- return use;
- }
-
- @SuppressWarnings("unchecked")
- public void addParam(final JAnnotationArrayMember array,
- JAnnotationValue annotationValue) {
- try {
- final Field values = JAnnotationArrayMember.class
- .getDeclaredField("values");
- values.setAccessible(true);
- ((List) values.get(array))
- .add(annotationValue);
- } catch (Exception ex) {
- throw new AssertionError(ex);
- }
- }
-
- public JAnnotationUse visitFloatArrayField(XFloatArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
- for (final Float value : field.getValue()) {
- // TODO
- array.param(value.intValue());
- }
- return use;
- }
-
- public JAnnotationUse visitIntArrayField(XIntArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
- for (final Integer value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitShortArrayField(XShortArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
- for (final Short value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitStringArrayField(XStringArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
- for (final String value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitAnnotationArrayField(XAnnotationArray field) {
-
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
-
- final XAnnotation[] annotations = field.getValue();
- for (final XAnnotation annotation : annotations) {
-
- final JAnnotationUse annotationUse = array.annotate(annotation
- .getAnnotationClass());
-
- final AnnotatingFieldVisitor visitor = new AnnotatingFieldVisitor(
- codeModel, annotationUse);
-
- annotation.accept(visitor);
-
- }
- return use;
- }
-
- public JAnnotationUse visitLongArrayField(XLongArray field) {
- final JAnnotationArrayMember array = use
- .paramArray(field.getName());
- for (final Long value : field.getValue()) {
- array.param(value);
- }
- return use;
- }
-
- public JAnnotationUse visitAnnotationField(
- org.jvnet.annox.model.XAnnotationField.XAnnotation field) {
- final JAnnotationUse annotationUse = use.annotationParam(field
- .getName(), field.getAnnotationClass());
-
- final AnnotatingFieldVisitor visitor = new AnnotatingFieldVisitor(
- codeModel, annotationUse);
- return field.getValue().accept(visitor);
- }
-
- }
-
-}
diff --git a/basics/tags/0.6.1/annotate/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin b/basics/tags/0.6.1/annotate/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
deleted file mode 100644
index 7f3c247c..00000000
--- a/basics/tags/0.6.1/annotate/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
+++ /dev/null
@@ -1 +0,0 @@
-org.jvnet.jaxb2_commons.plugin.annotate.AnnotatePlugin
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/A.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/A.java
deleted file mode 100644
index 0d06742d..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/A.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- *
- */
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface A {
- long longField();
-
- int intField();
-
- short shortField();
-
- char charField();
-
- byte byteField();
-
- double doubleField();
-
- float floatField();
-
- boolean booleanField();
-
- String stringField();
-
- E enumField();
-
- Class> classField();
-
- B annotationField();
-}
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/B.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/B.java
deleted file mode 100644
index 9f27a8d4..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/B.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- */
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface B {
-
- long[] longArrayField();
-
- int[] intArrayField();
-
- short[] shortArrayField();
-
- char[] charArrayField();
-
- byte[] byteArrayField();
-
- double[] doubleArrayField();
-
- float[] floatArrayField();
-
- boolean[] booleanArrayField();
-
- String[] stringArrayField();
-
- E[] enumArrayField();
-
- Class>[] classArrayField();
-
- B.C[] annotationArrayField();
-
- @Retention(RetentionPolicy.RUNTIME)
- public static @interface C {
- }
-}
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/D.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/D.java
deleted file mode 100644
index 4eae4782..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/D.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface D {
-
-}
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/E.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/E.java
deleted file mode 100644
index f8e7b4e5..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/E.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- *
- */
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-public enum E {
-
- ONE, TWO, THREE, FOUR;
-
-}
\ No newline at end of file
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/F.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/F.java
deleted file mode 100644
index fd8d8c21..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/F.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface F {
- String value();
-
-}
diff --git a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/RunPluginTest.java b/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/RunPluginTest.java
deleted file mode 100644
index 106f53db..00000000
--- a/basics/tags/0.6.1/annotate/src/test/java/org/jvnet/jaxb2_commons/plugin/annotate/tests/RunPluginTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.annotate.tests;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.project.MavenProject;
-import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
-import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
-
-public class RunPluginTest extends RunXJC2Mojo {
-
- @Override
- public File getSchemaDirectory() {
- return new File(getBaseDir(), "src/test/resources");
- }
-
- @Override
- protected void configureMojo(AbstractXJC2Mojo mojo) {
- super.configureMojo(mojo);
- mojo.setProject(new MavenProject());
- mojo.setForceRegenerate(true);
- mojo.setExtension(true);
-
- }
-
- @Override
- public List getArgs() {
- final List args = new ArrayList(super.getArgs());
- args.add("-Xannotate");
- return args;
- }
-}
diff --git a/basics/tags/0.6.1/annotate/src/test/resources/schema.xsd b/basics/tags/0.6.1/annotate/src/test/resources/schema.xsd
deleted file mode 100644
index 79a863a0..00000000
--- a/basics/tags/0.6.1/annotate/src/test/resources/schema.xsd
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 16
- 17
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 16
- 17
-
-
-
-
-
-
-
-
-
-
-
-
- 16
- 17
-
-
-
-
-
-
-
-
-
-
-
-
- 16
- 17
-
-
-
-
-
-
-
-
-
-
-
-
- 16
- 17
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/basics/tags/0.6.1/ant/.classpath b/basics/tags/0.6.1/ant/.classpath
deleted file mode 100644
index 82dcdf3c..00000000
--- a/basics/tags/0.6.1/ant/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/basics/tags/0.6.1/ant/.project b/basics/tags/0.6.1/ant/.project
deleted file mode 100644
index 41fdd059..00000000
--- a/basics/tags/0.6.1/ant/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- jaxb2-basics-ant
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.maven.ide.eclipse.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.maven.ide.eclipse.maven2Nature
-
-
diff --git a/basics/tags/0.6.1/ant/pom.xml b/basics/tags/0.6.1/ant/pom.xml
deleted file mode 100644
index 5aae8059..00000000
--- a/basics/tags/0.6.1/ant/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
- 4.0.0
- org.jvnet.jaxb2_commons
- jaxb2-basics-ant
- jar
- JAXB2 Basics - Ant Task
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-project
- 0.6.1
- ../pom.xml
-
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-jaxb-xjc
- provided
-
-
- org.apache.ant
- ant
- provided
-
-
- org.apache.ant
- ant-launcher
- test
-
-
-
- install
-
-
\ No newline at end of file
diff --git a/basics/tags/0.6.1/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java b/basics/tags/0.6.1/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java
deleted file mode 100644
index 9142eb0f..00000000
--- a/basics/tags/0.6.1/ant/src/main/java/org/jvnet/jaxb2_commons/xjc/XJC2Task.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.jvnet.jaxb2_commons.xjc;
-
-import java.io.File;
-import java.lang.reflect.Field;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-
-public class XJC2Task extends com.sun.tools.xjc.XJC2Task {
-
- @Override
- public void execute() throws BuildException {
-
- hack();
- super.execute();
- }
-
- protected void hack() {
- try {
- final Field declaredField = getClass().getSuperclass()
- .getDeclaredField("classpath");
- declaredField.setAccessible(true);
- final Path path = (Path) declaredField.get(this);
- if (path != null) {
- for (String pathElement : path.list()) {
- options.classpaths.add(new File(pathElement).toURI()
- .toURL());
- }
- }
- } catch (Exception ex) {
- throw new BuildException(ex);
- }
- }
-}
diff --git a/basics/tags/0.6.1/basic/.classpath b/basics/tags/0.6.1/basic/.classpath
deleted file mode 100644
index 2daddec3..00000000
--- a/basics/tags/0.6.1/basic/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/basics/tags/0.6.1/basic/.project b/basics/tags/0.6.1/basic/.project
deleted file mode 100644
index 2981ba9f..00000000
--- a/basics/tags/0.6.1/basic/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- jaxb2-basics
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.maven.ide.eclipse.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.maven.ide.eclipse.maven2Nature
-
-
diff --git a/basics/tags/0.6.1/basic/pom.xml b/basics/tags/0.6.1/basic/pom.xml
deleted file mode 100644
index ed3f3212..00000000
--- a/basics/tags/0.6.1/basic/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
- 4.0.0
- org.jvnet.jaxb2_commons
- jaxb2-basics
- jar
- 0.6.1
- JAXB2 Basics - Basic Plugins
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-project
- 0.6.1
- ../pom.xml
-
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-runtime
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-tools
-
-
- com.sun.xml.bind
- jaxb-impl
- provided
-
-
- org.jvnet.jaxb2_commons
- jaxb2-basics-jaxb-xjc
- provided
-
-
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin-testing
- test
-
-
-
- install
-
-
\ No newline at end of file
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java
deleted file mode 100644
index bf38fb75..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Customizations.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic";
-
- public static QName GENERATED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "generated");
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java
deleted file mode 100644
index 5ebeb60a..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/CustomizedIgnoring.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.util.CustomizationUtils;
-
-import com.sun.tools.xjc.model.CClassInfo;
-import com.sun.tools.xjc.model.CPropertyInfo;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-
-public class CustomizedIgnoring implements Ignoring {
-
- private final QName[] ignoredCustomizationElementNames;
-
- public CustomizedIgnoring(QName... names) {
- this.ignoredCustomizationElementNames = names;
- }
-
- public QName[] getIgnoredCustomizationElementNames() {
- return ignoredCustomizationElementNames;
- }
-
- public boolean isIgnored(ClassOutline classOutline) {
- for (QName name : getIgnoredCustomizationElementNames()) {
- if (CustomizationUtils.containsCustomization(classOutline, name)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isIgnored(FieldOutline fieldOutline) {
- for (QName name : getIgnoredCustomizationElementNames()) {
- if (CustomizationUtils.containsCustomization(fieldOutline, name)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isIgnored(CClassInfo classInfo) {
- for (QName name : getIgnoredCustomizationElementNames()) {
- if (CustomizationUtils.containsCustomization(classInfo, name)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isIgnored(CPropertyInfo propertyInfo) {
- for (QName name : getIgnoredCustomizationElementNames()) {
- if (CustomizationUtils.containsCustomization(propertyInfo, name)) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java
deleted file mode 100644
index 51fefbea..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/Ignoring.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin;
-
-import com.sun.tools.xjc.model.CClassInfo;
-import com.sun.tools.xjc.model.CPropertyInfo;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-
-public interface Ignoring {
-
- public boolean isIgnored(ClassOutline classOutline);
-
- public boolean isIgnored(FieldOutline fieldOutline);
-
- public boolean isIgnored(CClassInfo classInfo);
-
- public boolean isIgnored(CPropertyInfo propertyInfo);
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java
deleted file mode 100644
index f2b0d7ae..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/autoinheritance/AutoInheritancePlugin.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.autoinheritance;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JClass;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.model.CElementInfo;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.ElementOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class AutoInheritancePlugin extends AbstractParameterizablePlugin {
-
- private String xmlRootElementsExtend = null;
- private List xmlRootElementsImplement = new LinkedList();
-
- private String xmlTypesExtend = null;
- private List xmlTypesImplement = new LinkedList();
-
- private List jaxbElementsImplement = new LinkedList();
-
- public String getXmlRootElementsExtend() {
- return xmlRootElementsExtend;
- }
-
- public void setXmlRootElementsExtend(String globalElementsExtend) {
- this.xmlRootElementsExtend = globalElementsExtend;
- }
-
- public String getXmlRootElementsImplement() {
- return xmlRootElementsImplement.toString();
- }
-
- public void setXmlRootElementsImplement(String xmlRootElementsImplement) {
- this.xmlRootElementsImplement.add(xmlRootElementsImplement);
- }
-
- public String getXmlTypesExtend() {
- return xmlTypesExtend;
- }
-
- public void setXmlTypesExtend(String globalComplexTypesExtend) {
- this.xmlTypesExtend = globalComplexTypesExtend;
- }
-
- public String getXmlTypesImplement() {
- return xmlTypesImplement.toString();
- }
-
- public void setXmlTypesImplement(String xmlTypesImplement) {
- this.xmlTypesImplement.add(xmlTypesImplement);
- }
-
- public String getJaxbElementsImplement() {
- return jaxbElementsImplement.toString();
- }
-
- public void setJaxbElementsImplement(String jaxbElementsImplement) {
- this.jaxbElementsImplement.add(jaxbElementsImplement);
- }
-
- @Override
- public String getOptionName() {
- return "XautoInheritance";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses()) {
- if (classOutline.target.getElementName() != null) {
- processGlobalElement(classOutline);
- } else {
- processGlobalComplexType(classOutline);
- }
- }
- for (final CElementInfo elementInfo : outline.getModel()
- .getAllElements()) {
- final ElementOutline elementOutline = outline
- .getElement(elementInfo);
- if (elementOutline != null) {
- processGlobalJAXBElement(elementOutline);
- }
- }
- return true;
- }
-
- protected void processGlobalElement(ClassOutline classOutline) {
-
- generateExtends(classOutline.implClass, xmlRootElementsExtend);
- generateImplements(classOutline.implClass, xmlRootElementsImplement);
-
- }
-
- protected void processGlobalJAXBElement(ElementOutline elementOutline) {
-
- generateImplements(elementOutline.implClass, jaxbElementsImplement);
-
- }
-
- protected void processGlobalComplexType(ClassOutline classOutline) {
-
- generateExtends(classOutline.implClass, xmlTypesExtend);
- generateImplements(classOutline.implClass, xmlTypesImplement);
-
- }
-
- private void generateExtends(JDefinedClass theClass, String name) {
- if (name != null) {
- final JClass targetClass = theClass.owner().ref(name);
- if (theClass._extends() == theClass.owner().ref(Object.class)) {
- theClass._extends(targetClass);
- }
- }
- }
-
- private void generateImplements(JDefinedClass theClass, String name) {
- if (name != null) {
- final JClass targetClass = theClass.owner().ref(name);
- theClass._implements(targetClass);
- }
- }
-
- private void generateImplements(JDefinedClass theClass, List names) {
- if (names != null && !names.isEmpty()) {
- for (String name : names) {
- generateImplements(theClass, name);
- }
- }
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java
deleted file mode 100644
index 511cd361..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/CopyablePlugin.java
+++ /dev/null
@@ -1,337 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.copyable;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.lang.CopyStrategy;
-import org.jvnet.jaxb2_commons.lang.CopyTo;
-import org.jvnet.jaxb2_commons.lang.JAXBCopyStrategy;
-import org.jvnet.jaxb2_commons.locator.ObjectLocator;
-import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.Customizations;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
-import org.jvnet.jaxb2_commons.util.ClassUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
-import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JClass;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JConditional;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JOp;
-import com.sun.codemodel.JType;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class CopyablePlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xcopyable";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
-
- public FieldAccessorFactory getFieldAccessorFactory() {
- return fieldAccessorFactory;
- }
-
- public void setFieldAccessorFactory(
- FieldAccessorFactory fieldAccessorFactory) {
- this.fieldAccessorFactory = fieldAccessorFactory;
- }
-
- private Class extends CopyStrategy> copyStrategyClass = JAXBCopyStrategy.class;
-
- public void setCopyStrategyClass(final Class extends CopyStrategy> copyStrategy) {
- this.copyStrategyClass = copyStrategy;
- }
-
- public Class extends CopyStrategy> getCopyStrategyClass() {
- return copyStrategyClass;
- }
-
- public JExpression createCopyStrategy(JCodeModel codeModel) {
- return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
- CopyStrategy.class, getCopyStrategyClass());
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.copyable.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(
- org.jvnet.jaxb2_commons.plugin.copyable.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
-
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
-
- ClassUtils._implements(theClass, theClass.owner().ref(Cloneable.class));
- @SuppressWarnings("unused")
- final JMethod object$clone = generateObject$clone(classOutline,
- theClass);
- ClassUtils._implements(theClass, theClass.owner().ref(CopyTo.class));
-
- @SuppressWarnings("unused")
- final JMethod copyTo$copyTo = generateCopyTo$copyTo(classOutline,
- theClass);
- @SuppressWarnings("unused")
- final JMethod copyTo$copyTo1 = generateCopyTo$copyTo1(classOutline,
- theClass);
- // @SuppressWarnings("unused")
- // final JMethod copyable$copyTo = generateCopyable$CopyTo(classOutline,
- // theClass);
- // @SuppressWarnings("unused")
- // final JMethod copyable$copyTo1 =
- // generateCopyable$CopyTo1(classOutline,
- // theClass);
-
- // @SuppressWarnings("unused")
- // final JMethod copyFrom$copyFrom = generateCopyFrom$CopyFrom(
- // classOutline, theClass);
- // @SuppressWarnings("unused")
- // final JMethod copyable$copyFrom = generateCopyable$CopyFrom(
- // classOutline, theClass);
- if (!classOutline.target.isAbstract()) {
- @SuppressWarnings("unused")
- final JMethod createCopy = generateCopyTo$createNewInstance(
- classOutline, theClass);
-
- }
- }
-
- protected JMethod generateCopyTo$createNewInstance(
- final ClassOutline classOutline, final JDefinedClass theClass) {
-
- final JMethod existingMethod = theClass.getMethod("createNewInstance",
- new JType[0]);
- if (existingMethod == null) {
-
- final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass
- .owner().ref(Object.class), "createNewInstance");
- {
- final JBlock body = newMethod.body();
- body._return(JExpr._new(theClass));
- }
- return newMethod;
- } else {
- return existingMethod;
- }
- }
-
- protected JMethod generateObject$clone(final ClassOutline classOutline,
- final JDefinedClass theClass) {
-
- final JMethod clone = theClass.method(JMod.PUBLIC, theClass.owner()
- .ref(Object.class), "clone");
- {
- final JBlock body = clone.body();
- body._return(JExpr.invoke("copyTo").arg(
- JExpr.invoke("createNewInstance")));
- }
- return clone;
- }
-
- protected JMethod generateCopyTo$copyTo(final ClassOutline classOutline,
- final JDefinedClass theClass) {
-
- final JCodeModel codeModel = theClass.owner();
- final JMethod copyTo$copyTo = theClass.method(JMod.PUBLIC, codeModel
- .ref(Object.class), "copyTo");
- {
- final JVar target = copyTo$copyTo.param(Object.class, "target");
-
- final JBlock body = copyTo$copyTo.body();
- final JVar copyStrategy = body.decl(JMod.FINAL, codeModel
- .ref(CopyStrategy.class), "strategy",
- createCopyStrategy(codeModel));
-
- body._return(JExpr.invoke("copyTo").arg(JExpr._null()).arg(target)
- .arg(copyStrategy));
- }
- return copyTo$copyTo;
- }
-
- protected JMethod generateCopyTo$copyTo1(ClassOutline classOutline,
- final JDefinedClass theClass) {
- ClassUtils._implements(theClass, theClass.owner().ref(CopyTo.class));
-
- final JMethod copyTo = theClass.method(JMod.PUBLIC, theClass.owner()
- .ref(Object.class), "copyTo");
- {
- final JVar locator = copyTo.param(ObjectLocator.class, "locator");
- final JVar target = copyTo.param(Object.class, "target");
- final JVar copyStrategy = copyTo.param(CopyStrategy.class,
- "strategy");
-
- final JBlock body = copyTo.body();
-
- final JVar draftCopy;
- if (!classOutline.target.isAbstract()) {
- draftCopy = body.decl(JMod.FINAL, theClass.owner().ref(
- Object.class), "draftCopy",
-
- JOp.cond(JOp.eq(target, JExpr._null()), JExpr
- .invoke("createNewInstance"), target));
- } else {
- body
- ._if(JExpr._null().eq(target))
- ._then()
- ._throw(
- JExpr
- ._new(
- theClass
- .owner()
- .ref(
- IllegalArgumentException.class))
- .arg(
- "Target argument must not be null for abstract copyable classes."));
- draftCopy = target;
- }
-
- Boolean superClassImplementsCopyTo = StrategyClassUtils
- .superClassImplements(classOutline, getIgnoring(),
- CopyTo.class);
-
- if (superClassImplementsCopyTo == null) {
-
- } else if (superClassImplementsCopyTo.booleanValue()) {
- body.invoke(JExpr._super(), "copyTo").arg(locator).arg(
- draftCopy).arg(copyStrategy);
-
- } else {
-
- }
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- if (declaredFields.length > 0) {
-
- final JBlock bl = body._if(draftCopy._instanceof(theClass))
- ._then();
-
- final JVar copy = bl.decl(JMod.FINAL, theClass, "copy", JExpr
- .cast(theClass, draftCopy));
-
- for (final FieldOutline fieldOutline : declaredFields) {
-
- final FieldAccessorEx sourceFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, JExpr._this());
- final FieldAccessorEx copyFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, copy);
-
- if (sourceFieldAccessor.isConstant()) {
- continue;
- }
-
- final JBlock block = bl.block();
-
- final JBlock setValueBlock;
- final JBlock unsetValueBlock;
-
- final JExpression valueIsSet = sourceFieldAccessor
- .hasSetValue();
-
- if (valueIsSet != null) {
- final JConditional ifValueIsSet = block._if(valueIsSet);
- setValueBlock = ifValueIsSet._then();
- unsetValueBlock = ifValueIsSet._else();
- } else {
- setValueBlock = block;
- unsetValueBlock = null;
- }
-
- if (setValueBlock != null) {
-
- final JType copyFieldType = sourceFieldAccessor
- .getType();
- final JVar sourceField = setValueBlock.decl(
- copyFieldType, "source"
- + fieldOutline.getPropertyInfo()
- .getName(true));
- sourceFieldAccessor.toRawValue(setValueBlock,
- sourceField);
- final JExpression builtCopy = JExpr.invoke(
- copyStrategy, "copy").arg(
- theClass.owner().ref(LocatorUtils.class)
- .staticInvoke("property").arg(locator)
- .arg(
- fieldOutline.getPropertyInfo()
- .getName(false)).arg(
- sourceField)).arg(sourceField);
- final JVar copyField = setValueBlock.decl(
- copyFieldType, "copy"
- + fieldOutline.getPropertyInfo()
- .getName(true), copyFieldType
- .isPrimitive() ? builtCopy :
-
- JExpr.cast(copyFieldType, builtCopy));
- if (copyFieldType instanceof JClass
- && ((JClass) copyFieldType).isParameterized()) {
- copyField.annotate(SuppressWarnings.class).param(
- "value", "unchecked");
- }
- copyFieldAccessor.fromRawValue(setValueBlock, "unique"
- + fieldOutline.getPropertyInfo().getName(true),
- copyField);
- }
- if (unsetValueBlock != null) {
- copyFieldAccessor.unsetValues(unsetValueBlock);
-
- }
- }
- }
-
- body._return(draftCopy);
- }
- return copyTo;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java
deleted file mode 100644
index 63f046a3..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/copyable/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.copyable;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/copyable";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java
deleted file mode 100644
index 5f011bed..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.elementwrapper;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/elementWrapper";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java
deleted file mode 100644
index 60a52b80..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/elementwrapper/ElementWrapperPlugin.java
+++ /dev/null
@@ -1,286 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.elementwrapper;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.model.AbstractModelPlugin;
-import org.jvnet.jaxb2_commons.xjc.model.concrete.origin.DummyPropertyInfoOrigin;
-import org.jvnet.jaxb2_commons.xml.bind.model.MClassInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MElementPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MElementRefPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MElementRefsPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MElementsPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.MPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementRefPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementRefsPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.concrete.CMElementsPropertyInfo;
-import org.jvnet.jaxb2_commons.xml.bind.model.util.DefaultPropertyInfoVisitor;
-import org.jvnet.jaxb2_commons.xml.bind.model.util.DefaultTypeInfoVisitor;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.tools.xjc.model.Model;
-import com.sun.tools.xjc.model.nav.NClass;
-import com.sun.tools.xjc.model.nav.NType;
-
-public class ElementWrapperPlugin extends AbstractModelPlugin {
-
- @Override
- public String getOptionName() {
- return "XelementWrapper";
- }
-
- @Override
- public String getUsage() {
- return "Generates @XmlElementWrapper annotations.";
- }
-
- @Override
- protected void postProcessModel(Model model,
- final MModelInfo mmodel, ErrorHandler errorHandler) {
-
- final Collection> classInfos = new ArrayList>(
- mmodel.getClassInfos());
- for (final MClassInfo rootClassInfo : classInfos) {
- if (/*
- * TODO !getIgnoring().isIgnored(classInfo) &&
- */true) {
- List> properties = new ArrayList>(
- rootClassInfo.getProperties());
- for (MPropertyInfo propertyInfo0 : properties) {
-
- propertyInfo0
- .acceptPropertyInfoVisitor(new DefaultPropertyInfoVisitor() {
-
- @Override
- public Void visitElementPropertyInfo(
- final MElementPropertyInfo wrapperPropertyInfo) {
-
- processWrapperElementPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo);
- return null;
-
- }
- });
- }
- }
- }
-
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.elementwrapper.Customizations.IGNORED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(org.jvnet.jaxb2_commons.plugin.elementwrapper.Customizations.IGNORED_ELEMENT_NAME);
- }
-
- protected void processWrapperElementPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo) {
- wrapperPropertyInfo.getTypeInfo().acceptTypeInfoVisitor(
- new DefaultTypeInfoVisitor() {
- @Override
- public Void visitClassInfo(
- final MClassInfo wrapperClassInfo) {
- if (/*
- * TODO !getIgnoring ( ).isIgnored ( classInfo ) &&
- */wrapperClassInfo.getProperties().size() == 1) {
- final MPropertyInfo wrappedPropertyInfo = wrapperClassInfo
- .getProperties().get(0);
-
- if (wrappedPropertyInfo.isCollection()) {
- processWrappedPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo,
- wrapperClassInfo, wrappedPropertyInfo);
- }
- }
- return null;
- }
- });
- }
-
- protected void processWrappedPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo,
- final MClassInfo wrapperClassInfo,
- final MPropertyInfo wrappedPropertyInfo) {
- wrappedPropertyInfo
- .acceptPropertyInfoVisitor(new DefaultPropertyInfoVisitor() {
-
- @Override
- public Void visitElementPropertyInfo(
- final MElementPropertyInfo wrappedPropertyInfo) {
- processWrappedElementPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo,
- wrapperClassInfo, wrappedPropertyInfo);
- return null;
- }
-
- @Override
- public Void visitElementsPropertyInfo(
- MElementsPropertyInfo wrappedPropertyInfo) {
- processWrappedElementsPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo,
- wrapperClassInfo, wrappedPropertyInfo);
- return null;
- }
-
- @Override
- public Void visitElementRefPropertyInfo(
- final MElementRefPropertyInfo wrappedPropertyInfo) {
- processWrappedElementRefPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo,
- wrapperClassInfo, wrappedPropertyInfo);
- return null;
- }
-
- @Override
- public Void visitElementRefsPropertyInfo(
- MElementRefsPropertyInfo wrappedPropertyInfo) {
- processWrappedElementRefsPropertyInfo(mmodel,
- rootClassInfo, wrapperPropertyInfo,
- wrapperClassInfo, wrappedPropertyInfo);
- return null;
- }
- });
- }
-
- protected void processWrappedElementPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo,
- final MClassInfo wrapperClassInfo,
- final MElementPropertyInfo wrappedPropertyInfo) {
- System.out.println("Class info:" + rootClassInfo.getName());
- System.out.println("Wrapper property info:"
- + wrapperPropertyInfo.getPrivateName());
- System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
- System.out.println("Wrapped property info:"
- + wrappedPropertyInfo.getPrivateName());
-
- final MPropertyInfo propertyInfo = new CMElementPropertyInfo(
- new DummyPropertyInfoOrigin(), wrapperClassInfo,
- wrapperPropertyInfo.getPrivateName(),
- wrappedPropertyInfo.isCollection(),
- wrappedPropertyInfo.getTypeInfo(),
- wrappedPropertyInfo.getElementName(),
- wrapperPropertyInfo.getElementName());
-
- rootClassInfo.addProperty(propertyInfo);
-
- // TODO
- rootClassInfo.removeProperty(wrapperPropertyInfo);
- mmodel.removeClassInfo(wrapperClassInfo);
- }
-
- protected void processWrappedElementsPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo,
- final MClassInfo wrapperClassInfo,
- final MElementsPropertyInfo wrappedPropertyInfo) {
- System.out.println("Class info:" + rootClassInfo.getName());
- System.out.println("Wrapper property info:"
- + wrapperPropertyInfo.getPrivateName());
- System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
- System.out.println("Wrapped property info:"
- + wrappedPropertyInfo.getPrivateName());
-
- final MPropertyInfo propertyInfo = new CMElementsPropertyInfo(
- new DummyPropertyInfoOrigin(), wrapperClassInfo,
- wrapperPropertyInfo.getPrivateName(),
- wrappedPropertyInfo.isCollection(),
-
- wrappedPropertyInfo.getElementTypeInfos(),
- wrapperPropertyInfo.getElementName());
-
- rootClassInfo.addProperty(propertyInfo);
-
- // TODO
- rootClassInfo.removeProperty(wrapperPropertyInfo);
- mmodel.removeClassInfo(wrapperClassInfo);
- }
-
- protected void processWrappedElementRefPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo,
- final MClassInfo wrapperClassInfo,
- final MElementRefPropertyInfo wrappedPropertyInfo) {
- System.out.println("Class info:" + rootClassInfo.getName());
- System.out.println("Wrapper property info:"
- + wrapperPropertyInfo.getPrivateName());
- System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
- System.out.println("Wrapped property info:"
- + wrappedPropertyInfo.getPrivateName());
-
- final MPropertyInfo propertyInfo = new CMElementRefPropertyInfo(
- new DummyPropertyInfoOrigin(), wrapperClassInfo,
- wrapperPropertyInfo.getPrivateName(),
- wrappedPropertyInfo.isCollection(),
- wrappedPropertyInfo.getTypeInfo(),
- wrappedPropertyInfo.getElementName(),
- wrapperPropertyInfo.getElementName(),
- wrappedPropertyInfo.isMixed(),
- wrappedPropertyInfo.isDomAllowed(),
- wrappedPropertyInfo.isTypedObjectAllowed());
-
- rootClassInfo.addProperty(propertyInfo);
-
- // TODO
- rootClassInfo.removeProperty(wrapperPropertyInfo);
- mmodel.removeClassInfo(wrapperClassInfo);
- }
-
- protected void processWrappedElementRefsPropertyInfo(
- final MModelInfo mmodel,
- final MClassInfo rootClassInfo,
- final MElementPropertyInfo wrapperPropertyInfo,
- final MClassInfo wrapperClassInfo,
- final MElementRefsPropertyInfo wrappedPropertyInfo) {
- System.out.println("Class info:" + rootClassInfo.getName());
- System.out.println("Wrapper property info:"
- + wrapperPropertyInfo.getPrivateName());
- System.out.println("Wrapper class info :" + wrapperClassInfo.getName());
- System.out.println("Wrapped property info:"
- + wrappedPropertyInfo.getPrivateName());
-
- final MPropertyInfo propertyInfo = new CMElementRefsPropertyInfo(
- new DummyPropertyInfoOrigin(), wrapperClassInfo,
- wrapperPropertyInfo.getPrivateName(),
- wrappedPropertyInfo.isCollection(),
-
- wrappedPropertyInfo.getElementTypeInfos(),
- wrapperPropertyInfo.getElementName(),
- wrappedPropertyInfo.isMixed(),
- wrappedPropertyInfo.isDomAllowed(),
- wrappedPropertyInfo.isTypedObjectAllowed());
-
- rootClassInfo.addProperty(propertyInfo);
-
- // TODO
- rootClassInfo.removeProperty(wrapperPropertyInfo);
- mmodel.removeClassInfo(wrapperClassInfo);
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java
deleted file mode 100644
index dbc3ace9..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.equals;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/equals";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java
deleted file mode 100644
index 542d6255..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/equals/EqualsPlugin.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.equals;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.lang.Equals;
-import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
-import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
-import org.jvnet.jaxb2_commons.locator.ObjectLocator;
-import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.Customizations;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
-import org.jvnet.jaxb2_commons.util.ClassUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
-import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JConditional;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JOp;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class EqualsPlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xequals";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
-
- public FieldAccessorFactory getFieldAccessorFactory() {
- return fieldAccessorFactory;
- }
-
- public void setFieldAccessorFactory(
- FieldAccessorFactory fieldAccessorFactory) {
- this.fieldAccessorFactory = fieldAccessorFactory;
- }
-
- private Class extends EqualsStrategy> equalsStrategyClass = JAXBEqualsStrategy.class;
-
- public void setEqualsStrategyClass(
- Class extends EqualsStrategy> equalsStrategyClass) {
- this.equalsStrategyClass = equalsStrategyClass;
- }
-
- public Class extends EqualsStrategy> getEqualsStrategyClass() {
- return equalsStrategyClass;
- }
-
- public JExpression createEqualsStrategy(JCodeModel codeModel) {
- return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
- EqualsStrategy.class, getEqualsStrategyClass());
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(org.jvnet.jaxb2_commons.plugin.equals.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
-
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
- ClassUtils._implements(theClass, theClass.owner().ref(Equals.class));
-
- // @SuppressWarnings("unused")
- // final JMethod equals0 = generateEquals$Equals0(classOutline,
- // theClass);
- @SuppressWarnings("unused")
- final JMethod equals = generateEquals$equals(classOutline, theClass);
- @SuppressWarnings("unused")
- final JMethod objectEquals = generateObject$equals(classOutline,
- theClass);
- }
-
- protected JMethod generateObject$equals(final ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JCodeModel codeModel = theClass.owner();
- final JMethod objectEquals = theClass.method(JMod.PUBLIC,
- codeModel.BOOLEAN, "equals");
- {
- final JVar object = objectEquals.param(Object.class, "object");
- final JBlock body = objectEquals.body();
- final JVar equalsStrategy = body.decl(JMod.FINAL,
- codeModel.ref(EqualsStrategy.class), "strategy",
- createEqualsStrategy(codeModel));
- body._return(JExpr.invoke("equals").arg(JExpr._null())
- .arg(JExpr._null()).arg(object).arg(equalsStrategy));
- }
- return objectEquals;
- }
-
- // protected JMethod generateEquals$Equals0(final ClassOutline classOutline,
- // final JDefinedClass theClass) {
- // final JMethod equalsEquals0 = theClass.method(JMod.PUBLIC, theClass
- // .owner().BOOLEAN, "equals");
- // {
- // final JVar object = equalsEquals0.param(Object.class, "object");
- // final JVar equalsStrategy = equalsEquals0.param(
- // EqualsStrategy.class, "strategy");
- // final JBlock body = equalsEquals0.body();
- //
- // body._return(JExpr.invoke("equals").arg(JExpr._null()).arg(
- // JExpr._null()).arg(object).arg(equalsStrategy));
- // }
- // return equalsEquals0;
- // }
-
- protected JMethod generateEquals$equals(ClassOutline classOutline,
- final JDefinedClass theClass) {
-
- final JCodeModel codeModel = theClass.owner();
- final JMethod equals = theClass.method(JMod.PUBLIC, codeModel.BOOLEAN,
- "equals");
- {
- final JBlock body = equals.body();
- final JVar leftLocator = equals.param(ObjectLocator.class,
- "thisLocator");
- final JVar rightLocator = equals.param(ObjectLocator.class,
- "thatLocator");
- final JVar object = equals.param(Object.class, "object");
- final JVar equalsStrategy = equals.param(EqualsStrategy.class,
- "strategy");
-
- final JConditional ifNotInstanceof = body._if(JOp.not(object
- ._instanceof(theClass)));
- ifNotInstanceof._then()._return(JExpr.FALSE);
-
- //
- body._if(JExpr._this().eq(object))._then()._return(JExpr.TRUE);
-
- final Boolean superClassImplementsEquals = StrategyClassUtils
- .superClassImplements(classOutline, getIgnoring(),
- Equals.class);
-
- if (superClassImplementsEquals == null) {
- // No superclass
- } else if (superClassImplementsEquals.booleanValue()) {
- body._if(
- JOp.not(JExpr._super().invoke("equals")
- .arg(leftLocator).arg(rightLocator).arg(object)
- .arg(equalsStrategy)))._then()
- ._return(JExpr.FALSE);
-
- } else {
- body._if(JOp.not(JExpr._super().invoke("equals").arg(object)))
- ._then()._return(JExpr.FALSE);
- }
-
- final JExpression _this = JExpr._this();
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- if (declaredFields.length > 0) {
-
- final JVar _that = body.decl(JMod.FINAL, theClass, "that",
- JExpr.cast(theClass, object));
-
- for (final FieldOutline fieldOutline : declaredFields) {
-
- final FieldAccessorEx leftFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, _this);
- final FieldAccessorEx rightFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, _that);
-
- if (leftFieldAccessor.isConstant()
- || rightFieldAccessor.isConstant()) {
- continue;
- }
-
- final JBlock block = body.block();
-
- final String name = fieldOutline.getPropertyInfo().getName(
- true);
-
- final JVar lhsValue = block.decl(
- leftFieldAccessor.getType(), "lhs" + name);
- leftFieldAccessor.toRawValue(block, lhsValue);
-
- final JVar rhsValue = block.decl(
- rightFieldAccessor.getType(), "rhs" + name);
- rightFieldAccessor.toRawValue(block, rhsValue);
-
- final JExpression leftFieldLocator = codeModel
- .ref(LocatorUtils.class).staticInvoke("property")
- .arg(leftLocator)
- .arg(fieldOutline.getPropertyInfo().getName(false))
- .arg(lhsValue);
- final JExpression rightFieldLocator = codeModel
- .ref(LocatorUtils.class).staticInvoke("property")
- .arg(rightLocator)
- .arg(fieldOutline.getPropertyInfo().getName(false))
- .arg(rhsValue);
- block._if(
- JOp.not(JExpr.invoke(equalsStrategy, "equals")
- .arg(leftFieldLocator)
- .arg(rightFieldLocator).arg(lhsValue)
- .arg(rhsValue)))._then()
- ._return(JExpr.FALSE);
- }
- }
- body._return(JExpr.TRUE);
- }
- return equals;
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java
deleted file mode 100644
index 3db7cf63..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.hashcode;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/hashCode";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java
deleted file mode 100644
index ab419c7b..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/hashcode/HashCodePlugin.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.hashcode;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.lang.HashCode;
-import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
-import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
-import org.jvnet.jaxb2_commons.locator.ObjectLocator;
-import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.Customizations;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
-import org.jvnet.jaxb2_commons.util.ClassUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
-import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class HashCodePlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "XhashCode";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
-
- public FieldAccessorFactory getFieldAccessorFactory() {
- return fieldAccessorFactory;
- }
-
- public void setFieldAccessorFactory(
- FieldAccessorFactory fieldAccessorFactory) {
- this.fieldAccessorFactory = fieldAccessorFactory;
- }
-
-
- private Class extends HashCodeStrategy> hashCodeStrategyClass = JAXBHashCodeStrategy.class;
-
- public void setHashCodeStrategyClass(
- Class extends HashCodeStrategy> hashCodeStrategy) {
- this.hashCodeStrategyClass = hashCodeStrategy;
- }
-
- public Class extends HashCodeStrategy> getHashCodeStrategyClass() {
- return hashCodeStrategyClass;
- }
-
- public JExpression createHashCodeStrategy(JCodeModel codeModel) {
- return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
- HashCodeStrategy.class, getHashCodeStrategyClass());
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.hashcode.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(
- org.jvnet.jaxb2_commons.plugin.hashcode.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
-
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
- ClassUtils._implements(theClass, theClass.owner().ref(HashCode.class));
-
- // @SuppressWarnings("unused")
- // final JMethod hashCode$hashCode0 = generateHashCode$hashCode0(
- // classOutline, theClass);
- @SuppressWarnings("unused")
- final JMethod hashCode$hashCode = generateHashCode$hashCode(
- classOutline, theClass);
- @SuppressWarnings("unused")
- final JMethod object$hashCode = generateObject$hashCode(classOutline,
- theClass);
- }
-
- protected JMethod generateObject$hashCode(final ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JMethod object$hashCode = theClass.method(JMod.PUBLIC, theClass
- .owner().INT, "hashCode");
- {
- final JBlock body = object$hashCode.body();
- final JVar hashCodeStrategy = body.decl(JMod.FINAL, theClass.owner()
- .ref(HashCodeStrategy.class), "strategy",
- createHashCodeStrategy(theClass.owner()));
- body._return(JExpr._this().invoke("hashCode").arg(JExpr._null())
- .arg(hashCodeStrategy));
- }
- return object$hashCode;
- }
-
-
- protected JMethod generateHashCode$hashCode(ClassOutline classOutline,
- final JDefinedClass theClass) {
-
- JCodeModel codeModel = theClass.owner();
- final JMethod hashCode$hashCode = theClass.method(JMod.PUBLIC,
- codeModel.INT, "hashCode");
- {
- final JVar locator = hashCode$hashCode.param(ObjectLocator.class,
- "locator");
- final JVar hashCodeStrategy = hashCode$hashCode.param(
- HashCodeStrategy.class, "strategy");
- final JBlock body = hashCode$hashCode.body();
-
- final JExpression currentHashCodeExpression;
-
- final Boolean superClassImplementsHashCode = StrategyClassUtils
- .superClassImplements(classOutline, ignoring,
- HashCode.class);
-
- if (superClassImplementsHashCode == null) {
- currentHashCodeExpression = JExpr.lit(1);
- } else if (superClassImplementsHashCode.booleanValue()) {
- currentHashCodeExpression = JExpr._super().invoke("hashCode")
- .arg(locator).arg(hashCodeStrategy);
- } else {
- currentHashCodeExpression = JExpr._super().invoke("hashCode");
- }
-
- final JVar currentHashCode = body.decl(codeModel.INT,
- "currentHashCode", currentHashCodeExpression);
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- if (declaredFields.length > 0) {
-
- for (final FieldOutline fieldOutline : declaredFields) {
- final FieldAccessorEx fieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, JExpr._this());
- if (fieldAccessor.isConstant()) {
- continue;
- }
- final JBlock block = body.block();
-
- final JVar theValue = block.decl(fieldAccessor.getType(),
- "the"
- + fieldOutline.getPropertyInfo().getName(
- true));
-
- fieldAccessor.toRawValue(block, theValue);
-
- block.assign(currentHashCode, hashCodeStrategy.invoke(
- "hashCode").arg(
- codeModel.ref(LocatorUtils.class).staticInvoke(
- "property").arg(locator).arg(
- fieldOutline.getPropertyInfo().getName(
- false)).arg(theValue)).arg(
- currentHashCode).arg(theValue));
- }
- }
- body._return(currentHashCode);
- }
- return hashCode$hashCode;
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java
deleted file mode 100644
index 57c9831f..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/Customizations.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.inheritance;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.util.CustomizationUtils;
-
-import com.sun.tools.xjc.model.CClassInfo;
-import com.sun.tools.xjc.model.CPluginCustomization;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/inheritance";
-
- public static QName EXTENDS_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "extends");
-
- public static QName IMPLEMENTS_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "implements");
-
- private static final JAXBContext context;
- static {
- try {
- context = JAXBContext.newInstance(ObjectFactory.class.getPackage()
- .getName(), ObjectFactory.class.getClassLoader());
- } catch (JAXBException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- public static JAXBContext getContext() {
- return context;
- }
-
- public static void _extends(CClassInfo classInfo, String className) {
- final ExtendsClass extendsClass = new ExtendsClass();
- extendsClass.setClassName(className);
- final CPluginCustomization customization = CustomizationUtils
- .marshal(getContext(), Customizations.EXTENDS_ELEMENT_NAME,
- extendsClass);
- classInfo.getCustomizations().add(customization);
- customization.markAsAcknowledged();
-
- }
-
- public static void _implements(CClassInfo classInfo,
- String... interfaceNames) {
- for (String interfaceName : interfaceNames) {
- final ImplementsInterface implementsInterface = new ImplementsInterface();
- implementsInterface.setInterfaceName(interfaceName);
- final CPluginCustomization customization = CustomizationUtils
- .marshal(getContext(),
- Customizations.IMPLEMENTS_ELEMENT_NAME,
- implementsInterface);
- customization.markAsAcknowledged();
- classInfo.getCustomizations().add(customization);
- }
-
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java
deleted file mode 100644
index 1dac274a..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ExtendsClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.inheritance;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-@XmlRootElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "extends")
-@XmlAccessorType(XmlAccessType.PROPERTY)
-public class ExtendsClass {
-
- private String className;
-
- @XmlValue
- @XmlJavaTypeAdapter(value = CollapsedStringAdapter.class)
- String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java
deleted file mode 100644
index 0b92216f..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ImplementsInterface.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.inheritance;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-@XmlRootElement(namespace = "http://jaxb2-commons.dev.java.net/basic/inheritance", name = "implements")
-@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
-public class ImplementsInterface {
-
- private String interfaceName;
-
- @XmlValue
- @XmlJavaTypeAdapter(value = CollapsedStringAdapter.class)
- public String getInterfaceName() {
- return interfaceName;
- }
-
- public void setInterfaceName(String interfaceName) {
- this.interfaceName = interfaceName;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java
deleted file mode 100644
index e24e2e8a..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/InheritancePlugin.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.inheritance;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.util.CustomizationUtils;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JClass;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.model.CPluginCustomization;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class InheritancePlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xinheritance";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays.asList(Customizations.EXTENDS_ELEMENT_NAME,
- Customizations.IMPLEMENTS_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses()) {
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
-
- generateExtends(classOutline);
- generateImplements(classOutline);
-
- }
-
- private void generateExtends(ClassOutline classOutline) {
- final CPluginCustomization extendsClassCustomization = CustomizationUtils
- .findCustomization(classOutline,
- Customizations.EXTENDS_ELEMENT_NAME);
- if (extendsClassCustomization != null) {
-
- final ExtendsClass extendsClass = (ExtendsClass) CustomizationUtils
- .unmarshall(Customizations.getContext(),
- extendsClassCustomization);
-
- final String name = extendsClass.getClassName();
- final JClass targetClass = classOutline.implClass.owner().ref(name);
- classOutline.implClass._extends(targetClass);
- }
- }
-
- private void generateImplements(ClassOutline classOutline) {
- final List implementsInterfaceCustomizations = CustomizationUtils
- .findCustomizations(classOutline,
- Customizations.IMPLEMENTS_ELEMENT_NAME);
- for (final CPluginCustomization implementsInterfaceCustomization : implementsInterfaceCustomizations) {
- if (implementsInterfaceCustomization != null) {
-
- final ImplementsInterface implementsInterface = (ImplementsInterface) org.jvnet.jaxb2_commons.util.CustomizationUtils
- .unmarshall(Customizations.getContext(),
- implementsInterfaceCustomization);
- if (implementsInterface.getInterfaceName() != null) {
- final JClass targetClass = classOutline.implClass.owner()
- .ref(implementsInterface.getInterfaceName());
- classOutline.implClass._implements(targetClass);
- }
- }
- }
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java
deleted file mode 100644
index 68b06829..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/ObjectFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.inheritance;
-
-import javax.xml.bind.annotation.XmlRegistry;
-
-@XmlRegistry
-public class ObjectFactory {
-
- public ExtendsClass createExtendsClass() {
- return new ExtendsClass();
- }
-
- public ImplementsInterface createImplementsInterface() {
- return new ImplementsInterface();
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java
deleted file mode 100644
index 945ddd08..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/jaxbindex/JaxbIndexPlugin.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.jaxbindex;
-
-import org.jvnet.jaxb2_commons.util.CodeModelUtils;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.fmt.JTextFile;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.Outline;
-import com.sun.tools.xjc.outline.PackageOutline;
-
-public class JaxbIndexPlugin extends com.sun.tools.xjc.Plugin {
-
- public String getOptionName() {
- return "Xjaxbindex";
- }
-
- public String getUsage() {
- return "-Xjaxbindex: generate per-package jaxb.index file";
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
-
- for (final PackageOutline packageOutline : outline
- .getAllPackageContexts()) {
- final StringBuilder sb = new StringBuilder();
- for (final ClassOutline classOutline : packageOutline.getClasses()) {
- sb.append(CodeModelUtils.getLocalClassName(classOutline.ref));
- sb.append("\n");
- }
-
- final JTextFile indexFile = new JTextFile("jaxb.index");
- indexFile.setContents(sb.toString());
- packageOutline._package().addResourceFile(indexFile);
- }
- return true;
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java
deleted file mode 100644
index b3a2eb08..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.mergeable;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/mergeable";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java
deleted file mode 100644
index 46c8ed18..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/mergeable/MergeablePlugin.java
+++ /dev/null
@@ -1,269 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.mergeable;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.util.ClassUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
-import org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy;
-import org.jvnet.jaxb2_commons.lang.MergeFrom;
-import org.jvnet.jaxb2_commons.lang.MergeStrategy;
-import org.jvnet.jaxb2_commons.locator.ObjectLocator;
-import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.Customizations;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
-import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JType;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class MergeablePlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xmergeable";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
-
- public FieldAccessorFactory getFieldAccessorFactory() {
- return fieldAccessorFactory;
- }
-
- public void setFieldAccessorFactory(
- FieldAccessorFactory fieldAccessorFactory) {
- this.fieldAccessorFactory = fieldAccessorFactory;
- }
-
- private Class extends MergeStrategy> mergeStrategyClass = JAXBMergeStrategy.class;
-
- public void setMergeStrategyClass(
- final Class extends MergeStrategy> mergeStrategyClass) {
- this.mergeStrategyClass = mergeStrategyClass;
- }
-
- public Class extends MergeStrategy> getMergeStrategyClass() {
- return mergeStrategyClass;
- }
-
- public JExpression createMergeStrategy(JCodeModel codeModel) {
- return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
- MergeStrategy.class, getMergeStrategyClass());
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
- ClassUtils._implements(theClass, theClass.owner().ref(MergeFrom.class));
-
- @SuppressWarnings("unused")
- final JMethod mergeFrom$mergeFrom0 = generateMergeFrom$mergeFrom0(
- classOutline, theClass);
- @SuppressWarnings("unused")
- final JMethod mergeFrom$mergeFrom = generateMergeFrom$mergeFrom(
- classOutline, theClass);
-
- if (!classOutline.target.isAbstract()) {
- @SuppressWarnings("unused")
- final JMethod createCopy = generateMergeFrom$createNewInstance(
- classOutline, theClass);
-
- }
- }
-
- protected JMethod generateMergeFrom$mergeFrom0(
- final ClassOutline classOutline, final JDefinedClass theClass) {
-
- JCodeModel codeModel = theClass.owner();
- final JMethod mergeFrom$mergeFrom = theClass.method(JMod.PUBLIC,
- codeModel.VOID, "mergeFrom");
- {
- final JVar left = mergeFrom$mergeFrom.param(Object.class, "left");
- final JVar right = mergeFrom$mergeFrom.param(Object.class, "right");
- final JBlock body = mergeFrom$mergeFrom.body();
-
- final JVar mergeStrategy = body.decl(JMod.FINAL,
- codeModel.ref(MergeStrategy.class), "strategy",
- createMergeStrategy(codeModel));
-
- body.invoke("mergeFrom").arg(JExpr._null()).arg(JExpr._null())
- .arg(left).arg(right).arg(mergeStrategy);
- }
- return mergeFrom$mergeFrom;
- }
-
- protected JMethod generateMergeFrom$mergeFrom(ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JCodeModel codeModel = theClass.owner();
-
- final JMethod mergeFrom = theClass.method(JMod.PUBLIC, codeModel.VOID,
- "mergeFrom");
- {
- final JVar leftLocator = mergeFrom.param(ObjectLocator.class,
- "leftLocator");
- final JVar rightLocator = mergeFrom.param(ObjectLocator.class,
- "rightLocator");
- final JVar left = mergeFrom.param(Object.class, "left");
- final JVar right = mergeFrom.param(Object.class, "right");
-
- final JVar mergeStrategy = mergeFrom.param(MergeStrategy.class,
- "strategy");
-
- final JBlock methodBody = mergeFrom.body();
-
- Boolean superClassImplementsMergeFrom = StrategyClassUtils
- .superClassImplements(classOutline, getIgnoring(),
- MergeFrom.class);
-
- if (superClassImplementsMergeFrom == null) {
-
- } else if (superClassImplementsMergeFrom.booleanValue()) {
- methodBody.invoke(JExpr._super(), "mergeFrom").arg(leftLocator)
- .arg(rightLocator).arg(left).arg(right)
- .arg(mergeStrategy);
- } else {
-
- }
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- if (declaredFields.length > 0) {
-
- final JBlock body = methodBody._if(right._instanceof(theClass))
- ._then();
-
- JVar target = body.decl(JMod.FINAL, theClass, "target",
- JExpr._this());
- JVar leftObject = body.decl(JMod.FINAL, theClass, "leftObject",
- JExpr.cast(theClass, left));
- JVar rightObject = body.decl(JMod.FINAL, theClass,
- "rightObject", JExpr.cast(theClass, right));
- for (final FieldOutline fieldOutline : declaredFields) {
- final FieldAccessorEx leftFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, leftObject);
- final FieldAccessorEx rightFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, rightObject);
- if (leftFieldAccessor.isConstant()
- || rightFieldAccessor.isConstant()) {
- continue;
- }
- final JBlock block = body.block();
- final JVar leftField = block.decl(
- leftFieldAccessor.getType(),
- "lhs"
- + fieldOutline.getPropertyInfo().getName(
- true));
- leftFieldAccessor.toRawValue(block, leftField);
- final JVar rightField = block.decl(
- rightFieldAccessor.getType(),
- "rhs"
- + fieldOutline.getPropertyInfo().getName(
- true));
-
- rightFieldAccessor.toRawValue(block, rightField);
-
- final JExpression leftFieldLocator = codeModel
- .ref(LocatorUtils.class).staticInvoke("property")
- .arg(leftLocator)
- .arg(fieldOutline.getPropertyInfo().getName(false))
- .arg(leftField);
- final JExpression rightFieldLocator = codeModel
- .ref(LocatorUtils.class).staticInvoke("property")
- .arg(rightLocator)
- .arg(fieldOutline.getPropertyInfo().getName(false))
- .arg(rightField);
-
- final FieldAccessorEx targetFieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, target);
- targetFieldAccessor.fromRawValue(
- block,
- "unique"
- + fieldOutline.getPropertyInfo().getName(
- true),
-
- JExpr.cast(
- targetFieldAccessor.getType(),
-
- mergeStrategy.invoke("merge")
- .arg(leftFieldLocator)
- .arg(rightFieldLocator)
- .arg(leftField).arg(rightField)));
- }
- }
- }
- return mergeFrom;
- }
-
- protected JMethod generateMergeFrom$createNewInstance(
- final ClassOutline classOutline, final JDefinedClass theClass) {
-
- final JMethod existingMethod = theClass.getMethod("createNewInstance",
- new JType[0]);
- if (existingMethod == null) {
-
- final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass
- .owner().ref(Object.class), "createNewInstance");
- {
- final JBlock body = newMethod.body();
- body._return(JExpr._new(theClass));
- }
- return newMethod;
- } else {
- return existingMethod;
- }
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java
deleted file mode 100644
index b262c049..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/model/AbstractModelPlugin.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.model;
-
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.xjc.generator.MModelOutlineGenerator;
-import org.jvnet.jaxb2_commons.xjc.generator.concrete.ModelOutlineGeneratorFactory;
-import org.jvnet.jaxb2_commons.xjc.model.concrete.XJCCMInfoFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.MModelOutline;
-import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.model.Model;
-import com.sun.tools.xjc.model.nav.NClass;
-import com.sun.tools.xjc.model.nav.NType;
-import com.sun.tools.xjc.outline.Outline;
-import com.sun.tools.xjc.reader.Ring;
-
-public abstract class AbstractModelPlugin extends AbstractParameterizablePlugin {
-
- protected MModelInfo getModel(Model model) {
- try {
- @SuppressWarnings("unchecked")
- final MModelInfo modelInfo = (MModelInfo) Ring
- .get(MModelInfo.class);
- return modelInfo;
- } catch (Throwable t) {
- final MModelInfo mmodel = new XJCCMInfoFactory(model)
- .createModel();
- Ring.add(MModelInfo.class, mmodel);
- return mmodel;
- }
- }
-
- protected MModelOutline getModelOutline(
- MModelInfo modelInfo, Outline outline,
- Options options) {
- try {
- final MModelOutline modelOutline = (MModelOutline) Ring
- .get(MModelOutline.class);
- return modelOutline;
- } catch (Throwable t) {
- if (modelInfo.getOrigin() instanceof ModelOutlineGeneratorFactory) {
- MModelOutlineGenerator generator = ((ModelOutlineGeneratorFactory) modelInfo
- .getOrigin()).createGenerator(outline);
- MModelOutline modelOutline = generator.generate(modelInfo);
- Ring.add(MModelOutline.class, modelOutline);
- return modelOutline;
- } else {
- throw new AssertionError("Model is expected to be generateable");
- }
- }
- }
-
- private MModelInfo modelInfo;
-
- @Override
- public void postProcessModel(Model model, ErrorHandler errorHandler) {
- this.modelInfo = getModel(model);
- postProcessModel(model, modelInfo, errorHandler);
- }
-
- protected void postProcessModel(Model model,
- MModelInfo modelInfo, ErrorHandler errorHandler) {
- // Template method to be overridden by classes
- }
-
- @Override
- protected boolean run(Outline outline, Options options) throws Exception {
- if (modelInfo.getOrigin() instanceof ModelOutlineGeneratorFactory) {
- MModelOutlineGenerator generator = ((ModelOutlineGeneratorFactory) modelInfo
- .getOrigin()).createGenerator(outline);
- MModelOutline modelOutline = generator.generate(modelInfo);
- Ring.add(MModelOutline.class, modelOutline);
- } else {
- throw new AssertionError("Model is expected to be generateable");
- }
- return true;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java
deleted file mode 100644
index 6f1f26ec..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.setters;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/collectionsetters";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java
deleted file mode 100644
index b0c69927..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/setters/SettersPlugin.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.setters;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JType;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldAccessor;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class SettersPlugin extends AbstractParameterizablePlugin {
-
- private static final JType[] ABSENT = new JType[0];
-
- @Override
- public String getOptionName() {
- return "Xsetters";
- }
-
- @Override
- public String getUsage() {
- return "Generates setters for collections.";
- }
-
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
-
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
-
- generateSetters(classOutline, theClass);
-
- }
-
- private void generateSetters(ClassOutline classOutline,
- JDefinedClass theClass) {
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- for (final FieldOutline fieldOutline : declaredFields) {
-
- final String publicName = fieldOutline.getPropertyInfo().getName(
- true);
-
- final String getterName = "get" + publicName;
-
- final JMethod getter = theClass.getMethod(getterName, ABSENT);
-
- if (getter != null) {
- final JType type = getter.type();
- final JType rawType = fieldOutline.getRawType();
- final String setterName = "set" + publicName;
- final JMethod boxifiedSetter = theClass.getMethod(setterName,
- new JType[] { rawType.boxify() });
- final JMethod unboxifiedSetter = theClass.getMethod(setterName,
- new JType[] { rawType.unboxify() });
- final JMethod setter = boxifiedSetter != null ? boxifiedSetter
- : unboxifiedSetter;
-
- if (setter == null) {
- final JMethod generatedSetter = theClass.method(
- JMod.PUBLIC, theClass.owner().VOID, setterName);
- final JVar value = generatedSetter.param(type, "value");
- final FieldAccessor accessor = fieldOutline.create(JExpr
- ._this());
- accessor.unsetValues(generatedSetter.body());
- accessor.fromRawValue(generatedSetter.body(), "draft",
- value);
- }
- }
- }
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.setters.Customizations.IGNORED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(org.jvnet.jaxb2_commons.plugin.setters.Customizations.IGNORED_ELEMENT_NAME);
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java
deleted file mode 100644
index 2f65dfb5..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/Customizations.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.tostring;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/toString";
-
- public static QName IGNORED_ELEMENT_NAME = new QName(NAMESPACE_URI,
- "ignored");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java
deleted file mode 100644
index 80525091..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/tostring/ToStringPlugin.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.tostring;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
-import org.jvnet.jaxb2_commons.lang.ToString;
-import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
-import org.jvnet.jaxb2_commons.locator.ObjectLocator;
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.plugin.Customizations;
-import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring;
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils;
-import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils;
-import org.jvnet.jaxb2_commons.util.ClassUtils;
-import org.jvnet.jaxb2_commons.util.FieldAccessorFactory;
-import org.jvnet.jaxb2_commons.util.PropertyFieldAccessorFactory;
-import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.codemodel.JBlock;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.codemodel.JMethod;
-import com.sun.codemodel.JMod;
-import com.sun.codemodel.JVar;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.outline.ClassOutline;
-import com.sun.tools.xjc.outline.FieldOutline;
-import com.sun.tools.xjc.outline.Outline;
-
-public class ToStringPlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "XtoString";
- }
-
- @Override
- public String getUsage() {
- return "TBD";
- }
-
- private FieldAccessorFactory fieldAccessorFactory = PropertyFieldAccessorFactory.INSTANCE;
-
- public FieldAccessorFactory getFieldAccessorFactory() {
- return fieldAccessorFactory;
- }
-
- public void setFieldAccessorFactory(
- FieldAccessorFactory fieldAccessorFactory) {
- this.fieldAccessorFactory = fieldAccessorFactory;
- }
-
-
- private Class extends ToStringStrategy> toStringStrategyClass = JAXBToStringStrategy.class;
-
- public void setToStringStrategyClass(
- Class extends ToStringStrategy> toStringStrategy) {
- if (!ToStringStrategy.class.isAssignableFrom(toStringStrategy))
- throw new IllegalArgumentException("The class must extend ["
- + ToStringStrategy.class.getName() + "].");
- this.toStringStrategyClass = toStringStrategy;
- }
-
- public Class extends ToStringStrategy> getToStringStrategyClass() {
- return toStringStrategyClass;
- }
-
- public JExpression createToStringStrategy(JCodeModel codeModel) {
- return StrategyClassUtils.createStrategyInstanceExpression(codeModel,
- ToStringStrategy.class, getToStringStrategyClass());
- }
-
- private Ignoring ignoring = new CustomizedIgnoring(
- org.jvnet.jaxb2_commons.plugin.tostring.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
-
- public Ignoring getIgnoring() {
- return ignoring;
- }
-
- public void setIgnoring(Ignoring ignoring) {
- this.ignoring = ignoring;
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(
- org.jvnet.jaxb2_commons.plugin.tostring.Customizations.IGNORED_ELEMENT_NAME,
- Customizations.IGNORED_ELEMENT_NAME,
- Customizations.GENERATED_ELEMENT_NAME);
- }
-
- @Override
- public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
- for (final ClassOutline classOutline : outline.getClasses())
- if (!getIgnoring().isIgnored(classOutline)) {
- processClassOutline(classOutline);
- }
- return true;
- }
-
- protected void processClassOutline(ClassOutline classOutline) {
- final JDefinedClass theClass = classOutline.implClass;
- ClassUtils._implements(theClass, theClass.owner().ref(ToString.class));
-
- @SuppressWarnings("unused")
- final JMethod object$toString = generateObject$toString(classOutline,
- theClass);
- @SuppressWarnings("unused")
- final JMethod toString$append = generateToString$append(classOutline,
- theClass);
- @SuppressWarnings("unused")
- final JMethod toString$appendFields = generateToString$appendFields(
- classOutline, theClass);
- }
-
- protected JMethod generateObject$toString(final ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JCodeModel codeModel = theClass.owner();
- final JMethod object$toString = theClass.method(JMod.PUBLIC, codeModel
- .ref(String.class), "toString");
- {
- final JBlock body = object$toString.body();
-
- final JVar toStringStrategy =
-
- body.decl(JMod.FINAL, codeModel.ref(ToStringStrategy.class),
- "strategy", createToStringStrategy(codeModel));
-
- final JVar buffer = body.decl(JMod.FINAL, codeModel
- .ref(StringBuilder.class), "buffer", JExpr._new(codeModel
- .ref(StringBuilder.class)));
- body.invoke("append").arg(JExpr._null()).arg(buffer).arg(
- toStringStrategy);
- body._return(buffer.invoke("toString"));
- }
- return object$toString;
- }
-
- protected JMethod generateToString$append(final ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JCodeModel codeModel = theClass.owner();
- final JMethod toString$append = theClass.method(JMod.PUBLIC, codeModel
- .ref(StringBuilder.class), "append");
- {
-
- final JVar locator = toString$append.param(ObjectLocator.class,
- "locator");
- final JVar buffer = toString$append.param(StringBuilder.class,
- "buffer");
- final JVar toStringStrategy = toString$append.param(
- ToStringStrategy.class, "strategy");
-
- final JBlock body = toString$append.body();
-
- body.invoke(toStringStrategy, "appendStart").arg(locator).arg(
- JExpr._this()).arg(buffer);
- body.invoke("appendFields").arg(locator).arg(buffer).arg(
- toStringStrategy);
- body.invoke(toStringStrategy, "appendEnd").arg(locator).arg(
- JExpr._this()).arg(buffer);
- body._return(buffer);
- }
- return toString$append;
- }
-
- protected JMethod generateToString$appendFields(ClassOutline classOutline,
- final JDefinedClass theClass) {
- final JCodeModel codeModel = theClass.owner();
-
- final JMethod toString$appendFields = theClass.method(JMod.PUBLIC,
- codeModel.ref(StringBuilder.class), "appendFields");
- {
- final JVar locator = toString$appendFields.param(
- ObjectLocator.class, "locator");
- final JVar buffer = toString$appendFields.param(
- StringBuilder.class, "buffer");
- final JVar toStringStrategy = toString$appendFields.param(
- ToStringStrategy.class, "strategy");
- final JBlock body = toString$appendFields.body();
-
- final Boolean superClassImplementsToString = StrategyClassUtils
- .superClassImplements(classOutline, ignoring,
- ToString.class);
-
- if (superClassImplementsToString == null) {
- // No superclass
- } else if (superClassImplementsToString.booleanValue()) {
- body.invoke(JExpr._super(), "appendFields").arg(locator).arg(
- buffer).arg(toStringStrategy);
- } else {
- // Superclass does not implement ToString
- }
-
- final FieldOutline[] declaredFields = FieldOutlineUtils.filter(
- classOutline.getDeclaredFields(), getIgnoring());
-
- if (declaredFields.length > 0) {
-
- for (final FieldOutline fieldOutline : declaredFields) {
- final JBlock block = body.block();
- final FieldAccessorEx fieldAccessor = getFieldAccessorFactory()
- .createFieldAccessor(fieldOutline, JExpr._this());
- final JVar theValue = block.decl(fieldAccessor.getType(),
- "the"
- + fieldOutline.getPropertyInfo().getName(
- true));
- fieldAccessor.toRawValue(block, theValue);
-
- block.invoke(toStringStrategy, "appendField").arg(locator)
- .arg(JExpr._this()).arg(
- JExpr.lit(fieldOutline.getPropertyInfo()
- .getName(false))).arg(buffer).arg(
- theValue);
- }
- }
- body._return(buffer);
- }
- return toString$appendFields;
- }
-
-}
\ No newline at end of file
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java
deleted file mode 100644
index 85383363..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/ArrayUtils.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.util;
-
-import java.lang.reflect.Array;
-import java.util.LinkedList;
-import java.util.List;
-
-public class ArrayUtils {
-
- private ArrayUtils() {
-
- }
-
- public static T[] filter(T[] array, Predicate predicate,
- Class extends T> theClass) {
-
- if (array == null) {
- return null;
- } else {
- final List list = new LinkedList();
- for (T item : array) {
- if (predicate.evaluate(item)) {
- list.add(item);
- }
- }
- @SuppressWarnings("unchecked")
- final T[] newArray = (T[]) Array.newInstance(theClass, list.size());
- return list.toArray(newArray);
- }
-
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java
deleted file mode 100644
index 3b84494d..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/FieldOutlineUtils.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.util;
-
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-
-import com.sun.tools.xjc.outline.FieldOutline;
-
-public class FieldOutlineUtils {
-
- private FieldOutlineUtils() {
-
- }
-
- public static FieldOutline[] filter(final FieldOutline[] fieldOutlines,
- final Ignoring ignoring) {
- return ArrayUtils.filter(fieldOutlines, new Predicate() {
- public boolean evaluate(FieldOutline fieldOutline) {
- return !ignoring.isIgnored(fieldOutline);
-
- }
- }, FieldOutline.class);
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java
deleted file mode 100644
index a59d0c4c..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/Predicate.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.util;
-
-public interface Predicate {
-
- public boolean evaluate(T object);
-
-}
\ No newline at end of file
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java
deleted file mode 100644
index 13d8fe6b..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/util/StrategyClassUtils.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.util;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.jvnet.jaxb2_commons.plugin.Ignoring;
-
-import com.sun.codemodel.JClass;
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JExpr;
-import com.sun.codemodel.JExpression;
-import com.sun.tools.xjc.outline.ClassOutline;
-
-public class StrategyClassUtils {
- public static JExpression createStrategyInstanceExpression(
- JCodeModel codeModel, final Class extends T> strategyInterface,
- final Class extends T> strategyClass) {
- final JClass strategyJClass = codeModel.ref(strategyClass);
- try {
- final Method getInstanceMethod = strategyClass.getMethod(
- "getInstance", new Class>[0]);
- if (getInstanceMethod != null
- && strategyInterface.isAssignableFrom(getInstanceMethod
- .getReturnType())
- && Modifier.isStatic(getInstanceMethod.getModifiers())
- && Modifier.isPublic(getInstanceMethod.getModifiers())) {
- return strategyJClass.staticInvoke("getInstance");
- }
-
- } catch (Exception ignored) {
- // Nothing to do
- }
- try {
- final Field instanceField = strategyClass.getField("INSTANCE");
- if (instanceField != null
- && strategyInterface.isAssignableFrom(instanceField
- .getType())
- && Modifier.isStatic(instanceField.getModifiers())
- && Modifier.isPublic(instanceField.getModifiers())) {
- return strategyJClass.staticRef("INSTANCE");
- }
- } catch (Exception ignored) {
- // Nothing to do
- }
- return JExpr._new(strategyJClass);
- }
-
- public static Boolean superClassImplements(ClassOutline classOutline,
- Ignoring ignoring, Class extends T> theInterface) {
- if (classOutline.target.getBaseClass() != null) {
- if (!ignoring.isIgnored(classOutline.parent().getClazz(
- classOutline.target.getBaseClass()))) {
- return Boolean.TRUE;
- } else {
- return Boolean.FALSE;
- }
- } else if (classOutline.target.getRefBaseClass() != null) {
- try {
- if (theInterface.isAssignableFrom(Class
- .forName(classOutline.target.getRefBaseClass()
- .fullName()))) {
- return Boolean.TRUE;
- } else {
- return Boolean.FALSE;
- }
- } catch (ClassNotFoundException ignored) {
- // We'll assume it does implement
- return Boolean.TRUE;
- }
- } else {
- return null;
- }
- }
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java
deleted file mode 100644
index 673f2e53..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/Customizations.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.wildcard;
-
-import javax.xml.namespace.QName;
-
-public class Customizations {
-
- public static String NAMESPACE_URI = "http://jaxb2-commons.dev.java.net/basic/wildcard";
-
- public static QName LAX_ELEMENT_NAME = new QName(NAMESPACE_URI, "lax");
- public static QName STRICT_ELEMENT_NAME = new QName(NAMESPACE_URI, "strict");
- public static QName SKIP_ELEMENT_NAME = new QName(NAMESPACE_URI, "skip");
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java b/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java
deleted file mode 100644
index e84181a7..00000000
--- a/basics/tags/0.6.1/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/wildcard/WildcardPlugin.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.wildcard;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import javax.xml.namespace.QName;
-
-import org.jvnet.jaxb2_commons.plugin.AbstractParameterizablePlugin;
-import org.jvnet.jaxb2_commons.util.CustomizationUtils;
-import org.xml.sax.ErrorHandler;
-
-import com.sun.tools.xjc.model.CClassInfo;
-import com.sun.tools.xjc.model.CPropertyInfo;
-import com.sun.tools.xjc.model.CReferencePropertyInfo;
-import com.sun.tools.xjc.model.Model;
-import com.sun.xml.bind.v2.model.core.WildcardMode;
-
-public class WildcardPlugin extends AbstractParameterizablePlugin {
-
- @Override
- public String getOptionName() {
- return "Xwildcard";
- }
-
- @Override
- public String getUsage() {
- return "Allows specifying the wildcard mode in wildcard properties.";
- }
-
- @Override
- public void postProcessModel(Model model, ErrorHandler errorHandler) {
- for (CClassInfo classInfo : model.beans().values()) {
- for (CPropertyInfo propertyInfo : classInfo.getProperties()) {
- if (propertyInfo instanceof CReferencePropertyInfo) {
- final CReferencePropertyInfo referencePropertyInfo = (CReferencePropertyInfo) propertyInfo;
-
- if (CustomizationUtils.containsCustomization(
- classInfo, Customizations.LAX_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.LAX);
-
- } else if (CustomizationUtils.containsCustomization(
- classInfo, Customizations.SKIP_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.SKIP);
-
- } else if (CustomizationUtils.containsCustomization(
- classInfo, Customizations.STRICT_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.STRICT);
- }
-
-
- if (CustomizationUtils.containsCustomization(
- referencePropertyInfo,
- Customizations.LAX_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.LAX);
-
- } else if (CustomizationUtils.containsCustomization(
- referencePropertyInfo,
- Customizations.SKIP_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.SKIP);
-
- } else if (CustomizationUtils.containsCustomization(
- referencePropertyInfo,
- Customizations.STRICT_ELEMENT_NAME)) {
- referencePropertyInfo.setWildcard(WildcardMode.STRICT);
- }
- }
- }
- }
- }
-
- @Override
- public Collection getCustomizationElementNames() {
- return Arrays
- .asList(
- org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.LAX_ELEMENT_NAME,
- org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.SKIP_ELEMENT_NAME,
- org.jvnet.jaxb2_commons.plugin.wildcard.Customizations.STRICT_ELEMENT_NAME);
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin b/basics/tags/0.6.1/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
deleted file mode 100644
index 1f990bc4..00000000
--- a/basics/tags/0.6.1/basic/src/main/resources/META-INF/services/com.sun.tools.xjc.Plugin
+++ /dev/null
@@ -1,11 +0,0 @@
-org.jvnet.jaxb2_commons.plugin.jaxbindex.JaxbIndexPlugin
-org.jvnet.jaxb2_commons.plugin.tostring.ToStringPlugin
-org.jvnet.jaxb2_commons.plugin.equals.EqualsPlugin
-org.jvnet.jaxb2_commons.plugin.hashcode.HashCodePlugin
-org.jvnet.jaxb2_commons.plugin.copyable.CopyablePlugin
-org.jvnet.jaxb2_commons.plugin.mergeable.MergeablePlugin
-org.jvnet.jaxb2_commons.plugin.inheritance.InheritancePlugin
-org.jvnet.jaxb2_commons.plugin.setters.SettersPlugin
-org.jvnet.jaxb2_commons.plugin.wildcard.WildcardPlugin
-org.jvnet.jaxb2_commons.plugin.autoinheritance.AutoInheritancePlugin
-org.jvnet.jaxb2_commons.plugin.elementwrapper.ElementWrapperPlugin
\ No newline at end of file
diff --git a/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java b/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java
deleted file mode 100644
index 9e803563..00000000
--- a/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/copyable/tests/RunCopyablePlugin.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.copyable.tests;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
-import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
-
-public class RunCopyablePlugin extends RunXJC2Mojo {
-
- @Override
- public File getSchemaDirectory() {
- return new File(getBaseDir(), "src/test/resources");
- }
-
- @Override
- protected void configureMojo(AbstractXJC2Mojo mojo) {
- super.configureMojo(mojo);
- mojo.setForceRegenerate(true);
- }
-
- @Override
- public List getArgs() {
- final List args = new ArrayList(super.getArgs());
- args.add("-Xcopyable");
- return args;
- }
-
-}
diff --git a/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java b/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java
deleted file mode 100644
index cae87c57..00000000
--- a/basics/tags/0.6.1/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/equals/tests/RunEqualsPlugin.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.jvnet.jaxb2_commons.plugin.equals.tests;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
-import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
-
-public class RunEqualsPlugin extends RunXJC2Mojo {
-
- @Override
- public File getSchemaDirectory() {
- return new File(getBaseDir(), "src/test/resources");
- }
-
- @Override
- protected void configureMojo(AbstractXJC2Mojo mojo) {
- super.configureMojo(mojo);
- mojo.setForceRegenerate(true);
- }
-
- @Override
- public List getArgs() {
- final List