Package convex.core.data
Class ASymbolic
- All Implemented Interfaces:
IValidated,IWriteable,Comparable<ABlobLike<?>>
Abstract based class for symbolic objects (Keywords, Symbols)
-
Field Summary
FieldsFields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbytebyteAt(long i) Gets the byte at the specified position.protected longCalculates the Memory Size for this Cell.longcount()Returns the number of elements in this valueCreates a new Ref for this Cellempty()Returns a canonical, singleton empty instance of the same type as this Countable value.booleanequalsBytes(ABlob b) Compare the byte content of this BlobLike to a Blob valuefinal intEstimate the encoded data size for this Cell.get(long index) Gets the element at the specified element index in this valueintgetBytes(byte[] dest, int destOffset) Copies the bytes from this instance to a given destination arraygetElementRef(long index) Gets a Ref to the element at the specified element index in this collectionfinal StringShortgetName()Gets the name of this symbolic valuegetRef(int i) Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.final inthashCode()Gets the Java hashCode for this cell.longReturns the number of matching hex digits in the given hex range of another Blob.final booleanReturns true if this cell is a first class CVM Value allowable in the CVM state Sub-structural cells that are not themselves first class values should return false Records and types that are not permissible on the CVM should return false.final booleanReturns true if this cell instance is a first class value, i.e.booleanDetermines if this Cell Represents an embedded object.longConverts this BlobLike to the corresponding long value.slice(long start, long end) Gets a slice of this data structuretoBlob()Convert this BlobLike object to an ABlob instance, in the most efficient way.updateRefs(IRefFunction func) Updates all Refs in this object using the given function.abstract voidValidates this Symbolic valueprotected static booleanvalidateName(AString name) Methods inherited from class convex.core.data.ABlobLike
appendHex, byteAtUnchecked, compareTo, getBytes, getHexDigit, hexEquals, hexLength, hexMatch, toFlatBlob, toHexString, toHexStringMethods inherited from class convex.core.data.ACountable
isEmpty, size, sliceMethods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, encode, encodeRaw, equals, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, getTag, getType, isCanonical, toCanonical, toCVMString, toString, validateMethods inherited from class convex.core.data.AObject
attachEncoding, print, print, print
-
Field Details
-
name
-
-
Constructor Details
-
ASymbolic
-
-
Method Details
-
createRef
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns true if this cell is a first class CVM Value allowable in the CVM state Sub-structural cells that are not themselves first class values should return false Records and types that are not permissible on the CVM should return false. Pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValuein classACell- Returns:
- true if the object is a CVM Value, false otherwise
-
isDataValue
public final boolean isDataValue()Description copied from class:ACellReturns true if this cell instance is a first class value, i.e. not a component of a larger data structure Sub-structural cells that are not themselves first class values should return false Everything else should return true.- Overrides:
isDataValuein classABlobLike<CVMChar>- Returns:
- true if the object is a Value, false otherwise
-
calcMemorySize
protected long calcMemorySize()Description copied from class:ACellCalculates the Memory Size for this Cell. Assumes not already calculated Requires any child Refs to be either direct or of persisted in store at minimum, or you might get a MissingDataException- Overrides:
calcMemorySizein classACell- Returns:
- Memory Size of this Cell
-
estimatedEncodingSize
public final int estimatedEncodingSize()Description copied from interface:IWriteableEstimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is highly likely to contain the entire object when encoded, including the tag byte. Should not traverse soft Refs, i.e. must be usable on arbitrary partial data structures- Returns:
- The estimated size for the binary representation of this object.
-
getName
Gets the name of this symbolic value- Returns:
- Name as a short CVM String
-
validateName
-
isEmbedded
public boolean isEmbedded()Description copied from class:ACellDetermines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.- Overrides:
isEmbeddedin classACell- Returns:
- true if Cell is embedded, false otherwise
-
hashCode
public final int hashCode()Description copied from class:ACellGets the Java hashCode for this cell. Must be consistent with equals. Default is the hashCode of the Encoding blob, since this is consistent with encoding-based equality. However, different Types may provide more efficient hashcodes provided that the usual invariants are preserved -
validateCell
Validates this Symbolic value- Specified by:
validateCellin classACell- Throws:
InvalidDataException- If the symbolic value is invalid
-
byteAt
-
hexMatch
Description copied from class:ABlobLikeReturns the number of matching hex digits in the given hex range of another Blob. Assumes range is valid for both blobs. Returns length if this Blob is exactly equal to the specified hex range. -
empty
-
getBytes
public int getBytes(byte[] dest, int destOffset) Description copied from class:ABlobLikeCopies the bytes from this instance to a given destination array -
longValue
public long longValue()Description copied from class:ABlobLikeConverts this BlobLike to the corresponding long value. Assumes big-endian format, as if the entire blob is interpreted as an unsigned big integer. Higher bytes outside the Long range will be ignored, i.e. the lowest 64 bits are taken -
toBlob
-
equalsBytes
Description copied from class:ABlobLikeCompare the byte content of this BlobLike to a Blob value- Specified by:
equalsBytesin classABlobLike<CVMChar>- Parameters:
b- Blob value to compare with- Returns:
- `true` if byte contents are exactly equal, `false` otherwise
-
count
public long count()Description copied from class:ACountableReturns the number of elements in this value- Specified by:
countin classACountable<CVMChar>- Returns:
- Number of elements
-
getElementRef
Description copied from class:ACountableGets a Ref to the element at the specified element index in this collection- Overrides:
getElementRefin classABlobLike<CVMChar>- Parameters:
index- Index of element to get- Returns:
- Element at the specified index
-
get
Description copied from class:ACountableGets the element at the specified element index in this value- Specified by:
getin classACountable<CVMChar>- Parameters:
index- Index of element to get- Returns:
- Element at the specified index
-
slice
Description copied from class:ACountableGets a slice of this data structure- Specified by:
slicein classACountable<CVMChar>- Parameters:
start- Start index (inclusive)end- end index (exclusive)- Returns:
- Slice of data structure, or null if invalid slice
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance -
updateRefs
Description copied from class:ACellUpdates 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. The implementation *should* re-attach any original encoding in order to prevent re-encoding or surplus hashing 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.- Overrides:
updateRefsin classACell- Parameters:
func- Ref update function- Returns:
- Cell with updated Refs
-
getRefCount
public int getRefCount()Description copied from class:ACellGets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. Contained Refs may be either external or embedded.- Overrides:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-