Class BindableCpoOrderBy

java.lang.Object
org.synchronoss.cpo.core.BindableCpoOrderBy
All Implemented Interfaces:
CpoOrderBy

public class BindableCpoOrderBy extends Object implements CpoOrderBy
Default CpoOrderBy implementation: an immutable, bindable sort clause on a single attribute, optionally wrapped in a native datastore function and associated with a custom marker for multi-clause substitution.
Author:
david berry
  • Field Summary

    Fields inherited from interface org.synchronoss.cpo.core.CpoOrderBy

    DEFAULT_MARKER
  • Constructor Summary

    Constructors
    Constructor
    Description
    BindableCpoOrderBy(String attr, boolean asc)
    Creates an order-by clause on the given attribute using the CpoOrderBy.DEFAULT_MARKER.
    BindableCpoOrderBy(String attr, boolean asc, String func)
    Creates an order-by clause on the given attribute, wrapped in a native datastore function, using the CpoOrderBy.DEFAULT_MARKER.
    BindableCpoOrderBy(String marker, String attr, boolean asc)
    Creates an order-by clause on the given attribute using a custom marker, for use when more than one order-by expression must be substituted into the same native expression.
    BindableCpoOrderBy(String marker, String attr, boolean asc, String func)
    Creates an order-by clause on the given attribute, wrapped in a native datastore function, using a custom marker, for use when more than one order-by expression must be substituted into the same native expression.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Gets the boolean that determines if the objects will be returned from from the CpoAdapter in Ascending order or Descending order
    Gets the name of the attribute that is to be used to sort the results from the CpoAdapter.
    Gets a string representing a datasource specific function call that must be applied to the attribute that will be used for sorting.
    Gets the string marker that this cpoOrderBy will search for in the expression to replace
    toString(CpoClass cpoClass)
    Builds the native (SQL/CQL) order-by fragment for this clause against the given class's attribute-to-column mapping.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BindableCpoOrderBy

      public BindableCpoOrderBy(String attr, boolean asc)
      Creates an order-by clause on the given attribute using the CpoOrderBy.DEFAULT_MARKER.
      Parameters:
      attr - the name of the attribute to sort by
      asc - true to sort ascending, false to sort descending
    • BindableCpoOrderBy

      public BindableCpoOrderBy(String marker, String attr, boolean asc)
      Creates an order-by clause on the given attribute using a custom marker, for use when more than one order-by expression must be substituted into the same native expression.
      Parameters:
      marker - the marker string this clause replaces in the expression
      attr - the name of the attribute to sort by
      asc - true to sort ascending, false to sort descending
    • BindableCpoOrderBy

      public BindableCpoOrderBy(String attr, boolean asc, String func)
      Creates an order-by clause on the given attribute, wrapped in a native datastore function, using the CpoOrderBy.DEFAULT_MARKER.
      Parameters:
      attr - the name of the attribute to sort by
      asc - true to sort ascending, false to sort descending
      func - the native function expression to apply to the attribute (e.g. "upper(attribute_name)")
    • BindableCpoOrderBy

      public BindableCpoOrderBy(String marker, String attr, boolean asc, String func)
      Creates an order-by clause on the given attribute, wrapped in a native datastore function, using a custom marker, for use when more than one order-by expression must be substituted into the same native expression.
      Parameters:
      marker - the marker string this clause replaces in the expression
      attr - the name of the attribute to sort by
      asc - true to sort ascending, false to sort descending
      func - the native function expression to apply to the attribute (e.g. "upper(attribute_name)")
  • Method Details

    • getAscending

      public boolean getAscending()
      Gets the boolean that determines if the objects will be returned from from the CpoAdapter in Ascending order or Descending order
      Specified by:
      getAscending in interface CpoOrderBy
      Returns:
      boolean true if it is to sort in Ascensing Order false if it is to be sorted in Descending Order
    • getAttribute

      public String getAttribute()
      Gets the name of the attribute that is to be used to sort the results from the CpoAdapter.
      Specified by:
      getAttribute in interface CpoOrderBy
      Returns:
      String The name of the attribute
    • getFunction

      public String getFunction()
      Gets a string representing a datasource specific function call that must be applied to the attribute that will be used for sorting.

      i.e. - "upper(attribute_name)"

      Specified by:
      getFunction in interface CpoOrderBy
      Returns:
      String The name of the function
    • toString

      public String toString(CpoClass cpoClass) throws CpoException
      Builds the native (SQL/CQL) order-by fragment for this clause against the given class's attribute-to-column mapping.
      Specified by:
      toString in interface CpoOrderBy
      Parameters:
      cpoClass - the class metadata used to resolve the attribute to a datastore column
      Returns:
      the string that will be added into the expression
      Throws:
      CpoException - if the attribute cannot be resolved against cpoClass
    • getMarker

      public String getMarker()
      Gets the string marker that this cpoOrderBy will search for in the expression to replace
      Specified by:
      getMarker in interface CpoOrderBy
      Returns:
      String The marker of the CpoOrderBy