org.jvnet.jaxb2_commons.plugin.value_constructor
Class ValueConstructorPlugin

java.lang.Object
  extended by com.sun.tools.xjc.Plugin
      extended by org.jvnet.jaxb2_commons.plugin.value_constructor.ValueConstructorPlugin

public class ValueConstructorPlugin
extends com.sun.tools.xjc.Plugin

Generate two constructors for each generated class, one of which is a default constructor, the other takes an argument for each field in the class and initialises the field with the argument value. Without this plugin, XJC will not generate any explicit constructors.

Author:
Kenny MacLeod $Id: XjcValueConstructorPlugin.java,v 1.7 2007-11-26 18:35:27 skaffman Exp $

Constructor Summary
ValueConstructorPlugin()
           
 
Method Summary
protected  boolean generateConstructorParameter(com.sun.codemodel.JFieldVar field)
          Whether or not to generate a constructor parameter for the given field.
protected  Collection<com.sun.codemodel.JFieldVar> getInstanceFields(Collection<com.sun.codemodel.JFieldVar> fields)
          Takes a collection of fields, and returns a new collection containing only the instance (i.e. non-static) fields.
 String getOptionName()
           
protected  List<com.sun.codemodel.JFieldVar> getSuperclassFields(com.sun.codemodel.JDefinedClass implClass)
          Retrieve a List of the fields of each ancestor class.
 String getUsage()
           
 boolean run(com.sun.tools.xjc.outline.Outline outline, com.sun.tools.xjc.Options options, ErrorHandler errorHandler)
           
 
Methods inherited from class com.sun.tools.xjc.Plugin
getCustomizationURIs, isCustomizationTagName, onActivated, parseArgument, postProcessModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueConstructorPlugin

public ValueConstructorPlugin()
Method Detail

getOptionName

public String getOptionName()
Specified by:
getOptionName in class com.sun.tools.xjc.Plugin

getUsage

public String getUsage()
Specified by:
getUsage in class com.sun.tools.xjc.Plugin

run

public boolean run(com.sun.tools.xjc.outline.Outline outline,
                   com.sun.tools.xjc.Options options,
                   ErrorHandler errorHandler)
Specified by:
run in class com.sun.tools.xjc.Plugin

getInstanceFields

protected Collection<com.sun.codemodel.JFieldVar> getInstanceFields(Collection<com.sun.codemodel.JFieldVar> fields)
Takes a collection of fields, and returns a new collection containing only the instance (i.e. non-static) fields.


generateConstructorParameter

protected boolean generateConstructorParameter(com.sun.codemodel.JFieldVar field)
Whether or not to generate a constructor parameter for the given field.


getSuperclassFields

protected List<com.sun.codemodel.JFieldVar> getSuperclassFields(com.sun.codemodel.JDefinedClass implClass)
Retrieve a List of the fields of each ancestor class. I walk up the class hierarchy until I reach a class that isn't being generated by JAXB.



Copyright © 2011. All Rights Reserved.