FileDocCategorySizeDatePackage
GeneratedCollectionAliases.javaAPI DocHibernate 3.2.53729Fri Oct 14 17:43:44 BST 2005org.hibernate.loader

GeneratedCollectionAliases

public class GeneratedCollectionAliases extends Object implements CollectionAliases
CollectionAliases which handles the logic of selecting user provided aliases (via return-property), before using the default aliases.
author
Steve Ebersole and Max Rydahl Andersen

Fields Summary
private final String
suffix
private final String[]
keyAliases
private final String[]
indexAliases
private final String[]
elementAliases
private final String
identifierAlias
private Map
userProvidedAliases
Constructors Summary
public GeneratedCollectionAliases(Map userProvidedAliases, org.hibernate.persister.collection.CollectionPersister persister, String suffix)

		this.suffix = suffix;
		this.userProvidedAliases = userProvidedAliases;

		this.keyAliases = getUserProvidedAliases(
				"key", 
				persister.getKeyColumnAliases( suffix )
			);

		this.indexAliases = getUserProvidedAliases(
				"index",
				persister.getIndexColumnAliases( suffix )
				);
		
		this.elementAliases = getUserProvidedAliases( "element", 
				persister.getElementColumnAliases( suffix )
				);
				
		this.identifierAlias = getUserProvidedAlias( "id", 
				persister.getIdentifierColumnAlias( suffix )
				);
	
public GeneratedCollectionAliases(org.hibernate.persister.collection.CollectionPersister persister, String string)

		this(CollectionHelper.EMPTY_MAP, persister, string);
	
Methods Summary
public java.lang.StringgetSuffix()
Returns the suffix used to unique the column aliases for this particular alias set.

return
The uniqued column alias suffix.

		return suffix;
	
public java.lang.String[]getSuffixedElementAliases()
Returns the suffixed result-set column-aliases for the columns making up the collection's elements.

return
The element result-set column aliases.

		return elementAliases;
	
public java.lang.StringgetSuffixedIdentifierAlias()
Returns the suffixed result-set column-aliases for the column defining the collection's identifier (if any).

return
The identifier result-set column aliases.

		return identifierAlias;
	
public java.lang.String[]getSuffixedIndexAliases()
Returns the suffixed result-set column-aliases for the collumns making up the collection's index (map or list).

return
The index result-set column aliases.

		return indexAliases;
	
public java.lang.String[]getSuffixedKeyAliases()
Returns the suffixed result-set column-aliases for columns making up the key for this collection (i.e., its FK to its owner).

return
The key result-set column aliases.

		return keyAliases;
	
private java.lang.StringgetUserProvidedAlias(java.lang.String propertyPath, java.lang.String defaultAlias)

		String[] columns = (String[]) userProvidedAliases.get(propertyPath);
		if (columns==null) {
			return defaultAlias;
		} 
		else {
			return columns[0];
		}
	
private java.lang.String[]getUserProvidedAliases(java.lang.String propertyPath, java.lang.String[] defaultAliases)

		String[] result = (String[]) userProvidedAliases.get(propertyPath);
		if (result==null) {
			return defaultAliases;			
		} 
		else {
			return result;
		}
	
private java.lang.Stringjoin(java.lang.String[] aliases)

		if ( aliases == null) return null;

		return StringHelper.join( ", ", aliases );
	
public java.lang.StringtoString()

		return super.toString() + " [suffix=" + suffix +
		        ", suffixedKeyAliases=[" + join( keyAliases ) +
		        "], suffixedIndexAliases=[" + join( indexAliases ) +
		        "], suffixedElementAliases=[" + join( elementAliases ) +
		        "], suffixedIdentifierAlias=[" + identifierAlias + "]]";