- java.lang.Object
-
- swim.structure.Item
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Item
absent()
abstract void
alias()
abstract Item
and(Item that)
Record
appended(boolean item)
Record
appended(double item)
Record
appended(float item)
Record
appended(int item)
Record
appended(long item)
Record
appended(Object... items)
Record
appended(String item)
Record
appended(Item item)
abstract Item
bitwiseAnd(Item that)
abstract Item
bitwiseNot()
abstract Item
bitwiseOr(Item that)
abstract Item
bitwiseXor(Item that)
abstract Value
body()
abstract boolean
booleanValue()
Converts thisItem
into a primitiveboolean
value, if possible.abstract boolean
booleanValue(boolean orElse)
Converts thisItem
into a primitiveboolean
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveboolean
value.abstract Item
branch()
abstract byte
byteValue()
Converts thisItem
into a primitivebyte
value, if possible.abstract byte
byteValue(byte orElse)
Converts thisItem
into a primitivebyte
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivebyte
value.<T> T
cast(Form<T> form)
<T> T
cast(Form<T> form, T orElse)
abstract char
charValue()
Converts thisItem
into a primitivechar
value, if possible.abstract char
charValue(char orElse)
Converts thisItem
into a primitivechar
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivechar
value.<T> T
coerce(Form<T> form)
<T> T
coerce(Form<T> form, T orElse)
abstract Item
commit()
abstract int
compareTo(Item other)
Record
concat(Item that)
abstract Item
conditional(Item thenTerm, Item elseTerm)
abstract boolean
contains(Item item)
Returnstrue
if thisItem
is aRecord
that has a member equal toitem
; otherwise returnsfalse
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has no member equal toitem
.abstract boolean
containsKey(String key)
abstract boolean
containsKey(Value key)
abstract boolean
containsValue(Value value)
abstract <T> Output<T>
debug(Output<T> output)
Writes a developer readable, debug-formatted string representation of this object tooutput
.<T> Output<T>
display(Output<T> output)
Writes a human readable, display-formatted string representation of this object tooutput
.abstract Item
divide(Item that)
abstract double
doubleValue()
Converts thisItem
into a primitivedouble
value, if possible.abstract double
doubleValue(double orElse)
Converts thisItem
into a primitivedouble
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivedouble
value.static Item
empty()
Item
eq(Item that)
abstract boolean
equals(Object other)
Item
evaluate(Interpreter interpreter)
Item
evaluate(Item scope)
static Item
extant()
Selector
filter()
Selector
filter(Item predicate)
abstract Value
flattened()
Returns the sole member of thisItem
, if thisItem
is aRecord
with exactly one member, and its member is aValue
; returnsExtant
if thisItem
is an emptyRecord
; returnsAbsent
if thisItem
is aField
; otherwise returnsthis
if thisItem
is aRecord
with more than one member, or if thisItem
is a non-Record
Value
.abstract float
floatValue()
Converts thisItem
into a primitivefloat
value, if possible.abstract float
floatValue(float orElse)
Converts thisItem
into a primitivefloat
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivefloat
value.static Item
fromObject(Object object)
Item
ge(Item that)
abstract Value
get(String key)
abstract Value
get(Value key)
abstract Value
getAttr(String key)
abstract Value
getAttr(Text key)
abstract Field
getField(String key)
abstract Field
getField(Value key)
abstract Item
getItem(int index)
abstract Value
getSlot(String key)
abstract Value
getSlot(Value key)
static Item
globalScope()
Item
gt(Item that)
abstract int
hashCode()
abstract Item
head()
abstract Value
header(String tag)
Returns the value of the first member of thisItem
, if thisItem
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsAbsent
if thisItem
is not aRecord
, or if thisItem
is aRecord
whose first member is not anAttr
, or if thisItem
is aRecord
whose first member is anAttr
whosekey
does not equal thetag
.abstract Record
headers(String tag)
Returns theunflattened
header
of thisItem
, if thisItem
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsnull
.abstract BigInteger
integerValue()
Converts thisItem
into aBigInteger
value, if possible.abstract BigInteger
integerValue(BigInteger orElse)
Converts thisItem
into aBigInteger
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into aBigInteger
value.abstract int
intValue()
Converts thisItem
into a primitiveint
value, if possible.abstract int
intValue(int orElse)
Converts thisItem
into a primitiveint
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveint
value.abstract Item
inverse()
Item
invoke(Value args)
abstract boolean
isAliased()
abstract boolean
isConstant()
abstract boolean
isDefined()
abstract boolean
isDefinite()
Returnstrue
if thisItem
is not one of: an emptyRecord
,False
,Extant
, orAbsent
.abstract boolean
isDistinct()
abstract boolean
isMutable()
Iterator<Item>
iterator()
abstract Value
key()
abstract boolean
keyEquals(Object key)
abstract Value
lambda(Value template)
Item
le(Item that)
abstract int
length()
Returns the number of members contained in thisItem
, if thisItem
is aRecord
; otherwise returns0
if thisItem
is not aRecord
.abstract long
longValue()
Converts thisItem
into a primitivelong
value, if possible.abstract long
longValue(long orElse)
Converts thisItem
into a primitivelong
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivelong
value.Item
lt(Item that)
Item
max(Item that)
Item
min(Item that)
abstract Item
minus(Item that)
abstract Item
modulo(Item that)
Item
ne(Item that)
abstract Item
negative()
abstract Item
not()
abstract Number
numberValue()
Converts thisItem
into aNumber
object, if possible.abstract Number
numberValue(Number orElse)
Converts thisItem
into aNumber
object, if possible; otherwise returnsorElse
if thisItem
can't be converted into aNumber
object.abstract Item
or(Item that)
abstract Item
plus(Item that)
abstract Item
positive()
int
precedence()
Record
prepended(boolean item)
Record
prepended(double item)
Record
prepended(float item)
Record
prepended(int item)
Record
prepended(long item)
Record
prepended(Object... items)
Record
prepended(String item)
Record
prepended(Item item)
abstract Item
removed(String key)
abstract Item
removed(Value key)
abstract short
shortValue()
Converts thisItem
into a primitiveshort
value, if possible.abstract short
shortValue(short orElse)
Converts thisItem
into a primitiveshort
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveshort
value.abstract String
stringValue()
Converts thisItem
into aString
value, if possible.abstract String
stringValue(String orElse)
Converts thisItem
into aString
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into astring
value.Item
substitute(Interpreter interpreter)
Item
substitute(Item scope)
abstract String
tag()
abstract Record
tail()
Returns a view of all but the first member of thisItem
, if thisItem
is a non-emptyRecord
; otherwise returns an emptyRecord
if thisItem
is not aRecord
, or if thisItem
is itself an emptyRecord
.abstract Value
target()
abstract Item
times(Item that)
String
toString()
abstract Value
toValue()
Returns the value component of thisItem
, if thisItem
is aField
; otherwise returnsthis
if thisItem
is aValue
.abstract int
typeOrder()
Returns the heterogeneous sort order of thisItem
.abstract Record
unflattened()
Record
updated(String key, boolean value)
Record
updated(String key, double value)
Record
updated(String key, float value)
Record
updated(String key, int value)
Record
updated(String key, long value)
Record
updated(String key, String value)
Record
updated(String key, Value value)
Record
updated(Value key, boolean value)
Record
updated(Value key, double value)
Record
updated(Value key, float value)
Record
updated(Value key, int value)
Record
updated(Value key, long value)
Record
updated(Value key, String value)
Record
updated(Value key, Value value)
Record
updatedAttr(String key, boolean value)
Record
updatedAttr(String key, double value)
Record
updatedAttr(String key, float value)
Record
updatedAttr(String key, int value)
Record
updatedAttr(String key, long value)
Record
updatedAttr(String key, String value)
Record
updatedAttr(String key, Value value)
Record
updatedAttr(Text key, boolean value)
Record
updatedAttr(Text key, double value)
Record
updatedAttr(Text key, float value)
Record
updatedAttr(Text key, int value)
Record
updatedAttr(Text key, long value)
Record
updatedAttr(Text key, String value)
Record
updatedAttr(Text key, Value value)
Record
updatedSlot(String key, boolean value)
Record
updatedSlot(String key, double value)
Record
updatedSlot(String key, float value)
Record
updatedSlot(String key, int value)
Record
updatedSlot(String key, long value)
Record
updatedSlot(String key, String value)
Record
updatedSlot(String key, Value value)
Record
updatedSlot(Value key, boolean value)
Record
updatedSlot(Value key, double value)
Record
updatedSlot(Value key, float value)
Record
updatedSlot(Value key, int value)
Record
updatedSlot(Value key, long value)
Record
updatedSlot(Value key, String value)
Record
updatedSlot(Value key, Value value)
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
isDefined
public abstract boolean isDefined()
-
isDistinct
public abstract boolean isDistinct()
-
isDefinite
public abstract boolean isDefinite()
Returnstrue
if thisItem
is not one of: an emptyRecord
,False
,Extant
, orAbsent
.
-
isConstant
public abstract boolean isConstant()
-
key
public abstract Value key()
-
toValue
public abstract Value toValue()
Returns the value component of thisItem
, if thisItem
is aField
; otherwise returnsthis
if thisItem
is aValue
.
-
tag
public abstract String tag()
Returns thekey
string of the first member of thisItem
, if thisItem
is aRecord
, and its first member is anAttr
; otherwise returnsnull
if thisItem
is not aRecord
, or if thisItem
is aRecord
whose first member is not anAttr
.Used to concisely get the name of the discriminating attribute of a structure. The
tag
can be used to discern the nominal type of a polymorphic structure, similar to an XML element tag.
-
target
public abstract Value target()
Returns theflattened
members of thisItem
after all attributes have been removed, if thisItem
is aRecord
; otherwise returnsthis
if thisItem
is a non-Record
Value
, or returns the value component if thisItem
is aField
.Used to concisely get the scalar value of an attributed structure. An attributed structure is a
Record
with one or more attributes that modify one or more other members.
-
flattened
public abstract Value flattened()
Returns the sole member of thisItem
, if thisItem
is aRecord
with exactly one member, and its member is aValue
; returnsExtant
if thisItem
is an emptyRecord
; returnsAbsent
if thisItem
is aField
; otherwise returnsthis
if thisItem
is aRecord
with more than one member, or if thisItem
is a non-Record
Value
.Used to convert a unary
Record
into its memberValue
. Facilitates writing code that treats a unaryRecord
equivalently to a bareValue
.
-
unflattened
public abstract Record unflattened()
-
header
public abstract Value header(String tag)
Returns the value of the first member of thisItem
, if thisItem
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsAbsent
if thisItem
is not aRecord
, or if thisItem
is aRecord
whose first member is not anAttr
, or if thisItem
is aRecord
whose first member is anAttr
whosekey
does not equal thetag
.Used to conditionally get the value of the head
Attr
of a structure, if and only if the key string of the headAttr
is equal to thetag
. Can be used to check if a structure might conform to a nominal type namedtag
, while simultaneously getting the value of thetag
attribute.
-
headers
public abstract Record headers(String tag)
Returns theunflattened
header
of thisItem
, if thisItem
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsnull
.The
headers
of thetag
attribute of a structure are like the attributes of an XML element tag; through unlike an XML element,tag
attribute headers are not limited to string keys and values.
-
head
public abstract Item head()
-
tail
public abstract Record tail()
Returns a view of all but the first member of thisItem
, if thisItem
is a non-emptyRecord
; otherwise returns an emptyRecord
if thisItem
is not aRecord
, or if thisItem
is itself an emptyRecord
.
-
body
public abstract Value body()
-
length
public abstract int length()
Returns the number of members contained in thisItem
, if thisItem
is aRecord
; otherwise returns0
if thisItem
is not aRecord
.
-
contains
public abstract boolean contains(Item item)
Returnstrue
if thisItem
is aRecord
that has a member equal toitem
; otherwise returnsfalse
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has no member equal toitem
.
-
containsKey
public abstract boolean containsKey(Value key)
-
containsKey
public abstract boolean containsKey(String key)
Returnstrue
if thisItem
is aRecord
that has aField
with aText
key whose string value is equal to the givenkey
; otherwise returnsfalse
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent tocontainsKey(Value)
, but avoids boxing thekey
string into aText
value.
-
containsValue
public abstract boolean containsValue(Value value)
-
get
public abstract Value get(String key)
Returns the value of the lastField
member of thisItem
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent toget(Value)
, but avoids boxing thekey
string into aText
value.
-
getAttr
public abstract Value getAttr(String key)
Returns the value of the lastAttr
member of thisItem
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has noAttr
member with aText
key whose string value equals the givenkey
. Equivalent togetAttr(Text)
, but avoids boxing thekey
string into aText
value.
-
getSlot
public abstract Value getSlot(String key)
Returns the value of the lastSlot
member of thisItem
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has noSlot
member with aText
key whose string value equals the givenkey
. Equivalent togetSlot(Value)
, but avoids boxing thekey
string into aText
value.
-
getField
public abstract Field getField(String key)
Returns the lastField
member of thisItem
with aText
key whose string value is equal to the givenkey
; returnsnull
if thisItem
is not aRecord
, or if thisItem
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent togetField(Value)
, but avoids boxing thekey
string into aText
value.
-
getItem
public abstract Item getItem(int index)
-
appended
public Record appended(int item)
-
appended
public Record appended(long item)
-
appended
public Record appended(float item)
-
appended
public Record appended(double item)
-
appended
public Record appended(boolean item)
-
prepended
public Record prepended(int item)
-
prepended
public Record prepended(long item)
-
prepended
public Record prepended(float item)
-
prepended
public Record prepended(double item)
-
prepended
public Record prepended(boolean item)
-
not
public abstract Item not()
-
bitwiseNot
public abstract Item bitwiseNot()
-
negative
public abstract Item negative()
-
positive
public abstract Item positive()
-
inverse
public abstract Item inverse()
-
filter
public Selector filter()
-
evaluate
public Item evaluate(Interpreter interpreter)
-
substitute
public Item substitute(Interpreter interpreter)
-
stringValue
public abstract String stringValue()
Converts thisItem
into aString
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into aString
value.
-
stringValue
public abstract String stringValue(String orElse)
Converts thisItem
into aString
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into astring
value.
-
byteValue
public abstract byte byteValue()
Converts thisItem
into a primitivebyte
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitivebyte
value.
-
byteValue
public abstract byte byteValue(byte orElse)
Converts thisItem
into a primitivebyte
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivebyte
value.
-
shortValue
public abstract short shortValue()
Converts thisItem
into a primitiveshort
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitiveshort
value.
-
shortValue
public abstract short shortValue(short orElse)
Converts thisItem
into a primitiveshort
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveshort
value.
-
intValue
public abstract int intValue()
Converts thisItem
into a primitiveint
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitiveint
value.
-
intValue
public abstract int intValue(int orElse)
Converts thisItem
into a primitiveint
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveint
value.
-
longValue
public abstract long longValue()
Converts thisItem
into a primitivelong
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitivelong
value.
-
longValue
public abstract long longValue(long orElse)
Converts thisItem
into a primitivelong
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivelong
value.
-
floatValue
public abstract float floatValue()
Converts thisItem
into a primitivefloat
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitivefloat
value.
-
floatValue
public abstract float floatValue(float orElse)
Converts thisItem
into a primitivefloat
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivefloat
value.
-
doubleValue
public abstract double doubleValue()
Converts thisItem
into a primitivedouble
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitivedouble
value.
-
doubleValue
public abstract double doubleValue(double orElse)
Converts thisItem
into a primitivedouble
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivedouble
value.
-
integerValue
public abstract BigInteger integerValue()
Converts thisItem
into aBigInteger
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into aBigInteger
value.
-
integerValue
public abstract BigInteger integerValue(BigInteger orElse)
Converts thisItem
into aBigInteger
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into aBigInteger
value.
-
numberValue
public abstract Number numberValue()
Converts thisItem
into aNumber
object, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into aNumber
object.
-
numberValue
public abstract Number numberValue(Number orElse)
Converts thisItem
into aNumber
object, if possible; otherwise returnsorElse
if thisItem
can't be converted into aNumber
object.
-
charValue
public abstract char charValue()
Converts thisItem
into a primitivechar
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitivechar
value.
-
charValue
public abstract char charValue(char orElse)
Converts thisItem
into a primitivechar
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitivechar
value.
-
booleanValue
public abstract boolean booleanValue()
Converts thisItem
into a primitiveboolean
value, if possible.- Throws:
UnsupportedOperationException
- if thisItem
can't be converted into a primitiveboolean
value.
-
booleanValue
public abstract boolean booleanValue(boolean orElse)
Converts thisItem
into a primitiveboolean
value, if possible; otherwise returnsorElse
if thisItem
can't be converted into a primitiveboolean
value.
-
cast
public <T> T cast(Form<T> form)
-
cast
public <T> T cast(Form<T> form, T orElse)
-
coerce
public <T> T coerce(Form<T> form)
-
coerce
public <T> T coerce(Form<T> form, T orElse)
-
isAliased
public abstract boolean isAliased()
-
isMutable
public abstract boolean isMutable()
-
alias
public abstract void alias()
-
branch
public abstract Item branch()
-
commit
public abstract Item commit()
-
precedence
public int precedence()
-
typeOrder
public abstract int typeOrder()
Returns the heterogeneous sort order of thisItem
. Used to impose a total order on the set of all items. When comparing two items of different types, the items order according to theirtypeOrder
.
-
compareTo
public abstract int compareTo(Item other)
- Specified by:
compareTo
in interfaceComparable<Item>
-
keyEquals
public abstract boolean keyEquals(Object key)
-
debug
public abstract <T> Output<T> debug(Output<T> output)
Description copied from interface:Debug
Writes a developer readable, debug-formatted string representation of this object tooutput
.
-
display
public <T> Output<T> display(Output<T> output)
Description copied from interface:Display
Writes a human readable, display-formatted string representation of this object tooutput
.
-
empty
public static Item empty()
-
extant
public static Item extant()
-
absent
public static Item absent()
-
globalScope
public static Item globalScope()
-
-