Package org.faceless.publisher.ext
Class ScssStylesheetExtension
java.lang.Object
org.faceless.publisher.ext.ScssStylesheetExtension
- All Implemented Interfaces:
ReportFactoryExtension
,ResourceLoader
public class ScssStylesheetExtension
extends Object
implements ReportFactoryExtension, ResourceLoader
The ScssStylesheetExtension adds the ability to natively use the "Scss"
stylesheet format defined at https://sass-lang.com.
It adds a ResourceLoader
for objects with the media type text/x-stylesheet-scss
,
which is a synthetic media-type used in BFO Publisher when an HTML <link> element
is encountered with rel="stylesheet/scss"
- or it can be used directly.
It requires the de.larsgreger.sass
package in the classpath from
https://github.com/larsgrefer/dart-sass-java
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionload
(ResourceDescriptor descriptor, Resource resource, URL2Connection con) Attempt to load a Resource from the specified URL2Connection.void
register
(ReportFactory factory) Notify this object it has beem added to a ReportFactory.boolean
supports
(ResourceDescriptor descriptor) Return true if this ResourceLoader could load a descriptor of the specified type.void
unregister
(ReportFactory factory) Notify this object it has been removed from a ReportFactory.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.faceless.publisher.ext.ReportFactoryExtension
configure, load, register, unregister
Methods inherited from interface org.faceless.publisher.resource.ResourceLoader
isTrustRequired
-
Field Details
-
MEDIATYPE
The synthetic MediaType "text/x-stylesheet-less" which is used to identify resources loaded by this ResourceLoader
-
-
Constructor Details
-
ScssStylesheetExtension
public ScssStylesheetExtension()
-
-
Method Details
-
unregister
Description copied from interface:ReportFactoryExtension
Notify this object it has been removed from a ReportFactory. Will be called when this object is removed from the list returned byReportFactory.getReportFactoryExtensions()
. The default implementation is a no-op.- Specified by:
unregister
in interfaceReportFactoryExtension
-
register
Description copied from interface:ReportFactoryExtension
Notify this object it has beem added to a ReportFactory. Will be called when this object is added to the list returned byReportFactory.getReportFactoryExtensions()
. The default implementation is a no-op.- Specified by:
register
in interfaceReportFactoryExtension
-
supports
Description copied from interface:ResourceLoader
Return true if this ResourceLoader could load a descriptor of the specified type. The resourceClass, outputClass and mediaType of the descriptor should be checked as appropriate. The MediaType in particular will not be a wildcard for normal use; it may be a wildcard if we're being called fromResourceManager.getResourceLoader(org.faceless.publisher.type.MediaType, java.lang.Class<?>)
.- Specified by:
supports
in interfaceResourceLoader
-
load
public ResourceFlavor load(ResourceDescriptor descriptor, Resource resource, URL2Connection con) throws IOException Description copied from interface:ResourceLoader
Attempt to load a Resource from the specified URL2Connection. If the ResourceLoader applies (it should test the resource mediatype and class) then it should load the resource from the URL. If the URI has a fragment and the loaded resource to ALL fragments, it should change the URI to have no fragment. Likewise if any aspect of the MediaType does not apply (i.e. the encoding) then it should remove it, so the Resource describes the widest possible URI and MediaType that would match this object. Finally, on success this method should set the Object on the resource, or throw an exception on failure. The supplied "con" will have an InputStream that is mark-capable already. If the stream is a gzip or brotli compresed stream, decompression will already be applied. The mediatype wil be set on "d". Returning null from this object is considered an error condition - if that happens we shouldn't have got here, and the only reason we did was because "supports" for the same descriptor returned true.- Specified by:
load
in interfaceResourceLoader
- Parameters:
descriptor
- the descriptor of what type of flavor we want.resource
- the Resource we're populatingcon
- the URLConnection to load the resource from- Returns:
- the new Flavor, or null if it doesn't apply.
- Throws:
IOException
-