org.norther.tammi.root.rt.util
Class VariableTransporter

java.lang.Object
  extended by org.norther.tammi.root.rt.util.VariableTransporter
All Implemented Interfaces:
Serializable, EventListener, TransportListener
Direct Known Subclasses:
MetaElementImporter, PasswordImporter, PermissionImporter

public class VariableTransporter
extends Object
implements TransportListener, Serializable

An attribute transporter for persistent variables.

Version:
$Id: VariableTransporter.java,v 1.43 2010-04-19 09:17:48 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
VariableTransporter()
          Constructs a new transporter.
 
Method Summary
 void exported(TransportedObjectEvent event)
          Notifies the object that it has been exported to the repository.
 String getEnumerationKey(Variable var, String name, Object enumObject, String enumValueField, String enumKeyField, Persister persister)
          Gets the enumeration key.
 Object getEnumerationValue(Variable var, String name, Object enumObject, String enumValueField, String enumKeyField, Persister persister)
          Gets the enumeration value.
 AttributeFilter getExportFilter()
          Gets the export filter.
 AttributeFilter getImportFilter()
          Gets the import filter.
 EnumeratedAttribute getNullableEnum(Variable var, String name, String enumValueField, String enumKeyField, Persister persister)
          Gets a nullable enumerated attribute to be applied as a non-mandatory value.
 void imported(TransportedObjectEvent event)
          Notifies the object that it has been imported from the repository.
 boolean isEmptyEnumeration(VariableAttributeInfo info)
          Checks whether the enumeration of the specified attribute is empty.
 boolean isEqualTypes(Variable source, Variable target)
          Checks whether the source and target types are equal.
 List<EnumeratedAttribute> transportEnumeration(Variable var, String name, DependenceRule dr, String enumKeyField, Persister persister)
          Transports the dependent foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values.
 List<EnumeratedAttribute> transportEnumeration(Variable var, String name, String enumClassName, String enumKeyField, Persister persister)
          Transports the specified foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values.
 List<EnumeratedAttribute> transportEnumeration(Variable var, String name, String enumClassName, String enumValueField, String enumKeyField, Persister persister)
          Transports the specified foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values.
 void transportEnumerations(Variable var, String enumKeyField, Persister persister)
          Transports dependent foreign enumerations of the specified variable.
 void transportUserId(Variable var, String idFieldName, Persister persister)
          Transports the user id of the specified variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableTransporter

public VariableTransporter()
Constructs a new transporter.

Method Detail

getImportFilter

public AttributeFilter getImportFilter()
Description copied from interface: TransportListener
Gets the import filter.

Specified by:
getImportFilter in interface TransportListener
Returns:
the filter or null.

getExportFilter

public AttributeFilter getExportFilter()
Description copied from interface: TransportListener
Gets the export filter.

Specified by:
getExportFilter in interface TransportListener
Returns:
the filter or null.

imported

public void imported(TransportedObjectEvent event)
Description copied from interface: TransportListener
Notifies the object that it has been imported from the repository.

Specified by:
imported in interface TransportListener
Parameters:
event - the transported object event.

exported

public void exported(TransportedObjectEvent event)
Description copied from interface: TransportListener
Notifies the object that it has been exported to the repository.

Specified by:
exported in interface TransportListener
Parameters:
event - the transported object event.

transportUserId

public void transportUserId(Variable var,
                            String idFieldName,
                            Persister persister)
Transports the user id of the specified variable.

Parameters:
var - the local variable.
idFieldName - the user id field name.
persister - the persister to apply.

transportEnumerations

public void transportEnumerations(Variable var,
                                  String enumKeyField,
                                  Persister persister)
Transports dependent foreign enumerations of the specified variable.

Parameters:
var - the local variable.
enumKeyField - the enumeration key field.
persister - the persister to apply.

transportEnumeration

public List<EnumeratedAttribute> transportEnumeration(Variable var,
                                                      String name,
                                                      DependenceRule dr,
                                                      String enumKeyField,
                                                      Persister persister)
                                               throws AttributeNotFoundException,
                                                      PersistenceException
Transports the dependent foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values. The primary key of the object is applied to the enumeration value.

Parameters:
var - the local variable.
name - the local field name.
dr - the dependent field rule.
enumKeyField - the enumeration key field.
persister - the persister to apply.
Returns:
the enumeration.
Throws:
AttributeNotFoundException - for missing attributes.
PersistenceException - if a persister operation fails.

transportEnumeration

public List<EnumeratedAttribute> transportEnumeration(Variable var,
                                                      String name,
                                                      String enumClassName,
                                                      String enumKeyField,
                                                      Persister persister)
                                               throws AttributeNotFoundException,
                                                      PersistenceException
Transports the specified foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values. The primary key of the object is applied to the enumeration value.

Parameters:
var - the local variable.
name - the local field name.
enumClassName - the foreign class name.
enumKeyField - the enumeration key field.
persister - the persister to apply.
Returns:
the enumeration.
Throws:
AttributeNotFoundException - for missing attributes.
PersistenceException - if a persister operation fails.

transportEnumeration

public List<EnumeratedAttribute> transportEnumeration(Variable var,
                                                      String name,
                                                      String enumClassName,
                                                      String enumValueField,
                                                      String enumKeyField,
                                                      Persister persister)
                                               throws AttributeNotFoundException,
                                                      PersistenceException
Transports the specified foreign enumeration by calling the corresponding methods on foreign objects to retrieve the enumeration keys and values.

Parameters:
var - the local variable.
name - the local field name.
enumClassName - the foreign class name.
enumValueField - the enumeration value field
enumKeyField - the enumeration key field
persister - the persister to apply.
Returns:
the enumeration.
Throws:
AttributeNotFoundException - for missing attributes.
PersistenceException - if a persister operation fails.

getEnumerationKey

public String getEnumerationKey(Variable var,
                                String name,
                                Object enumObject,
                                String enumValueField,
                                String enumKeyField,
                                Persister persister)
                         throws AttributeNotFoundException
Gets the enumeration key. By default, the enumeration field value of the foreign object is applied.

Parameters:
var - the local variable.
name - the local field name.
enumObject - the foreign object.
enumValueField - the enumeration value field.
enumKeyField - the enumeration key field.
persister - the persister to apply.
Returns:
the enumeration key.
Throws:
AttributeNotFoundException - for missing attributes.

getEnumerationValue

public Object getEnumerationValue(Variable var,
                                  String name,
                                  Object enumObject,
                                  String enumValueField,
                                  String enumKeyField,
                                  Persister persister)
                           throws AttributeNotFoundException
Gets the enumeration value. By default, the primary key of the foreign object is applied.

Parameters:
var - the local variable.
name - the local field name.
enumObject - the foreign object.
enumValueField - the enumeration value field.
enumKeyField - the enumeration key field.
persister - the persister to apply.
Returns:
the enumeration value.
Throws:
AttributeNotFoundException - for missing attributes.

getNullableEnum

public EnumeratedAttribute getNullableEnum(Variable var,
                                           String name,
                                           String enumValueField,
                                           String enumKeyField,
                                           Persister persister)
                                    throws AttributeNotFoundException
Gets a nullable enumerated attribute to be applied as a non-mandatory value.

Parameters:
var - the local variable.
name - the local field name.
enumValueField - the enumeration value field.
enumKeyField - the enumeration key field.
persister - the persister to apply.
Returns:
the nullable enumerated attribute.
Throws:
AttributeNotFoundException - for missing attributes.

isEmptyEnumeration

public boolean isEmptyEnumeration(VariableAttributeInfo info)
Checks whether the enumeration of the specified attribute is empty.

Parameters:
info - the variable attribute info.
Returns:
true for an empty enumeration, false otherwise.

isEqualTypes

public boolean isEqualTypes(Variable source,
                            Variable target)
Checks whether the source and target types are equal.

Parameters:
source - the source variable.
target - the target variable.
Returns:
true if equal, false otherwise.


Copyright © 2004 The Norther Organization. All rights reserved.