Package convex.core.data
Class StringTree
- All Implemented Interfaces:
IValidated,IWriteable,Comparable<AString>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionprotected bytebyteAt(long i) Gets a byte at the specified index.intstatic StringTreestatic StringTreeintencodeRaw(byte[] bs, int pos) Encode the data of this String.intencodeRawData(byte[] bs, int pos) Encode the raw UTF-8 data of this String.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.intintAt(long i) Gets 32 bytes integer at given position.booleanReturns true if this Cell is in a canonical representation for message writing.final booleanReturns true if this Cell represents a first class CVM Value.protected voidprintEscaped(BlobBuilder sb, long start, long end) Prints this string as escaped UTF-8static StringTreeread(long length, ByteBuffer bb) slice(long start, long end) Gets a slice of this string, or null if not a valid slicetoBlob()Converts this String to a Blob byte representation.Converts this Cell to its canonical version.updateRefs(IRefFunction func) Updates all Refs in this object using the given function.voidValidates the local structure and invariants of this cell.protected voidMethods inherited from class convex.core.data.AString
append, append, charAt, count, empty, encode, get, getElementRef, getTag, getType, hashCode, print, split, toCVMString, toStringMethods inherited from class convex.core.data.ACountable
isEmpty, size, sliceMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, isCompletelyEncoded, isEmbedded, mark, mark, validate, writeMethods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
MINIMUM_LENGTH
public static final int MINIMUM_LENGTH- See Also:
-
MAX_ENCODING_LENGTH
public static final int MAX_ENCODING_LENGTH- See Also:
-
-
Method Details
-
create
-
create
-
slice
Description copied from class:AStringGets a slice of this string, or null if not a valid slice -
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
-
encodeRaw
public int encodeRaw(byte[] bs, int pos) Description copied from class:AStringEncode the data of this String. Assumes tag already written -
encodeRawData
public int encodeRawData(byte[] bs, int pos) Description copied from class:AStringEncode the raw UTF-8 data of this String. Assumes tag/length already written- Specified by:
encodeRawDatain classAString- Parameters:
bs- Byte array to encode topos- Position in target array to write to- Returns:
- End position in array after encoding
-
read
- Throws:
BadFormatException
-
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 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.
-
isCanonical
public boolean isCanonical()Description copied from class:ACellReturns true if this Cell is in a canonical representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).- Specified by:
isCanonicalin classACell- Returns:
- true if the object is in canonical format, false otherwise
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values 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
-
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.- Specified by:
getRefCountin classACell- Returns:
- The number of Refs in this Cell
-
getRef
Description copied from class:ACellGets a numbered child Ref from within this Cell. -
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. 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
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Returns this Cell if already canonical, may be O(n) in size of value otherwise.- Specified by:
toCanonicalin classACell- Returns:
- Canonical version of Cell
-
byteAt
protected byte byteAt(long i) Description copied from class:AStringGets a byte at the specified index. Returns -1 (0xff) if outside String. -
intAt
public int intAt(long i) Description copied from class:AStringGets 32 bytes integer at given position. Extends with 255 (invalid UTF-8) if needed. The main purpose of this function is to enable fast peeking at UTF-8 characters -
compareTo
- Specified by:
compareToin interfaceComparable<AString>- Specified by:
compareToin classAString
-
toBlob
Description copied from class:AStringConverts this String to a Blob byte representation. Must round trip all values. -
writeToBuffer
- Specified by:
writeToBufferin classAString
-
printEscaped
Description copied from class:AStringPrints this string as escaped UTF-8- Specified by:
printEscapedin classAString
-