package topher; /** * Simplistic Database with one view (selection) sorted by a list of * attributes (sortCriteria) and filtered by a list of "attribute-value- * assertions" (filter). Each of these is a pair of an attribute and a list * of values. * When applied to an object the filter is considered true if the object's * value for that attribute is in the list or if the list is empty. */ public class DB { public attribute extent: **; // ** means "zero or more of any" // the first asterisk is the "wildcard" type, // the second is the cardinality specifier public attribute sortCriteria: Attribute*; public attribute selection: **; public attribute filter: AttributeValueAssertion*; private function applyFilter(obj):Boolean; } function DB.applyFilter(obj) = not (false in (select f.evaluate(obj) from f in filter)); attribute DB.selection = bind extent[x|this.applyFilter(x)] order by select obj[a] from a in sortCriteria, obj in .;