lookup method
Use the specified {@code byteBuffer} and its {@code encoding} to find a string in the string table, if it exists, return its reference, if not, constructs a new one.
If the string to be lookup is located in StringLocation.eVoid, this means that the string will not be used, can simply return an empty string.
The byte buffer used to lookup The StringEncoding of a supported encoding The location of the string If the string located in the value position of the k-v structure
Return The string corresponding to ByteData
Implementation
@override
String lookup(ByteData byteData, StringEncoding encoding,
StringLocation location, Object? relatedKey) {
switch (location) {
case StringLocation.objectKey:
case StringLocation.denseArrayKey:
case StringLocation.sparseArrayKey:
{}
return _lookupKey(byteData, encoding, location);
case StringLocation.objectValue:
case StringLocation.denseArrayItem:
case StringLocation.sparseArrayItem:
case StringLocation.mapValue:
return _lookupValue(byteData, encoding, location, relatedKey);
case StringLocation.errorMessage:
case StringLocation.errorStack:
case StringLocation.regexp:
case StringLocation.setItem:
case StringLocation.topLevel:
return super.lookup(byteData, encoding, location, relatedKey);
case StringLocation.eVoid:
return "";
default:
throw ArgumentError("lookup expected location : $location");
}
}