org.exolab.castor.builder

Class CollectionInfo

public class CollectionInfo extends FieldInfo

A helper used for generating source that deals with Collections

Version: $Revision: 1.5 $ $Date: 2005/04/09 04:41:20 $

Author: Keith Visco

Field Summary
static StringDEFAULT_REFERENCE_SUFFIX
static StringREFERENCE_SUFFIX_PROPERTY
The property used to overwrite the reference suffix for extra collection methods
protected XSListxsList
Constructor Summary
CollectionInfo(XSType contentType, String name, String elementName)
Creates a new CollectionInfo
Method Summary
voidcreateAccessMethods(JClass jClass)
Creates the Access methods for the collection described by this CollectionInfo
voidcreateAddInsertMethod(JMethod method)
Creates implementation of add method with an index.
voidcreateAddMethod(JMethod method)
Creates implementation of add method.
protected voidcreateBoundPropertyCode(JSourceCode jsc)
Creates the necessary source code for notifying PropertyChangeListeners when the collection has been updated.
voidcreateEnumerateMethod(JMethod method)
Creates implementation of Enumerate method.
voidcreateGetByIndexMethod(JMethod method)
Creates implementation of the get(index) method.
voidcreateGetCollectionReferenceMethod(JMethod method)
Creates implementation of collection reference get method.
voidcreateGetCountMethod(JMethod method)
Creates implementation of getCount method.
voidcreateGetMethod(JMethod method)
Creates implementation of object[] get() method.
voidcreateRemoveAllMethod(JMethod method)
Creates implementation of removeAll() method.
voidcreateRemoveByIndexMethod(JMethod method)
Creates implementation of remove(int i) method.
voidcreateRemoveByObjectMethod(JMethod method)
Creates implementation of remove(Object) method.
voidcreateSetArrayMethod(JMethod method)
Creates implementation of array set method
voidcreateSetByIndexMethod(JMethod method)
Creates implementation of set method.
voidcreateSetCollectionMethod(JMethod method)
Creates implementation of collection set method.
voidcreateSetCollectionReferenceMethod(JMethod method)
Creates implementation of collection reference set method.
protected booleanextraMethods()
Returns true if extra collection methods should be generated.
voidgenerateInitializerCode(JSourceCode jsc)
Creates code for initialization of this Member
FieldInfogetContent()
StringgetContentName()
XSTypegetContentType()
StringgetElementName()
JMethodgetReadMethod()
Returns the main read method for this member
StringgetReadMethodName()
protected StringgetReferenceMethodSuffix()
Returns the suffix (ending) that should be used when creating the extra collection methods
StringgetWriteMethodName()
XSListgetXSList()
booleanisMultivalued()
Return whether or not this member is a multivalued member or not
voidsetCreateExtraMethods(boolean extraMethods)
Sets whether or not to create extra collection methods for accessing the actual collection
voidsetReferenceMethodSuffix(String suffix)
Sets the method suffix (ending) to use when creating the extra collection methods.

Field Detail

DEFAULT_REFERENCE_SUFFIX

public static final String DEFAULT_REFERENCE_SUFFIX

REFERENCE_SUFFIX_PROPERTY

public static final String REFERENCE_SUFFIX_PROPERTY
The property used to overwrite the reference suffix for extra collection methods

xsList

protected XSList xsList

Constructor Detail

CollectionInfo

public CollectionInfo(XSType contentType, String name, String elementName)
Creates a new CollectionInfo

Parameters: contentType the content type of the collection, ie. the type of objects that the collection will contain name the name of the Collection elementName the element name for each element in collection

Method Detail

createAccessMethods

public void createAccessMethods(JClass jClass)
Creates the Access methods for the collection described by this CollectionInfo

Parameters: jClass the JClass to add the methods to.

createAddInsertMethod

public void createAddInsertMethod(JMethod method)
Creates implementation of add method with an index.

Parameters: method the JMethod in which to create the source code.

createAddMethod

public void createAddMethod(JMethod method)
Creates implementation of add method.

Parameters: method the JMethod in which to create the source code.

createBoundPropertyCode

protected void createBoundPropertyCode(JSourceCode jsc)
Creates the necessary source code for notifying PropertyChangeListeners when the collection has been updated.

Parameters: jsc the JSourceCode to add the new source code to.

createEnumerateMethod

public void createEnumerateMethod(JMethod method)
Creates implementation of Enumerate method.

Parameters: method the JMethod in which to create the source code.

createGetByIndexMethod

public void createGetByIndexMethod(JMethod method)
Creates implementation of the get(index) method.

createGetCollectionReferenceMethod

public void createGetCollectionReferenceMethod(JMethod method)
Creates implementation of collection reference get method. This method simply returns the actual reference to the collection.

Parameters: method the JMethod in which to create the source code.

createGetCountMethod

public void createGetCountMethod(JMethod method)
Creates implementation of getCount method.

Parameters: method the JMethod in which to create the source code.

createGetMethod

public void createGetMethod(JMethod method)
Creates implementation of object[] get() method.

Parameters: method the JMethod in which to create the source code.

createRemoveAllMethod

public void createRemoveAllMethod(JMethod method)
Creates implementation of removeAll() method.

Parameters: method the JMethod in which to create the source code.

createRemoveByIndexMethod

public void createRemoveByIndexMethod(JMethod method)
Creates implementation of remove(int i) method.

Parameters: method the JMethod in which to create the source code.

createRemoveByObjectMethod

public void createRemoveByObjectMethod(JMethod method)
Creates implementation of remove(Object) method.

Parameters: method the JMethod in which to create the source code.

createSetArrayMethod

public void createSetArrayMethod(JMethod method)
Creates implementation of array set method

Parameters: method the JMethod in which to create the source code.

createSetByIndexMethod

public void createSetByIndexMethod(JMethod method)
Creates implementation of set method.

Parameters: method the JMethod in which to create the source code.

createSetCollectionMethod

public void createSetCollectionMethod(JMethod method)
Creates implementation of collection set method. The method will assign the field a copy of the given collection. The fields will be checked for type safety.

Parameters: method the JMethod in which to create the source code.

createSetCollectionReferenceMethod

public void createSetCollectionReferenceMethod(JMethod method)
Creates implementation of collection reference set method. This method is a non-type safe method which simply assigns the given collection to the field.

Parameters: method the JMethod in which to create the source code.

extraMethods

protected final boolean extraMethods()
Returns true if extra collection methods should be generated. The extra collection methods are methods which return an actual reference to the underlying collection as opposed to an enumeration, iterator, or copy.

Returns: true if extra collection methods should be generated

generateInitializerCode

public void generateInitializerCode(JSourceCode jsc)
Creates code for initialization of this Member

Parameters: jsc the JSourceCode in which to add the source to

getContent

public FieldInfo getContent()

getContentName

public String getContentName()

getContentType

public XSType getContentType()

getElementName

public String getElementName()

getReadMethod

public JMethod getReadMethod()
Returns the main read method for this member

Returns: the main read method for this member

getReadMethodName

public String getReadMethodName()

getReferenceMethodSuffix

protected final String getReferenceMethodSuffix()
Returns the suffix (ending) that should be used when creating the extra collection methods

Returns: the suffix for the reference methods

getWriteMethodName

public String getWriteMethodName()

getXSList

public XSList getXSList()

isMultivalued

public boolean isMultivalued()
Return whether or not this member is a multivalued member or not

Returns: true if this member can appear more than once

setCreateExtraMethods

public void setCreateExtraMethods(boolean extraMethods)
Sets whether or not to create extra collection methods for accessing the actual collection

Parameters: extraMethods a boolean that when true indicates that extra collection accessor methods should be created. False by default.

See Also: CollectionInfo

setReferenceMethodSuffix

public void setReferenceMethodSuffix(String suffix)
Sets the method suffix (ending) to use when creating the extra collection methods.

Parameters: suffix the method suffix to use when creating the extra collection methods. If null or emtpty the default value, as specified by DEFAULT_REFERENCE_SUFFIX will used.

See Also: CollectionInfo

Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com