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

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

public abstract class Expr
extends java.lang.Object
implements java.io.Serializable

Abstract base for an expression (for a FilterBean). Expressions must be Serializable so that they can be persisted. They must not attempt to cache any reference, direct or indirect, to a DataSourceBean.

Expression objects must be immutable and their accept()/sort() methods must be idempotent.

Expressions may be nested like this:

 new SortExpr(new FilterExpr(null, new BuiltInFilters.filtAll(null)),
              new BuiltInFilters.sortByName(BuiltInFilters.sortByName.SMART))
 

Operations such as filtering and sorting may be carried out concurrently internally, so filters and sorts should be thread-safe and should preferably admit concurrency if possible.

FIXME: this and all derived classes and expressions must support equals() and hashCode() where possible.

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
private  Expr upstream
          The upstream expression pipeline.
 
Constructor Summary
protected Expr(Expr _upstream)
          Construct us with the upstream expression.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality depends on the upstream expressions being equal (or both null).
 Name.ExhibitFull[] eval(AllExhibitProperties aep, Name.ExhibitFull[] in)
          Evaluate this expression.
 int hashCode()
          Hash depends on upstream object, or is zero if none.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

upstream

private final Expr upstream
The upstream expression pipeline.


serialVersionUID

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

See Also:
Constant Field Values
Constructor Detail

Expr

protected Expr(Expr _upstream)
Construct us with the upstream expression. If the upstream expression is null then we are the head of the expression chain and process the input first.

Method Detail

eval

public Name.ExhibitFull[] eval(AllExhibitProperties aep,
                               Name.ExhibitFull[] in)
Evaluate this expression. 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 identity expression.

The head of the expression chain takes a copy of the inputs and returns them; other items just pass the data up untouched.


hashCode

public int hashCode()
Hash depends on upstream object, or is zero if none.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Equality depends on the upstream expressions being equal (or both null). This does not return true unless the structure is the same and all elements are the same.

Overrides:
equals in class java.lang.Object

DHD Multimedia Gallery V1.57.21

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