Class DataFormatHandler
java.lang.Object
jfx.incubator.scene.control.richtext.model.DataFormatHandler
- Direct Known Subclasses:
-
HtmlExportFormatHandler,PlainTextFormatHandler,RichTextFormatHandler,RtfFormatHandler
public abstract class DataFormatHandler extends Object
Facilitates import/export of styled text into/from a StyledTextModel.
- Since:
- 24
Constructor Summary
| Constructor | Description |
|---|---|
DataFormatHandler |
Creates a DataHandler instance for the specified format. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
abstract Object |
copy |
Creates an object to be put into the Clipboard for the given text range. |
abstract StyledInput |
createStyledInput |
Creates a StyledInput for the given input string. |
final DataFormat |
getDataFormat() |
Returns the DataFormat associated with this handler. |
abstract void |
save |
Save the text range in the handler's format to the output stream (e.g. |
Constructor Details
DataFormatHandler
public DataFormatHandler(DataFormat f)
Creates a DataHandler instance for the specified format.
- Parameters:
-
f- data format
Method Details
createStyledInput
public abstract StyledInput createStyledInput(String input, StyleAttributeMap attr) throws IOException
Creates a StyledInput for the given input string. When pasting, the caller may pass the style attributes
attr at the insertion point. This argument may be used by the implementation if the format contains no styles on its own (for example, in the plain text format case).- Parameters:
-
input- the input string -
attr- the style attributes (can be null) - Returns:
- the StyledInput
- Throws:
-
IOException- when operation is not supported or an I/O error occurs -
UnsupportedOperationException- if the copy operation is not supported
copy
public abstract Object copy(StyledTextModel model, StyleResolver resolver, TextPos start, TextPos end) throws IOException
Creates an object to be put into the Clipboard for the given text range. The caller must guarantee that the
start precedes the end position. Typically, the implementation creates an instance of StyledOutput and calls StyledTextModel.export(TextPos, TextPos, StyledOutput) method.
- Parameters:
-
model- source model -
resolver- view-specific style resolver -
start- start text position -
end- end text position - Returns:
- an object to be placed to the Clipboard
- Throws:
-
IOException- when an I/O error occurs -
UnsupportedOperationException- if the copy operation is not supported
save
public abstract void save(StyledTextModel model, StyleResolver resolver, TextPos start, TextPos end, OutputStream out) throws IOException
Save the text range in the handler's format to the output stream (e.g. save to file). The caller must guarantee that the
start precedes the end position. It is the responsibility of the caller to close the OutputStream. Typically, the implementation creates an instance of StyledOutput and calls StyledTextModel.export(TextPos, TextPos, StyledOutput) method.
- Parameters:
-
model- source model -
resolver- view-specific style resolver -
start- start text position -
end- end text position -
out- targetOutputStream - Throws:
-
IOException- when an I/O error occurs -
UnsupportedOperationException- if the copy operation is not supported
getDataFormat
public final DataFormat getDataFormat()
Returns the
DataFormat associated with this handler.- Returns:
- the data format
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.