org.exolab.castor.builder
Class CollectionInfo

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

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 java.lang.String DEFAULT_REFERENCE_SUFFIX
           
static java.lang.String REFERENCE_SUFFIX_PROPERTY
          The property used to overwrite the reference suffix for extra collection methods
protected  XSList xsList
           
 
Fields inherited from class org.exolab.castor.builder.FieldInfo
READ_METHOD, READ_WRITE_METHODS, WRITE_METHOD
 
Fields inherited from class org.exolab.castor.builder.XMLInfo
ATTRIBUTE_TYPE, ELEMENT_TYPE, TEXT_TYPE
 
Constructor Summary
CollectionInfo(XSType contentType, java.lang.String name, java.lang.String elementName)
          Creates a new CollectionInfo
 
Method Summary
 void createAccessMethods(JClass jClass)
          Creates the Access methods for the collection described by this CollectionInfo
 void createAddInsertMethod(JMethod method)
          Creates implementation of add method with an index.
 void createAddMethod(JMethod method)
          Creates implementation of add method.
protected  void createBoundPropertyCode(JSourceCode jsc)
          Creates the necessary source code for notifying PropertyChangeListeners when the collection has been updated.
 void createEnumerateMethod(JMethod method)
          Creates implementation of Enumerate method.
 void createGetByIndexMethod(JMethod method)
          Creates implementation of the get(index) method.
 void createGetCollectionReferenceMethod(JMethod method)
          Creates implementation of collection reference get method.
 void createGetCountMethod(JMethod method)
          Creates implementation of getCount method.
 void createGetMethod(JMethod method)
          Creates implementation of object[] get() method.
 void createRemoveAllMethod(JMethod method)
          Creates implementation of removeAll() method.
 void createRemoveByIndexMethod(JMethod method)
          Creates implementation of remove(int i) method.
 void createRemoveByObjectMethod(JMethod method)
          Creates implementation of remove(Object) method.
 void createSetArrayMethod(JMethod method)
          Creates implementation of array set method
 void createSetByIndexMethod(JMethod method)
          Creates implementation of set method.
 void createSetCollectionMethod(JMethod method)
          Creates implementation of collection set method.
 void createSetCollectionReferenceMethod(JMethod method)
          Creates implementation of collection reference set method.
protected  boolean extraMethods()
          Returns true if extra collection methods should be generated.
 void generateInitializerCode(JSourceCode jsc)
          Creates code for initialization of this Member
 FieldInfo getContent()
           
 java.lang.String getContentName()
           
 XSType getContentType()
           
 java.lang.String getElementName()
           
 JMethod getReadMethod()
          Returns the main read method for this member
 java.lang.String getReadMethodName()
          Returns the name of the read method for this FieldInfo
protected  java.lang.String getReferenceMethodSuffix()
          Returns the suffix (ending) that should be used when creating the extra collection methods
 java.lang.String getWriteMethodName()
          Returns the name of the write method for this FieldInfo
 XSList getXSList()
           
 boolean isMultivalued()
          Return whether or not this member is a multivalued member or not
 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.FieldInfo
createGetterComment, createGetterMethod, createHasAndDeleteMethods, createJavaField, createSetterComment, createSetterMethod, getComment, getDeclaringClassInfo, getDefaultValue, getDeleteMethodName, getFixedValue, getHasMethodName, getMethods, getName, getValidator, getXMLFieldHandler, isBound, isContainer, isHasAndDeleteMethods, isNillable, isTransient, methodSuffix, setBound, setComment, setContainer, setDeclaringClassInfo, setDefaultValue, setFinal, setFixedValue, setMethods, setNillable, setReference, setStatic, setTransient, setValidator, setXMLFieldHandler
 
Methods inherited from class org.exolab.castor.builder.XMLInfo
getNamespacePrefix, getNamespaceURI, getNodeName, getNodeType, getNodeTypeName, getSchemaType, isRequired, 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

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

DEFAULT_REFERENCE_SUFFIX

public static final java.lang.String DEFAULT_REFERENCE_SUFFIX
See Also:
Constant Field Values

xsList

protected XSList xsList
Constructor Detail

CollectionInfo

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

generateInitializerCode

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

Overrides:
generateInitializerCode in class FieldInfo
Parameters:
jsc - the JSourceCode in which to add the source to

getReadMethodName

public java.lang.String getReadMethodName()
Description copied from class: FieldInfo
Returns the name of the read method for this FieldInfo

Overrides:
getReadMethodName in class FieldInfo
Returns:
the name of the read method for this FieldInfo

getWriteMethodName

public java.lang.String getWriteMethodName()
Description copied from class: FieldInfo
Returns the name of the write method for this FieldInfo

Overrides:
getWriteMethodName in class FieldInfo
Returns:
the name of the write method for this FieldInfo

createAccessMethods

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

Overrides:
createAccessMethods in class FieldInfo
Parameters:
jClass - the JClass to add the methods to.
See Also:
FieldInfo.createGetterMethod(org.exolab.javasource.JClass), FieldInfo.createSetterMethod(org.exolab.javasource.JClass), FieldInfo.createHasAndDeleteMethods(org.exolab.javasource.JClass)

getReadMethod

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

Returns:
the main read method for this member

getXSList

public XSList getXSList()

getContentName

public java.lang.String getContentName()

getContentType

public XSType getContentType()

getContent

public FieldInfo getContent()

getElementName

public java.lang.String getElementName()

isMultivalued

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

Overrides:
isMultivalued in class XMLInfo
Returns:
true if this member can appear more than once

createAddMethod

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

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

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.

createGetMethod

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

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

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.

createGetByIndexMethod

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


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.

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

setReferenceMethodSuffix

public 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)

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.

createGetCountMethod

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

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

createEnumerateMethod

public void createEnumerateMethod(JMethod method)
Creates implementation of Enumerate 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.

createRemoveByIndexMethod

public void createRemoveByIndexMethod(JMethod method)
Creates implementation of remove(int i) 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.

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

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