Package convex.core.data
Class StringSlice
- All Implemented Interfaces:
IValidated
,IWriteable
,CharSequence
,Comparable<AString>
AString subclass representing a subsequence of another charsequence
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AString
append(char charValue)
protected void
appendToStringBuffer(StringBuilder sb, int start, int length)
char
charAt(int index)
static AString
create(StringTree source, int start, int len)
int
encode(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, including a tag byte which will be written firstint
encodeRaw(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, excluding the tag byteint
Estimate the encoded data size for this Cell.int
Gets the number of Refs contained within this Cell.boolean
Returns true if this Cell is in a canonical format for message writing.boolean
Returns true if this object represents a first class CVM Value.subSequence(int start, int end)
Converts this Cell to its canonical version.void
Validates the local structure and invariants of this cell.Methods inherited from class convex.core.data.AString
compareTo, count, empty, get, getElementRef, getTag, getType, length, print, toString
Methods inherited from class convex.core.data.ACountable
isEmpty, size
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, hashCode, isEmbedded, updateRefs, validate, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
StringSlice
-
-
Method Details
-
create
-
charAt
public char charAt(int index) -
subSequence
- Specified by:
subSequence
in interfaceCharSequence
- Specified by:
subSequence
in classAString
-
validateCell
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 classACell
- 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 interfaceIWriteable
- Overrides:
encode
in classAString
- 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:ACell
Writes this Cell's encoding to a byte array, excluding the tag byte -
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.
-
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 classACell
- Returns:
- true if the object is in canonical format, false otherwise
-
isCVMValue
public final 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- Specified by:
isCVMValue
in classACell
- Returns:
- true if the object is a CVM Value, false otherwise
-
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 classACell
- Returns:
- The number of Refs in this Cell
-
appendToStringBuffer
- Specified by:
appendToStringBuffer
in classAString
-
append
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Returns this if already canonical- Specified by:
toCanonical
in classACell
- Returns:
- Canonical version of Cell
-