Package convex.core.data.prim
Class CVMBool
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.prim.APrimitive
convex.core.data.prim.CVMBool
- All Implemented Interfaces:
IValidated,IWriteable
Class for CVM Boolean types.
Two canonical values are provided, TRUE and FALSE. No other instances should exist.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CVMBoolstatic final Stringstatic final intstatic final CVMBoolstatic final StringFields inherited from class convex.core.data.ACell
cachedRef, memorySize -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic CVMBoolcreate(boolean value) doubleintencode(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.intencodeRaw(byte[] bs, int pos) Writes this Cell's encoding to a byte array, excluding the tag byte.booleanChecks for equality with another Cell.intEstimate the encoded data size for this Cell.getRef(int i) Gets a numbered child Ref from within this Cell.intGets the number of Refs contained within this Cell.bytegetTag()Gets the tag byte for this cell.getType()Gets the most specific known runtime Type for this Cell.inthashCode()Gets the Java hashCode for this cell.longnot()static CVMBoolof(boolean b) Get the canonical CVMBool value for true or falsestatic ACellbooleanprint(BlobBuilder bb, long limit) Prints this Object to a readable String Representation.toBlob()toCVMString(long limit) Returns the CVM String representation of this Cell.toString()Returns the Java String representation of this Cell.updateRefs(IRefFunction func) Updates all Refs in this object using the given function.voidValidates the local structure and invariants of this cell.Methods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, isCanonical, isCVMValue, isDataValue, isEmbedded, toCanonicalMethods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, createRef, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, validateMethods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
TRUE
-
FALSE
-
MAX_ENCODING_LENGTH
public static final int MAX_ENCODING_LENGTH- See Also:
-
TRUE_STRING
- See Also:
-
FALSE_STRING
- See Also:
-
-
Method Details
-
getType
-
create
-
of
Get the canonical CVMBool value for true or false- Parameters:
b- Boolean specifying- Returns:
- CVMBool value representing false or true
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. WARNING: May need to convert to a canonical instance- Overrides:
getRefin classAPrimitive- Type Parameters:
R- Type of referenced Cell- Parameters:
i- Index of ref to get- Returns:
- The Ref at the specified index
-
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 classAPrimitive- 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 classAPrimitive- Returns:
- The number of Refs in this Cell
-
longValue
public long longValue()- Specified by:
longValuein classAPrimitive- Returns:
- Java long value representing this primitive CVM value
-
estimatedEncodingSize
public 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.
-
validateCell
Description copied from class:ACellValidates 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:
validateCellin classACell- Throws:
InvalidDataException- If the Cell is invalid
-
encode
public int encode(byte[] bs, int pos) Description copied from class:ACellWrites this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.- Specified by:
encodein interfaceIWriteable- Specified by:
encodein classACell- Parameters:
bs- A byte array to which to write the encodingpos- The offset into the byte array- Returns:
- New position after writing
-
encodeRaw
public int encodeRaw(byte[] bs, int pos) Description copied from class:ACellWrites this Cell's encoding to a byte array, excluding the tag byte. -
print
Description copied from class:AObjectPrints this Object to a readable String Representation. SECURITY: Must halt and return false in O(1) time when limit of printing is exceeded otherwise DoS attacks may be possible. -
doubleValue
public double doubleValue()- Specified by:
doubleValuein classAPrimitive- Returns:
- Java double value representing this primitive CVM value
-
booleanValue
public boolean booleanValue() -
getTag
public byte getTag()Description copied from class:ACellGets the tag byte for this cell. The tag byte is always equal to the first byte of the Cell's canonical Encoding, and is sufficient to distinguish how to read the rest of the encoding. -
parse
-
toCVMString
Description copied from class:ACellReturns the CVM String representation of this Cell. Normally, this is as printed, but may be different for some types. SHOULD return null in O(1) time if the length of the CVM String can be proved to exceed the limit. MUST complete in O(limit) time and space otherwise The String representation is intended to be a easy-to-read textual representation of the Cell's data content.- Overrides:
toCVMStringin classACell- Parameters:
limit- Limit of CVM String length in UTF-8 bytes- Returns:
- CVM String, or null if limit exceeded
-
hashCode
public 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 -
equals
Description copied from class:ACellChecks for equality with another Cell. In general, Cells are considered equal if they have the same canonical representation, i.e. an identical encoding with the same hash value. Subclasses SHOULD override this if they have a more efficient equals implementation. MUST NOT require reads from Store. -
toBlob
-
not
-
toString
-