Package net.carcdr.ycrdt.jni
Class JniFormattingChunk
java.lang.Object
net.carcdr.ycrdt.jni.JniFormattingChunk
- All Implemented Interfaces:
net.carcdr.ycrdt.FormattingChunk
Represents a chunk of text with associated formatting attributes.
In Y-CRDT, formatted text is stored as a sequence of chunks (deltas), where each chunk contains text content and optional formatting attributes. This class provides a Java representation of these chunks for retrieving formatted text content.
Example usage:
try (YDoc doc = new JniYDoc();
YXmlText text = doc.getXmlText("mytext");
YTransaction txn = doc.beginTransaction()) {
// Insert some formatted text
text.insertWithAttributes(txn, 0, "Hello", Map.of("bold", true));
text.insert(txn, 5, " World");
// Retrieve formatting chunks
List<FormattingChunk> chunks = text.getFormattingChunks(txn);
for (FormattingChunk chunk : chunks) {
System.out.println("Text: " + chunk.getText());
System.out.println("Attributes: " + chunk.getAttributes());
}
}
- Since:
- 0.1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJniFormattingChunk(String text, Map<String, Object> attributes) Creates a new JniFormattingChunk with the specified text and attributes. -
Method Summary
-
Constructor Details
-
JniFormattingChunk
Creates a new JniFormattingChunk with the specified text and attributes.- Parameters:
text- the text content of this chunk (must not be null)attributes- the formatting attributes for this chunk (may be null or empty)- Throws:
IllegalArgumentException- if text is null
-
-
Method Details
-
getText
- Specified by:
getTextin interfacenet.carcdr.ycrdt.FormattingChunk
-
getAttributes
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfacenet.carcdr.ycrdt.FormattingChunk
-
equals
-
hashCode
-
toString
-