org.exolab.castor.builder.factory
Class CollectionMemberAndAccessorFactory

java.lang.Object
  extended by org.exolab.castor.builder.factory.FieldMemberAndAccessorFactory
      extended by org.exolab.castor.builder.factory.CollectionMemberAndAccessorFactory
Direct Known Subclasses:
CollectionJ2MemberAndAccessorFactory, CollectionODMG30MemberAndAccessorFactory

public class CollectionMemberAndAccessorFactory
extends FieldMemberAndAccessorFactory

This factory takes a CollectionInfo and generates the suitable JFields and the accessor methods into the JClass.


Constructor Summary
CollectionMemberAndAccessorFactory(JavaNaming naming)
          Creates a factory that offers public methods to create the field initialization code as well as the accessor methods.
 
Method Summary
protected  void addMaxSizeCheck(CollectionInfo fieldInfo, java.lang.String methodName, JSourceCode sourceCode)
          Creates the add max size check.
 void createAccessMethods(FieldInfo fieldInfo, JClass jClass, boolean useJava50, AnnotationBuilder[] annotationBuilders)
          Adds the getter/setter for this field to the jClass.
protected  void createAddByIndexMethod(CollectionInfo fieldInfo, JClass jClass)
          Creates the add by index method.
protected  void createAddMethod(CollectionInfo fieldInfo, JClass jClass)
          Creates the add method for this collection.
protected  void createBoundPropertyCode(CollectionInfo fieldInfo, JSourceCode sourceCode)
          Creates bound property code..
protected  void createCollectionIterationMethods(CollectionInfo fieldInfo, JClass jClass, boolean useJava50)
          Generate methods for iterating over the objects in the collection.
protected  void createEnumerateMethod(CollectionInfo fieldInfo, JClass jClass, boolean useJava50)
          Creates the enumerate method.
protected  void createGetByIndexMethod(CollectionInfo fieldInfo, JClass jClass)
          Creates the get by index method.
protected  void createIteratorMethod(CollectionInfo fieldInfo, JClass jClass, boolean useJava50)
          Creates the iterate method.
protected  void createRemoveByIndexMethod(CollectionInfo fieldInfo, JClass jClass)
          Creates the remove by index method.
protected  void createSetByIndexMethod(CollectionInfo fieldInfo, JClass jClass)
          Creates the set by index method.
 void generateInitializerCode(FieldInfo fieldInfo, JSourceCode sourceCode)
          Creates the field initialization code in a constructor.
 
Methods inherited from class org.exolab.castor.builder.factory.FieldMemberAndAccessorFactory
createJavaField, getJavaNaming
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionMemberAndAccessorFactory

public CollectionMemberAndAccessorFactory(JavaNaming naming)
Creates a factory that offers public methods to create the field initialization code as well as the accessor methods.

Parameters:
naming - JavaNaming to use
Method Detail

generateInitializerCode

public void generateInitializerCode(FieldInfo fieldInfo,
                                    JSourceCode sourceCode)
Creates the field initialization code in a constructor.

Overrides:
generateInitializerCode in class FieldMemberAndAccessorFactory
Parameters:
fieldInfo - the fieldInfo to translate
sourceCode - the JSourceCode in which to add the source to

createAccessMethods

public final void createAccessMethods(FieldInfo fieldInfo,
                                      JClass jClass,
                                      boolean useJava50,
                                      AnnotationBuilder[] annotationBuilders)
Adds the getter/setter for this field to the jClass.

Overrides:
createAccessMethods in class FieldMemberAndAccessorFactory
Parameters:
fieldInfo - the fieldInfo to translate
jClass - the jclass the jField will be added to
useJava50 - java version flag

createAddMethod

protected void createAddMethod(CollectionInfo fieldInfo,
                               JClass jClass)
Creates the add method for this collection.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.

createBoundPropertyCode

protected void createBoundPropertyCode(CollectionInfo fieldInfo,
                                       JSourceCode sourceCode)
Creates bound property code..

Parameters:
fieldInfo - the collectionInfo to translate
sourceCode - the sourceCode to attach to

createEnumerateMethod

protected void createEnumerateMethod(CollectionInfo fieldInfo,
                                     JClass jClass,
                                     boolean useJava50)
Creates the enumerate method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.
useJava50 - java version flag

createGetByIndexMethod

protected void createGetByIndexMethod(CollectionInfo fieldInfo,
                                      JClass jClass)
Creates the get by index method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.

createCollectionIterationMethods

protected void createCollectionIterationMethods(CollectionInfo fieldInfo,
                                                JClass jClass,
                                                boolean useJava50)
Generate methods for iterating over the objects in the collection. For Java-1 collections, we only generate an Enumerator. Implementations for other versions of Java should call this method for backward compatbility and then add any additional new methods.

Parameters:
fieldInfo - the collectionI to translate
jClass - the JClass to which we add this method
useJava50 - true if source code is supposed to be generated for Java 5

createAddByIndexMethod

protected void createAddByIndexMethod(CollectionInfo fieldInfo,
                                      JClass jClass)
Creates the add by index method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.
useJava50 - java version flag

createIteratorMethod

protected void createIteratorMethod(CollectionInfo fieldInfo,
                                    JClass jClass,
                                    boolean useJava50)
Creates the iterate method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.
useJava50 - java version flag

createRemoveByIndexMethod

protected void createRemoveByIndexMethod(CollectionInfo fieldInfo,
                                         JClass jClass)
Creates the remove by index method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.

createSetByIndexMethod

protected void createSetByIndexMethod(CollectionInfo fieldInfo,
                                      JClass jClass)
Creates the set by index method.

Parameters:
fieldInfo - the collectionInfo to translate
jClass - the jClass to add the method to.

addMaxSizeCheck

protected void addMaxSizeCheck(CollectionInfo fieldInfo,
                               java.lang.String methodName,
                               JSourceCode sourceCode)
Creates the add max size check.

Parameters:
fieldInfo - the collectionInfo to translate
methodName - the method name
sourceCode - the sourceCode to attach to


Copyright © 2011. All Rights Reserved.