class BinaryString extends LazyBinaryFormat<String> implements Comparable<BinaryString> {

	public BinaryString substring(int beginIndex, int endIndex) {
		ensureMaterialized();
		if (endIndex <= beginIndex || beginIndex >= sizeInBytes) {
			return EMPTY_UTF8;
		}
		if (inFirstSegment()) {
			MemorySegment segment = segments[0];
			int i = 0;
			int c = 0;
			while (i < sizeInBytes && c < beginIndex) {
				i += numBytesForFirstByte(segment.get(i + offset));
				c += 1;
			}

			int j = i;
			while (i < sizeInBytes && c < endIndex) {
				i += numBytesForFirstByte(segment.get(i + offset));
				c += 1;
			}

			if (i > j) {
				byte[] bytes = new byte[i - j];
				segment.get(offset + j, bytes, 0, i - j);
				return fromBytes(bytes);
			} else {
				return EMPTY_UTF8;
			}
		} else {
			return substringMultiSegs(beginIndex, endIndex);
		}
	}

	public  BinaryString();
	private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes);
	private  BinaryString(String javaObject);
	private  BinaryString(MemorySegment[] segments, int offset, int sizeInBytes, String javaObject);

}