org.exolab.castor.builder.info
Class CollectionInfo

java.lang.Object
  extended by org.exolab.castor.builder.info.XMLInfo
      extended by org.exolab.castor.builder.info.FieldInfo
          extended by org.exolab.castor.builder.info.CollectionInfo
Direct Known Subclasses:
CollectionInfoJ2, CollectionInfoODMG30

public class CollectionInfo
extends FieldInfo

A helper used for generating source that deals with Collections.

Version:
$Revision: 6978 $ $Date: 2006-02-23 01:08:24 -0700 (Thu, 23 Feb 2006) $
Author:
Keith Visco

Field Summary
static java.lang.String DEFAULT_REFERENCE_SUFFIX
          Default suffix for the setter/getter by reference method names.
static java.lang.String REFERENCE_SUFFIX_PROPERTY
          The property used to overwrite the reference suffix for extra collection methods.
 
Fields inherited from class org.exolab.castor.builder.info.FieldInfo
READ_METHOD, READ_WRITE_METHODS, WRITE_METHOD
 
Fields inherited from class org.exolab.castor.builder.info.XMLInfo
ATTRIBUTE_TYPE, CHOICE_NODE_NAME_ERROR_INDICATION, ELEMENT_TYPE, TEXT_TYPE
 
Constructor Summary
CollectionInfo(XSType contentType, java.lang.String name, java.lang.String elementName, boolean useJava50)
          Creates a new CollectionInfo.
 
Method Summary
protected  void addMaxSizeCheck(java.lang.String methodName, JSourceCode sourceCode)
           
 void createAccessMethods(JClass jClass, boolean useJava50)
          Generate the various accessor methods.
protected  void createAddAndRemoveMethods(JClass jClass)
           
protected  void createAddByIndexMethod(JClass jClass)
           
protected  void createAddMethod(JClass jClass)
           
protected  void createBoundPropertyCode(JSourceCode sourceCode)
          Creates the necessary source code for notifying PropertyChangeListeners when the collection has been updated.
protected  void createCollectionIterationMethods(JClass jClass, boolean useJava50)
          Generate methods for iterating over the objects in the collection.
protected  void createEnumerateMethod(JClass jClass, boolean useJava50)
           
protected  boolean createExtraMethods()
          Returns true if extra collection methods should be generated.
protected  void createGetAndSetMethods(JClass jClass, boolean useJava50)
           
protected  void createGetAsArrayMethod(JClass jClass, boolean useJava50)
           
protected  void createGetAsReferenceMethod(JClass jClass)
           
protected  void createGetByIndexMethod(JClass jClass)
           
protected  void createGetCountMethod(JClass jClass)
           
protected  void createIteratorMethod(JClass jClass, boolean useJava50)
           
protected  void createRemoveAllMethod(JClass jClass)
          Creates implementation of removeAll() method.
protected  void createRemoveByIndexMethod(JClass jClass)
          Creates implementation of remove(int i) method.
protected  void createRemoveObjectMethod(JClass jClass)
          Creates implementation of remove(Object) method.
protected  void createSetAsArrayMethod(JClass jClass, boolean useJava50)
           
protected  void createSetAsCopyMethod(JClass jClass)
          Creates implementation of collection set method.
protected  void createSetAsReferenceMethod(JClass jClass, boolean useJava50)
          Creates implementation of collection reference set method.
protected  void createSetByIndexMethod(JClass jClass)
           
 void generateInitializerCode(JSourceCode sourceCode)
          Creates code for initialization of this Member.
 FieldInfo getContent()
          Return the contents of the collection.
 java.lang.String getContentName()
          Returns the variable name for the content of the collection.
 XSType getContentType()
          Returns the type of content in this collection.
 java.lang.String getElementName()
          Returns the name to be used when referring to the elements of this collection.
 java.lang.String getMethodSuffix()
          Returns the method suffix for creating method names.
protected  java.lang.String getReferenceMethodSuffix()
          Returns the suffix (ending) that should be used when creating the extra collection methods.
 XSListType getXSList()
          Returns the schema type represented by this collection.
 boolean isMultivalued()
          Return whether or not the object described by this XMLInfo is multi-valued (appears more than once in the XML document).
 void setCreateExtraMethods(boolean extraMethods)
          Sets whether or not to create extra collection methods for accessing the actual collection.
 void setReferenceMethodSuffix(java.lang.String suffix)
          Sets the method suffix (ending) to use when creating the extra collection methods.
 
Methods inherited from class org.exolab.castor.builder.info.FieldInfo
createGetterComment, createGetterMethod, createHasAndDeleteMethods, createJavaField, createSetterComment, createSetterMethod, getComment, getDeclaringClassInfo, getDefaultValue, getDeleteMethodName, getFixedValue, getHasMethodName, getMethods, getName, getReadMethodName, getSubstitutionGroupMembers, getValidator, getWriteMethodName, getXMLFieldHandler, isBound, isContainer, isHasAndDeleteMethods, isNillable, isTransient, setBound, setComment, setContainer, setDeclaringClassInfo, setDefaultValue, setFieldInfoReference, setFinal, setFixedValue, setMethods, setNillable, setStatic, setSubstitutionGroupMembers, setTransient, setValidator, setVisibility, setXMLFieldHandler
 
Methods inherited from class org.exolab.castor.builder.info.XMLInfo
getNamespacePrefix, getNamespaceURI, getNodeName, getNodeType, getNodeTypeName, getSchemaType, isElementDefinition, isRequired, setElementDefinition, setMultivalued, setNamespacePrefix, setNamespaceURI, setNodeName, setNodeType, setRequired, setSchemaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REFERENCE_SUFFIX

public static final java.lang.String DEFAULT_REFERENCE_SUFFIX
Default suffix for the setter/getter by reference method names.

See Also:
Constant Field Values

REFERENCE_SUFFIX_PROPERTY

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

See Also:
Constant Field Values
Constructor Detail

CollectionInfo

public CollectionInfo(XSType contentType,
                      java.lang.String name,
                      java.lang.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

createAccessMethods

public final void createAccessMethods(JClass jClass,
                                      boolean useJava50)
Generate the various accessor methods. Creates the access methods for field associated with this FieldInfo. The access methods include getters, setters, and "has" and "delete" methods if necessary.

Overrides:
createAccessMethods in class FieldInfo
Parameters:
jClass - the JClass to add the methods to
useJava50 - true if source code is supposed to be generated for Java 5
See Also:
#createAccessMethods(org.exolab.javasource.JClass, boolean)

generateInitializerCode

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

Overrides:
generateInitializerCode in class FieldInfo
Parameters:
sourceCode - the JSourceCode in which to add the source to
See Also:
#generateInitializerCode(org.exolab.javasource.JSourceCode)

getContent

public final FieldInfo getContent()
Return the contents of the collection.

Returns:
the contents of the collection.

getContentName

public final java.lang.String getContentName()
Returns the variable name for the content of the collection.

Returns:
the variable name for the content of the collection.

getContentType

public final XSType getContentType()
Returns the type of content in this collection.

Returns:
the type of content in this collection.

getElementName

public final java.lang.String getElementName()
Returns the name to be used when referring to the elements of this collection.

Returns:
the name to be used when referring to the elements of this collection.

getXSList

public final XSListType getXSList()
Returns the schema type represented by this collection.

Returns:
the schema type represented by this collection.

isMultivalued

public final boolean isMultivalued()
Return whether or not the object described by this XMLInfo is multi-valued (appears more than once in the XML document).

Overrides:
isMultivalued in class XMLInfo
Returns:
true if this object can appear more than once.
See Also:
XMLInfo.isMultivalued()

setCreateExtraMethods

public final 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:
setReferenceMethodSuffix(java.lang.String)

setReferenceMethodSuffix

public final void setReferenceMethodSuffix(java.lang.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:
setCreateExtraMethods(boolean)

addMaxSizeCheck

protected final void addMaxSizeCheck(java.lang.String methodName,
                                     JSourceCode sourceCode)

createAddMethod

protected void createAddMethod(JClass jClass)

createBoundPropertyCode

protected final 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.

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

createGetAsArrayMethod

protected final void createGetAsArrayMethod(JClass jClass,
                                            boolean useJava50)

createGetAsReferenceMethod

protected final void createGetAsReferenceMethod(JClass jClass)

createGetByIndexMethod

protected void createGetByIndexMethod(JClass jClass)

createAddAndRemoveMethods

protected final void createAddAndRemoveMethods(JClass jClass)

createGetAndSetMethods

protected final 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

createGetCountMethod

protected final void createGetCountMethod(JClass jClass)

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

createAddByIndexMethod

protected void createAddByIndexMethod(JClass jClass)

createIteratorMethod

protected final void createIteratorMethod(JClass jClass,
                                          boolean useJava50)

createRemoveAllMethod

protected final 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 final void createRemoveObjectMethod(JClass jClass)
Creates implementation of remove(Object) method.

Parameters:
jClass - the JClass to which we add this method

createSetAsArrayMethod

protected final void createSetAsArrayMethod(JClass jClass,
                                            boolean useJava50)

createSetAsCopyMethod

protected final 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 final 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)

getMethodSuffix

public final java.lang.String getMethodSuffix()
Returns the method suffix for creating method names.

Overrides:
getMethodSuffix in class FieldInfo
Returns:
the method suffix used when creating method names.
See Also:
FieldInfo.getMethodSuffix()

getReferenceMethodSuffix

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

Returns:
the suffix for the reference methods


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