com.metamatrix.common.object
Class PropertiedObjectsEditorImpl

java.lang.Object
  extended by com.metamatrix.common.object.PropertiedObjectEditorImpl
      extended by com.metamatrix.common.object.PropertiedObjectsEditorImpl
All Implemented Interfaces:
PropertiedObjectEditor, PropertiedObjectsEditor, PropertyAccessPolicy, UserTransactionFactory

public class PropertiedObjectsEditorImpl
extends PropertiedObjectEditorImpl
implements PropertiedObjectsEditor


Field Summary
 
Fields inherited from interface com.metamatrix.common.object.PropertiedObjectsEditor
DIFFERENT_VALUES
 
Fields inherited from interface com.metamatrix.common.object.PropertiedObjectEditor
NO_VALUE
 
Fields inherited from interface com.metamatrix.common.object.PropertyAccessPolicy
DEFAULT_READ_ONLY_PRIVILEGE
 
Constructor Summary
PropertiedObjectsEditorImpl()
           
PropertiedObjectsEditorImpl(PropertyAccessPolicy policy)
           
PropertiedObjectsEditorImpl(PropertyAccessPolicy policy, UserTransactionFactory txnFactory)
           
PropertiedObjectsEditorImpl(UserTransactionFactory txnFactory)
           
 
Method Summary
 java.util.List getObjects()
          Return the ordered list of PropertiedObject instances that this editor is set to use.
 java.util.List getSharedPropertyDefinitions()
          Obtain the list of PropertyDefinitions that are defined by all of the propertied objects this editor is set to use.
 java.lang.Object getValue(int index, PropertyDefinition def)
          Obtain from the PropertiedObject at the specified index the property value that corresponds to the specified PropertyDefinition.
 java.lang.Object getValue(PropertyDefinition def)
          Determine whether all of PropertiedObjects this editor is using have the same value for the specified PropertyDefinition.
 java.util.List getValues(PropertyDefinition def)
          Return the ordered list of property values for the specified property definition, ordered by the list of PropertiedObjects that this editor is currently set to use.
 boolean hasObjects()
          Return whether this editor currently is set to use any PropertiedObjects.
 boolean isValidValue(int index, PropertyDefinition def, java.lang.Object value)
          Return whether the specified value is considered valid.
 void setObjects(java.util.List objs)
          Set the ordered list of PropertiedObject instances that this editor is to use.
 void setValue(int index, PropertyDefinition def, java.lang.Object value)
          Set the value of the property defined by the PropertyDefinition on the Propertied PropertiedObject at the specified index in this editor's list of objects.
 void setValue(PropertyDefinition def, java.lang.Object value)
          Set the specified value for the PropertyDefinition on all of PropertiedObjects this editor is using.
 void setValues(PropertyDefinition def, java.util.List values)
          Set the value for the specified PropertyDefinition on each of the PropertiedObject instances that this editor is set to use.
 
Methods inherited from class com.metamatrix.common.object.PropertiedObjectEditorImpl
assertPropertiedObject, createReadTransaction, createWriteTransaction, createWriteTransaction, getAllowedValues, getPolicy, getPropertyDefinitions, getValue, isReadOnly, isReadOnly, isValidValue, reset, setPolicy, setReadOnly, setReadOnly, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.metamatrix.common.object.PropertiedObjectEditor
getAllowedValues, getPolicy, getPropertyDefinitions, getValue, isReadOnly, isValidValue, setPolicy, setValue
 
Methods inherited from interface com.metamatrix.common.object.PropertyAccessPolicy
isReadOnly, reset, setReadOnly, setReadOnly
 
Methods inherited from interface com.metamatrix.common.transaction.UserTransactionFactory
createReadTransaction, createWriteTransaction, createWriteTransaction
 

Constructor Detail

PropertiedObjectsEditorImpl

public PropertiedObjectsEditorImpl(PropertyAccessPolicy policy,
                                   UserTransactionFactory txnFactory)

PropertiedObjectsEditorImpl

public PropertiedObjectsEditorImpl()

PropertiedObjectsEditorImpl

public PropertiedObjectsEditorImpl(PropertyAccessPolicy policy)

PropertiedObjectsEditorImpl

public PropertiedObjectsEditorImpl(UserTransactionFactory txnFactory)
Method Detail

getObjects

public java.util.List getObjects()
Description copied from interface: PropertiedObjectsEditor
Return the ordered list of PropertiedObject instances that this editor is set to use.

Specified by:
getObjects in interface PropertiedObjectsEditor
Returns:
the instances of PropertiedObject that are used this this editor; may be null or a zero-length collection.

setObjects

public void setObjects(java.util.List objs)
Description copied from interface: PropertiedObjectsEditor
Set the ordered list of PropertiedObject instances that this editor is to use.

Specified by:
setObjects in interface PropertiedObjectsEditor
Parameters:
objs - the instances of PropertiedObject that are to be used this this editor; may be null or a zero-length collection.

hasObjects

public boolean hasObjects()
Return whether this editor currently is set to use any PropertiedObjects.

Specified by:
hasObjects in interface PropertiedObjectsEditor
Returns:
true if this editor has at least one PropertiedObject that it is set to use, or false otherwise.

getSharedPropertyDefinitions

public java.util.List getSharedPropertyDefinitions()
Obtain the list of PropertyDefinitions that are defined by all of the propertied objects this editor is set to use.

Specified by:
getSharedPropertyDefinitions in interface PropertiedObjectsEditor
Returns:
an unmodifiable list of the PropertyDefinition objects that are shared by all instances used by this editor; never null but possibly empty

getValues

public java.util.List getValues(PropertyDefinition def)
Return the ordered list of property values for the specified property definition, ordered by the list of PropertiedObjects that this editor is currently set to use. If this editor has no objects that it is using, then this method returns an empty List.

The type of objects in the list and whether the list may contain null references depend upon the type and cardinality defined by the PropertyDefinition.

Specified by:
getValues in interface PropertiedObjectsEditor
Parameters:
def - the reference to the PropertyDefinition describing the property value is to be returned; may not be null
Returns:
the list of values for the property, one for each PropertiedObject this editor is set to use and ordered in the same order; the value of the references in the returned List are dependent upon the PropertyDefinition (i.e., they are a Collection if the property is multi-valued, or may be null if the multiplicity includes "0")
Throws:
java.lang.AssertionError - if def is null

setValues

public void setValues(PropertyDefinition def,
                      java.util.List values)
Set the value for the specified PropertyDefinition on each of the PropertiedObject instances that this editor is set to use. The values are correlated to the PropertiedObjects by the order of each list; thus the following must be true:

(this.hasObjects() && ( values.size() == this.getObjects().size() )

If a PropertiedObject instance in the list of objects this editor is using that does not have the specified PropertyDefinition, the value is not set on that object.

Specified by:
setValues in interface PropertiedObjectsEditor
Parameters:
def - the reference to the PropertyDefinition describing the property whose values are to be changed; may not be null
values - the new values for the property organized in the same order as the list of PropertiedObjects that this editor is currently using; may not be null although it may contain null values if the PropertyDefinition has a multiplicity that includes "0")
Throws:
java.lang.IllegalArgumentException - if any of the values are considered invalid for the PropertyDefinition.
java.lang.AssertionError - if either of def or values is null

getValue

public java.lang.Object getValue(int index,
                                 PropertyDefinition def)
Obtain from the PropertiedObject at the specified index the property value that corresponds to the specified PropertyDefinition. The return type and cardinality (including whether the value may be null) depend upon the PropertyDefinition.

Specified by:
getValue in interface PropertiedObjectsEditor
Parameters:
obj - the propertied object whose property value is to be obtained; may not be null
index - the index of the PropertiedObject whose property value is to be returned; must be within the range of the list of PropertiedObjects
def - the reference to the PropertyDefinition describing the property whose value is to be returned; may not be null
Returns:
the value for the property, which may be a collection if the property is multi-valued, or may be null if the multiplicity includes "0", or the NO_VALUE reference if the specified object does not contain the specified PropertyDefinition
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= this.getObjects().size()).
java.lang.AssertionError - if def is null

isValidValue

public boolean isValidValue(int index,
                            PropertyDefinition def,
                            java.lang.Object value)
Return whether the specified value is considered valid.

Specified by:
isValidValue in interface PropertiedObjectsEditor
Parameters:
index - the index of the PropertiedObject whose property value is to be returned; must be within the range of the list of PropertiedObjects
def - the reference to the PropertyDefinition describing the property whose value is to be validated; may not be null
value - the proposed value for the property, which may be a collection if the property is multi-valued, or may be null if the multiplicity includes "0"
Returns:
true if the value is considered valid, or false otherwise.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= this.getObjects().size()).
java.lang.AssertionError - if def is null

setValue

public void setValue(int index,
                     PropertyDefinition def,
                     java.lang.Object value)
Set the value of the property defined by the PropertyDefinition on the Propertied PropertiedObject at the specified index in this editor's list of objects.

Specified by:
setValue in interface PropertiedObjectsEditor
Parameters:
index - the index of the PropertiedObject whose property value is to be returned; must be within the range of the list of PropertiedObjects
def - the reference to the PropertyDefinition describing the property whose value is to be changed; may not be null
value - the new value for the property; the cardinality and type must conform PropertyDefinition
Throws:
java.lang.IllegalArgumentException - if the value does not correspond to the PropertyDefinition requirements.
java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= this.getObjects().size()).
java.lang.AssertionError - if def is null, or if the object is read only

getValue

public java.lang.Object getValue(PropertyDefinition def)
Determine whether all of PropertiedObjects this editor is using have the same value for the specified PropertyDefinition. If they do, then return that value; if not, then return the PropertiedObjectsEditor.DIFFERENT_VALUES object.

Specified by:
getValue in interface PropertiedObjectsEditor
Parameters:
def - the reference to the PropertyDefinition describing the property whose values are to be evaluated for equivalency; may not be null
Returns:
the uniform value that all of the PropertiedObject instances this editor is using have, or PropertiedObjectsEditor.DIFFERENT_VALUES if at least two of the values are different; never null

setValue

public void setValue(PropertyDefinition def,
                     java.lang.Object value)
Set the specified value for the PropertyDefinition on all of PropertiedObjects this editor is using. The value must be considered valid for the specified PropertyDefinition. If a PropertiedObject instance in the list of objects this editor is using that does not have the specified PropertyDefinition, the value is not set on that object.

Specified by:
setValue in interface PropertiedObjectsEditor
Parameters:
def - the reference to the PropertyDefinition describing the property whose value is to be set on all referenced PropertiedObjects; may not be null
value - the new value for the property; the cardinality and type must conform PropertyDefinition
Throws:
java.lang.IllegalArgumentException - if the value is considered invalid for the PropertyDefinition.


Copyright © 2009. All Rights Reserved.