public class SpincastUtils extends Object implements ISpincastUtils
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SpincastUtils(ISpincastConfig spincastConfig) |
| Modifier and Type | Method and Description |
|---|---|
File |
getAppJarDirectory()
Returns the working directory: the directory
in which the executable .jar is located.
|
protected String |
getCurrentVersionFromPom() |
Locale |
getLocaleBestMatchFromAcceptLanguageHeader(String header)
Gets the best Locale to use given a "Accept-Language" HTTP header.
|
String |
getMimeTypeFromExtension(String extension)
Gets the
mime type from the extension. |
String |
getMimeTypeFromPath(String path)
Gets the
mime type from a path, using its extension. |
protected ISpincastConfig |
getSpincastConfig() |
String |
getSpincastCurrentVersion()
Gets the current Spincast version
|
boolean |
isContentTypeToSkipGziping(String contentType)
Should the specified
Content-Type be gzipped? |
void |
zipDirectory(File directoryToZip,
File targetZipFile,
boolean includeDirItself)
Zips a directory.
|
void |
zipExtract(File zipFile,
File targetDir)
Extracts a .zip file to the specified directory.
|
@Inject public SpincastUtils(ISpincastConfig spincastConfig)
protected ISpincastConfig getSpincastConfig()
public boolean isContentTypeToSkipGziping(String contentType)
ISpincastUtilsContent-Type be gzipped?isContentTypeToSkipGziping in interface ISpincastUtilspublic String getMimeTypeFromPath(String path)
ISpincastUtilsmime type from a path, using its extension.getMimeTypeFromPath in interface ISpincastUtilsmime type or null if it can't be
decided.public String getMimeTypeFromExtension(String extension)
ISpincastUtilsmime type from the extension.getMimeTypeFromExtension in interface ISpincastUtilsmime type or null if it can't be
decided.public Locale getLocaleBestMatchFromAcceptLanguageHeader(String header)
ISpincastUtilsgetLocaleBestMatchFromAcceptLanguageHeader in interface ISpincastUtilsnull
if the given header can't be parsed.public File getAppJarDirectory()
ISpincastUtilsgetAppJarDirectory in interface ISpincastUtilsnull if the application is
running inside an IDE.public String getSpincastCurrentVersion()
ISpincastUtilsgetSpincastCurrentVersion in interface ISpincastUtilsprotected String getCurrentVersionFromPom()
public void zipDirectory(File directoryToZip, File targetZipFile, boolean includeDirItself)
ISpincastUtilszipDirectory in interface ISpincastUtilstargetZipFile - the target .zip file. If the parent directories don't
exist, tries to create them.public void zipExtract(File zipFile, File targetDir)
ISpincastUtilszipExtract in interface ISpincastUtilstargetDir - The target directory. If it doesn't exist, tried to
create it (and its parents, if required).Copyright © 2016. All rights reserved.