spring.turbo.core.resource.HexProtocolResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-turbo Show documentation
Show all versions of spring-turbo Show documentation
Another enhancement library of SpringBoot/SpringFramework. Have fun.
The newest version!
package spring.turbo.core.resource;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ProtocolResolver;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
import spring.turbo.util.HexUtils;
/**
* @author 应卓
* @see ByteArrayResource
* @since 3.3.2
*/
final class HexProtocolResolver implements ProtocolResolver {
private static final String HEX_PREFIX = "hex:";
/**
* {@inheritDoc}
*/
@Nullable
@Override
public Resource resolve(String location, ResourceLoader resourceLoader) {
if (location.startsWith(HEX_PREFIX)) {
var value = location.substring(HEX_PREFIX.length());
return new ByteArrayResource(HexUtils.decodeToBytes(value));
}
return null;
}
}