- java.lang.Object
-
- swim.structure.Item
-
- swim.structure.Value
-
- swim.structure.Record
-
- All Implemented Interfaces:
Comparable<Item>,Iterable<Item>,Collection<Item>,List<Item>,Debug,Display,Builder<Item,Record>,PairBuilder<Value,Value,Record>
- Direct Known Subclasses:
AbstractRecordOutlet,RecordStreamlet
public abstract class Record extends Value implements List<Item>, Builder<Item,Record>, PairBuilder<Value,Value,Record>
-
-
Constructor Summary
Constructors Constructor Description Record()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanadd(boolean item)booleanadd(double item)booleanadd(float item)booleanadd(int item)voidadd(int index, boolean item)voidadd(int index, double item)voidadd(int index, float item)voidadd(int index, int item)voidadd(int index, long item)voidadd(int index, String item)abstract voidadd(int index, Item item)booleanadd(long item)booleanadd(String item)abstract booleanadd(Item item)Adds a single input value to this builder, returningtrueif the state of the builder changed.booleanadd(Value key, Value value)Adds an input pair to this builder, returningtrueif the state of the builder changed.booleanaddAll(int index, Collection<? extends Item> items)booleanaddAll(Collection<? extends Item> items)Adds multiple input values to this builder, returningtrueif the state of the builder changed.voidalias()Recordappended(Object... items)Recordappended(Item item)RecordasMutable()Recordattr(String key)Recordattr(String key, boolean value)Recordattr(String key, double value)Recordattr(String key, float value)Recordattr(String key, int value)Recordattr(String key, long value)Recordattr(String key, String value)Recordattr(String key, Value value)Recordattr(Text key)Recordattr(Text key, boolean value)Recordattr(Text key, double value)Recordattr(Text key, float value)Recordattr(Text key, int value)Recordattr(Text key, long value)Recordattr(Text key, String value)Recordattr(Text key, Value value)Recordbind()Returns the output result of this builder.Valuebody()Recordbranch()abstract voidclear()Recordcommit()intcompareTo(Item other)intcompareTo(Record that)Recordconcat(Item that)booleancontains(Object item)Returnstrueif thisRecordhas a member equal toItem.fromObject(item); otherwise returnsfalseif thisRecordhas no member equal toItem.fromObject(item).booleancontains(Item item)Returnstrueif thisRecordhas a member equal toitem; otherwise returnsfalseif thisRecordhas no member equal toitem.booleancontainsAll(Collection<?> items)Returnstrueif thisRecordhas a member equal to every item initems; returnsfalseif any item initemsis not contained in thisRecord.booleancontainsKey(String key)Returnstrueif thisRecordhas aFieldmember with a key that is equal to the givenkey; otherwise returnsfalseif thisRecordhas noFieldmember with a key equal to the givenkey.booleancontainsKey(Value key)Returnstrueif thisRecordhas aFieldmember with a key that is equal to the givenkey; otherwise returnsfalseif thisRecordhas noFieldmember with a key equal to the givenkey.booleancontainsValue(Value value)Returnstrueif thisRecordhas aFieldmember with a value that is equal to the givenvalue; otherwise returnsfalseif thisRecordhas noFieldmember with a value equal to the givenvalue.static Recordcreate()static Recordcreate(int initialSize)<T> Output<T>debug(Output<T> output)Writes a developer readable, debug-formatted string representation of this object tooutput.static Recordempty()Set<Map.Entry<Value,Value>>entrySet()booleanequals(Object other)Recordevaluate(Interpreter interpreter)intfieldCount()Returns the number ofFieldmembers contained in thisRecord.Iterator<Field>fieldIterator()Set<Field>fieldSet()Valueflattened()Returns the sole member of thisRecord, if thisRecordhas exactly one member, and its member is aValue; returnsExtantif thisRecordis empty; otherwise returnsthisif thisRecordhas more than one member.abstract Itemget(int index)Returns the member of thisRecordat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.Valueget(String key)Valueget(Value key)ValuegetAttr(String key)ValuegetAttr(Text key)FieldgetField(String key)Returns the lastFieldmember of thisRecordwhose key is equal to the givenkey; returnsnullif thisRecordhas noFieldmember with akeyequal to the givenkey.FieldgetField(Value key)Returns the lastFieldmember of thisRecordwhose key is equal to the givenkey; returnsnullif thisRecordhas noFieldmember with akeyequal to the givenkey.abstract ItemgetItem(int index)ValuegetSlot(String key)ValuegetSlot(Value key)inthashCode()Itemhead()Valueheader(String tag)Recordheaders(String tag)intindexOf(Object item)booleanisAliased()booleanisArray()booleanisConstant()booleanisDefinite()Returnstrueif thisValueis not one of: an emptyRecord,False,Extant, orAbsent.abstract booleanisEmpty()Returnstrueif thisRecordhas no members.booleanisMutable()booleanisObject()Recorditem(boolean item)Recorditem(double item)Recorditem(float item)Recorditem(int item)Recorditem(long item)Recorditem(String item)Recorditem(Item item)Iterator<Item>iterator()Iterator<Value>keyIterator()Set<Value>keySet()intlastIndexOf(Object item)intlength()Returns the number of members contained in thisRecord; equivalent tosize().ListIterator<Item>listIterator()ListIterator<Item>listIterator(int index)static Recordof()static Recordof(Object object)static Recordof(Object... objects)Recordprepended(Object... items)Recordprepended(Item item)Valueput(String key, boolean newValue)Valueput(String key, double newValue)Valueput(String key, float newValue)Valueput(String key, int newValue)Valueput(String key, long newValue)Valueput(String key, String newValue)Valueput(String key, Value newValue)Valueput(Value key, boolean newValue)Valueput(Value key, double newValue)Valueput(Value key, float newValue)Valueput(Value key, int newValue)Valueput(Value key, long newValue)Valueput(Value key, String newValue)Valueput(Value key, Value newValue)voidputAll(Map<? extends Value,? extends Value> fields)ValueputAttr(String key, boolean newValue)ValueputAttr(String key, double newValue)ValueputAttr(String key, float newValue)ValueputAttr(String key, int newValue)ValueputAttr(String key, long newValue)ValueputAttr(String key, String newValue)ValueputAttr(String key, Value newValue)ValueputAttr(Text key, boolean newValue)ValueputAttr(Text key, double newValue)ValueputAttr(Text key, float newValue)ValueputAttr(Text key, int newValue)ValueputAttr(Text key, long newValue)ValueputAttr(Text key, String newValue)ValueputAttr(Text key, Value newValue)ValueputSlot(String key, boolean newValue)ValueputSlot(String key, double newValue)ValueputSlot(String key, float newValue)ValueputSlot(String key, int newValue)ValueputSlot(String key, long newValue)ValueputSlot(String key, String newValue)ValueputSlot(String key, Value newValue)ValueputSlot(Value key, boolean newValue)ValueputSlot(Value key, double newValue)ValueputSlot(Value key, float newValue)ValueputSlot(Value key, int newValue)ValueputSlot(Value key, long newValue)ValueputSlot(Value key, String newValue)ValueputSlot(Value key, Value newValue)abstract Itemremove(int index)booleanremove(Object object)booleanremoveAll(Collection<?> items)Recordremoved(String key)Recordremoved(Value key)booleanremoveKey(String key)booleanremoveKey(Value key)booleanretainAll(Collection<?> items)Itemset(int index, Item item)Replaces the member of thisRecordat the givenindexwith a newitem, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.ItemsetItem(int index, boolean value)ItemsetItem(int index, double value)ItemsetItem(int index, float value)ItemsetItem(int index, int value)ItemsetItem(int index, long value)ItemsetItem(int index, String value)abstract ItemsetItem(int index, Item item)Replaces the member of thisRecordat the givenindexwith a newitem, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.abstract intsize()Returns the number of members contained in thisRecord.Recordslot(String key)Recordslot(String key, boolean value)Recordslot(String key, double value)Recordslot(String key, float value)Recordslot(String key, int value)Recordslot(String key, long value)Recordslot(String key, String value)Recordslot(String key, Value value)Recordslot(Value key)Recordslot(Value key, boolean value)Recordslot(Value key, double value)Recordslot(Value key, float value)Recordslot(Value key, int value)Recordslot(Value key, long value)Recordslot(Value key, String value)Recordslot(Value key, Value value)StringstringValue()Converts thisValueinto aStringvalue, if possible.StringstringValue(String orElse)Converts thisValueinto aStringvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into astringvalue.RecordsubList(int fromIndex, int toIndex)Recordsubstitute(Interpreter interpreter)Stringtag()Returns thekeystring of the first member of thisRecord, if the first member is anAttr; otherwise returnsnullif the first member is not anAttr.Recordtail()Returns a view of all but the first member of thisRecord, if thisRecordis non-empty; otherwise returns an emptyRecord, if thisRecordis itself empty.Valuetarget()Returns theflattenedmembers of thisRecordafter all attributes have been removed.Item[]toArray()<T> T[]toArray(T[] array)inttypeOrder()Returns the heterogeneous sort order of thisItem.Recordunflattened()ReturnsthisRecord.Recordupdated(String key, Value value)Recordupdated(Value key, Value value)RecordupdatedAttr(String key, Value value)RecordupdatedAttr(Text key, Value value)RecordupdatedSlot(String key, Value value)RecordupdatedSlot(Value key, Value value)intvalueCount()Returns the number ofValuemembers contained in thisRecord.Iterator<Value>valueIterator()Collection<Value>values()-
Methods inherited from class swim.structure.Value
absent, and, and, bitwiseAnd, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseOr, bitwiseXor, bitwiseXor, booleanValue, booleanValue, builder, byteValue, byteValue, charValue, charValue, conditional, conditional, divide, divide, doubleValue, doubleValue, eq, eq, extant, floatValue, floatValue, fromObject, ge, ge, gt, gt, integerValue, integerValue, intValue, intValue, inverse, isDefined, isDistinct, key, keyEquals, lambda, le, le, longValue, longValue, lt, lt, minus, minus, modulo, modulo, ne, ne, negative, not, numberValue, numberValue, or, or, plus, plus, positive, shortValue, shortValue, times, times, toValue
-
Methods inherited from class swim.structure.Item
appended, appended, appended, appended, appended, appended, cast, cast, coerce, coerce, display, evaluate, filter, filter, globalScope, invoke, max, min, precedence, prepended, prepended, prepended, prepended, prepended, prepended, substitute, toString, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Method Detail
-
isDefinite
public boolean isDefinite()
Description copied from class:ValueReturnstrueif thisValueis not one of: an emptyRecord,False,Extant, orAbsent.- Overrides:
isDefinitein classValue
-
isEmpty
public abstract boolean isEmpty()
Returnstrueif thisRecordhas no members.
-
isArray
public boolean isArray()
-
isObject
public boolean isObject()
-
size
public abstract int size()
Returns the number of members contained in thisRecord.
-
length
public final int length()
Returns the number of members contained in thisRecord; equivalent tosize().
-
fieldCount
public int fieldCount()
Returns the number ofFieldmembers contained in thisRecord.
-
valueCount
public int valueCount()
Returns the number ofValuemembers contained in thisRecord.
-
isConstant
public boolean isConstant()
Description copied from class:Item- Specified by:
isConstantin classItem
-
tag
public String tag()
Returns thekeystring of the first member of thisRecord, if the first member is anAttr; otherwise returnsnullif the first member is not anAttr.Used to concisely get the name of the discriminating attribute of a structure. The
tagcan be used to discern the nominal type of a polymorphic structure, similar to an XML element tag.
-
target
public Value target()
Returns theflattenedmembers of thisRecordafter all attributes have been removed.Used to concisely get the scalar value of an attributed structure. An attributed structure is a
Recordwith one or more attributes that modify one or more other members.
-
flattened
public Value flattened()
Returns the sole member of thisRecord, if thisRecordhas exactly one member, and its member is aValue; returnsExtantif thisRecordis empty; otherwise returnsthisif thisRecordhas more than one member.Used to convert a unary
Recordinto its memberValue. Facilitates writing code that treats a unaryRecordequivalently to a bareValue.
-
unflattened
public Record unflattened()
ReturnsthisRecord.- Overrides:
unflattenedin classValue
-
header
public Value header(String tag)
Returns the value of the first member of thisRecord, if the first member is anAttrwhosekeystring is equal totag; otherwise returnsAbsentif the first member of thisRecordis not anAttr, or if the first member of thisRecordis anAttrwhosekeydoes not equal thetag.Used to conditionally get the value of the head
Attrof a structure, if and only if the key string of the headAttris equal to thetag. Can be used to check if a structure might conform to a nominal type namedtag, while simultaneously getting the value of thetagattribute.
-
headers
public Record headers(String tag)
Returns theunflattenedheaderof thisRecord. Theheadersof thetagattribute of a structure are like the attributes of an XML element tag; through unlike an XML element,tagattribute headers are not limited to string keys and values.
-
tail
public Record tail()
Returns a view of all but the first member of thisRecord, if thisRecordis non-empty; otherwise returns an emptyRecord, if thisRecordis itself empty.
-
body
public Value body()
-
contains
public boolean contains(Object item)
Returnstrueif thisRecordhas a member equal toItem.fromObject(item); otherwise returnsfalseif thisRecordhas no member equal toItem.fromObject(item).
-
contains
public boolean contains(Item item)
Returnstrueif thisRecordhas a member equal toitem; otherwise returnsfalseif thisRecordhas no member equal toitem.
-
containsAll
public boolean containsAll(Collection<?> items)
Returnstrueif thisRecordhas a member equal to every item initems; returnsfalseif any item initemsis not contained in thisRecord.- Specified by:
containsAllin interfaceCollection<Item>- Specified by:
containsAllin interfaceList<Item>
-
containsKey
public boolean containsKey(Value key)
Returnstrueif thisRecordhas aFieldmember with a key that is equal to the givenkey; otherwise returnsfalseif thisRecordhas noFieldmember with a key equal to the givenkey.- Overrides:
containsKeyin classValue
-
containsKey
public boolean containsKey(String key)
Returnstrueif thisRecordhas aFieldmember with a key that is equal to the givenkey; otherwise returnsfalseif thisRecordhas noFieldmember with a key equal to the givenkey. Equivalent tocontainsKey(Value), but avoids boxing thekeystring into aTextvalue.- Overrides:
containsKeyin classValue
-
containsValue
public boolean containsValue(Value value)
Returnstrueif thisRecordhas aFieldmember with a value that is equal to the givenvalue; otherwise returnsfalseif thisRecordhas noFieldmember with a value equal to the givenvalue.- Overrides:
containsValuein classValue
-
lastIndexOf
public int lastIndexOf(Object item)
- Specified by:
lastIndexOfin interfaceList<Item>
-
get
public Value get(String key)
Returns the value of the lastFieldmember of thisRecordwhose key is equal to the givenkey; returnsAbsentif thisRecordhas noFieldmember with a key equal to the givenkey. Equivalent toget(Value), but avoids boxing thekeystring into aTextvalue.
-
getAttr
public Value getAttr(String key)
Returns the value of the lastAttrmember of thisRecordwhose key is equal to the givenkey; returnsAbsentif thisRecordhas noAttrmember with a key equal to the givenkey. Equivalent togetAttr(Text), but avoids boxing thekeystring into aTextvalue.
-
getSlot
public Value getSlot(String key)
Returns the value of the lastSlotmember of thisRecordwhose key is equal to the givenkey; returnsAbsentif thisRecordhas noSlotmember with a key equal to the givenkey. Equivalent togetSlot(Value), but avoids boxing thekeystring into aTextvalue.
-
getField
public Field getField(Value key)
Returns the lastFieldmember of thisRecordwhose key is equal to the givenkey; returnsnullif thisRecordhas noFieldmember with akeyequal to the givenkey.
-
getField
public Field getField(String key)
Returns the lastFieldmember of thisRecordwhose key is equal to the givenkey; returnsnullif thisRecordhas noFieldmember with akeyequal to the givenkey. Equivalent togetField(Value), but avoids boxing thekeystring into aTextvalue.
-
get
public abstract Item get(int index)
Returns the member of thisRecordat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Specified by:
getin interfaceList<Item>- Throws:
IndexOutOfBoundsException- if theindexis out of bounds.
-
getItem
public abstract Item getItem(int index)
-
set
public Item set(int index, Item item)
Replaces the member of thisRecordat the givenindexwith a newitem, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord. Equivalent tosetItem(int, Item).- Specified by:
setin interfaceList<Item>- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public abstract Item setItem(int index, Item item)
Replaces the member of thisRecordat the givenindexwith a newitem, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, String value)
Replaces the member of thisRecordat the givenindexwith aTextvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, int value)
Replaces the member of thisRecordat the givenindexwith aNumvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, long value)
Replaces the member of thisRecordat the givenindexwith aNumvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, float value)
Replaces the member of thisRecordat the givenindexwith aNumvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, double value)
Replaces the member of thisRecordat the givenindexwith aNumvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
setItem
public Item setItem(int index, boolean value)
Replaces the member of thisRecordat the givenindexwith aBoolvalue, returning the previousItemat the givenindex, if theindexis greater than or equal to zero, and less than thelengthof thisRecord.- Throws:
UnsupportedOperationException- if this is an immutableRecord.IndexOutOfBoundsException- if theindexis out of bounds.
-
add
public abstract boolean add(Item item)
Description copied from interface:BuilderAdds a single input value to this builder, returningtrueif the state of the builder changed.
-
add
public boolean add(String item)
-
add
public boolean add(int item)
-
add
public boolean add(long item)
-
add
public boolean add(float item)
-
add
public boolean add(double item)
-
add
public boolean add(boolean item)
-
add
public void add(int index, String item)
-
add
public void add(int index, int item)
-
add
public void add(int index, long item)
-
add
public void add(int index, float item)
-
add
public void add(int index, double item)
-
add
public void add(int index, boolean item)
-
add
public boolean add(Value key, Value value)
Description copied from interface:PairBuilderAdds an input pair to this builder, returningtrueif the state of the builder changed.- Specified by:
addin interfacePairBuilder<Value,Value,Record>
-
addAll
public boolean addAll(Collection<? extends Item> items)
Description copied from interface:BuilderAdds multiple input values to this builder, returningtrueif the state of the builder changed.
-
addAll
public boolean addAll(int index, Collection<? extends Item> items)
-
item
public Record item(int item)
-
item
public Record item(long item)
-
item
public Record item(float item)
-
item
public Record item(double item)
-
item
public Record item(boolean item)
-
remove
public boolean remove(Object object)
-
removeKey
public boolean removeKey(Value key)
-
removeKey
public boolean removeKey(String key)
-
removeAll
public boolean removeAll(Collection<?> items)
-
retainAll
public boolean retainAll(Collection<?> items)
-
clear
public abstract void clear()
-
updatedAttr
public Record updatedAttr(Text key, Value value)
- Overrides:
updatedAttrin classItem
-
updatedAttr
public Record updatedAttr(String key, Value value)
- Overrides:
updatedAttrin classItem
-
updatedSlot
public Record updatedSlot(Value key, Value value)
- Overrides:
updatedSlotin classItem
-
updatedSlot
public Record updatedSlot(String key, Value value)
- Overrides:
updatedSlotin classItem
-
evaluate
public Record evaluate(Interpreter interpreter)
-
substitute
public Record substitute(Interpreter interpreter)
- Overrides:
substitutein classItem
-
stringValue
public String stringValue()
Description copied from class:ValueConverts thisValueinto aStringvalue, if possible.- Overrides:
stringValuein classValue
-
stringValue
public String stringValue(String orElse)
Description copied from class:ValueConverts thisValueinto aStringvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into astringvalue.- Overrides:
stringValuein classValue
-
asMutable
public Record asMutable()
-
bind
public Record bind()
Description copied from interface:BuilderReturns the output result of this builder.
-
toArray
public Item[] toArray()
-
toArray
public <T> T[] toArray(T[] array)
-
subList
public Record subList(int fromIndex, int toIndex)
-
values
public Collection<Value> values()
-
listIterator
public ListIterator<Item> listIterator()
- Specified by:
listIteratorin interfaceList<Item>
-
listIterator
public ListIterator<Item> listIterator(int index)
- Specified by:
listIteratorin interfaceList<Item>
-
typeOrder
public int typeOrder()
Description copied from class:ItemReturns 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 int compareTo(Item other)
- Specified by:
compareToin interfaceComparable<Item>- Specified by:
compareToin classItem
-
compareTo
public int compareTo(Record that)
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
debug
public <T> Output<T> debug(Output<T> output)
Description copied from interface:DebugWrites a developer readable, debug-formatted string representation of this object tooutput.
-
empty
public static Record empty()
-
create
public static Record create()
-
create
public static Record create(int initialSize)
-
of
public static Record of()
-
-