org.kuali.rice.krad.datadictionary.validation
Class SingleAttributeValueReader

java.lang.Object
  extended by org.kuali.rice.krad.datadictionary.validation.BaseAttributeValueReader
      extended by org.kuali.rice.krad.datadictionary.validation.SingleAttributeValueReader
All Implemented Interfaces:
AttributeValueReader

public class SingleAttributeValueReader
extends BaseAttributeValueReader

This class allows a single attribute value to be exposed to the validation service, along with some guidance about how that value should be interpreted, provided by the AttributeDefinition that corresponds. It's a special AttributeValueReader since it explicitly doesn't expose any other attribute values, so it should only be used when the underlying business object is not available and we want to limit access to (for example) validation that requires only a single attribute value. This eliminates more complicated validation like 'this field is required when another field is filled in.'

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
 
Fields inherited from class org.kuali.rice.krad.datadictionary.validation.BaseAttributeValueReader
attributeName, entryName
 
Constructor Summary
SingleAttributeValueReader(Object value, String entryName, String attributeName, AttributeDefinition definition)
           
 
Method Summary
 Constrainable getDefinition(String attributeName)
          This method provides access to the constrainable attribute definition of a specific attribute name.
 List<Constrainable> getDefinitions()
          This method returns a list of all constrainable dictionary metadata definitions for attributes or fields encapsulated by this object.
 Constrainable getEntry()
          The dictionary metadata associated with an object (its "entry" in the dictionary) can also be constrainable, in which case the object value itself can be validated against one or more constraints.
 String getLabel(String attributeName)
          This method looks up a label for a specific attribute name.
 Object getObject()
          The underlying object itself (not the field/attribute value, but the object).
 String getPath()
          The path is a string representation of specifically which attribute (at some depth) is being accessed, for example, on a person object there might be the following field path: joe.home.mailingAddress.state
 Class<?> getType(String selectedAttributeName)
          The type of the attribute specified.
<X> X
getValue()
          A convenience method for looking up the attribute value that is currently being processed.
<X> X
getValue(String attributeName)
          A method for looking up any attribute value by name for the object being processed.
 
Methods inherited from class org.kuali.rice.krad.datadictionary.validation.BaseAttributeValueReader
getAttributeName, getCleanSearchableValues, getEntryName, setAttributeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleAttributeValueReader

public SingleAttributeValueReader(Object value,
                                  String entryName,
                                  String attributeName,
                                  AttributeDefinition definition)
Method Detail

getDefinition

public Constrainable getDefinition(String attributeName)
Description copied from interface: AttributeValueReader
This method provides access to the constrainable attribute definition of a specific attribute name. If the value of the metadata associated with the object field does not implement constrainable, or if no metadata is associated with this object field, then null should be returned.

Parameters:
attributeName - - the name of the attribute/field whose metadata is being requested
Returns:
dictionary metadata object implementing some constrainable capability

getDefinitions

public List<Constrainable> getDefinitions()
Description copied from interface: AttributeValueReader
This method returns a list of all constrainable dictionary metadata definitions for attributes or fields encapsulated by this object.

Returns:
a list of constrainable definitions

getEntry

public Constrainable getEntry()
Description copied from interface: AttributeValueReader
The dictionary metadata associated with an object (its "entry" in the dictionary) can also be constrainable, in which case the object value itself can be validated against one or more constraints. If the specific entry for the dictionary object encapsulated by this reader is not constrainable, or if no entry exists for this dictionary object, or no dictionary object is being encapsulted, then null should be returned.

Returns:
the constrainable dictionary entry metadata for this object, or null
See Also:
AttributeValueReader.getEntry()

getLabel

public String getLabel(String attributeName)
Description copied from interface: AttributeValueReader
This method looks up a label for a specific attribute name.

Returns:
some descriptive label that can be exposed to the end user for error messages

getObject

public Object getObject()
Description copied from interface: AttributeValueReader
The underlying object itself (not the field/attribute value, but the object).

Returns:
the object that is being encapsulated by this reader, or null if no object is being encapsulated.

getPath

public String getPath()
Description copied from interface: AttributeValueReader
The path is a string representation of specifically which attribute (at some depth) is being accessed, for example, on a person object there might be the following field path: joe.home.mailingAddress.state

Returns:
the string representation of the attribute identifier currently being processed

getType

public Class<?> getType(String selectedAttributeName)
Description copied from interface: AttributeValueReader
The type of the attribute specified. A Java class.

Returns:
the type of the attribute referenced by the passed name, or null if no attribute exists of that name

getValue

public <X> X getValue()
           throws AttributeValidationException
Description copied from interface: AttributeValueReader
A convenience method for looking up the attribute value that is currently being processed.

Returns:
Throws:
AttributeValidationException

getValue

public <X> X getValue(String attributeName)
           throws AttributeValidationException
Description copied from interface: AttributeValueReader
A method for looking up any attribute value by name for the object being processed.

Returns:
Throws:
AttributeValidationException


Copyright © 2005-2011 The Kuali Foundation. All Rights Reserved.