Class ADataFn<T extends ACell>

Type Parameters:
T - Type of function return value
All Implemented Interfaces:
IValidated, IWriteable, IFn<T>
Direct Known Subclasses:
KeywordFn, MapFn, SeqFn, SetFn

public abstract class ADataFn<T extends ACell> extends AFn<T>
Abstract base class for data structure lookup functions. Not a canonical object, can't exist as CVM value.
  • Constructor Details

    • ADataFn

      public ADataFn()
  • Method Details

    • estimatedEncodingSize

      public int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.
      Returns:
      The estimated size for the binary representation of this object.
    • invoke

      public Context<T> invoke(Context<ACell> context, ACell[] args)
      Description copied from interface: IFn
      Invoke this function in the given context.
      Specified by:
      invoke in interface IFn<T extends ACell>
      Specified by:
      invoke in class AFn<T extends ACell>
      Parameters:
      context - Context in which the function is to be executed
      args - Arguments to the function
      Returns:
      Context containing result of function invocation, or an exceptional value
    • updateRefs

      public AFn<T> updateRefs(IRefFunction func)
      Description copied from class: ACell
      Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.
      Specified by:
      updateRefs in class AFn<T extends ACell>
      Parameters:
      func - Ref update function
      Returns:
      Cell with updated Refs
    • hasArity

      public boolean hasArity(int n)
      Description copied from class: AFn
      Tests if this function supports the given arity.
      Specified by:
      hasArity in class AFn<T extends ACell>
      Parameters:
      n - Arity to check
      Returns:
      true if function supports the given arity, false otherwise
    • validateCell

      public void validateCell() throws InvalidDataException
      Description copied from class: ACell
      Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.
      Specified by:
      validateCell in class ACell
      Throws:
      InvalidDataException - If the Cell is invalid
    • encode

      public int encode(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, including a tag byte which will be written first
      Specified by:
      encode in interface IWriteable
      Specified by:
      encode in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • encodeRaw

      public int encodeRaw(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, excluding the tag byte
      Specified by:
      encodeRaw in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • isCanonical

      public boolean isCanonical()
      Description copied from class: ACell
      Returns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.
      Specified by:
      isCanonical in class ACell
      Returns:
      true if the object is in canonical format, false otherwise
    • toCanonical

      public ACell toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Returns this if already canonical
      Specified by:
      toCanonical in class ACell
      Returns:
      Canonical version of Cell
    • isCVMValue

      public boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures
      Overrides:
      isCVMValue in class AFn<T extends ACell>
      Returns:
      true if the object is a CVM Value, false otherwise
    • getTag

      public byte getTag()
      Description copied from class: ACell
      Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding
      Overrides:
      getTag in class AFn<T extends ACell>
      Returns:
      Tag byte for this Cell
    • getRefCount

      public int getRefCount()
      Description copied from class: ACell
      Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance. Contained Refs may be either external or embedded.
      Specified by:
      getRefCount in class ACell
      Returns:
      The number of Refs in this Cell