public final class WroUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static InputStream |
EMPTY_STREAM |
static Pattern |
EMTPY_LINE_PATTERN
Empty line pattern.
|
| Constructor and Description |
|---|
WroUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
cleanImageUrl(String imageUrl)
Cleans the image url by trimming result and removing \' or \" characters if such exists.
|
static ThreadFactory |
createDaemonThreadFactory(String name) |
static File |
createTempDirectory() |
static File |
createTempFile() |
static File |
createTempFile(String extension)
Creates a temp file which has a certain extension.
|
static WroModelFactory |
factoryFor(WroModel model)
A simple way to create a
WroModelFactory. |
static String |
getFullPath(String path)
Similar to
FilenameUtils.getFullPath(String), but fixes the problem with Windows platform for situations
when the path starts with "/" (servlet context relative resources) which are resolved to "\" on windows. |
static String |
getImplementationVersion() |
static String |
getPathInfoFromLocation(javax.servlet.http.HttpServletRequest request,
String location)
Retrieve pathInfo from a given location.
|
static String |
getServletPathFromLocation(javax.servlet.http.HttpServletRequest request,
String location)
Retrieve servletPath from a given location.
|
static File |
getWorkingDirectory() |
static boolean |
isGzipSupported(javax.servlet.http.HttpServletRequest request)
Analyze headers of the request and searches for mangled (by proxy) for "Accept-Encoding" header and its mangled
variations and gzip header value and its mangled variations.
|
static String |
loadRegexpWithKey(String key)
Load the regular expression stored in in regexp.properties resource file.
|
static boolean |
matchesUrl(javax.servlet.http.HttpServletRequest request,
String path)
Utility used to verify that requestURI matches provided path
|
static ResourcePostProcessor |
newResourceProcessor(Resource resource,
ResourcePreProcessor preProcessor)
A factory method for creating a
ResourceProcessor based on provided ResourcePreProcessor. |
static String |
normalize(String path)
Similar to
FilenameUtils.normalize(String), but fixes the problem with Windows platform for situations
when the path starts with "/" (servlet context relative resources) which are resolved to "\" on windows. |
static String |
removeQueryString(String path)
Removes the query string from the provided path (everything followed by '?' including the question mark).
|
static void |
safeCopy(Reader reader,
Writer writer)
Copy and close the reader and writer streams.
|
static <T> ObjectFactory<T> |
simpleObjectFactory(T object) |
static boolean |
startsWithIgnoreCase(String str,
String prefix)
Case insensitive check if a String starts with a specified prefix.
|
static String |
toDateAsString(long milliseconds)
Transforms milliseconds into date format for response header of this form: Sat, 10 Apr 2010 17:31:31 GMT.
|
static String |
toJSMultiLineString(String data)
Transforms a java multi-line string into javascript multi-line string.
|
static String |
toPackageAsFolder(Class<?> clazz)
Creates a folder like implementation for a class.
|
public static final Pattern EMTPY_LINE_PATTERN
public static final InputStream EMPTY_STREAM
public static ThreadFactory createDaemonThreadFactory(String name)
ThreadFactory with daemon threads.public static String toDateAsString(long milliseconds)
milliseconds - to transformpublic static String getPathInfoFromLocation(javax.servlet.http.HttpServletRequest request, String location)
request - location - where to search contextPath.public static boolean startsWithIgnoreCase(String str, String prefix)
Case insensitive check if a String starts with a specified prefix.
nulls are handled without exceptions. Two null references are considered to be equal. The
comparison is case insensitive.
StringUtils.startsWithIgnoreCase(null, null) = true
StringUtils.startsWithIgnoreCase(null, "abcdef") = false
StringUtils.startsWithIgnoreCase("abc", null) = false
StringUtils.startsWithIgnoreCase("abc", "abcdef") = true
StringUtils.startsWithIgnoreCase("abc", "ABCDEF") = true
str - the String to check, may be nullprefix - the prefix to find, may be nulltrue if the String starts with the prefix, case insensitive, or both nullString.startsWith(String)public static String toPackageAsFolder(Class<?> clazz)
clazz - used as a base location for determining the package path.public static String getServletPathFromLocation(javax.servlet.http.HttpServletRequest request, String location)
location - where to search the servletPath.public static boolean isGzipSupported(javax.servlet.http.HttpServletRequest request)
public static String toJSMultiLineString(String data)
://stackoverflow.com/questions/805107/multiline-strings-in-javascript/data - a string containing new lines.public static boolean matchesUrl(javax.servlet.http.HttpServletRequest request,
String path)
public static ResourcePostProcessor newResourceProcessor(Resource resource, ResourcePreProcessor preProcessor)
ResourceProcessor based on provided ResourcePreProcessor.preProcessor - ResourcePreProcessor to use as a ResourceProcessor.ResourceProcessor.public static WroModelFactory factoryFor(WroModel model)
WroModelFactory.model - WroModel instance to be returned by the factory.public static <T> ObjectFactory<T> simpleObjectFactory(T object)
public static String loadRegexpWithKey(String key)
key - the key of the regexp to load.public static String getImplementationVersion()
public static void safeCopy(Reader reader, Writer writer) throws IOException
reader - The source stream.writer - The destination stream.IOException - If content cannot be copy.public static File createTempFile()
File with unique name located in temp folder.public static File createTempDirectory()
public static File createTempFile(String extension)
extension - of the created temp file.public static final String cleanImageUrl(String imageUrl)
imageUrl - to clean.public static final String removeQueryString(String path)
public static final File getWorkingDirectory()
public static final String getFullPath(String path)
FilenameUtils.getFullPath(String), but fixes the problem with Windows platform for situations
when the path starts with "/" (servlet context relative resources) which are resolved to "\" on windows.path - to compute filePath from.public static final String normalize(String path)
FilenameUtils.normalize(String), but fixes the problem with Windows platform for situations
when the path starts with "/" (servlet context relative resources) which are resolved to "\" on windows.path - to compute filePath from.Copyright © 2008-2014. All Rights Reserved.