psdi.app.workorder.virtual

Class OrderBy

  • java.lang.Object
    • psdi.app.workorder.virtual.OrderBy
  • All Implemented Interfaces:
    java.lang.Comparable, java.util.Comparator


    public class OrderBy
    extends java.lang.Object
    implements java.lang.Comparable, java.util.Comparator
    This helper class parses order by clauses and reorders internal Mbo vectors using the order by clause given. It also compares other order by clauses.
    • Constructor Summary

      Constructors 
      Constructor and Description
      OrderBy()
      Default constructor takes no parameters.
      OrderBy(java.lang.String clause)
      Optional constructor takes a String for the initial order by.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int compare(java.lang.Object o1, java.lang.Object o2)
      Compares two Mbos using the order by clause given earlier.
      int compareTo(java.lang.Object o)
      Compares this OrderBy object to another object.
      java.lang.String getOrderBy()
      Returns the order by clause in standard form.
      boolean isEmpty()
      Tests to see if any order by has been defined.
      java.util.List orderMboList(java.util.List mboList)
      Reorders the list of Mbos using the order by set earlier.
      void setOrderBy(java.lang.String clause)
      Parses the order by clause and stores the information internally.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • OrderBy

        public OrderBy()
        Default constructor takes no parameters.
      • OrderBy

        public OrderBy(java.lang.String clause)
        Optional constructor takes a String for the initial order by.
        Parameters:
        clause -
    • Method Detail

      • setOrderBy

        public void setOrderBy(java.lang.String clause)
        Parses the order by clause and stores the information internally.
        Parameters:
        clause - The order by clause. Assumed to contain attribute names, commas, and optionally asc & desc tags. If null or the empty string, this order by is cleared.
        Throws:
        MXApplicationException - Thrown with "workorder", "OrderBy" if the clause can't be read
      • isEmpty

        public boolean isEmpty()
        Tests to see if any order by has been defined.
        Returns:
        true if there is no order by defined.
      • getOrderBy

        public java.lang.String getOrderBy()
        Returns the order by clause in standard form.
        Returns:
        The Order By clause. If no defined, the empty string will be returned.
      • orderMboList

        public java.util.List orderMboList(java.util.List mboList)
        Reorders the list of Mbos using the order by set earlier. If no order by was set, this does nothing.
      • compare

        public int compare(java.lang.Object o1,
                           java.lang.Object o2)
        Compares two Mbos using the order by clause given earlier. Depending on the order by given it likely that several Mbos will be found to be equal. The Mbo's Wonum attribute is used to tie-breaker in this case.
        Specified by:
        compare in interface java.util.Comparator
        Parameters:
        o1 - - the first object to be compared.
        o2 - - the second object to be compared.
        Returns:
        A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. This comparison will only return zero if o1 and o2 are the same object.
        Throws:
        java.lang.ClassCastException - if the objects aren't both Mbos.
      • compareTo

        public int compareTo(java.lang.Object o)
        Compares this OrderBy object to another object.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        o - The other object to compare to
        Returns:
        A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        java.lang.ClassCastException - Is thrown if the parameter is not a String, representing an order by clause or another OrderBy object.