com.sun.tools.xjc.generator.bean
Class BeanGenerator

java.lang.Object
  extended by com.sun.tools.xjc.generator.bean.BeanGenerator
All Implemented Interfaces:
Outline

public final class BeanGenerator
extends Object
implements Outline

Generates fields and accessors.


Field Summary
(package private)  Map<CElementInfo,ElementOutlineImpl> elements
          elements that generate classes to the generated classes.
 
Method Summary
 com.sun.codemodel.JClass addRuntime(Class clazz)
          Copies the specified class into the user's package and returns a reference to it.
static Outline generate(Model model, ErrorReceiver _errorReceiver)
          Generates beans into code model according to the BGM, and produces the reflection model.
 void generateAdapterIfNecessary(CPropertyInfo prop, com.sun.codemodel.JAnnotatable field)
          Generates XmlJavaTypeAdapter from PropertyInfo if necessary.
 com.sun.codemodel.JClass generateStaticClass(Class src, com.sun.codemodel.JPackage out)
           
 Iterable<? extends PackageOutline> getAllPackageContexts()
          Gets all package-wise contexts at once.
 Collection<ClassOutlineImpl> getClasses()
          Returns all the ClassOutlines known to this object.
 CodeModelClassFactory getClassFactory()
          Gets a reference to new CodeModelClassFactory(getErrorHandler()).
 ClassOutlineImpl getClazz(CClassInfo bean)
          Obtains per-class context information.
 com.sun.codemodel.JCodeModel getCodeModel()
          Short for getModel().codeModel.
 com.sun.codemodel.JClassContainer getContainer(CClassInfoParent parent, Aspect aspect)
           
 ElementOutlineImpl getElement(CElementInfo ei)
          If the CElementInfo generates a class, returns such a class.
 EnumOutline getEnum(CEnumLeafInfo eli)
           
 Collection<EnumOutline> getEnums()
          Gets all the EnumOutlines.
 ErrorReceiver getErrorReceiver()
          Any error during the back-end proccessing should be sent to this object.
 FieldOutline getField(CPropertyInfo prop)
          Gets the object that wraps the generated field for a given CPropertyInfo.
 Model getModel()
          This outline is for this model.
 PackageOutlineImpl getPackageContext(com.sun.codemodel.JPackage p)
          Gets per-package context information.
 com.sun.codemodel.JPackage[] getUsedPackages(Aspect aspect)
          Returns all used JPackages.
 com.sun.codemodel.JType resolve(CTypeRef ref, Aspect a)
          Resolves a type reference to the actual (possibly generated) type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elements

final Map<CElementInfo,ElementOutlineImpl> elements
elements that generate classes to the generated classes.

Method Detail

generate

public static Outline generate(Model model,
                               ErrorReceiver _errorReceiver)
Generates beans into code model according to the BGM, and produces the reflection model.

Parameters:
_errorReceiver - This object will receive all the errors discovered during the back-end stage.
Returns:
returns a Outline which will in turn be used to further generate marshaller/unmarshaller, or null if the processing fails (errors should have been reported to the error recevier.)

getModel

public Model getModel()
Description copied from interface: Outline
This outline is for this model.

Specified by:
getModel in interface Outline

getCodeModel

public com.sun.codemodel.JCodeModel getCodeModel()
Description copied from interface: Outline
Short for getModel().codeModel.

Specified by:
getCodeModel in interface Outline

getContainer

public com.sun.codemodel.JClassContainer getContainer(CClassInfoParent parent,
                                                      Aspect aspect)
Specified by:
getContainer in interface Outline

resolve

public final com.sun.codemodel.JType resolve(CTypeRef ref,
                                             Aspect a)
Description copied from interface: Outline
Resolves a type reference to the actual (possibly generated) type. Short for resolve(ref.getType(),aspect).

Specified by:
resolve in interface Outline

getUsedPackages

public final com.sun.codemodel.JPackage[] getUsedPackages(Aspect aspect)
Returns all used JPackages. A JPackage is considered as "used" if a ClassItem or a InterfaceItem resides in that package. This value is dynamically calculated every time because one can freely remove ClassItem/InterfaceItem.

Returns:
Given the same input, the order of packages in the array is always the same regardless of the environment.

getErrorReceiver

public ErrorReceiver getErrorReceiver()
Description copied from interface: Outline
Any error during the back-end proccessing should be sent to this object.

Specified by:
getErrorReceiver in interface Outline

getClassFactory

public CodeModelClassFactory getClassFactory()
Description copied from interface: Outline
Gets a reference to new CodeModelClassFactory(getErrorHandler()).

Specified by:
getClassFactory in interface Outline

getPackageContext

public PackageOutlineImpl getPackageContext(com.sun.codemodel.JPackage p)
Description copied from interface: Outline
Gets per-package context information. This method works for every visible package (those packages which are supposed to be used by client applications.)

Specified by:
getPackageContext in interface Outline
Returns:
If this grammar doesn't produce anything in the specified package, return null.

getClasses

public Collection<ClassOutlineImpl> getClasses()
Description copied from interface: Outline
Returns all the ClassOutlines known to this object.

Specified by:
getClasses in interface Outline

getClazz

public ClassOutlineImpl getClazz(CClassInfo bean)
Description copied from interface: Outline
Obtains per-class context information.

Specified by:
getClazz in interface Outline

getElement

public ElementOutlineImpl getElement(CElementInfo ei)
Description copied from interface: Outline
If the CElementInfo generates a class, returns such a class. Otherwise return null.

Specified by:
getElement in interface Outline

getEnum

public EnumOutline getEnum(CEnumLeafInfo eli)
Specified by:
getEnum in interface Outline

getEnums

public Collection<EnumOutline> getEnums()
Description copied from interface: Outline
Gets all the EnumOutlines.

Specified by:
getEnums in interface Outline

getAllPackageContexts

public Iterable<? extends PackageOutline> getAllPackageContexts()
Description copied from interface: Outline
Gets all package-wise contexts at once.

Specified by:
getAllPackageContexts in interface Outline

getField

public FieldOutline getField(CPropertyInfo prop)
Description copied from interface: Outline
Gets the object that wraps the generated field for a given CPropertyInfo.

Specified by:
getField in interface Outline

generateAdapterIfNecessary

public final void generateAdapterIfNecessary(CPropertyInfo prop,
                                             com.sun.codemodel.JAnnotatable field)
Generates XmlJavaTypeAdapter from PropertyInfo if necessary. Also generates other per-property annotations (such as XmlID, XmlIDREF, and XmlMimeType if necessary.


addRuntime

public final com.sun.codemodel.JClass addRuntime(Class clazz)
Description copied from interface: Outline
Copies the specified class into the user's package and returns a reference to it.

Specified by:
addRuntime in interface Outline

generateStaticClass

public com.sun.codemodel.JClass generateStaticClass(Class src,
                                                    com.sun.codemodel.JPackage out)