org.hd.d.pg2k.webSvr.exhibit
Class SortExpr

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.exhibit.Expr
      extended by org.hd.d.pg2k.webSvr.exhibit.SortExpr
All Implemented Interfaces:
java.io.Serializable

public final class SortExpr
extends Expr
implements java.io.Serializable

Wraps a sorter to make an expression (for a FilterBean). Sorters must be Serializable so that expressions can be persisted. They must not attempt to cache any reference, direct or indirect, to a DataSourceBean.

Sorter objects must be immutable and the sort() method must be idempotent.

TODO: do object validation on deserialisation

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
private  SortIF sorter
          The sort we apply here; never null.
 
Constructor Summary
SortExpr(Expr _upstream, SortIF _sorter)
          Construct us with the upstream expression.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality depends on underlying expression and this sorter.
 Name.ExhibitFull[] eval(AllExhibitProperties aep, Name.ExhibitFull[] in)
          Evaluate this expression applying our sort.
 int hashCode()
          Hash depends on underlying expression and this sorter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sorter

private final SortIF sorter
The sort we apply here; never null.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

SortExpr

public SortExpr(Expr _upstream,
                SortIF _sorter)
Construct us with the upstream expression. If the upstream expression is null this is the first element in the expression pipeline.

Method Detail

eval

public Name.ExhibitFull[] eval(AllExhibitProperties aep,
                               Name.ExhibitFull[] in)
Evaluate this expression applying our sort. Given the upstream expression, compute its results and then compute ours on it.

We return a set of names, possibly empty.

The result array contains no duplicates nor nulls (providing the input is similarly well-behaved) and is never null itself.

Designed to be overridden and have super() called to collect upstream results... By itself returns all the exhibits untouched, ie is a null filter/sorter.

The result may be the input array sorted in place to avoid copying, or may be a new array possibly smaller than the input array; this may perform filtering or other operations that needs to operate on the whole (current) set of exhibits at once.

Overrides:
eval in class Expr

hashCode

public int hashCode()
Hash depends on underlying expression and this sorter.

Overrides:
hashCode in class Expr

equals

public boolean equals(java.lang.Object obj)
Equality depends on underlying expression and this sorter.

Overrides:
equals in class Expr

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.