coldbox.system.core.dynamic

Class BeanPopulator

railo-context.Component
        extended by coldbox.system.core.dynamic.BeanPopulator
Class Attributes:
  • output : false
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  

    This is a bean populator that binds different types of data to a bean.

    Constructor Summary
    init()
          Constructor.
    Method Summary
    private struct getRelationshipMetaData(any target)
         Prepares a structure of target relational meta data.
    private Util getUtil()
         Create and return a util object.
    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 bean 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 bean from query.
    any populateFromQueryWithPrefix(any target, query qry, [Numeric rowNumber='1'], [string scope=''], [boolean trustedSetter='false'], [string include=''], [string exclude=''], string prefix, [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'])
         Populates an Object using only specific columns from a query.
    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 bean from a structure.
    any populateFromStructWithPrefix(any target, struct memento, [string scope], [boolean trustedSetter='false'], [string include=''], [string exclude=''], [boolean ignoreEmpty='false'], [string nullEmptyInclude=''], [string nullEmptyExclude=''], [boolean composeRelationships='false'], string prefix)
         Populate a named or instantiated bean from a structure.
    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 bean from an XML packet.
     
    Methods inherited from class railo-context.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

    getUtil

    private Util getUtil()

    Create and return a util object


    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 bean 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

    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 bean from query

    Parameters:
    target - The target to populate
    qry - The query to popluate the bean object with
    rowNumber - The query row number to use for population
    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

    populateFromQueryWithPrefix

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

    Populates an Object using only specific columns from a query. Useful for performing a query with joins that needs to populate multiple objects.

    Parameters:
    target - This can be an instantiated bean object or a bean instantitation path as a string. If you pass an instantiation path and the bean has an 'init' method. It will be executed. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
    qry - The query to popluate the bean object with
    rowNumber - The query row number to use for population
    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
    prefix - The prefix used to filter, Example: 'user_' would apply to the following columns: 'user_id' and 'user_name' but not 'address_id'.
    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

    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 bean from a structure

    Parameters:
    target - The target to populate
    memento - The structure to populate the object with.
    scope - Use scope injection instead of setters population.
    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

    populateFromStructWithPrefix

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

    Populate a named or instantiated bean from a structure

    Parameters:
    target - The target to populate
    memento - The structure to populate the object with.
    scope - Use scope injection instead of setters population.
    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
    prefix - The prefix used to filter, Example: 'user' would apply to the following formfield: 'user_id' and 'user_name' but not 'address_id'.

    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 bean from an XML packet

    Parameters:
    target - The target to populate
    xml - The XML string or packet
    root - The XML root element to start from
    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