com.isomorphic.criteria

## Class AdvancedCriteria

- com.isomorphic.criteria.AdvancedCriteria

-     public class AdvancedCriteria

  AdvancedCriteria is a format for representing search criteria which may include operators on field values such as "less than", or may include sub-clauses such as several criteria applied to fields joined by an "OR" operator.

  The server-side AdvancedCriteria handling feature is only available with the Power and Enterprise Editions of SmartClient; the Pro Edition is limited to ordinary criteria handling on the server side)

  AdvancedCriteria objects can be created directly in java. For example:

       AdvancedCriteria criteria = new AdvancedCriteria(DefaultOperators.And, new Criterion[]{
         new SimpleCriterion("countryCode", "contains", "C"),
         new SimpleCriterion("countryName", "startsWith", "C")
       });

  In addition to building a raw AdvancedCriteria object as described above, the `DataSource.parseAdvancedCriteria(Map)` and `Evaluator.parseAdvancedCriteria(Map)` methods may be used to create AdvancedCriteria based on simple fieldName / value mappings.

  Also an AdvancedCriteria instance can be retrieved from a DSRequest via `DSRequest.getAdvancedCriteria()` These same AdvancedCriteria objects can be directly created server side, and applied to a DSRequest via `DSRequest.setAdvancedCriteria(AdvancedCriteria)`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `CONSTRUCTOR_NAME` _constructor attribute value

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdvancedCriteria(Criterion _criteria)` Convert existing Criterion to AdvancedCriteria.
    `AdvancedCriteria(Operator operator, Criterion[] criteria)` Combine an array of criterion into AdvancedCriteria instance using operator.
    `AdvancedCriteria(java.lang.String operator, Criterion[] criteria)` Combine an array of criterion into AdvancedCriteria instance using operator in the format of String.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Criterion` | `asCriterion()` Convert AdvancedCriteria into Criterion format.
    `static AdvancedCriteria` | `fromCollections(java.lang.Object criteria)` Creates an AdvancedCriteria object from Java collections.
    `static AdvancedCriteria` | `fromCollections(java.lang.Object criteria, OperatorBase operator)` Creates an AdvancedCriteria object from Java collections.
    `static AdvancedCriteria` | `fromCollections(java.lang.Object criteria, java.lang.String operator)` Creates an AdvancedCriteria object from Java collections.
    `java.util.Map` | `getCriteriaAsMap()` Convert AdvancedCriteria into Map object.
    `Criterion` | `getFieldCriterion(java.lang.String fieldName)` Returns the depth-first match of a criterion matching the given fieldName.
    `java.util.Set` | `getFieldCriterions(java.lang.String fieldName)` Returns all criterions matching the given fieldName.
    `java.lang.Object` | `getFieldValue(java.lang.String fieldName)` Returns the depth-first value of a criterion matching the given fieldName.

- - ### Field Detail

    - #### CONSTRUCTOR_NAME

          public static final java.lang.String CONSTRUCTOR_NAME

      _constructor attribute value
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AdvancedCriteria

          public AdvancedCriteria(Criterion _criteria)

      Convert existing Criterion to AdvancedCriteria.
      Parameters:
        `_criteria` - - criteria to use in AdvancedCriteria.

    - #### AdvancedCriteria

          public AdvancedCriteria(Operator operator,
                          Criterion[] criteria)

      Combine an array of criterion into AdvancedCriteria instance using operator. For example:

           AdvancedCriteria criteria = new AdvancedCriteria(DefaultOperators.And, new Criterion[]{
             new SimpleCriterion("countryCode", "contains", "C"),
             new SimpleCriterion("countryName", "startsWith", "C")
           });

      You can pass another AdvancedCriteria in the array of criteria by using `AdvancedCriteria.asCriterion()` method.
      Parameters:
        `operator` - - operator that will be used to combine criteria.
        `criteria` - - criteria that will be combined.

    - #### AdvancedCriteria

          public AdvancedCriteria(java.lang.String operator,
                          Criterion[] criteria)

      Combine an array of criterion into AdvancedCriteria instance using operator in the format of String. For example:

           AdvancedCriteria criteria = new AdvancedCriteria("and", new Criterion[]{
             new SimpleCriterion("countryCode", "contains", "C"),
             new SimpleCriterion("countryName", "startsWith", "C")
           });

      You can pass another AdvancedCriteria in the array of criteria by using `AdvancedCriteria.asCriterion()` method.
      Parameters:
        `operator` - - operator that will be used to combine criteria.
        `criteria` - - criterias that will be combined.

  - ### Method Detail

    - #### getFieldValue

          public java.lang.Object getFieldValue(java.lang.String fieldName)

      Returns the depth-first value of a criterion matching the given fieldName.
      Parameters:
        `fieldName` - - name of field to search value for.
      Returns:
        first found value or null if no value was found.

    - #### getFieldCriterion

          public Criterion getFieldCriterion(java.lang.String fieldName)

      Returns the depth-first match of a criterion matching the given fieldName.
      Parameters:
        `fieldName` - - name of field to search value for.
      Returns:
        first found value or null if no value was found.

    - #### getFieldCriterions

          public java.util.Set getFieldCriterions(java.lang.String fieldName)

      Returns all criterions matching the given fieldName.
      Parameters:
        `fieldName` - - name of field to search value for.
      Returns:
        all criterions matching fieldName. The Set will be empty if no matches were found.

    - #### getCriteriaAsMap

          public java.util.Map getCriteriaAsMap()

      Convert AdvancedCriteria into Map object.
      Returns:
        AdvancedCriteria represented as Map.

    - #### fromCollections

          public static AdvancedCriteria fromCollections(java.lang.Object criteria)

      Creates an AdvancedCriteria object from Java collections.

      You may pass collections reflecting simple or advanced criteria to this method.

      If criteria were passed as simple Criteria this method will convert them to the more general AdvancedCriteria format by turning them into an AND Criterion containing one or more "equals" Criteria.

      Note that AdvancedCriteria will only be able to be executed by the built-in server DataSources (JPA, Hibernate, SQL) in Power Edition and above.

      Parameters:
        `criteria` - - criteria in java collections (nested maps) format
      Returns:
        The resulting advanced criteria

    - #### fromCollections

          public static AdvancedCriteria fromCollections(java.lang.Object criteria,
                                         java.lang.String operator)

      Creates an AdvancedCriteria object from Java collections.

      You may pass collections reflecting simple or advanced criteria to this method.

      If criteria were passed as simple Criteria this method will convert them to the more general AdvancedCriteria format by turning them into an AND Criterion containing one or more Criteria with the operator specified by the operator argument to this method.

      Note that AdvancedCriteria will only be able to be executed by the built-in server DataSources (JPA, Hibernate, SQL) in Power Edition and above.

      Parameters:
        `criteria` - - criteria in java collections (nested maps) format
        `operator` - - default operator to use
      Returns:
        The resulting advanced criteria

    - #### fromCollections

          public static AdvancedCriteria fromCollections(java.lang.Object criteria,
                                         OperatorBase operator)

      Creates an AdvancedCriteria object from Java collections.

      You may pass collections reflecting simple or advanced criteria to this method.

      If criteria were passed as simple Criteria this method will convert them to the more general AdvancedCriteria format by turning them into an AND Criterion containing one or more Criteria with the operator specified by the operator argument to this method.

      Note that AdvancedCriteria will only be able to be executed by the built-in server DataSources (JPA, Hibernate, SQL) in Power Edition and above.

      Parameters:
        `criteria` - - criteria in java collections (nested maps) format
        `operator` - - default operator to use
      Returns:
        The resulting advanced criteria

    - #### asCriterion

          public Criterion asCriterion()

      Convert AdvancedCriteria into Criterion format.
      Returns:
        AdvancedCriteria represented as Criterion.