帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

53 lines
1.2 KiB

package com.fine.theme.icon;
import com.fr.general.IOUtils;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.third.errorprone.annotations.Immutable;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.util.StringJoiner;
/**
* url图标资源
*
* @author vito
* @since 11.0
* Created on 2023/11/15
*/
@Immutable
public class UrlIconResource implements IconResource {
private final String path;
public UrlIconResource(String path) {
this.path = path;
}
public String getPath() {
return path;
}
@Override
@NotNull
public InputStream getInputStream() {
InputStream inputStream = getInputStream(path);
if (inputStream == null) {
throw new IconException("Icon load failed: " + path);
}
return inputStream;
}
private InputStream getInputStream(String path) {
InputStream inputStream = IOUtils.getInputStream(path);
return inputStream != null ? inputStream : ResourceIOUtils.read(path);
}
@Override
public String toString() {
return new StringJoiner(", ", UrlIconResource.class.getSimpleName() + "[", "]")
.add("path='" + path + "'")
.toString();
}
}