public class WebLogos extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
The debug flag.
|
static String[] |
FILE_EXTS
Supported file extensions: ".png", ".jpg", ".jpeg", ".gif", ".bmp", ...
|
Constructor and Description |
---|
WebLogos(ServerShell server)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static String |
fileNameToSite(String fileName)
Converts a logo file name into a potential web site name.
|
WSFileProvider |
getFileProvider()
Gets the file provider for logos that are persistent.
|
WebLogo |
requestWebLogo(String site)
Requests a new logo for a web site.
|
static File |
siteToFileName(File root,
String site)
Gets the file name to use in the file provider for a web site logo.
|
static String |
siteToFileName(String site)
Gets the file name to use in the file provider for a web site logo.
|
static String |
siteToFileName(String site,
int width,
int height,
int quality)
Gets the file name to use in the file provider for a web site logo.
|
static String |
stringToSite(String site)
Converts an URL or email to a potential web site.
|
static String |
urlToSite(InternetAddress address)
Converts an email address into a potential web site name.
|
static String |
urlToSite(URL url)
Converts a URL into a potential web site name.
|
public static final boolean DEBUG
public static final String[] FILE_EXTS
public WebLogos(ServerShell server) throws IOException
server
- The server instance.IOException
- If the COMMON_PERSISTENT file provider could notIllegalStateException
- If constructor is called outside of the server itself.public static String siteToFileName(String site, int width, int height, int quality)
site
- The web site name, e.g. "oracle.com" or "www.oracle.com".width
- The requested width of the image, range 10-1000.height
- The requested height of the image, range 10-1000.quality
- The quality of the image (0=pixel-perfect as PNG, otherwise 1-100 for JPG quality).quality
is 1-100,
or ".png" when quality
is zero (loss-less).
"website-"+site.toLowerCase()+
"-logo-"+width+
'x'+height+
".jpg".IllegalArgumentException
- If width
is not in range of 10-1000,
height
is not in range of 10-1000, or
quality
is not in range of 0-100.public static File siteToFileName(File root, String site)
root
- The root of the file provider that contains the web site
logos. The lastest updated file will be returned with the
file name supported.site
- The web site name, e.g. "oracle.com" or "www.oracle.com".null
is returned. If a valid file
is returned,
it is canonical.public static String siteToFileName(String site)
site
- The web site name, e.g. "oracle.com" or "www.oracle.com".public static String fileNameToSite(String fileName)
fileName
- The file name.null
is doesn't follow the rule
"website-"+site.toLowerCase()+"-logo.[png|jpg|...]"
.public static String urlToSite(URL url) throws MalformedURLException
url
- The URL.null
it cannot be established
properly. The protocol is not specified (http/https).MalformedURLException
- If the address cannot be turned into a web site "URL".public static String urlToSite(InternetAddress address) throws MalformedURLException
address
- The mail address.null
it cannot be established
properly. The protocol is not specified (http/https).MalformedURLException
- If the address cannot be turned into a web site "URL".public static String stringToSite(String site) throws MalformedURLException
site
- The string as a potential site.MalformedURLException
public WSFileProvider getFileProvider()
public WebLogo requestWebLogo(String site) throws MalformedURLException, IllegalStateException
WebLogo.waitForCompletion(Runnable)
.site
- A URL string where the protocol will be stripped.MalformedURLException
- If the protocol in invalid.IllegalStateException
- If the WebThumbs instance is disposed of
or was not initialized with a proper API key.iizi® is a registered trademark of Mindus SARL. © Copyright Mindus SARL, 2020. All rights reserved.