com.sun.tools.xjc.generator.bean.field
Class SingleField

java.lang.Object
  extended by com.sun.tools.xjc.generator.bean.field.SingleField
All Implemented Interfaces:
FieldOutline
Direct Known Subclasses:
SinglePrimitiveAccessField

public class SingleField
extends java.lang.Object

Realizes a property through one getter and one setter. This renders:

 T' field;
 T getXXX() { ... }
 void setXXX(T value) { ... }
 

Normally T'=T, but under some tricky circumstances they could be different (like T'=Integer, T=int.) This realization is only applicable to fields with (1,1) or (0,1) multiplicity.


Nested Class Summary
protected  class SingleField.Accessor
           
 
Field Summary
protected  com.sun.codemodel.JCodeModel codeModel
           
protected  com.sun.codemodel.JType exposedType
          The publicly visible type of this field.
protected  com.sun.codemodel.JType implType
          The type of this field, which can hold all the possible types.
protected  ClassOutlineImpl outline
           
protected  CPropertyInfo prop
           
 
Constructor Summary
protected SingleField(ClassOutlineImpl context, CPropertyInfo prop)
           
protected SingleField(ClassOutlineImpl context, CPropertyInfo prop, boolean forcePrimitiveAccess)
           
 
Method Summary
protected  void annotate(com.sun.codemodel.JAnnotatable field)
          Annotate the field according to the recipes given as CPropertyInfo.
protected  com.sun.codemodel.JExpression castToImplType(com.sun.codemodel.JExpression exp)
          Case from exposedType to implType if necessary.
 FieldAccessor create(com.sun.codemodel.JExpression targetObject)
          Creates a new FieldAccessor of this field for the specified object.
protected  void createField()
           
protected  com.sun.codemodel.JFieldVar generateField(com.sun.codemodel.JType type)
          Generates the field declaration.
 com.sun.codemodel.JType getFieldType()
          Returns the type used to store the value of the field in memory.
protected  java.lang.String getGetterMethod()
          Gets the name of the getter method.
protected  Options getOptions()
          Gets the Options in the current compilation context.
 CPropertyInfo getPropertyInfo()
          Gets the corresponding model object.
 com.sun.codemodel.JType getRawType()
          Gets the type of the "raw value".
protected  com.sun.codemodel.JType getType(Aspect aspect)
          Compute the type of a CPropertyInfo
protected  java.util.List<java.lang.Object> listPossibleTypes(CPropertyInfo prop)
          Returns contents to be added to javadoc.
 ClassOutline parent()
          Gets the enclosing ClassOutline.
protected  com.sun.codemodel.JFieldVar ref()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outline

protected final ClassOutlineImpl outline

prop

protected final CPropertyInfo prop

codeModel

protected final com.sun.codemodel.JCodeModel codeModel

implType

protected final com.sun.codemodel.JType implType
The type of this field, which can hold all the possible types.


exposedType

protected final com.sun.codemodel.JType exposedType
The publicly visible type of this field. If we are generating value classes implType==exposedType.

Constructor Detail

SingleField

protected SingleField(ClassOutlineImpl context,
                      CPropertyInfo prop)

SingleField

protected SingleField(ClassOutlineImpl context,
                      CPropertyInfo prop,
                      boolean forcePrimitiveAccess)
Parameters:
forcePrimitiveAccess - forces the setter/getter to expose the primitive type. it's a pointless customization, but it's nevertheless in the spec.
Method Detail

getFieldType

public final com.sun.codemodel.JType getFieldType()
Returns the type used to store the value of the field in memory.


create

public FieldAccessor create(com.sun.codemodel.JExpression targetObject)
Description copied from interface: FieldOutline
Creates a new FieldAccessor of this field for the specified object.

Parameters:
targetObject - Evaluates to an object, and the field on this object will be accessed.

createField

protected final void createField()

getGetterMethod

protected java.lang.String getGetterMethod()
Gets the name of the getter method.

This encapsulation is necessary because sometimes we use isXXXX as the method name.


ref

protected com.sun.codemodel.JFieldVar ref()

getRawType

public final com.sun.codemodel.JType getRawType()
Description copied from interface: FieldOutline
Gets the type of the "raw value".

This type can represent the entire value of this field. For fields that can carry multiple values, this is an array.

This type allows the client of the outline to generate code to set/get values from a property.


parent

public final ClassOutline parent()
Description copied from interface: FieldOutline
Gets the enclosing ClassOutline.

Specified by:
parent in interface FieldOutline

getPropertyInfo

public final CPropertyInfo getPropertyInfo()
Description copied from interface: FieldOutline
Gets the corresponding model object.

Specified by:
getPropertyInfo in interface FieldOutline

annotate

protected void annotate(com.sun.codemodel.JAnnotatable field)
Annotate the field according to the recipes given as CPropertyInfo.


getOptions

protected final Options getOptions()
Gets the Options in the current compilation context.


generateField

protected final com.sun.codemodel.JFieldVar generateField(com.sun.codemodel.JType type)
Generates the field declaration.


castToImplType

protected final com.sun.codemodel.JExpression castToImplType(com.sun.codemodel.JExpression exp)
Case from exposedType to implType if necessary.


getType

protected com.sun.codemodel.JType getType(Aspect aspect)
Compute the type of a CPropertyInfo

Parameters:
aspect -

listPossibleTypes

protected final java.util.List<java.lang.Object> listPossibleTypes(CPropertyInfo prop)
Returns contents to be added to javadoc.