use of org.incode.module.document.dom.impl.renderers.RendererFromCharsToCharsWithPreviewToUrl in project estatio by estatio.
the class DocumentTemplate method preview.
// endregion
// region > preview (programmatic)
@Programmatic
public URL preview(final Object rendererModel) throws IOException {
serviceRegistry2.injectServicesInto(rendererModel);
if (!getContentRenderingStrategy().isPreviewsToUrl()) {
throw new IllegalStateException(String.format("RenderingStrategy '%s' does not support previewing to URL", getContentRenderingStrategy().getReference()));
}
final DocumentNature inputNature = getContentRenderingStrategy().getInputNature();
final DocumentNature outputNature = getContentRenderingStrategy().getOutputNature();
final Renderer renderer = getContentRenderingStrategy().newRenderer();
switch(inputNature) {
case BYTES:
switch(outputNature) {
case BYTES:
return ((RendererFromBytesToBytesWithPreviewToUrl) renderer).previewBytesToBytes(getType(), getAtPath(), getVersion(), asBytes(), rendererModel);
case CHARACTERS:
return ((RendererFromBytesToCharsWithPreviewToUrl) renderer).previewBytesToChars(getType(), getAtPath(), getVersion(), asBytes(), rendererModel);
default:
// shouldn't happen, above switch statement is complete
throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
}
case CHARACTERS:
switch(outputNature) {
case BYTES:
return ((RendererFromCharsToBytesWithPreviewToUrl) renderer).previewCharsToBytes(getType(), getAtPath(), getVersion(), asChars(), rendererModel);
case CHARACTERS:
return ((RendererFromCharsToCharsWithPreviewToUrl) renderer).previewCharsToChars(getType(), getAtPath(), getVersion(), asChars(), rendererModel);
default:
// shouldn't happen, above switch statement is complete
throw new IllegalArgumentException(String.format("Unknown output DocumentNature '%s'", outputNature));
}
default:
// shouldn't happen, above switch statement is complete
throw new IllegalArgumentException(String.format("Unknown input DocumentNature '%s'", inputNature));
}
}
Aggregations