Top Description Inners Fields Constructors Methods
com.sun.tools.xjc.generator.bean.field

pack-priv abstract Class AbstractListField

extends AbstractField
Class Inheritance
Known Direct Subclasses
com.sun.tools.xjc.generator.bean.field.ArrayField, com.sun.tools.xjc.generator.bean.field.ContentListField, com.sun.tools.xjc.generator.bean.field.DummyListField, com.sun.tools.xjc.generator.bean.field.NoExtendedContentField, com.sun.tools.xjc.generator.bean.field.UntypedListField
Imports
java.util.List, com.sun.codemodel.JBlock, .JClass, .JExpr, .JExpression, .JFieldRef, .JFieldVar, .JMethod, .JMod, .JOp, .JPrimitiveType, .JType, com.sun.tools.xjc.generator.bean.ClassOutlineImpl, .MethodWriter, com.sun.tools.xjc.model.CPropertyInfo, org.glassfish.jaxb.core.api.impl.NameConverter

Common code for property renderer that generates a List as its underlying data structure.

For performance reasons, the actual list object used to store data is lazily created.

Author
Kohsuke Kawaguchi ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class

Field Summary

Modifier and TypeField and Description
private final boolean
eagerInstanciation

True to create a new instance of List eagerly in the constructor.

protected JFieldVar
field

The field that stores the list.

private JMethod
internalGetter

a method that lazily initializes a List.

protected final JClass
protected final JPrimitiveType
primitiveType

If this collection property is a collection of a primitive type, this variable refers to that primitive type.

Inherited from com.sun.tools.xjc.generator.bean.field.AbstractField:
codeModelexposedTypeimplTypeoutlineprop

Constructor Summary

AccessConstructor and Description
protected
AbstractListField(ClassOutlineImpl outline, CPropertyInfo prop, boolean eagerInstanciation)

Call generate() method right after this.

Method Summary

Modifier and TypeMethod and Description
protected void
protected final void
fixNullRef(JBlock block)

Generates statement(s) so that the successive Accessor#ref(boolean) with true will always return a non-null list.

protected final void
protected abstract void
generateAccessors()

Generates accessor methods.

private void
protected abstract JClass
getCoreListType()

Concrete class that implements the List interface.

public JType
getRawType()

Implements com.sun.tools.xjc.outline.FieldOutline.getRawType.

Gets the type of the "raw value".

private JExpression
Inherited from com.sun.tools.xjc.generator.bean.field.AbstractField:
annotatecastToImplTypegenerateFieldgetOptionsgetPropertyInfogetTypelistPossibleTypesparent

Field Detail

eagerInstanciationback to summary
private final boolean eagerInstanciation

True to create a new instance of List eagerly in the constructor. False otherwise.

Setting it to true makes the generated code slower (as more list instances need to be allocated), but it works correctly if the user specifies the custom type of a list.

fieldback to summary
protected JFieldVar field

The field that stores the list.

internalGetterback to summary
private JMethod internalGetter

a method that lazily initializes a List. Lazily created. [RESULT] List _getFoo() { if(field==null) field = create new list; return field; }

listTback to summary
protected final JClass listT
primitiveTypeback to summary
protected final JPrimitiveType primitiveType

If this collection property is a collection of a primitive type, this variable refers to that primitive type. Otherwise null.

Constructor Detail

AbstractListFieldback to summary
protected AbstractListField(ClassOutlineImpl outline, CPropertyInfo prop, boolean eagerInstanciation)

Call generate() method right after this.

Method Detail

appendJavadocback to summary
protected void appendJavadoc(MethodWriter writer)
fixNullRefback to summary
protected final void fixNullRef(JBlock block)

Generates statement(s) so that the successive Accessor#ref(boolean) with true will always return a non-null list. This is useful to avoid generating redundant internal getter.

generateback to summary
protected final void generate()
generateAccessorsback to summary
protected abstract void generateAccessors()

Generates accessor methods.

generateInternalGetterback to summary
private void generateInternalGetter()
getCoreListTypeback to summary
protected abstract JClass getCoreListType()

Concrete class that implements the List interface. Used as the actual data storage.

getRawTypeback to summary
public JType getRawType()

Implements com.sun.tools.xjc.outline.FieldOutline.getRawType.

Doc from com.sun.tools.xjc.outline.FieldOutline.getRawType.

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.

Annotations
@Override
newCoreListback to summary
private JExpression newCoreList()
com.sun.tools.xjc.generator.bean.field back to summary

protected abstract Class AbstractListField.Accessor

extends Accessor
Class Inheritance
Known Direct Subclasses
com.sun.tools.xjc.generator.bean.field.ArrayField.Accessor, com.sun.tools.xjc.generator.bean.field.ContentListField.Accessor, com.sun.tools.xjc.generator.bean.field.DummyListField.Accessor, com.sun.tools.xjc.generator.bean.field.NoExtendedContentField.Accessor, com.sun.tools.xjc.generator.bean.field.UntypedListField.Accessor

Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
protected final JFieldRef
field

Reference to the AbstractListField#field of the target object.

Inherited from com.sun.tools.xjc.generator.bean.field.AbstractField.Accessor:
$target

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected final JExpression
public JExpression
public JExpression
hasSetValue()

Implements com.sun.tools.xjc.outline.FieldAccessor.hasSetValue.

Return an expression that evaluates to true only when this field has a set value(s).

protected final JExpression
ref(boolean
if true, the returned expression may be null (this is when the list is still not constructed.) This could be useful when the caller can deal with null more efficiently. When the list is null, it should be treated as if the list is empty. if false, the returned expression will never be null. This is the behavior users would see.
canBeNull
)

Returns a reference to the List field that stores the data.

protected final JExpression
public void
unsetValues(JBlock body)

Implements com.sun.tools.xjc.outline.FieldAccessor.unsetValues.

Generates a code fragment to remove any "set" value and move this field to the "unset" state.

Inherited from com.sun.tools.xjc.generator.bean.field.AbstractField.Accessor:
getPropertyInfoowner

Field Detail

fieldback to summary
protected final JFieldRef field

Reference to the AbstractListField#field of the target object.

Constructor Detail

Accessorback to summary
protected Accessor(JExpression $target)

Method Detail

boxback to summary
protected final JExpression box(JExpression exp)
countback to summary
public JExpression count()
hasSetValueback to summary
public JExpression hasSetValue()

Implements com.sun.tools.xjc.outline.FieldAccessor.hasSetValue.

Doc from com.sun.tools.xjc.outline.FieldAccessor.hasSetValue.

Return an expression that evaluates to true only when this field has a set value(s).

Annotations
@Override
refback to summary
protected final JExpression ref(boolean canBeNull)

Returns a reference to the List field that stores the data.

Using this method hides the fact that the list is lazily created.

Parameters
canBeNull:boolean

if true, the returned expression may be null (this is when the list is still not constructed.) This could be useful when the caller can deal with null more efficiently. When the list is null, it should be treated as if the list is empty. if false, the returned expression will never be null. This is the behavior users would see.

unboxback to summary
protected final JExpression unbox(JExpression exp)
unsetValuesback to summary
public void unsetValues(JBlock body)

Implements com.sun.tools.xjc.outline.FieldAccessor.unsetValues.

Doc from com.sun.tools.xjc.outline.FieldAccessor.unsetValues.

Generates a code fragment to remove any "set" value and move this field to the "unset" state.

Annotations
@Override