Class ResultSetCpoData

All Implemented Interfaces:
CpoData

public abstract class ResultSetCpoData extends AbstractBindableCpoData
Base CpoData implementation for reading a bound attribute's value out of a datastore result row (e.g. a JDBC ResultSet or Cassandra Row). Resolves the appropriate MethodMapEntry for the attribute's data type on first use and caches it, since it cannot change across invocations of the same bound instance; datastore implementations supply the actual reflective invocation via invokeGetterImpl(org.synchronoss.cpo.core.meta.domain.CpoAttribute, org.synchronoss.cpo.core.meta.MethodMapEntry<?, ?>).
Author:
dberry
  • Constructor Details

    • ResultSetCpoData

      public ResultSetCpoData(MethodMapper<?> methodMapper, Object rs, CpoAttribute cpoAttribute, int index)
      Creates an instance bound to a single column/attribute of the given result row.
      Parameters:
      methodMapper - the mapper used to resolve the getter method for the attribute's data type
      rs - the datastore-specific result row object (e.g. ResultSet or Row)
      cpoAttribute - the attribute this instance reads
      index - the positional index (e.g. column index) of this binding
  • Method Details

    • getRs

      public Object getRs()
      Gets the datastore-specific result row object this instance reads from.
      Returns:
      the result row object (e.g. ResultSet or Row)
    • invokeGetter

      public Object invokeGetter() throws CpoException
      Invokes the bean's getter for the bound attribute.

      Not implemented by this base class; subclasses that support reflective getter invocation must override this method.

      Resolves (and caches) the MethodMapEntry for the attribute's data getter return type, invokes the datastore-specific getter via invokeGetterImpl(org.synchronoss.cpo.core.meta.domain.CpoAttribute, org.synchronoss.cpo.core.meta.MethodMapEntry<?, ?>), and applies the attribute's transform.

      Specified by:
      invokeGetter in interface CpoData
      Overrides:
      invokeGetter in class AbstractCpoData
      Returns:
      the value returned by the attribute's getter
      Throws:
      CpoException - if the getter cannot be invoked