Class DataFormatHandler
java.lang.Object
jfx.incubator.scene.control.richtext.model.DataFormatHandler
- Direct Known Subclasses:
HtmlExportFormatHandler
,PlainTextFormatHandler
,RichTextFormatHandler
,RtfFormatHandler
Facilitates import/export of styled text into/from a StyledTextModel.
- Since:
- 24
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a DataHandler instance for the specified format. -
Method Summary
Modifier and TypeMethodDescriptionabstract Object
copy
(StyledTextModel model, StyleResolver resolver, TextPos start, TextPos end) Creates an object to be put into the Clipboard for the given text range.abstract StyledInput
createStyledInput
(String input, StyleAttributeMap attr) Creates a StyledInput for the given input string.final DataFormat
Returns theDataFormat
associated with this handler.abstract void
save
(StyledTextModel model, StyleResolver resolver, TextPos start, TextPos end, OutputStream out) Save the text range in the handler's format to the output stream (e.g.
-
Constructor Details
-
DataFormatHandler
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 attributesattr
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 stringattr
- the style attributes (can be null)- Returns:
- the StyledInput
- Throws:
IOException
- when operation is not supported or an I/O error occursUnsupportedOperationException
- 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 thestart
precedes theend
position.Typically, the implementation creates an instance of
StyledOutput
and callsStyledTextModel.export(TextPos, TextPos, StyledOutput)
method.- Parameters:
model
- source modelresolver
- view-specific style resolverstart
- start text positionend
- end text position- Returns:
- an object to be placed to the Clipboard
- Throws:
IOException
- when an I/O error occursUnsupportedOperationException
- 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 thestart
precedes theend
position. It is the responsibility of the caller to close theOutputStream
.Typically, the implementation creates an instance of
StyledOutput
and callsStyledTextModel.export(TextPos, TextPos, StyledOutput)
method.- Parameters:
model
- source modelresolver
- view-specific style resolverstart
- start text positionend
- end text positionout
- targetOutputStream
- Throws:
IOException
- when an I/O error occursUnsupportedOperationException
- if the copy operation is not supported
-
getDataFormat
Returns theDataFormat
associated with this handler.- Returns:
- the data format
-