public class DocumentConverterResult extends Object
This class provides information about the success or failure of a document conversion operation. When the conversion is successful, it contains the converted Markdown content. When the conversion fails, it contains error information including an error message and exception details.
try (MarkdownConverter converter = new MarkdownConverter("document.docx")) {
DocumentConverterResult result = converter.convert();
if (result.isSuccess()) {
// Use the converted Markdown content
System.out.println(result.getContent());
} else {
// Handle the conversion error
System.err.println("Conversion failed: " + result.getErrorMessage());
if (result.getException() != null) {
result.getException().printStackTrace();
}
}
}
| Modifier and Type | Method and Description |
|---|---|
static DocumentConverterResult |
failure(String errorMessage,
Exception exception)
Creates a failed conversion result with error information.
|
String |
getContent()
Gets the converted Markdown content.
|
String |
getErrorMessage()
Gets the error message if the conversion failed.
|
Exception |
getException()
Gets the exception that occurred during conversion, if any.
|
boolean |
isSuccess()
Gets whether the conversion was successful.
|
static DocumentConverterResult |
success()
Creates a successful conversion result without Markdown content.
|
static DocumentConverterResult |
success(String content)
Creates a successful conversion result with Markdown content.
|
public boolean isSuccess()
true if the conversion was successful; otherwise, false.public String getErrorMessage()
null if successful.public String getContent()
null if conversion failed
or the content was written to a stream or file.public Exception getException()
null if successful.public static DocumentConverterResult success()
This method is typically used when the converted content is written to a stream or file.
DocumentConverterResult indicating a successful conversion.public static DocumentConverterResult success(String content)
content - The converted Markdown content.DocumentConverterResult containing the converted Markdown content.IllegalArgumentException - if content is null.public static DocumentConverterResult failure(String errorMessage, Exception exception)
errorMessage - The error message describing why the conversion failed.exception - The exception that caused the conversion to fail.DocumentConverterResult containing the error information.IllegalArgumentException - if errorMessage is null.Copyright © 2026. All rights reserved.