Package org.pkl.core.resource
Interface ResourceReader
-
- All Superinterfaces:
ReaderBase
public interface ResourceReader extends ReaderBase
SPI for reading external resources from Pkl. Once a resource reader has been registered, Pkl code can read its resources withread("<URI>"), provided that resource URIs match an entry in the resource allowlist (--allowed-resources).See
ResourceReadersfor predefined resource readers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetUriScheme()The URI scheme associated with resources read by this resource reader.java.util.Optional<java.lang.Object>read(java.net.URI uri)Reads the resource with the given URI.-
Methods inherited from interface org.pkl.core.runtime.ReaderBase
hasElement, hasFragmentPaths, hasHierarchicalUris, isGlobbable, listElements, resolveUri
-
-
-
-
Method Detail
-
getUriScheme
java.lang.String getUriScheme()
The URI scheme associated with resources read by this resource reader.
-
read
java.util.Optional<java.lang.Object> read(java.net.URI uri) throws java.io.IOException, java.net.URISyntaxException, SecurityManagerExceptionReads the resource with the given URI. ReturnsOptional.empty()if a resource with the given URI cannot be found.Supported resource types are:
StringResource
IOException— if an error occurred while reading the resource, outside of the resource not being found.URISyntaxException— if the URI format is invalid for the resource.SecurityManagerException— If the resource read is invalid per the security manager.
- Throws:
java.io.IOExceptionjava.net.URISyntaxExceptionSecurityManagerException
-
-