org.exolab.castor.builder

Class CollectionInfo

public class CollectionInfo extends FieldInfo

A helper used for generating source that deals with Collections

Version: $Revision: 6387 $ $Date: 2006-02-23 01:08:24 -0700 (Thu, 23 Feb 2006) $

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
Constructor Summary
CollectionInfo(XSType contentType, String name, String elementName, boolean useJava50)
Creates a new CollectionInfo
Method Summary
protected voidaddMaxSizeCheck(String methodName, JSourceCode sourceCode)
voidcreateAccessMethods(JClass jClass, boolean useJava50)
Generate the various accessor methods. {@inheritDoc }
protected voidcreateAddAndRemoveMethods(JClass jClass)
protected voidcreateAddMethod(JClass jClass)
protected voidcreateBoundPropertyCode(JSourceCode sourceCode)
Creates the necessary source code for notifying PropertyChangeListeners when the collection has been updated.
protected voidcreateCollectionIterationMethods(JClass jClass, boolean useJava50)
Generate methods for iterating over the objects in the collection.
protected voidcreateEnumerateMethod(JClass jClass, boolean useJava50)
protected booleancreateExtraMethods()
Returns true if extra collection methods should be generated.
protected voidcreateGetAndSetMethods(JClass jClass, boolean useJava50)
protected voidcreateGetAsArrayMethod(JClass jClass, boolean useJava50)
protected voidcreateGetAsReferenceMethod(JClass jClass)
protected voidcreateGetByIndexMethod(JClass jClass)
protected voidcreateGetCountMethod(JClass jClass)
protected voidcreateInsertMethod(JClass jClass)
protected voidcreateIteratorMethod(JClass jClass, boolean useJava50)
protected voidcreateRemoveAllMethod(JClass jClass)
Creates implementation of removeAll() method.
protected voidcreateRemoveByIndexMethod(JClass jClass)
Creates implementation of remove(int i) method.
protected voidcreateRemoveObjectMethod(JClass jClass)
Creates implementation of remove(Object) method.
protected voidcreateSetAsArrayMethod(JClass jClass, boolean useJava50)
protected voidcreateSetAsCopyMethod(JClass jClass)
Creates implementation of collection set method.
protected voidcreateSetAsReferenceMethod(JClass jClass, boolean useJava50)
Creates implementation of collection reference set method.
protected voidcreateSetByIndexMethod(JClass jClass)
voidgenerateInitializerCode(JSourceCode sourceCode)
{@inheritDoc }
FieldInfogetContent()
StringgetContentName()
XSTypegetContentType()
StringgetElementName()
protected StringgetMethodSuffix()
{@inheritDoc }
protected StringgetReferenceMethodSuffix()
Returns the suffix (ending) that should be used when creating the extra collection methods.
XSListgetXSList()
booleanisMultivalued()
{@inheritDoc }
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

Constructor Detail

CollectionInfo

public CollectionInfo(XSType contentType, String name, String elementName, boolean useJava50)
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 useJava50 true if source code is supposed to be generated for Java 5

Method Detail

addMaxSizeCheck

protected void addMaxSizeCheck(String methodName, JSourceCode sourceCode)

createAccessMethods

public void createAccessMethods(JClass jClass, boolean useJava50)
Generate the various accessor methods. {@inheritDoc }

See Also: FieldInfo

createAddAndRemoveMethods

protected void createAddAndRemoveMethods(JClass jClass)

Parameters: jClass

createAddMethod

protected void createAddMethod(JClass jClass)

createBoundPropertyCode

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

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

createCollectionIterationMethods

protected void createCollectionIterationMethods(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: jClass the JClass to which we add this method useJava50 true if source code is supposed to be generated for Java 5

createEnumerateMethod

protected void createEnumerateMethod(JClass jClass, boolean useJava50)

createExtraMethods

protected final boolean createExtraMethods()
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

createGetAndSetMethods

protected void createGetAndSetMethods(JClass jClass, boolean useJava50)

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

createGetAsArrayMethod

protected void createGetAsArrayMethod(JClass jClass, boolean useJava50)

createGetAsReferenceMethod

protected void createGetAsReferenceMethod(JClass jClass)

createGetByIndexMethod

protected void createGetByIndexMethod(JClass jClass)

createGetCountMethod

protected void createGetCountMethod(JClass jClass)

createInsertMethod

protected void createInsertMethod(JClass jClass)

createIteratorMethod

protected void createIteratorMethod(JClass jClass, boolean useJava50)

createRemoveAllMethod

protected void createRemoveAllMethod(JClass jClass)
Creates implementation of removeAll() method.

Parameters: jClass the JClass to which we add this method

createRemoveByIndexMethod

protected void createRemoveByIndexMethod(JClass jClass)
Creates implementation of remove(int i) method.

Parameters: jClass the JClass to which we add this method

createRemoveObjectMethod

protected void createRemoveObjectMethod(JClass jClass)
Creates implementation of remove(Object) method.

Parameters: jClass the JClass to which we add this method

createSetAsArrayMethod

protected void createSetAsArrayMethod(JClass jClass, boolean useJava50)

createSetAsCopyMethod

protected void createSetAsCopyMethod(JClass jClass)
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: jClass

createSetAsReferenceMethod

protected void createSetAsReferenceMethod(JClass jClass, boolean useJava50)
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: jClass useJava50 true if source code is supposed to be generated for Java 5

createSetByIndexMethod

protected void createSetByIndexMethod(JClass jClass)

generateInitializerCode

public void generateInitializerCode(JSourceCode sourceCode)
{@inheritDoc }

See Also: generateInitializerCode

getContent

public FieldInfo getContent()

getContentName

public String getContentName()

getContentType

public XSType getContentType()

getElementName

public String getElementName()

getMethodSuffix

protected String getMethodSuffix()
{@inheritDoc }

See Also: getMethodSuffix

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

getXSList

public XSList getXSList()

isMultivalued

public boolean isMultivalued()
{@inheritDoc }

See Also: isMultivalued

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-2006. All rights reserved http://www.intalio.com