coldbox.system.core.dynamic

Class BeanPopulator

lucee.Component
    extended by coldbox.system.core.dynamic.BeanPopulator

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com --- This is a bean populator that binds different types of data to a bean.

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Constructor Summary
    init()
          Constructor.
    Method Summary
    private struct getRelationshipMetaData(any target)
         Prepares a structure of target relational meta data.
    any populateFromJson(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from a Json string.
    any populateFromQuery(any target, query qry, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from a Query object.
    any populateFromQueryWithPrefix(any target, query qry, string prefix, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from a Query object using a column prefix.
    any populateFromStruct(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from a struct object using a key prefix.
    any populateFromStructWithPrefix(any target, struct memento, string prefix, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from a struct object using a key prefix.
    any populateFromXML(any target, any xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populate a named or instantiated instance from an XML Packet.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Method Detail

    getRelationshipMetaData

    private struct getRelationshipMetaData(any target)

    Prepares a structure of target relational meta data

    Parameters:
    target - The target to work on

    populateFromJson

    public any populateFromJson(any target, string JSONString, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from a Json string

    Parameters:
    target - The target to populate
    JSONString - The JSON string to populate the object with. It has to be valid JSON and also a structure with name-key value pairs.
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet

    populateFromQuery

    public any populateFromQuery(any target, query qry, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from a Query object

    Parameters:
    target - The target to populate
    qry - The query to populate the object with
    rowNumber - The row number to use for population, defaults to 1
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet

    populateFromQueryWithPrefix

    public any populateFromQueryWithPrefix(any target, query qry, string prefix, [numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from a Query object using a column prefix

    Parameters:
    target - The target to populate
    qry - The query to populate the object with
    prefix - The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'.
    rowNumber - The row number to use for population, defaults to 1
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet

    populateFromStruct

    public any populateFromStruct(any target, struct memento, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from a struct object using a key prefix

    Parameters:
    target - The target to populate
    memento - The structure to populate the target with
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet

    populateFromStructWithPrefix

    public any populateFromStructWithPrefix(any target, struct memento, string prefix, [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from a struct object using a key prefix

    Parameters:
    target - The target to populate
    memento - The structure to populate the target with
    prefix - The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'.
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet

    populateFromXML

    public any populateFromXML(any target, any xml, [string root=''], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])

    Populate a named or instantiated instance from an XML Packet

    Parameters:
    target - The target to populate
    xml - The XML string or packet to populate the target with
    root - The XML root element to start from, else defaults to XMLRoot
    scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
    trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean
    include - A list of keys to include in the population
    exclude - A list of keys to exclude in the population
    ignoreEmpty - Ignore empty values on populations, great for ORM population
    nullEmptyInclude - A list of keys to NULL when empty
    nullEmptyExclude - A list of keys to NOT NULL when empty
    composeRelationships - Automatically attempt to compose relationships from memento
    Returns:
    The target populated with the packet