java.lang.Object
swim.structure.Item
swim.structure.Value
swim.structure.Expression
swim.structure.Selector
- All Implemented Interfaces:
Comparable<Item>,Iterable<Item>,swim.codec.Debug,swim.codec.Display
- Direct Known Subclasses:
ChildrenSelector,DescendantsSelector,FilterSelector,GetAttrSelector,GetItemSelector,GetSelector,IdentitySelector,KeysSelector,LiteralSelector,ValuesSelector
A composable
Expression that returns references to Items when
it is evaluated, providing a foundation on top of which
expression languages may be built.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SelectorThe means to chainSelectors.children()intprotected abstract int<T> swim.codec.Output<T>debug(swim.codec.Output<T> output) abstract <T> swim.codec.Output<T>debugThen(swim.codec.Output<T> output) final Itemevaluate(Interpreter interpreter) Evaluates thisSelectoragainst someInterpreter.filter()abstract <T> TforSelected(Interpreter interpreter, Selectee<T> callback) getItem(int index) static Selectoridentity()Creates, but does not evaluate, anInvokeOperatorwhere thisSelectorevaluates to the operator.booleankeys()static Selectorabstract ItemmapSelected(Interpreter interpreter, Selectee<Item> transform) intabstract Selectorthen()Returns theSelectorthat thisSelectoruses to match sub-selections.values()Methods inherited from class swim.structure.Expression
and, and, bitwiseAnd, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseOr, bitwiseXor, bitwiseXor, conditional, conditional, divide, divide, eq, eq, ge, ge, gt, gt, inverse, le, le, lt, lt, minus, minus, modulo, modulo, ne, ne, negative, not, or, or, plus, plus, positive, times, timesMethods inherited from class swim.structure.Value
absent, alias, body, booleanValue, booleanValue, branch, builder, byteValue, byteValue, charValue, charValue, commit, contains, containsKey, containsKey, containsValue, doubleValue, doubleValue, empty, extant, flattened, floatValue, floatValue, fromObject, getField, getField, getSlot, getSlot, head, header, headers, integerValue, integerValue, intValue, intValue, isAliased, isDefined, isDefinite, isDistinct, isMutable, key, keyEquals, lambda, length, longValue, longValue, numberValue, numberValue, removed, removed, shortValue, shortValue, stringValue, stringValue, tag, tail, target, toValue, unflattenedMethods inherited from class swim.structure.Item
appended, appended, appended, appended, appended, appended, appended, appended, cast, cast, coerce, coerce, concat, display, equals, evaluate, globalScope, hashCode, iterator, max, min, prepended, prepended, prepended, prepended, prepended, prepended, prepended, prepended, substitute, substitute, toString, typeOrder, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlotMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Selector
public Selector()
-
-
Method Details
-
isConstant
public boolean isConstant()Description copied from class:Item- Specified by:
isConstantin classItem
-
then
Returns theSelectorthat thisSelectoruses to match sub-selections. -
forSelected
Evaluatescallback.selectedagainst theItemsthat match thisSelector'sselection criteria. That is, it pushes suchItemstointerpreter, then invokescallbackagainst it. To support chainedSelectors, this is a recursive procedure that invokesforSelectedthroughthis.thenwherever it exists (which it always does outside ofIdentitySelector); we define "subselection" to be such an invocation.- Returns:
- the result of executing
callbackfrom the context of the lastSelectorin the chain formed bySelector thenfields.
-
mapSelected
-
evaluate
Evaluates thisSelectoragainst someInterpreter. This is accomplished by creating a newSelecteeBuilderand populating its internalRecordwith (recursive) calls toforSelected(swim.structure.Interpreter, swim.structure.Selectee<T>). -
andThen
The means to chainSelectors.By design, this is not a strict functional composition. For two
Selectorss1ands2,s1.andThen(s2)does not necessarily return a newSelectors3such thats3.evaluate(args)is equivalent tos2.evaluate(s1.evaluate(args)).The reason for this is that for result set yielding
Selectors(e.g.ChildrenSelector), we wish to invoke thethenagainst every result. Under strict functional rules,ChildrenSelector#andThen(getSelector).evaluate(args)would instead return at most one defined value regardless of the number of children. -
get
-
get
-
getAttr
-
getAttr
-
getItem
- Parameters:
index- theindexfield in the composingGetItemSelector.
-
getItem
-
keys
-
values
-
children
-
descendants
-
filter
-
filter
-
invoke
Creates, but does not evaluate, anInvokeOperatorwhere thisSelectorevaluates to the operator. -
precedence
public int precedence()- Overrides:
precedencein classItem
-
debug
public <T> swim.codec.Output<T> debug(swim.codec.Output<T> output) -
debugThen
public abstract <T> swim.codec.Output<T> debugThen(swim.codec.Output<T> output) -
compareTo
- Specified by:
compareToin interfaceComparable<Item>- Specified by:
compareToin classItem
-
compareTo
-
identity
-
literal
-