id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
7,300
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/IOUtils.java
IOUtils.write
public static void write(byte[] byteArray, OutputStream out) throws IOException { if (byteArray != null) { out.write(byteArray); } }
java
public static void write(byte[] byteArray, OutputStream out) throws IOException { if (byteArray != null) { out.write(byteArray); } }
[ "public", "static", "void", "write", "(", "byte", "[", "]", "byteArray", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "if", "(", "byteArray", "!=", "null", ")", "{", "out", ".", "write", "(", "byteArray", ")", ";", "}", "}" ]
Writes all the contents of a byte array to an OutputStream. @param byteArray the input to read from @param out the output stream to write to @throws java.io.IOException if an IOExcption occurs
[ "Writes", "all", "the", "contents", "of", "a", "byte", "array", "to", "an", "OutputStream", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/IOUtils.java#L142-L146
7,301
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/IOUtils.java
IOUtils.copy
public static void copy(ReadableByteChannel inChannel, WritableByteChannel outChannel) throws IOException { if (inChannel instanceof FileChannel) { ((FileChannel) inChannel).transferTo(0, ((FileChannel) inChannel).size(), outChannel); } else { final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024); try { while (inChannel.read(buffer) != -1) { // prepare the buffer to be drained buffer.flip(); // write to the channel, may block outChannel.write(buffer); // If partial transfer, shift remainder down // If buffer is empty, same as doing clear() buffer.compact(); } // EOF will leave buffer in fill state buffer.flip(); // make sure the buffer is fully drained. while (buffer.hasRemaining()) { outChannel.write(buffer); } } finally { IOUtils.close(inChannel); IOUtils.close(outChannel); } } }
java
public static void copy(ReadableByteChannel inChannel, WritableByteChannel outChannel) throws IOException { if (inChannel instanceof FileChannel) { ((FileChannel) inChannel).transferTo(0, ((FileChannel) inChannel).size(), outChannel); } else { final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024); try { while (inChannel.read(buffer) != -1) { // prepare the buffer to be drained buffer.flip(); // write to the channel, may block outChannel.write(buffer); // If partial transfer, shift remainder down // If buffer is empty, same as doing clear() buffer.compact(); } // EOF will leave buffer in fill state buffer.flip(); // make sure the buffer is fully drained. while (buffer.hasRemaining()) { outChannel.write(buffer); } } finally { IOUtils.close(inChannel); IOUtils.close(outChannel); } } }
[ "public", "static", "void", "copy", "(", "ReadableByteChannel", "inChannel", ",", "WritableByteChannel", "outChannel", ")", "throws", "IOException", "{", "if", "(", "inChannel", "instanceof", "FileChannel", ")", "{", "(", "(", "FileChannel", ")", "inChannel", ")", ".", "transferTo", "(", "0", ",", "(", "(", "FileChannel", ")", "inChannel", ")", ".", "size", "(", ")", ",", "outChannel", ")", ";", "}", "else", "{", "final", "ByteBuffer", "buffer", "=", "ByteBuffer", ".", "allocateDirect", "(", "16", "*", "1024", ")", ";", "try", "{", "while", "(", "inChannel", ".", "read", "(", "buffer", ")", "!=", "-", "1", ")", "{", "// prepare the buffer to be drained", "buffer", ".", "flip", "(", ")", ";", "// write to the channel, may block", "outChannel", ".", "write", "(", "buffer", ")", ";", "// If partial transfer, shift remainder down", "// If buffer is empty, same as doing clear()", "buffer", ".", "compact", "(", ")", ";", "}", "// EOF will leave buffer in fill state", "buffer", ".", "flip", "(", ")", ";", "// make sure the buffer is fully drained.", "while", "(", "buffer", ".", "hasRemaining", "(", ")", ")", "{", "outChannel", ".", "write", "(", "buffer", ")", ";", "}", "}", "finally", "{", "IOUtils", ".", "close", "(", "inChannel", ")", ";", "IOUtils", ".", "close", "(", "outChannel", ")", ";", "}", "}", "}" ]
Copy the readable byte channel to the writable byte channel @param inChannel the readable byte channel @param outChannel the writable byte channel @throws IOException if an IOException occurs.
[ "Copy", "the", "readable", "byte", "channel", "to", "the", "writable", "byte", "channel" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/IOUtils.java#L158-L187
7,302
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/AbstractChainedResourceBundlePostProcessor.java
AbstractChainedResourceBundlePostProcessor.getId
@Override public String getId() { StringBuilder strId = new StringBuilder(); strId.append(id); if (nextProcessor != null) { strId.append(",").append(nextProcessor.getId()); } return strId.toString(); }
java
@Override public String getId() { StringBuilder strId = new StringBuilder(); strId.append(id); if (nextProcessor != null) { strId.append(",").append(nextProcessor.getId()); } return strId.toString(); }
[ "@", "Override", "public", "String", "getId", "(", ")", "{", "StringBuilder", "strId", "=", "new", "StringBuilder", "(", ")", ";", "strId", ".", "append", "(", "id", ")", ";", "if", "(", "nextProcessor", "!=", "null", ")", "{", "strId", ".", "append", "(", "\",\"", ")", ".", "append", "(", "nextProcessor", ".", "getId", "(", ")", ")", ";", "}", "return", "strId", ".", "toString", "(", ")", ";", "}" ]
Returns the ID of the ChainedResourceBundlePostProcessor @return the ID of the ChainedResourceBundlePostProcessor
[ "Returns", "the", "ID", "of", "the", "ChainedResourceBundlePostProcessor" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/AbstractChainedResourceBundlePostProcessor.java#L62-L70
7,303
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/AbstractChainedResourceBundlePostProcessor.java
AbstractChainedResourceBundlePostProcessor.addNextProcessor
@Override public void addNextProcessor(ChainedResourceBundlePostProcessor nextProcessor) { if (!isVariantPostProcessor) { isVariantPostProcessor = nextProcessor.isVariantPostProcessor(); } if (this.nextProcessor == null) { this.nextProcessor = nextProcessor; } else { this.nextProcessor.addNextProcessor(nextProcessor); } }
java
@Override public void addNextProcessor(ChainedResourceBundlePostProcessor nextProcessor) { if (!isVariantPostProcessor) { isVariantPostProcessor = nextProcessor.isVariantPostProcessor(); } if (this.nextProcessor == null) { this.nextProcessor = nextProcessor; } else { this.nextProcessor.addNextProcessor(nextProcessor); } }
[ "@", "Override", "public", "void", "addNextProcessor", "(", "ChainedResourceBundlePostProcessor", "nextProcessor", ")", "{", "if", "(", "!", "isVariantPostProcessor", ")", "{", "isVariantPostProcessor", "=", "nextProcessor", ".", "isVariantPostProcessor", "(", ")", ";", "}", "if", "(", "this", ".", "nextProcessor", "==", "null", ")", "{", "this", ".", "nextProcessor", "=", "nextProcessor", ";", "}", "else", "{", "this", ".", "nextProcessor", ".", "addNextProcessor", "(", "nextProcessor", ")", ";", "}", "}" ]
Set the next post processor in the chain. @param nextProcessor the post processor to set
[ "Set", "the", "next", "post", "processor", "in", "the", "chain", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/AbstractChainedResourceBundlePostProcessor.java#L112-L122
7,304
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.extractBinaryResourceInfo
public static String[] extractBinaryResourceInfo(String path) { String[] resourceInfo = new String[2]; String resourcePath = path; if (resourcePath.startsWith(JawrConstant.URL_SEPARATOR)) { resourcePath = resourcePath.substring(1); } Matcher matcher = CACHE_BUSTER_PATTERN.matcher(resourcePath); StringBuffer result = new StringBuffer(); if (matcher.find()) { matcher.appendReplacement(result, StringUtils.isEmpty(matcher.group(GENERATED_BINARY_WEB_RESOURCE_PREFIX_INDEX)) ? CACHE_BUSTER_STANDARD_BINARY_WEB_RESOURCE_REPLACE_PATTERN : CACHE_BUSTER_GENERATED_BINARY_WEB_RESOURCE_REPLACE_PATTERN); resourceInfo[0] = result.toString(); resourceInfo[1] = matcher.group(1); } else { resourceInfo[0] = path; } return resourceInfo; }
java
public static String[] extractBinaryResourceInfo(String path) { String[] resourceInfo = new String[2]; String resourcePath = path; if (resourcePath.startsWith(JawrConstant.URL_SEPARATOR)) { resourcePath = resourcePath.substring(1); } Matcher matcher = CACHE_BUSTER_PATTERN.matcher(resourcePath); StringBuffer result = new StringBuffer(); if (matcher.find()) { matcher.appendReplacement(result, StringUtils.isEmpty(matcher.group(GENERATED_BINARY_WEB_RESOURCE_PREFIX_INDEX)) ? CACHE_BUSTER_STANDARD_BINARY_WEB_RESOURCE_REPLACE_PATTERN : CACHE_BUSTER_GENERATED_BINARY_WEB_RESOURCE_REPLACE_PATTERN); resourceInfo[0] = result.toString(); resourceInfo[1] = matcher.group(1); } else { resourceInfo[0] = path; } return resourceInfo; }
[ "public", "static", "String", "[", "]", "extractBinaryResourceInfo", "(", "String", "path", ")", "{", "String", "[", "]", "resourceInfo", "=", "new", "String", "[", "2", "]", ";", "String", "resourcePath", "=", "path", ";", "if", "(", "resourcePath", ".", "startsWith", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "resourcePath", "=", "resourcePath", ".", "substring", "(", "1", ")", ";", "}", "Matcher", "matcher", "=", "CACHE_BUSTER_PATTERN", ".", "matcher", "(", "resourcePath", ")", ";", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "result", ",", "StringUtils", ".", "isEmpty", "(", "matcher", ".", "group", "(", "GENERATED_BINARY_WEB_RESOURCE_PREFIX_INDEX", ")", ")", "?", "CACHE_BUSTER_STANDARD_BINARY_WEB_RESOURCE_REPLACE_PATTERN", ":", "CACHE_BUSTER_GENERATED_BINARY_WEB_RESOURCE_REPLACE_PATTERN", ")", ";", "resourceInfo", "[", "0", "]", "=", "result", ".", "toString", "(", ")", ";", "resourceInfo", "[", "1", "]", "=", "matcher", ".", "group", "(", "1", ")", ";", "}", "else", "{", "resourceInfo", "[", "0", "]", "=", "path", ";", "}", "return", "resourceInfo", ";", "}" ]
Returns the binary resource info from the path @param path the path @return the binary resource info from the path
[ "Returns", "the", "binary", "resource", "info", "from", "the", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L208-L230
7,305
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.normalizePathMapping
public static String normalizePathMapping(String pathMapping) { String normalizedPathMapping = normalizePath(pathMapping); if (normalizedPathMapping.endsWith("/**")) normalizedPathMapping = normalizedPathMapping.substring(0, normalizedPathMapping.length() - 3); return normalizedPathMapping; }
java
public static String normalizePathMapping(String pathMapping) { String normalizedPathMapping = normalizePath(pathMapping); if (normalizedPathMapping.endsWith("/**")) normalizedPathMapping = normalizedPathMapping.substring(0, normalizedPathMapping.length() - 3); return normalizedPathMapping; }
[ "public", "static", "String", "normalizePathMapping", "(", "String", "pathMapping", ")", "{", "String", "normalizedPathMapping", "=", "normalizePath", "(", "pathMapping", ")", ";", "if", "(", "normalizedPathMapping", ".", "endsWith", "(", "\"/**\"", ")", ")", "normalizedPathMapping", "=", "normalizedPathMapping", ".", "substring", "(", "0", ",", "normalizedPathMapping", ".", "length", "(", ")", "-", "3", ")", ";", "return", "normalizedPathMapping", ";", "}" ]
Normalizes a bundle path mapping. If it ends with a wildcard, the wildcard is removed. @param pathMapping the bundle path mapping @return the normalized path mapping
[ "Normalizes", "a", "bundle", "path", "mapping", ".", "If", "it", "ends", "with", "a", "wildcard", "the", "wildcard", "is", "removed", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L240-L246
7,306
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.asDirPath
public static String asDirPath(String path) { String dirPath = path; if (!path.equals(JawrConstant.URL_SEPARATOR)) { dirPath = JawrConstant.URL_SEPARATOR + normalizePath(path) + JawrConstant.URL_SEPARATOR; } return dirPath; }
java
public static String asDirPath(String path) { String dirPath = path; if (!path.equals(JawrConstant.URL_SEPARATOR)) { dirPath = JawrConstant.URL_SEPARATOR + normalizePath(path) + JawrConstant.URL_SEPARATOR; } return dirPath; }
[ "public", "static", "String", "asDirPath", "(", "String", "path", ")", "{", "String", "dirPath", "=", "path", ";", "if", "(", "!", "path", ".", "equals", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "dirPath", "=", "JawrConstant", ".", "URL_SEPARATOR", "+", "normalizePath", "(", "path", ")", "+", "JawrConstant", ".", "URL_SEPARATOR", ";", "}", "return", "dirPath", ";", "}" ]
Normalizes a path and adds a separator at its start and its end. @param path the path @return the normalized path
[ "Normalizes", "a", "path", "and", "adds", "a", "separator", "at", "its", "start", "and", "its", "end", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L265-L271
7,307
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.joinDomainToPath
public static String joinDomainToPath(String domainName, String path) { StringBuilder sb = new StringBuilder(); if (domainName.endsWith(JawrConstant.URL_SEPARATOR)) { sb.append(domainName.substring(0, domainName.length() - 1)); } else { sb.append(domainName); } sb.append(JawrConstant.URL_SEPARATOR).append(PathNormalizer.normalizePath(path)); return sb.toString(); }
java
public static String joinDomainToPath(String domainName, String path) { StringBuilder sb = new StringBuilder(); if (domainName.endsWith(JawrConstant.URL_SEPARATOR)) { sb.append(domainName.substring(0, domainName.length() - 1)); } else { sb.append(domainName); } sb.append(JawrConstant.URL_SEPARATOR).append(PathNormalizer.normalizePath(path)); return sb.toString(); }
[ "public", "static", "String", "joinDomainToPath", "(", "String", "domainName", ",", "String", "path", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "domainName", ".", "endsWith", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "sb", ".", "append", "(", "domainName", ".", "substring", "(", "0", ",", "domainName", ".", "length", "(", ")", "-", "1", ")", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "domainName", ")", ";", "}", "sb", ".", "append", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ".", "append", "(", "PathNormalizer", ".", "normalizePath", "(", "path", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Normalizes a domain name and a path and joins them as a single url. @param domainName @param path @return
[ "Normalizes", "a", "domain", "name", "and", "a", "path", "and", "joins", "them", "as", "a", "single", "url", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L341-L353
7,308
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.normalizePaths
public static final Set<String> normalizePaths(Set<String> paths) { Set<String> ret = new HashSet<>(); for (Iterator<String> it = paths.iterator(); it.hasNext();) { String path = normalizePath((String) it.next()); ret.add(path); } return ret; }
java
public static final Set<String> normalizePaths(Set<String> paths) { Set<String> ret = new HashSet<>(); for (Iterator<String> it = paths.iterator(); it.hasNext();) { String path = normalizePath((String) it.next()); ret.add(path); } return ret; }
[ "public", "static", "final", "Set", "<", "String", ">", "normalizePaths", "(", "Set", "<", "String", ">", "paths", ")", "{", "Set", "<", "String", ">", "ret", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "it", "=", "paths", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "String", "path", "=", "normalizePath", "(", "(", "String", ")", "it", ".", "next", "(", ")", ")", ";", "ret", ".", "add", "(", "path", ")", ";", "}", "return", "ret", ";", "}" ]
Normalizes all the paths in a Set. @param paths @return
[ "Normalizes", "all", "the", "paths", "in", "a", "Set", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L382-L389
7,309
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.addGetParameter
public static String addGetParameter(String path, String parameterKey, String parameter) { StringBuilder sb = new StringBuilder(path); if (path.indexOf("?") > 0) { sb.append("&"); } else { sb.append("?"); } sb.append(parameterKey).append("=").append(parameter); return sb.toString(); }
java
public static String addGetParameter(String path, String parameterKey, String parameter) { StringBuilder sb = new StringBuilder(path); if (path.indexOf("?") > 0) { sb.append("&"); } else { sb.append("?"); } sb.append(parameterKey).append("=").append(parameter); return sb.toString(); }
[ "public", "static", "String", "addGetParameter", "(", "String", "path", ",", "String", "parameterKey", ",", "String", "parameter", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "path", ")", ";", "if", "(", "path", ".", "indexOf", "(", "\"?\"", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\"&\"", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\"?\"", ")", ";", "}", "sb", ".", "append", "(", "parameterKey", ")", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "parameter", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Adds a key and value to the request path & or ? will be used as needed path + ? or & + parameterKey=parameter @param path the url to add the parameterKey and parameter too @param parameterKey the key in the get request (parameterKey=parameter) @param parameter the parameter to add to the end of the url @return a String with the url parameter added: path + ? or & + parameterKey=parameter
[ "Adds", "a", "key", "and", "value", "to", "the", "request", "path", "&", "or", "?", "will", "be", "used", "as", "needed" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L437-L446
7,310
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.getParentPath
public static String getParentPath(String path) { String parentPath = null; if (StringUtils.isEmpty(path)) { parentPath = ""; } else { parentPath = path; if (parentPath.length() > 1 && parentPath.endsWith(JawrConstant.URL_SEPARATOR)) { parentPath = parentPath.substring(0, parentPath.length() - 2); } int index = parentPath.lastIndexOf(JawrConstant.URL_SEPARATOR); if (index > 0) { return parentPath.substring(0, index + 1); } else { parentPath = JawrConstant.URL_SEPARATOR; } } return parentPath; }
java
public static String getParentPath(String path) { String parentPath = null; if (StringUtils.isEmpty(path)) { parentPath = ""; } else { parentPath = path; if (parentPath.length() > 1 && parentPath.endsWith(JawrConstant.URL_SEPARATOR)) { parentPath = parentPath.substring(0, parentPath.length() - 2); } int index = parentPath.lastIndexOf(JawrConstant.URL_SEPARATOR); if (index > 0) { return parentPath.substring(0, index + 1); } else { parentPath = JawrConstant.URL_SEPARATOR; } } return parentPath; }
[ "public", "static", "String", "getParentPath", "(", "String", "path", ")", "{", "String", "parentPath", "=", "null", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "path", ")", ")", "{", "parentPath", "=", "\"\"", ";", "}", "else", "{", "parentPath", "=", "path", ";", "if", "(", "parentPath", ".", "length", "(", ")", ">", "1", "&&", "parentPath", ".", "endsWith", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "parentPath", "=", "parentPath", ".", "substring", "(", "0", ",", "parentPath", ".", "length", "(", ")", "-", "2", ")", ";", "}", "int", "index", "=", "parentPath", ".", "lastIndexOf", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ";", "if", "(", "index", ">", "0", ")", "{", "return", "parentPath", ".", "substring", "(", "0", ",", "index", "+", "1", ")", ";", "}", "else", "{", "parentPath", "=", "JawrConstant", ".", "URL_SEPARATOR", ";", "}", "}", "return", "parentPath", ";", "}" ]
Determines the parent path of a filename or a directory. <pre> PathUtils.getParentPath( null ) = "" PathUtils.getParentPath( "" ) = "" PathUtils.getParentPath( "/" ) = "/" PathUtils.getParentPath( "/usr/local/" ) = "/usr/local/" PathUtils.getRelativePath( "/usr/local/bin/java.sh" ) = ""/usr/local/bin/" </pre> @param path the path @return the parent path.
[ "Determines", "the", "parent", "path", "of", "a", "filename", "or", "a", "directory", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L471-L491
7,311
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.getPathName
public static String getPathName(String path) { String pathName = null; if (StringUtils.isEmpty(path)) { pathName = ""; } else { pathName = path; if (pathName.length() > 1 && pathName.endsWith(JawrConstant.URL_SEPARATOR)) { pathName = pathName.substring(0, pathName.length() - 1); } int index = pathName.lastIndexOf(JawrConstant.URL_SEPARATOR); if (index > 0) { pathName = pathName.substring(index + 1); } else { pathName = JawrConstant.URL_SEPARATOR; } } return pathName; }
java
public static String getPathName(String path) { String pathName = null; if (StringUtils.isEmpty(path)) { pathName = ""; } else { pathName = path; if (pathName.length() > 1 && pathName.endsWith(JawrConstant.URL_SEPARATOR)) { pathName = pathName.substring(0, pathName.length() - 1); } int index = pathName.lastIndexOf(JawrConstant.URL_SEPARATOR); if (index > 0) { pathName = pathName.substring(index + 1); } else { pathName = JawrConstant.URL_SEPARATOR; } } return pathName; }
[ "public", "static", "String", "getPathName", "(", "String", "path", ")", "{", "String", "pathName", "=", "null", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "path", ")", ")", "{", "pathName", "=", "\"\"", ";", "}", "else", "{", "pathName", "=", "path", ";", "if", "(", "pathName", ".", "length", "(", ")", ">", "1", "&&", "pathName", ".", "endsWith", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "pathName", "=", "pathName", ".", "substring", "(", "0", ",", "pathName", ".", "length", "(", ")", "-", "1", ")", ";", "}", "int", "index", "=", "pathName", ".", "lastIndexOf", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ";", "if", "(", "index", ">", "0", ")", "{", "pathName", "=", "pathName", ".", "substring", "(", "index", "+", "1", ")", ";", "}", "else", "{", "pathName", "=", "JawrConstant", ".", "URL_SEPARATOR", ";", "}", "}", "return", "pathName", ";", "}" ]
Determines the filename of a path. <pre> PathNormalizer.getPathName( null ) = "" PathNormalizer.getPathName( "" ) = "" PathNormalizer.getPathName( "/" ) = "/" PathNormalizer.getPathName( "/usr/local/" ) = "local" PathNormalizer.getPathName( "/usr/local/bin/java.sh" ) = "java.sh" </pre> @param path the path @return the path name.
[ "Determines", "the", "filename", "of", "a", "path", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L509-L528
7,312
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java
PathNormalizer.uppercaseDrive
static final String uppercaseDrive(String path) { String resultPath = null; if (path != null) { if (path.length() >= 2 && path.charAt(1) == ':') { resultPath = Character.toUpperCase(path.charAt(0)) + path.substring(1); } else { resultPath = path; } } return resultPath; }
java
static final String uppercaseDrive(String path) { String resultPath = null; if (path != null) { if (path.length() >= 2 && path.charAt(1) == ':') { resultPath = Character.toUpperCase(path.charAt(0)) + path.substring(1); } else { resultPath = path; } } return resultPath; }
[ "static", "final", "String", "uppercaseDrive", "(", "String", "path", ")", "{", "String", "resultPath", "=", "null", ";", "if", "(", "path", "!=", "null", ")", "{", "if", "(", "path", ".", "length", "(", ")", ">=", "2", "&&", "path", ".", "charAt", "(", "1", ")", "==", "'", "'", ")", "{", "resultPath", "=", "Character", ".", "toUpperCase", "(", "path", ".", "charAt", "(", "0", ")", ")", "+", "path", ".", "substring", "(", "1", ")", ";", "}", "else", "{", "resultPath", "=", "path", ";", "}", "}", "return", "resultPath", ";", "}" ]
Cygwin prefers lowercase drive letters, but other parts of maven use uppercase @param path @return String
[ "Cygwin", "prefers", "lowercase", "drive", "letters", "but", "other", "parts", "of", "maven", "use", "uppercase" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PathNormalizer.java#L922-L932
7,313
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getCommonProperty
public String getCommonProperty(String key, String defaultValue) { return props.getProperty(PropertiesBundleConstant.PROPS_PREFIX + key, defaultValue); }
java
public String getCommonProperty(String key, String defaultValue) { return props.getProperty(PropertiesBundleConstant.PROPS_PREFIX + key, defaultValue); }
[ "public", "String", "getCommonProperty", "(", "String", "key", ",", "String", "defaultValue", ")", "{", "return", "props", ".", "getProperty", "(", "PropertiesBundleConstant", ".", "PROPS_PREFIX", "+", "key", ",", "defaultValue", ")", ";", "}" ]
Returns the value of the common property, or the default value if no value is defined instead. @param key the key of the property @param defaultValue the default value @return the value of the common property
[ "Returns", "the", "value", "of", "the", "common", "property", "or", "the", "default", "value", "if", "no", "value", "is", "defined", "instead", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L94-L96
7,314
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getCustomBundleProperty
public String getCustomBundleProperty(String bundleName, String key, String defaultValue) { return props.getProperty(prefix + PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_PROPERTY + bundleName + key, defaultValue); }
java
public String getCustomBundleProperty(String bundleName, String key, String defaultValue) { return props.getProperty(prefix + PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_PROPERTY + bundleName + key, defaultValue); }
[ "public", "String", "getCustomBundleProperty", "(", "String", "bundleName", ",", "String", "key", ",", "String", "defaultValue", ")", "{", "return", "props", ".", "getProperty", "(", "prefix", "+", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_PROPERTY", "+", "bundleName", "+", "key", ",", "defaultValue", ")", ";", "}" ]
Returns the value of the custom bundle property, or the default value if no value is defined @param bundleName the bundle name @param key the key of the property @param defaultValue the default value @return the value of the custom bundle property, or the default value if no value is defined
[ "Returns", "the", "value", "of", "the", "custom", "bundle", "property", "or", "the", "default", "value", "if", "no", "value", "is", "defined" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L138-L141
7,315
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getCustomBundlePropertyAsList
public List<String> getCustomBundlePropertyAsList(String bundleName, String key) { List<String> propertiesList = new ArrayList<>(); StringTokenizer tk = new StringTokenizer(getCustomBundleProperty(bundleName, key, ""), ","); while (tk.hasMoreTokens()) propertiesList.add(tk.nextToken().trim()); return propertiesList; }
java
public List<String> getCustomBundlePropertyAsList(String bundleName, String key) { List<String> propertiesList = new ArrayList<>(); StringTokenizer tk = new StringTokenizer(getCustomBundleProperty(bundleName, key, ""), ","); while (tk.hasMoreTokens()) propertiesList.add(tk.nextToken().trim()); return propertiesList; }
[ "public", "List", "<", "String", ">", "getCustomBundlePropertyAsList", "(", "String", "bundleName", ",", "String", "key", ")", "{", "List", "<", "String", ">", "propertiesList", "=", "new", "ArrayList", "<>", "(", ")", ";", "StringTokenizer", "tk", "=", "new", "StringTokenizer", "(", "getCustomBundleProperty", "(", "bundleName", ",", "key", ",", "\"\"", ")", ",", "\",\"", ")", ";", "while", "(", "tk", ".", "hasMoreTokens", "(", ")", ")", "propertiesList", ".", "add", "(", "tk", ".", "nextToken", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "propertiesList", ";", "}" ]
Returns as a list, the comma separated values of a property @param bundleName the bundle name @param key the key of the property @return a list of the comma separated values of a property
[ "Returns", "as", "a", "list", "the", "comma", "separated", "values", "of", "a", "property" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L181-L187
7,316
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getCustomBundleVariantSets
public Map<String, VariantSet> getCustomBundleVariantSets(String bundleName) { Map<String, VariantSet> variantSets = new HashMap<>(); StringTokenizer tk = new StringTokenizer( getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_VARIANTS, ""), ";"); while (tk.hasMoreTokens()) { String[] mapEntry = tk.nextToken().trim().split(":"); String type = mapEntry[0]; String defaultVariant = mapEntry[1]; String values = mapEntry[2]; String[] variantsArray = StringUtils.split(values, ","); List<String> variants = new ArrayList<>(); variants.addAll(Arrays.asList(variantsArray)); VariantSet variantSet = new VariantSet(type, defaultVariant, variants); variantSets.put(type, variantSet); } return variantSets; }
java
public Map<String, VariantSet> getCustomBundleVariantSets(String bundleName) { Map<String, VariantSet> variantSets = new HashMap<>(); StringTokenizer tk = new StringTokenizer( getCustomBundleProperty(bundleName, PropertiesBundleConstant.BUNDLE_FACTORY_CUSTOM_VARIANTS, ""), ";"); while (tk.hasMoreTokens()) { String[] mapEntry = tk.nextToken().trim().split(":"); String type = mapEntry[0]; String defaultVariant = mapEntry[1]; String values = mapEntry[2]; String[] variantsArray = StringUtils.split(values, ","); List<String> variants = new ArrayList<>(); variants.addAll(Arrays.asList(variantsArray)); VariantSet variantSet = new VariantSet(type, defaultVariant, variants); variantSets.put(type, variantSet); } return variantSets; }
[ "public", "Map", "<", "String", ",", "VariantSet", ">", "getCustomBundleVariantSets", "(", "String", "bundleName", ")", "{", "Map", "<", "String", ",", "VariantSet", ">", "variantSets", "=", "new", "HashMap", "<>", "(", ")", ";", "StringTokenizer", "tk", "=", "new", "StringTokenizer", "(", "getCustomBundleProperty", "(", "bundleName", ",", "PropertiesBundleConstant", ".", "BUNDLE_FACTORY_CUSTOM_VARIANTS", ",", "\"\"", ")", ",", "\";\"", ")", ";", "while", "(", "tk", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "[", "]", "mapEntry", "=", "tk", ".", "nextToken", "(", ")", ".", "trim", "(", ")", ".", "split", "(", "\":\"", ")", ";", "String", "type", "=", "mapEntry", "[", "0", "]", ";", "String", "defaultVariant", "=", "mapEntry", "[", "1", "]", ";", "String", "values", "=", "mapEntry", "[", "2", "]", ";", "String", "[", "]", "variantsArray", "=", "StringUtils", ".", "split", "(", "values", ",", "\",\"", ")", ";", "List", "<", "String", ">", "variants", "=", "new", "ArrayList", "<>", "(", ")", ";", "variants", ".", "addAll", "(", "Arrays", ".", "asList", "(", "variantsArray", ")", ")", ";", "VariantSet", "variantSet", "=", "new", "VariantSet", "(", "type", ",", "defaultVariant", ",", "variants", ")", ";", "variantSets", ".", "put", "(", "type", ",", "variantSet", ")", ";", "}", "return", "variantSets", ";", "}" ]
Returns the map of variantSet for the bundle @param bundleName the bundle name @return the map of variantSet for the bundle
[ "Returns", "the", "map", "of", "variantSet", "for", "the", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L241-L260
7,317
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getProperty
public String getProperty(String key, String defaultValue) { return props.getProperty(prefix + key, defaultValue); }
java
public String getProperty(String key, String defaultValue) { return props.getProperty(prefix + key, defaultValue); }
[ "public", "String", "getProperty", "(", "String", "key", ",", "String", "defaultValue", ")", "{", "return", "props", ".", "getProperty", "(", "prefix", "+", "key", ",", "defaultValue", ")", ";", "}" ]
Returns the value of a property, or the default value if no value is defined @param key the key of the property @param defaultValue the default value @return the value of a property, or the default value if no value is defined
[ "Returns", "the", "value", "of", "a", "property", "or", "the", "default", "value", "if", "no", "value", "is", "defined" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L288-L290
7,318
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getPropertyBundleNameSet
public Set<String> getPropertyBundleNameSet() { Set<String> bundleNameSet = new HashSet<>(); for (Object key : props.keySet()) { Matcher matcher = bundleNamePattern.matcher((String) key); if (matcher.matches()) { String id = matcher.group(2); bundleNameSet.add(id); } } return bundleNameSet; }
java
public Set<String> getPropertyBundleNameSet() { Set<String> bundleNameSet = new HashSet<>(); for (Object key : props.keySet()) { Matcher matcher = bundleNamePattern.matcher((String) key); if (matcher.matches()) { String id = matcher.group(2); bundleNameSet.add(id); } } return bundleNameSet; }
[ "public", "Set", "<", "String", ">", "getPropertyBundleNameSet", "(", ")", "{", "Set", "<", "String", ">", "bundleNameSet", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Object", "key", ":", "props", ".", "keySet", "(", ")", ")", "{", "Matcher", "matcher", "=", "bundleNamePattern", ".", "matcher", "(", "(", "String", ")", "key", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "String", "id", "=", "matcher", ".", "group", "(", "2", ")", ";", "bundleNameSet", ".", "add", "(", "id", ")", ";", "}", "}", "return", "bundleNameSet", ";", "}" ]
Returns the set of names for the bundles @return the set of names for the bundles
[ "Returns", "the", "set", "of", "names", "for", "the", "bundles" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L297-L310
7,319
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java
PropertiesConfigHelper.getCustomMap
private Map<String, String> getCustomMap(Pattern keyPattern) { Map<String, String> map = new HashMap<>(); for (Iterator<Object> it = props.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); Matcher matcher = keyPattern.matcher(key); if (matcher.matches()) { String id = matcher.group(2); String propertyValue = props.getProperty(key); map.put(id, propertyValue); } } return map; }
java
private Map<String, String> getCustomMap(Pattern keyPattern) { Map<String, String> map = new HashMap<>(); for (Iterator<Object> it = props.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); Matcher matcher = keyPattern.matcher(key); if (matcher.matches()) { String id = matcher.group(2); String propertyValue = props.getProperty(key); map.put(id, propertyValue); } } return map; }
[ "private", "Map", "<", "String", ",", "String", ">", "getCustomMap", "(", "Pattern", "keyPattern", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "Object", ">", "it", "=", "props", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "String", "key", "=", "(", "String", ")", "it", ".", "next", "(", ")", ";", "Matcher", "matcher", "=", "keyPattern", ".", "matcher", "(", "key", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", "{", "String", "id", "=", "matcher", ".", "group", "(", "2", ")", ";", "String", "propertyValue", "=", "props", ".", "getProperty", "(", "key", ")", ";", "map", ".", "put", "(", "id", ",", "propertyValue", ")", ";", "}", "}", "return", "map", ";", "}" ]
Returns the map, where the key is the 2 group of the pattern and the value is the property value @param keyPattern the pattern of the key @return the map.
[ "Returns", "the", "map", "where", "the", "key", "is", "the", "2", "group", "of", "the", "pattern", "and", "the", "value", "is", "the", "property", "value" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/factory/util/PropertiesConfigHelper.java#L347-L361
7,320
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/MessageBundleControl.java
MessageBundleControl.getFallbackLocale
public Locale getFallbackLocale() { Locale locale = null; if (this.fallbackToSystemLocale) { locale = Locale.getDefault(); } else { locale = new Locale("", ""); } return locale; }
java
public Locale getFallbackLocale() { Locale locale = null; if (this.fallbackToSystemLocale) { locale = Locale.getDefault(); } else { locale = new Locale("", ""); } return locale; }
[ "public", "Locale", "getFallbackLocale", "(", ")", "{", "Locale", "locale", "=", "null", ";", "if", "(", "this", ".", "fallbackToSystemLocale", ")", "{", "locale", "=", "Locale", ".", "getDefault", "(", ")", ";", "}", "else", "{", "locale", "=", "new", "Locale", "(", "\"\"", ",", "\"\"", ")", ";", "}", "return", "locale", ";", "}" ]
Returns the fall-back locale @return the fall-back locale
[ "Returns", "the", "fall", "-", "back", "locale" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/MessageBundleControl.java#L181-L191
7,321
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/AutoPrefixerPostProcessor.java
AutoPrefixerPostProcessor.initialize
private void initialize(JawrConfig config) { StopWatch stopWatch = new StopWatch("Initializing JS engine for Autoprefixer"); stopWatch.start(); // Load JavaScript Script Engine String script = config.getProperty(AUTOPREFIXER_SCRIPT_LOCATION, AUTOPREFIXER_SCRIPT_DEFAULT_LOCATION); String jsEngineName = config.getJavascriptEngineName(AUTOPREFIXER_JS_ENGINE); jsEngine = new JavascriptEngine(jsEngineName, true); jsEngine.getBindings().put("logger", LOGGER); try(InputStream inputStream = getResourceInputStream(config, script)){ jsEngine.evaluate("autoprefixer.js", inputStream); } catch (IOException e) { throw new BundlingProcessException(e); } String strOptions = config.getProperty(AUTOPREFIXER_SCRIPT_OPTIONS, AUTOPREFIXER_DEFAULT_OPTIONS); this.options = jsEngine.execEval(strOptions); jsEngine.evaluate("initAutoPrefixer.js", String.format("if(logger.isDebugEnabled()){ logger.debug('Autoprefixer config : '+autoprefixer(%s).info());}", strOptions)); jsEngine.evaluate("jawrAutoPrefixerProcess.js", "function process(cssSource, opts){\n" + "var result = autoprefixer.process.apply(autoprefixer, [cssSource, opts]);\n" + "if(result.warnings){\n" + "result.warnings().forEach(function(message){\n" + "if(logger.isWarnEnabled()){\n" + "logger.warn(message.toString());\n" + "}\n" + "});}\n" + "return result.css;\n" + "}"); stopWatch.stop(); if (PERF_LOGGER.isDebugEnabled()) { PERF_LOGGER.debug(stopWatch.shortSummary()); } }
java
private void initialize(JawrConfig config) { StopWatch stopWatch = new StopWatch("Initializing JS engine for Autoprefixer"); stopWatch.start(); // Load JavaScript Script Engine String script = config.getProperty(AUTOPREFIXER_SCRIPT_LOCATION, AUTOPREFIXER_SCRIPT_DEFAULT_LOCATION); String jsEngineName = config.getJavascriptEngineName(AUTOPREFIXER_JS_ENGINE); jsEngine = new JavascriptEngine(jsEngineName, true); jsEngine.getBindings().put("logger", LOGGER); try(InputStream inputStream = getResourceInputStream(config, script)){ jsEngine.evaluate("autoprefixer.js", inputStream); } catch (IOException e) { throw new BundlingProcessException(e); } String strOptions = config.getProperty(AUTOPREFIXER_SCRIPT_OPTIONS, AUTOPREFIXER_DEFAULT_OPTIONS); this.options = jsEngine.execEval(strOptions); jsEngine.evaluate("initAutoPrefixer.js", String.format("if(logger.isDebugEnabled()){ logger.debug('Autoprefixer config : '+autoprefixer(%s).info());}", strOptions)); jsEngine.evaluate("jawrAutoPrefixerProcess.js", "function process(cssSource, opts){\n" + "var result = autoprefixer.process.apply(autoprefixer, [cssSource, opts]);\n" + "if(result.warnings){\n" + "result.warnings().forEach(function(message){\n" + "if(logger.isWarnEnabled()){\n" + "logger.warn(message.toString());\n" + "}\n" + "});}\n" + "return result.css;\n" + "}"); stopWatch.stop(); if (PERF_LOGGER.isDebugEnabled()) { PERF_LOGGER.debug(stopWatch.shortSummary()); } }
[ "private", "void", "initialize", "(", "JawrConfig", "config", ")", "{", "StopWatch", "stopWatch", "=", "new", "StopWatch", "(", "\"Initializing JS engine for Autoprefixer\"", ")", ";", "stopWatch", ".", "start", "(", ")", ";", "// Load JavaScript Script Engine", "String", "script", "=", "config", ".", "getProperty", "(", "AUTOPREFIXER_SCRIPT_LOCATION", ",", "AUTOPREFIXER_SCRIPT_DEFAULT_LOCATION", ")", ";", "String", "jsEngineName", "=", "config", ".", "getJavascriptEngineName", "(", "AUTOPREFIXER_JS_ENGINE", ")", ";", "jsEngine", "=", "new", "JavascriptEngine", "(", "jsEngineName", ",", "true", ")", ";", "jsEngine", ".", "getBindings", "(", ")", ".", "put", "(", "\"logger\"", ",", "LOGGER", ")", ";", "try", "(", "InputStream", "inputStream", "=", "getResourceInputStream", "(", "config", ",", "script", ")", ")", "{", "jsEngine", ".", "evaluate", "(", "\"autoprefixer.js\"", ",", "inputStream", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "String", "strOptions", "=", "config", ".", "getProperty", "(", "AUTOPREFIXER_SCRIPT_OPTIONS", ",", "AUTOPREFIXER_DEFAULT_OPTIONS", ")", ";", "this", ".", "options", "=", "jsEngine", ".", "execEval", "(", "strOptions", ")", ";", "jsEngine", ".", "evaluate", "(", "\"initAutoPrefixer.js\"", ",", "String", ".", "format", "(", "\"if(logger.isDebugEnabled()){ logger.debug('Autoprefixer config : '+autoprefixer(%s).info());}\"", ",", "strOptions", ")", ")", ";", "jsEngine", ".", "evaluate", "(", "\"jawrAutoPrefixerProcess.js\"", ",", "\"function process(cssSource, opts){\\n\"", "+", "\"var result = autoprefixer.process.apply(autoprefixer, [cssSource, opts]);\\n\"", "+", "\"if(result.warnings){\\n\"", "+", "\"result.warnings().forEach(function(message){\\n\"", "+", "\"if(logger.isWarnEnabled()){\\n\"", "+", "\"logger.warn(message.toString());\\n\"", "+", "\"}\\n\"", "+", "\"});}\\n\"", "+", "\"return result.css;\\n\"", "+", "\"}\"", ")", ";", "stopWatch", ".", "stop", "(", ")", ";", "if", "(", "PERF_LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "PERF_LOGGER", ".", "debug", "(", "stopWatch", ".", "shortSummary", "(", ")", ")", ";", "}", "}" ]
Initialize the postprocessor
[ "Initialize", "the", "postprocessor" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/AutoPrefixerPostProcessor.java#L82-L113
7,322
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java
IECssBundleGenerator.generateContent
private String generateContent(GeneratorContext context, ResourceBundlesHandler bundlesHandler, String bundlePath, Map<String, String> variants) { // Here we create a new context where the bundle name is the Jawr // generator CSS path String cssGeneratorBundlePath = PathNormalizer.joinPaths(context.getConfig().getServletMapping(), ResourceGenerator.CSS_DEBUGPATH); JoinableResourceBundle tempBundle = new JoinableResourceBundleImpl(cssGeneratorBundlePath, null, null, "css", null, null, context.getConfig().getGeneratorRegistry()); BundleProcessingStatus tempStatus = new BundleProcessingStatus(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE, tempBundle, context.getResourceReaderHandler(), context.getConfig()); CSSURLPathRewriterPostProcessor postProcessor = new CSSURLPathRewriterPostProcessor(); ResourceBundlePathsIterator it = null; StringWriter resultWriter = new StringWriter(); StringBuffer result = resultWriter.getBuffer(); ConditionalCommentCallbackHandler callbackHandler = new ConditionalCommentRenderer(resultWriter); if (bundlesHandler.isGlobalResourceBundle(bundlePath)) { it = bundlesHandler.getGlobalResourceBundlePaths(bundlePath, callbackHandler, variants); } else { it = bundlesHandler.getBundlePaths(bundlePath, callbackHandler, variants); } while (it.hasNext()) { BundlePath resourcePath = it.nextPath(); if (resourcePath != null) { tempStatus.setLastPathAdded(resourcePath.getPath()); Reader cssReader = null; try{ JoinableResourceBundle bundle = context.getBundle(); cssReader = context.getResourceReaderHandler().getResource(bundle, resourcePath.getPath(), true); StringWriter writer = new StringWriter(); IOUtils.copy(cssReader, writer, true); StringBuffer resourceData = postProcessor.postProcessBundle(tempStatus, writer.getBuffer()); result.append("/** CSS resource : ").append(resourcePath.getPath()).append(" **/\n"); result.append(resourceData); if (it.hasNext()) { result.append("\n\n"); } } catch (ResourceNotFoundException e) { LOGGER.debug("The resource '" + resourcePath.getPath() + "' was not found"); } catch (IOException e) { throw new BundlingProcessException(e); }finally { IOUtils.close(cssReader); } } } return result.toString(); }
java
private String generateContent(GeneratorContext context, ResourceBundlesHandler bundlesHandler, String bundlePath, Map<String, String> variants) { // Here we create a new context where the bundle name is the Jawr // generator CSS path String cssGeneratorBundlePath = PathNormalizer.joinPaths(context.getConfig().getServletMapping(), ResourceGenerator.CSS_DEBUGPATH); JoinableResourceBundle tempBundle = new JoinableResourceBundleImpl(cssGeneratorBundlePath, null, null, "css", null, null, context.getConfig().getGeneratorRegistry()); BundleProcessingStatus tempStatus = new BundleProcessingStatus(BundleProcessingStatus.BUNDLE_PROCESSING_TYPE, tempBundle, context.getResourceReaderHandler(), context.getConfig()); CSSURLPathRewriterPostProcessor postProcessor = new CSSURLPathRewriterPostProcessor(); ResourceBundlePathsIterator it = null; StringWriter resultWriter = new StringWriter(); StringBuffer result = resultWriter.getBuffer(); ConditionalCommentCallbackHandler callbackHandler = new ConditionalCommentRenderer(resultWriter); if (bundlesHandler.isGlobalResourceBundle(bundlePath)) { it = bundlesHandler.getGlobalResourceBundlePaths(bundlePath, callbackHandler, variants); } else { it = bundlesHandler.getBundlePaths(bundlePath, callbackHandler, variants); } while (it.hasNext()) { BundlePath resourcePath = it.nextPath(); if (resourcePath != null) { tempStatus.setLastPathAdded(resourcePath.getPath()); Reader cssReader = null; try{ JoinableResourceBundle bundle = context.getBundle(); cssReader = context.getResourceReaderHandler().getResource(bundle, resourcePath.getPath(), true); StringWriter writer = new StringWriter(); IOUtils.copy(cssReader, writer, true); StringBuffer resourceData = postProcessor.postProcessBundle(tempStatus, writer.getBuffer()); result.append("/** CSS resource : ").append(resourcePath.getPath()).append(" **/\n"); result.append(resourceData); if (it.hasNext()) { result.append("\n\n"); } } catch (ResourceNotFoundException e) { LOGGER.debug("The resource '" + resourcePath.getPath() + "' was not found"); } catch (IOException e) { throw new BundlingProcessException(e); }finally { IOUtils.close(cssReader); } } } return result.toString(); }
[ "private", "String", "generateContent", "(", "GeneratorContext", "context", ",", "ResourceBundlesHandler", "bundlesHandler", ",", "String", "bundlePath", ",", "Map", "<", "String", ",", "String", ">", "variants", ")", "{", "// Here we create a new context where the bundle name is the Jawr", "// generator CSS path", "String", "cssGeneratorBundlePath", "=", "PathNormalizer", ".", "joinPaths", "(", "context", ".", "getConfig", "(", ")", ".", "getServletMapping", "(", ")", ",", "ResourceGenerator", ".", "CSS_DEBUGPATH", ")", ";", "JoinableResourceBundle", "tempBundle", "=", "new", "JoinableResourceBundleImpl", "(", "cssGeneratorBundlePath", ",", "null", ",", "null", ",", "\"css\"", ",", "null", ",", "null", ",", "context", ".", "getConfig", "(", ")", ".", "getGeneratorRegistry", "(", ")", ")", ";", "BundleProcessingStatus", "tempStatus", "=", "new", "BundleProcessingStatus", "(", "BundleProcessingStatus", ".", "BUNDLE_PROCESSING_TYPE", ",", "tempBundle", ",", "context", ".", "getResourceReaderHandler", "(", ")", ",", "context", ".", "getConfig", "(", ")", ")", ";", "CSSURLPathRewriterPostProcessor", "postProcessor", "=", "new", "CSSURLPathRewriterPostProcessor", "(", ")", ";", "ResourceBundlePathsIterator", "it", "=", "null", ";", "StringWriter", "resultWriter", "=", "new", "StringWriter", "(", ")", ";", "StringBuffer", "result", "=", "resultWriter", ".", "getBuffer", "(", ")", ";", "ConditionalCommentCallbackHandler", "callbackHandler", "=", "new", "ConditionalCommentRenderer", "(", "resultWriter", ")", ";", "if", "(", "bundlesHandler", ".", "isGlobalResourceBundle", "(", "bundlePath", ")", ")", "{", "it", "=", "bundlesHandler", ".", "getGlobalResourceBundlePaths", "(", "bundlePath", ",", "callbackHandler", ",", "variants", ")", ";", "}", "else", "{", "it", "=", "bundlesHandler", ".", "getBundlePaths", "(", "bundlePath", ",", "callbackHandler", ",", "variants", ")", ";", "}", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "BundlePath", "resourcePath", "=", "it", ".", "nextPath", "(", ")", ";", "if", "(", "resourcePath", "!=", "null", ")", "{", "tempStatus", ".", "setLastPathAdded", "(", "resourcePath", ".", "getPath", "(", ")", ")", ";", "Reader", "cssReader", "=", "null", ";", "try", "{", "JoinableResourceBundle", "bundle", "=", "context", ".", "getBundle", "(", ")", ";", "cssReader", "=", "context", ".", "getResourceReaderHandler", "(", ")", ".", "getResource", "(", "bundle", ",", "resourcePath", ".", "getPath", "(", ")", ",", "true", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "IOUtils", ".", "copy", "(", "cssReader", ",", "writer", ",", "true", ")", ";", "StringBuffer", "resourceData", "=", "postProcessor", ".", "postProcessBundle", "(", "tempStatus", ",", "writer", ".", "getBuffer", "(", ")", ")", ";", "result", ".", "append", "(", "\"/** CSS resource : \"", ")", ".", "append", "(", "resourcePath", ".", "getPath", "(", ")", ")", ".", "append", "(", "\" **/\\n\"", ")", ";", "result", ".", "append", "(", "resourceData", ")", ";", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "result", ".", "append", "(", "\"\\n\\n\"", ")", ";", "}", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "LOGGER", ".", "debug", "(", "\"The resource '\"", "+", "resourcePath", ".", "getPath", "(", ")", "+", "\"' was not found\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "close", "(", "cssReader", ")", ";", "}", "}", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Generates the Css content for the bundle path @param context the generator context @param bundlesHandler the bundles handler @param bundlePath the bundle path @param variants the variants @return the generated CSS content
[ "Generates", "the", "Css", "content", "for", "the", "bundle", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java#L123-L180
7,323
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java
IECssBundleGenerator.getVariantMap
private Map<String, String> getVariantMap(ResourceBundlesHandler bundlesHandler, String contextPath, String bundlePath) { JoinableResourceBundle bundle = bundlesHandler.resolveBundleForPath(bundlePath); Set<String> variantTypes = bundle.getVariants().keySet(); String variantKey = getVariantKey(contextPath); String[] variantValues = new String[0]; if (variantKey.length() > 0) { if (variantKey.length() == 1) { variantValues = new String[] { "", "" }; } else { variantValues = variantKey.split(String.valueOf(JawrConstant.VARIANT_SEPARATOR_CHAR)); } } Map<String, String> variants = new HashMap<>(); if (variantTypes.size() != variantValues.length) { throw new BundlingProcessException("For the resource '" + contextPath + "', the number variant types for the bundle don't match the variant values."); } int i = 0; for (String variantType : variantTypes) { variants.put(variantType, variantValues[i++]); } return variants; }
java
private Map<String, String> getVariantMap(ResourceBundlesHandler bundlesHandler, String contextPath, String bundlePath) { JoinableResourceBundle bundle = bundlesHandler.resolveBundleForPath(bundlePath); Set<String> variantTypes = bundle.getVariants().keySet(); String variantKey = getVariantKey(contextPath); String[] variantValues = new String[0]; if (variantKey.length() > 0) { if (variantKey.length() == 1) { variantValues = new String[] { "", "" }; } else { variantValues = variantKey.split(String.valueOf(JawrConstant.VARIANT_SEPARATOR_CHAR)); } } Map<String, String> variants = new HashMap<>(); if (variantTypes.size() != variantValues.length) { throw new BundlingProcessException("For the resource '" + contextPath + "', the number variant types for the bundle don't match the variant values."); } int i = 0; for (String variantType : variantTypes) { variants.put(variantType, variantValues[i++]); } return variants; }
[ "private", "Map", "<", "String", ",", "String", ">", "getVariantMap", "(", "ResourceBundlesHandler", "bundlesHandler", ",", "String", "contextPath", ",", "String", "bundlePath", ")", "{", "JoinableResourceBundle", "bundle", "=", "bundlesHandler", ".", "resolveBundleForPath", "(", "bundlePath", ")", ";", "Set", "<", "String", ">", "variantTypes", "=", "bundle", ".", "getVariants", "(", ")", ".", "keySet", "(", ")", ";", "String", "variantKey", "=", "getVariantKey", "(", "contextPath", ")", ";", "String", "[", "]", "variantValues", "=", "new", "String", "[", "0", "]", ";", "if", "(", "variantKey", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "variantKey", ".", "length", "(", ")", "==", "1", ")", "{", "variantValues", "=", "new", "String", "[", "]", "{", "\"\"", ",", "\"\"", "}", ";", "}", "else", "{", "variantValues", "=", "variantKey", ".", "split", "(", "String", ".", "valueOf", "(", "JawrConstant", ".", "VARIANT_SEPARATOR_CHAR", ")", ")", ";", "}", "}", "Map", "<", "String", ",", "String", ">", "variants", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "variantTypes", ".", "size", "(", ")", "!=", "variantValues", ".", "length", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"For the resource '\"", "+", "contextPath", "+", "\"', the number variant types for the bundle don't match the variant values.\"", ")", ";", "}", "int", "i", "=", "0", ";", "for", "(", "String", "variantType", ":", "variantTypes", ")", "{", "variants", ".", "put", "(", "variantType", ",", "variantValues", "[", "i", "++", "]", ")", ";", "}", "return", "variants", ";", "}" ]
Returns the variant map from the context path @param bundlesHandler the bundles handler @param contextPath the context path @param bundlePath the bundle path @return the variant map for the current context
[ "Returns", "the", "variant", "map", "from", "the", "context", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java#L193-L219
7,324
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java
IECssBundleGenerator.getBundlePath
private String getBundlePath(String contextPath) { String bundlePath = contextPath; int idx = -1; if (bundlePath.startsWith(JawrConstant.URL_SEPARATOR)) { idx = bundlePath.indexOf(JawrConstant.URL_SEPARATOR, 1); } else { idx = bundlePath.indexOf(JawrConstant.URL_SEPARATOR, 1); } if (idx != -1) { bundlePath = bundlePath.substring(idx); } return bundlePath; }
java
private String getBundlePath(String contextPath) { String bundlePath = contextPath; int idx = -1; if (bundlePath.startsWith(JawrConstant.URL_SEPARATOR)) { idx = bundlePath.indexOf(JawrConstant.URL_SEPARATOR, 1); } else { idx = bundlePath.indexOf(JawrConstant.URL_SEPARATOR, 1); } if (idx != -1) { bundlePath = bundlePath.substring(idx); } return bundlePath; }
[ "private", "String", "getBundlePath", "(", "String", "contextPath", ")", "{", "String", "bundlePath", "=", "contextPath", ";", "int", "idx", "=", "-", "1", ";", "if", "(", "bundlePath", ".", "startsWith", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", "{", "idx", "=", "bundlePath", ".", "indexOf", "(", "JawrConstant", ".", "URL_SEPARATOR", ",", "1", ")", ";", "}", "else", "{", "idx", "=", "bundlePath", ".", "indexOf", "(", "JawrConstant", ".", "URL_SEPARATOR", ",", "1", ")", ";", "}", "if", "(", "idx", "!=", "-", "1", ")", "{", "bundlePath", "=", "bundlePath", ".", "substring", "(", "idx", ")", ";", "}", "return", "bundlePath", ";", "}" ]
Returns the IE Css bundle path from the context path @param contextPath the context path @return the IE Css bundle path
[ "Returns", "the", "IE", "Css", "bundle", "path", "from", "the", "context", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java#L228-L241
7,325
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java
IECssBundleGenerator.getVariantKey
private String getVariantKey(String contextPath) { // Remove first slash String resultPath = contextPath.substring(1); String variantKey = ""; // eval the existence of a suffix String prefix = resultPath.substring(0, resultPath.indexOf(JawrConstant.URL_SEPARATOR)); // The prefix also contains variant information after a '.' if (prefix.indexOf('.') != -1) { variantKey = prefix.substring(prefix.indexOf('.') + 1); } return variantKey.trim(); }
java
private String getVariantKey(String contextPath) { // Remove first slash String resultPath = contextPath.substring(1); String variantKey = ""; // eval the existence of a suffix String prefix = resultPath.substring(0, resultPath.indexOf(JawrConstant.URL_SEPARATOR)); // The prefix also contains variant information after a '.' if (prefix.indexOf('.') != -1) { variantKey = prefix.substring(prefix.indexOf('.') + 1); } return variantKey.trim(); }
[ "private", "String", "getVariantKey", "(", "String", "contextPath", ")", "{", "// Remove first slash", "String", "resultPath", "=", "contextPath", ".", "substring", "(", "1", ")", ";", "String", "variantKey", "=", "\"\"", ";", "// eval the existence of a suffix", "String", "prefix", "=", "resultPath", ".", "substring", "(", "0", ",", "resultPath", ".", "indexOf", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ")", ";", "// The prefix also contains variant information after a '.'", "if", "(", "prefix", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "{", "variantKey", "=", "prefix", ".", "substring", "(", "prefix", ".", "indexOf", "(", "'", "'", ")", "+", "1", ")", ";", "}", "return", "variantKey", ".", "trim", "(", ")", ";", "}" ]
Returns the variant key from the context path. @param contextPath the path @return the variant key
[ "Returns", "the", "variant", "key", "from", "the", "context", "path", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/IECssBundleGenerator.java#L250-L264
7,326
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.getBundleRendererContext
public static BundleRendererContext getBundleRendererContext(HttpServletRequest request, BundleRenderer renderer) { String bundleRendererCtxAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + renderer.getResourceType(); // If we are handling an error dispatch, we should remove the current // RendererContext to use a new one String jawrErrorDispathAttributeName = JAWR_ERROR_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, ERROR_EXCEPTION, bundleRendererCtxAttributeName, jawrErrorDispathAttributeName); // If we are handling a forward dispatch, we should remove the current // RendererContext to use a new one String jawrForwardDispathAttributeName = JAWR_FOWARD_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, FORWARD_REQUEST_URI, bundleRendererCtxAttributeName, jawrForwardDispathAttributeName); BundleRendererContext ctx = (BundleRendererContext) request.getAttribute(bundleRendererCtxAttributeName); if (ctx == null) { ctx = new BundleRendererContext(request, renderer.getBundler().getConfig()); request.setAttribute(bundleRendererCtxAttributeName, ctx); } return ctx; }
java
public static BundleRendererContext getBundleRendererContext(HttpServletRequest request, BundleRenderer renderer) { String bundleRendererCtxAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + renderer.getResourceType(); // If we are handling an error dispatch, we should remove the current // RendererContext to use a new one String jawrErrorDispathAttributeName = JAWR_ERROR_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, ERROR_EXCEPTION, bundleRendererCtxAttributeName, jawrErrorDispathAttributeName); // If we are handling a forward dispatch, we should remove the current // RendererContext to use a new one String jawrForwardDispathAttributeName = JAWR_FOWARD_DISPATCH + renderer.getResourceType(); clearRequestWhenDispatch(request, FORWARD_REQUEST_URI, bundleRendererCtxAttributeName, jawrForwardDispathAttributeName); BundleRendererContext ctx = (BundleRendererContext) request.getAttribute(bundleRendererCtxAttributeName); if (ctx == null) { ctx = new BundleRendererContext(request, renderer.getBundler().getConfig()); request.setAttribute(bundleRendererCtxAttributeName, ctx); } return ctx; }
[ "public", "static", "BundleRendererContext", "getBundleRendererContext", "(", "HttpServletRequest", "request", ",", "BundleRenderer", "renderer", ")", "{", "String", "bundleRendererCtxAttributeName", "=", "BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX", "+", "renderer", ".", "getResourceType", "(", ")", ";", "// If we are handling an error dispatch, we should remove the current", "// RendererContext to use a new one", "String", "jawrErrorDispathAttributeName", "=", "JAWR_ERROR_DISPATCH", "+", "renderer", ".", "getResourceType", "(", ")", ";", "clearRequestWhenDispatch", "(", "request", ",", "ERROR_EXCEPTION", ",", "bundleRendererCtxAttributeName", ",", "jawrErrorDispathAttributeName", ")", ";", "// If we are handling a forward dispatch, we should remove the current", "// RendererContext to use a new one", "String", "jawrForwardDispathAttributeName", "=", "JAWR_FOWARD_DISPATCH", "+", "renderer", ".", "getResourceType", "(", ")", ";", "clearRequestWhenDispatch", "(", "request", ",", "FORWARD_REQUEST_URI", ",", "bundleRendererCtxAttributeName", ",", "jawrForwardDispathAttributeName", ")", ";", "BundleRendererContext", "ctx", "=", "(", "BundleRendererContext", ")", "request", ".", "getAttribute", "(", "bundleRendererCtxAttributeName", ")", ";", "if", "(", "ctx", "==", "null", ")", "{", "ctx", "=", "new", "BundleRendererContext", "(", "request", ",", "renderer", ".", "getBundler", "(", ")", ".", "getConfig", "(", ")", ")", ";", "request", ".", "setAttribute", "(", "bundleRendererCtxAttributeName", ",", "ctx", ")", ";", "}", "return", "ctx", ";", "}" ]
Returns the bundle renderer context. @param request the request @param renderer the bundle renderer @return the bundle renderer context.
[ "Returns", "the", "bundle", "renderer", "context", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L87-L109
7,327
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.clearRequestWhenDispatch
protected static void clearRequestWhenDispatch(HttpServletRequest request, String requestDispatchAttribute, String bundleRendererCtxAttributeName, String jawrDispathAttributeName) { if (request.getAttribute(requestDispatchAttribute) != null && request.getAttribute(jawrDispathAttributeName) == null) { request.removeAttribute(bundleRendererCtxAttributeName); request.setAttribute(jawrDispathAttributeName, Boolean.TRUE); } }
java
protected static void clearRequestWhenDispatch(HttpServletRequest request, String requestDispatchAttribute, String bundleRendererCtxAttributeName, String jawrDispathAttributeName) { if (request.getAttribute(requestDispatchAttribute) != null && request.getAttribute(jawrDispathAttributeName) == null) { request.removeAttribute(bundleRendererCtxAttributeName); request.setAttribute(jawrDispathAttributeName, Boolean.TRUE); } }
[ "protected", "static", "void", "clearRequestWhenDispatch", "(", "HttpServletRequest", "request", ",", "String", "requestDispatchAttribute", ",", "String", "bundleRendererCtxAttributeName", ",", "String", "jawrDispathAttributeName", ")", "{", "if", "(", "request", ".", "getAttribute", "(", "requestDispatchAttribute", ")", "!=", "null", "&&", "request", ".", "getAttribute", "(", "jawrDispathAttributeName", ")", "==", "null", ")", "{", "request", ".", "removeAttribute", "(", "bundleRendererCtxAttributeName", ")", ";", "request", ".", "setAttribute", "(", "jawrDispathAttributeName", ",", "Boolean", ".", "TRUE", ")", ";", "}", "}" ]
Clears the request when dispatch @param request the request @param requestDispatchAttribute the request attribute name to determine the dispatch type @param bundleRendererCtxAttributeName the bundle renderer context attribute to clean @param jawrDispathAttributeName the jawr dispatch attribute used to ensure that the clear is done only once
[ "Clears", "the", "request", "when", "dispatch" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L124-L131
7,328
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.setBundleRendererContext
public static void setBundleRendererContext(ServletRequest request, String resourceType, BundleRendererContext ctx) { String globalBundleAddedAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + resourceType; request.setAttribute(globalBundleAddedAttributeName, ctx); }
java
public static void setBundleRendererContext(ServletRequest request, String resourceType, BundleRendererContext ctx) { String globalBundleAddedAttributeName = BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX + resourceType; request.setAttribute(globalBundleAddedAttributeName, ctx); }
[ "public", "static", "void", "setBundleRendererContext", "(", "ServletRequest", "request", ",", "String", "resourceType", ",", "BundleRendererContext", "ctx", ")", "{", "String", "globalBundleAddedAttributeName", "=", "BUNDLE_RENDERER_CONTEXT_ATTR_PREFIX", "+", "resourceType", ";", "request", ".", "setAttribute", "(", "globalBundleAddedAttributeName", ",", "ctx", ")", ";", "}" ]
Sets the bundle renderer context. @param request the request @param resourceType the resource type @param ctx the bundle renderer context to set.
[ "Sets", "the", "bundle", "renderer", "context", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L143-L147
7,329
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.isRequestGzippable
public static boolean isRequestGzippable(HttpServletRequest req, JawrConfig jawrConfig) { boolean rets; // If gzip is completely off, return false. if (!jawrConfig.isGzipResourcesModeOn()) rets = false; else if (req.getHeader("Accept-Encoding") != null && req.getHeader("Accept-Encoding").contains("gzip")) { // If gzip for IE6 or less is off, the user agent is checked to // avoid compression. if (!jawrConfig.isGzipResourcesForIESixOn() && isIE6orLess(req)) { rets = false; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Gzip enablement for IE executed, with result:" + rets); } } else rets = true; } else rets = false; return rets; }
java
public static boolean isRequestGzippable(HttpServletRequest req, JawrConfig jawrConfig) { boolean rets; // If gzip is completely off, return false. if (!jawrConfig.isGzipResourcesModeOn()) rets = false; else if (req.getHeader("Accept-Encoding") != null && req.getHeader("Accept-Encoding").contains("gzip")) { // If gzip for IE6 or less is off, the user agent is checked to // avoid compression. if (!jawrConfig.isGzipResourcesForIESixOn() && isIE6orLess(req)) { rets = false; if (LOGGER.isDebugEnabled()) { LOGGER.debug("Gzip enablement for IE executed, with result:" + rets); } } else rets = true; } else rets = false; return rets; }
[ "public", "static", "boolean", "isRequestGzippable", "(", "HttpServletRequest", "req", ",", "JawrConfig", "jawrConfig", ")", "{", "boolean", "rets", ";", "// If gzip is completely off, return false.", "if", "(", "!", "jawrConfig", ".", "isGzipResourcesModeOn", "(", ")", ")", "rets", "=", "false", ";", "else", "if", "(", "req", ".", "getHeader", "(", "\"Accept-Encoding\"", ")", "!=", "null", "&&", "req", ".", "getHeader", "(", "\"Accept-Encoding\"", ")", ".", "contains", "(", "\"gzip\"", ")", ")", "{", "// If gzip for IE6 or less is off, the user agent is checked to", "// avoid compression.", "if", "(", "!", "jawrConfig", ".", "isGzipResourcesForIESixOn", "(", ")", "&&", "isIE6orLess", "(", "req", ")", ")", "{", "rets", "=", "false", ";", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Gzip enablement for IE executed, with result:\"", "+", "rets", ")", ";", "}", "}", "else", "rets", "=", "true", ";", "}", "else", "rets", "=", "false", ";", "return", "rets", ";", "}" ]
Determines whether gzip is suitable for the current request given the current config. @param req @param jawrConfig @return
[ "Determines", "whether", "gzip", "is", "suitable", "for", "the", "current", "request", "given", "the", "current", "config", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L157-L176
7,330
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.isIE
public static boolean isIE(HttpServletRequest req) { String agent = req.getHeader("User-Agent"); return null != agent && agent.contains("MSIE"); }
java
public static boolean isIE(HttpServletRequest req) { String agent = req.getHeader("User-Agent"); return null != agent && agent.contains("MSIE"); }
[ "public", "static", "boolean", "isIE", "(", "HttpServletRequest", "req", ")", "{", "String", "agent", "=", "req", ".", "getHeader", "(", "\"User-Agent\"", ")", ";", "return", "null", "!=", "agent", "&&", "agent", ".", "contains", "(", "\"MSIE\"", ")", ";", "}" ]
Checks if the user agent is IE @param req the request @return true if the user agent is IE
[ "Checks", "if", "the", "user", "agent", "is", "IE" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L185-L189
7,331
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.isIEVersionInferiorOrEqualTo
private static boolean isIEVersionInferiorOrEqualTo(HttpServletRequest req, int ieVersion) { boolean result = false; String agent = req.getHeader("User-Agent"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("User-Agent for this request:" + agent); } if (agent != null) { Matcher matcher = IE_USER_AGENT_PATTERN.matcher(agent); if (matcher.find()) { int version = Integer.parseInt(matcher.group(1)); if (version <= ieVersion) { result = true; } } } return result; }
java
private static boolean isIEVersionInferiorOrEqualTo(HttpServletRequest req, int ieVersion) { boolean result = false; String agent = req.getHeader("User-Agent"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("User-Agent for this request:" + agent); } if (agent != null) { Matcher matcher = IE_USER_AGENT_PATTERN.matcher(agent); if (matcher.find()) { int version = Integer.parseInt(matcher.group(1)); if (version <= ieVersion) { result = true; } } } return result; }
[ "private", "static", "boolean", "isIEVersionInferiorOrEqualTo", "(", "HttpServletRequest", "req", ",", "int", "ieVersion", ")", "{", "boolean", "result", "=", "false", ";", "String", "agent", "=", "req", ".", "getHeader", "(", "\"User-Agent\"", ")", ";", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"User-Agent for this request:\"", "+", "agent", ")", ";", "}", "if", "(", "agent", "!=", "null", ")", "{", "Matcher", "matcher", "=", "IE_USER_AGENT_PATTERN", ".", "matcher", "(", "agent", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "int", "version", "=", "Integer", ".", "parseInt", "(", "matcher", ".", "group", "(", "1", ")", ")", ";", "if", "(", "version", "<=", "ieVersion", ")", "{", "result", "=", "true", ";", "}", "}", "}", "return", "result", ";", "}" ]
Checks if the user agent is IE and the version is equal or less than the one passed in parameter @param req the request @param the IE version to check @return true if the user agent is IE and the version is equal or less than the one passed in parameter
[ "Checks", "if", "the", "user", "agent", "is", "IE", "and", "the", "version", "is", "equal", "or", "less", "than", "the", "one", "passed", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L226-L245
7,332
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.setRequestDebuggable
public static void setRequestDebuggable(HttpServletRequest req, JawrConfig jawrConfig) { // make sure we have set an overrideKey // make sure the overrideKey exists in the request // lastly, make sure the keys match if (jawrConfig.getDebugOverrideKey().length() > 0 && null != req.getParameter(JawrConstant.OVERRIDE_KEY_PARAMETER_NAME) && jawrConfig .getDebugOverrideKey().equals(req.getParameter(JawrConstant.OVERRIDE_KEY_PARAMETER_NAME))) { ThreadLocalJawrContext.setDebugOverriden(true); } else { ThreadLocalJawrContext.setDebugOverriden(false); } // Inherit the debuggable property of the session if the session is a // debuggable one inheritSessionDebugProperty(req); }
java
public static void setRequestDebuggable(HttpServletRequest req, JawrConfig jawrConfig) { // make sure we have set an overrideKey // make sure the overrideKey exists in the request // lastly, make sure the keys match if (jawrConfig.getDebugOverrideKey().length() > 0 && null != req.getParameter(JawrConstant.OVERRIDE_KEY_PARAMETER_NAME) && jawrConfig .getDebugOverrideKey().equals(req.getParameter(JawrConstant.OVERRIDE_KEY_PARAMETER_NAME))) { ThreadLocalJawrContext.setDebugOverriden(true); } else { ThreadLocalJawrContext.setDebugOverriden(false); } // Inherit the debuggable property of the session if the session is a // debuggable one inheritSessionDebugProperty(req); }
[ "public", "static", "void", "setRequestDebuggable", "(", "HttpServletRequest", "req", ",", "JawrConfig", "jawrConfig", ")", "{", "// make sure we have set an overrideKey", "// make sure the overrideKey exists in the request", "// lastly, make sure the keys match", "if", "(", "jawrConfig", ".", "getDebugOverrideKey", "(", ")", ".", "length", "(", ")", ">", "0", "&&", "null", "!=", "req", ".", "getParameter", "(", "JawrConstant", ".", "OVERRIDE_KEY_PARAMETER_NAME", ")", "&&", "jawrConfig", ".", "getDebugOverrideKey", "(", ")", ".", "equals", "(", "req", ".", "getParameter", "(", "JawrConstant", ".", "OVERRIDE_KEY_PARAMETER_NAME", ")", ")", ")", "{", "ThreadLocalJawrContext", ".", "setDebugOverriden", "(", "true", ")", ";", "}", "else", "{", "ThreadLocalJawrContext", ".", "setDebugOverriden", "(", "false", ")", ";", "}", "// Inherit the debuggable property of the session if the session is a", "// debuggable one", "inheritSessionDebugProperty", "(", "req", ")", ";", "}" ]
Determines whether to override the debug settings. Sets the debugOverride status on ThreadLocalJawrContext @param req the request @param jawrConfig the jawr config
[ "Determines", "whether", "to", "override", "the", "debug", "settings", ".", "Sets", "the", "debugOverride", "status", "on", "ThreadLocalJawrContext" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L257-L274
7,333
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.inheritSessionDebugProperty
public static void inheritSessionDebugProperty(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { String sessionId = session.getId(); JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) session.getServletContext() .getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER); // If the session ID is a debuggable session ID, activate debug mode // for the request. if (appConfigMgr != null && appConfigMgr.isDebugSessionId(sessionId)) { ThreadLocalJawrContext.setDebugOverriden(true); } } }
java
public static void inheritSessionDebugProperty(HttpServletRequest request) { HttpSession session = request.getSession(false); if (session != null) { String sessionId = session.getId(); JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) session.getServletContext() .getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER); // If the session ID is a debuggable session ID, activate debug mode // for the request. if (appConfigMgr != null && appConfigMgr.isDebugSessionId(sessionId)) { ThreadLocalJawrContext.setDebugOverriden(true); } } }
[ "public", "static", "void", "inheritSessionDebugProperty", "(", "HttpServletRequest", "request", ")", "{", "HttpSession", "session", "=", "request", ".", "getSession", "(", "false", ")", ";", "if", "(", "session", "!=", "null", ")", "{", "String", "sessionId", "=", "session", ".", "getId", "(", ")", ";", "JawrApplicationConfigManager", "appConfigMgr", "=", "(", "JawrApplicationConfigManager", ")", "session", ".", "getServletContext", "(", ")", ".", "getAttribute", "(", "JawrConstant", ".", "JAWR_APPLICATION_CONFIG_MANAGER", ")", ";", "// If the session ID is a debuggable session ID, activate debug mode", "// for the request.", "if", "(", "appConfigMgr", "!=", "null", "&&", "appConfigMgr", ".", "isDebugSessionId", "(", "sessionId", ")", ")", "{", "ThreadLocalJawrContext", ".", "setDebugOverriden", "(", "true", ")", ";", "}", "}", "}" ]
Sets a request debuggable if the session is a debuggable session. @param request the request
[ "Sets", "a", "request", "debuggable", "if", "the", "session", "is", "a", "debuggable", "session", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L282-L297
7,334
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.getRenderedUrl
public static String getRenderedUrl(String url, JawrConfig jawrConfig, String contextPath, boolean sslRequest) { String contextPathOverride = getContextPathOverride(sslRequest, jawrConfig); // If the contextPathOverride is not null and we are in production mode, // or if we are in debug mode but we should use the contextPathOverride // even in debug mode // then use the contextPathOverride String renderedUrl = url; if (contextPathOverride != null && ((jawrConfig.isDebugModeOn() && jawrConfig.isUseContextPathOverrideInDebugMode()) || !jawrConfig.isDebugModeOn())) { String override = contextPathOverride; // Blank override, create url relative to path if ("".equals(override)) { if (url.startsWith("/")) { renderedUrl = renderedUrl.substring(1); } } else { renderedUrl = PathNormalizer.joinPaths(override, renderedUrl); } } else { renderedUrl = PathNormalizer.joinPaths(contextPath, renderedUrl); } return renderedUrl; }
java
public static String getRenderedUrl(String url, JawrConfig jawrConfig, String contextPath, boolean sslRequest) { String contextPathOverride = getContextPathOverride(sslRequest, jawrConfig); // If the contextPathOverride is not null and we are in production mode, // or if we are in debug mode but we should use the contextPathOverride // even in debug mode // then use the contextPathOverride String renderedUrl = url; if (contextPathOverride != null && ((jawrConfig.isDebugModeOn() && jawrConfig.isUseContextPathOverrideInDebugMode()) || !jawrConfig.isDebugModeOn())) { String override = contextPathOverride; // Blank override, create url relative to path if ("".equals(override)) { if (url.startsWith("/")) { renderedUrl = renderedUrl.substring(1); } } else { renderedUrl = PathNormalizer.joinPaths(override, renderedUrl); } } else { renderedUrl = PathNormalizer.joinPaths(contextPath, renderedUrl); } return renderedUrl; }
[ "public", "static", "String", "getRenderedUrl", "(", "String", "url", ",", "JawrConfig", "jawrConfig", ",", "String", "contextPath", ",", "boolean", "sslRequest", ")", "{", "String", "contextPathOverride", "=", "getContextPathOverride", "(", "sslRequest", ",", "jawrConfig", ")", ";", "// If the contextPathOverride is not null and we are in production mode,", "// or if we are in debug mode but we should use the contextPathOverride", "// even in debug mode", "// then use the contextPathOverride", "String", "renderedUrl", "=", "url", ";", "if", "(", "contextPathOverride", "!=", "null", "&&", "(", "(", "jawrConfig", ".", "isDebugModeOn", "(", ")", "&&", "jawrConfig", ".", "isUseContextPathOverrideInDebugMode", "(", ")", ")", "||", "!", "jawrConfig", ".", "isDebugModeOn", "(", ")", ")", ")", "{", "String", "override", "=", "contextPathOverride", ";", "// Blank override, create url relative to path", "if", "(", "\"\"", ".", "equals", "(", "override", ")", ")", "{", "if", "(", "url", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "renderedUrl", "=", "renderedUrl", ".", "substring", "(", "1", ")", ";", "}", "}", "else", "{", "renderedUrl", "=", "PathNormalizer", ".", "joinPaths", "(", "override", ",", "renderedUrl", ")", ";", "}", "}", "else", "{", "renderedUrl", "=", "PathNormalizer", ".", "joinPaths", "(", "contextPath", ",", "renderedUrl", ")", ";", "}", "return", "renderedUrl", ";", "}" ]
Renders the URL taking in account the context path, the jawr config @param url the URL @param jawrConfig the jawr config @param contextPath the context path @param sslRequest the flag indicating if it's an SSL request or not @return the new URL
[ "Renders", "the", "URL", "taking", "in", "account", "the", "context", "path", "the", "jawr", "config" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L325-L352
7,335
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java
RendererRequestUtils.refreshConfigIfNeeded
public static boolean refreshConfigIfNeeded(HttpServletRequest request, JawrConfig jawrConfig) { boolean refreshed = false; if (request.getAttribute(JawrConstant.JAWR_BUNDLE_REFRESH_CHECK) == null) { request.setAttribute(JawrConstant.JAWR_BUNDLE_REFRESH_CHECK, Boolean.TRUE); if (jawrConfig.getRefreshKey().length() > 0 && null != request.getParameter(JawrConstant.REFRESH_KEY_PARAM) && jawrConfig.getRefreshKey().equals(request.getParameter(JawrConstant.REFRESH_KEY_PARAM))) { JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) request.getSession() .getServletContext().getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER); if (appConfigMgr == null) { throw new IllegalStateException( "JawrApplicationConfigManager is not present in servlet context. Initialization of Jawr either failed or never occurred."); } appConfigMgr.refreshConfig(); refreshed = true; } } return refreshed; }
java
public static boolean refreshConfigIfNeeded(HttpServletRequest request, JawrConfig jawrConfig) { boolean refreshed = false; if (request.getAttribute(JawrConstant.JAWR_BUNDLE_REFRESH_CHECK) == null) { request.setAttribute(JawrConstant.JAWR_BUNDLE_REFRESH_CHECK, Boolean.TRUE); if (jawrConfig.getRefreshKey().length() > 0 && null != request.getParameter(JawrConstant.REFRESH_KEY_PARAM) && jawrConfig.getRefreshKey().equals(request.getParameter(JawrConstant.REFRESH_KEY_PARAM))) { JawrApplicationConfigManager appConfigMgr = (JawrApplicationConfigManager) request.getSession() .getServletContext().getAttribute(JawrConstant.JAWR_APPLICATION_CONFIG_MANAGER); if (appConfigMgr == null) { throw new IllegalStateException( "JawrApplicationConfigManager is not present in servlet context. Initialization of Jawr either failed or never occurred."); } appConfigMgr.refreshConfig(); refreshed = true; } } return refreshed; }
[ "public", "static", "boolean", "refreshConfigIfNeeded", "(", "HttpServletRequest", "request", ",", "JawrConfig", "jawrConfig", ")", "{", "boolean", "refreshed", "=", "false", ";", "if", "(", "request", ".", "getAttribute", "(", "JawrConstant", ".", "JAWR_BUNDLE_REFRESH_CHECK", ")", "==", "null", ")", "{", "request", ".", "setAttribute", "(", "JawrConstant", ".", "JAWR_BUNDLE_REFRESH_CHECK", ",", "Boolean", ".", "TRUE", ")", ";", "if", "(", "jawrConfig", ".", "getRefreshKey", "(", ")", ".", "length", "(", ")", ">", "0", "&&", "null", "!=", "request", ".", "getParameter", "(", "JawrConstant", ".", "REFRESH_KEY_PARAM", ")", "&&", "jawrConfig", ".", "getRefreshKey", "(", ")", ".", "equals", "(", "request", ".", "getParameter", "(", "JawrConstant", ".", "REFRESH_KEY_PARAM", ")", ")", ")", "{", "JawrApplicationConfigManager", "appConfigMgr", "=", "(", "JawrApplicationConfigManager", ")", "request", ".", "getSession", "(", ")", ".", "getServletContext", "(", ")", ".", "getAttribute", "(", "JawrConstant", ".", "JAWR_APPLICATION_CONFIG_MANAGER", ")", ";", "if", "(", "appConfigMgr", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"JawrApplicationConfigManager is not present in servlet context. Initialization of Jawr either failed or never occurred.\"", ")", ";", "}", "appConfigMgr", ".", "refreshConfig", "(", ")", ";", "refreshed", "=", "true", ";", "}", "}", "return", "refreshed", ";", "}" ]
Refresh the Jawr config if a manual reload has been ask using the refresh key parameter from the URL @param request the request @param jawrConfig the Jawr config @return true if the config has been refreshed
[ "Refresh", "the", "Jawr", "config", "if", "a", "manual", "reload", "has", "been", "ask", "using", "the", "refresh", "key", "parameter", "from", "the", "URL" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/servlet/RendererRequestUtils.java#L382-L403
7,336
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getSkinMapping
public Map<String, Map<String, VariantSet>> getSkinMapping(ResourceBrowser rsBrowser, JawrConfig config) { Map<String, Map<String, VariantSet>> currentSkinMapping = new HashMap<>(); PropertiesConfigHelper props = new PropertiesConfigHelper(config.getConfigProperties(), JawrConstant.CSS_TYPE); Set<String> skinRootDirectories = props.getPropertyAsSet(JawrConstant.SKIN_DEFAULT_ROOT_DIRS); if (skinMappingType.equals(JawrConstant.SKIN_TYPE_MAPPING_SKIN_LOCALE)) { updateSkinMappingUsingTypeSkinLocale(rsBrowser, config, currentSkinMapping, skinRootDirectories); } else { updateSkinMappingUsingTypeLocaleSkin(rsBrowser, config, currentSkinMapping, skinRootDirectories); } return currentSkinMapping; }
java
public Map<String, Map<String, VariantSet>> getSkinMapping(ResourceBrowser rsBrowser, JawrConfig config) { Map<String, Map<String, VariantSet>> currentSkinMapping = new HashMap<>(); PropertiesConfigHelper props = new PropertiesConfigHelper(config.getConfigProperties(), JawrConstant.CSS_TYPE); Set<String> skinRootDirectories = props.getPropertyAsSet(JawrConstant.SKIN_DEFAULT_ROOT_DIRS); if (skinMappingType.equals(JawrConstant.SKIN_TYPE_MAPPING_SKIN_LOCALE)) { updateSkinMappingUsingTypeSkinLocale(rsBrowser, config, currentSkinMapping, skinRootDirectories); } else { updateSkinMappingUsingTypeLocaleSkin(rsBrowser, config, currentSkinMapping, skinRootDirectories); } return currentSkinMapping; }
[ "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "VariantSet", ">", ">", "getSkinMapping", "(", "ResourceBrowser", "rsBrowser", ",", "JawrConfig", "config", ")", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "VariantSet", ">", ">", "currentSkinMapping", "=", "new", "HashMap", "<>", "(", ")", ";", "PropertiesConfigHelper", "props", "=", "new", "PropertiesConfigHelper", "(", "config", ".", "getConfigProperties", "(", ")", ",", "JawrConstant", ".", "CSS_TYPE", ")", ";", "Set", "<", "String", ">", "skinRootDirectories", "=", "props", ".", "getPropertyAsSet", "(", "JawrConstant", ".", "SKIN_DEFAULT_ROOT_DIRS", ")", ";", "if", "(", "skinMappingType", ".", "equals", "(", "JawrConstant", ".", "SKIN_TYPE_MAPPING_SKIN_LOCALE", ")", ")", "{", "updateSkinMappingUsingTypeSkinLocale", "(", "rsBrowser", ",", "config", ",", "currentSkinMapping", ",", "skinRootDirectories", ")", ";", "}", "else", "{", "updateSkinMappingUsingTypeLocaleSkin", "(", "rsBrowser", ",", "config", ",", "currentSkinMapping", ",", "skinRootDirectories", ")", ";", "}", "return", "currentSkinMapping", ";", "}" ]
Returns the skin mapping from the Jawr config @param rsBrowser the resource browser @param config the Jawr config @return the skin mapping
[ "Returns", "the", "skin", "mapping", "from", "the", "Jawr", "config" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L312-L324
7,337
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.updateSkinMappingUsingTypeSkinLocale
private void updateSkinMappingUsingTypeSkinLocale(ResourceBrowser rsBrowser, JawrConfig config, Map<String, Map<String, VariantSet>> skinMapping, Set<String> skinRootDirectories) { String defaultSkinName = null; String defaultLocaleName = null; // Check if there are no directory which is contained in another root // directory for (Iterator<String> itRootDir = skinRootDirectories.iterator(); itRootDir.hasNext();) { String defaultSkinDir = PathNormalizer.asDirPath(itRootDir.next()); String defaultSkinDirName = PathNormalizer.getPathName(defaultSkinDir); String skinRootDir = PathNormalizer.getParentPath(defaultSkinDir); String skinName = null; String localeName = null; if (LocaleUtils.LOCALE_SUFFIXES.contains(defaultSkinDirName)) { // The // rootDir // point // to // a // locale // directory localeName = defaultSkinDirName; skinName = PathNormalizer.getPathName(skinRootDir); skinRootDir = PathNormalizer.getParentPath(skinRootDir); } else { skinName = defaultSkinDirName; } if (defaultSkinName == null) { defaultSkinName = skinName; } else if (!defaultSkinName.equals(skinName)) { throw new BundlingProcessException( "The default skin for the skin root directories are not the same. Please check your configuration."); } if (defaultLocaleName == null) { defaultLocaleName = localeName; } else if (!defaultLocaleName.equals(localeName)) { throw new BundlingProcessException( "The default locale for the skin root directories are not the same. Please check your configuration."); } checkRootDirectoryNotOverlap(defaultSkinDir, skinRootDirectories); Map<String, VariantSet> variantsMap = getVariants(rsBrowser, skinRootDir, skinName, localeName, true); skinMapping.put(skinRootDir, variantsMap); } // Init resolver cssSkinResolver.setDefaultSkin(defaultSkinName); cssSkinResolver.setSkinCookieName(config.getSkinCookieName()); }
java
private void updateSkinMappingUsingTypeSkinLocale(ResourceBrowser rsBrowser, JawrConfig config, Map<String, Map<String, VariantSet>> skinMapping, Set<String> skinRootDirectories) { String defaultSkinName = null; String defaultLocaleName = null; // Check if there are no directory which is contained in another root // directory for (Iterator<String> itRootDir = skinRootDirectories.iterator(); itRootDir.hasNext();) { String defaultSkinDir = PathNormalizer.asDirPath(itRootDir.next()); String defaultSkinDirName = PathNormalizer.getPathName(defaultSkinDir); String skinRootDir = PathNormalizer.getParentPath(defaultSkinDir); String skinName = null; String localeName = null; if (LocaleUtils.LOCALE_SUFFIXES.contains(defaultSkinDirName)) { // The // rootDir // point // to // a // locale // directory localeName = defaultSkinDirName; skinName = PathNormalizer.getPathName(skinRootDir); skinRootDir = PathNormalizer.getParentPath(skinRootDir); } else { skinName = defaultSkinDirName; } if (defaultSkinName == null) { defaultSkinName = skinName; } else if (!defaultSkinName.equals(skinName)) { throw new BundlingProcessException( "The default skin for the skin root directories are not the same. Please check your configuration."); } if (defaultLocaleName == null) { defaultLocaleName = localeName; } else if (!defaultLocaleName.equals(localeName)) { throw new BundlingProcessException( "The default locale for the skin root directories are not the same. Please check your configuration."); } checkRootDirectoryNotOverlap(defaultSkinDir, skinRootDirectories); Map<String, VariantSet> variantsMap = getVariants(rsBrowser, skinRootDir, skinName, localeName, true); skinMapping.put(skinRootDir, variantsMap); } // Init resolver cssSkinResolver.setDefaultSkin(defaultSkinName); cssSkinResolver.setSkinCookieName(config.getSkinCookieName()); }
[ "private", "void", "updateSkinMappingUsingTypeSkinLocale", "(", "ResourceBrowser", "rsBrowser", ",", "JawrConfig", "config", ",", "Map", "<", "String", ",", "Map", "<", "String", ",", "VariantSet", ">", ">", "skinMapping", ",", "Set", "<", "String", ">", "skinRootDirectories", ")", "{", "String", "defaultSkinName", "=", "null", ";", "String", "defaultLocaleName", "=", "null", ";", "// Check if there are no directory which is contained in another root", "// directory", "for", "(", "Iterator", "<", "String", ">", "itRootDir", "=", "skinRootDirectories", ".", "iterator", "(", ")", ";", "itRootDir", ".", "hasNext", "(", ")", ";", ")", "{", "String", "defaultSkinDir", "=", "PathNormalizer", ".", "asDirPath", "(", "itRootDir", ".", "next", "(", ")", ")", ";", "String", "defaultSkinDirName", "=", "PathNormalizer", ".", "getPathName", "(", "defaultSkinDir", ")", ";", "String", "skinRootDir", "=", "PathNormalizer", ".", "getParentPath", "(", "defaultSkinDir", ")", ";", "String", "skinName", "=", "null", ";", "String", "localeName", "=", "null", ";", "if", "(", "LocaleUtils", ".", "LOCALE_SUFFIXES", ".", "contains", "(", "defaultSkinDirName", ")", ")", "{", "// The", "// rootDir", "// point", "// to", "// a", "// locale", "// directory", "localeName", "=", "defaultSkinDirName", ";", "skinName", "=", "PathNormalizer", ".", "getPathName", "(", "skinRootDir", ")", ";", "skinRootDir", "=", "PathNormalizer", ".", "getParentPath", "(", "skinRootDir", ")", ";", "}", "else", "{", "skinName", "=", "defaultSkinDirName", ";", "}", "if", "(", "defaultSkinName", "==", "null", ")", "{", "defaultSkinName", "=", "skinName", ";", "}", "else", "if", "(", "!", "defaultSkinName", ".", "equals", "(", "skinName", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The default skin for the skin root directories are not the same. Please check your configuration.\"", ")", ";", "}", "if", "(", "defaultLocaleName", "==", "null", ")", "{", "defaultLocaleName", "=", "localeName", ";", "}", "else", "if", "(", "!", "defaultLocaleName", ".", "equals", "(", "localeName", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The default locale for the skin root directories are not the same. Please check your configuration.\"", ")", ";", "}", "checkRootDirectoryNotOverlap", "(", "defaultSkinDir", ",", "skinRootDirectories", ")", ";", "Map", "<", "String", ",", "VariantSet", ">", "variantsMap", "=", "getVariants", "(", "rsBrowser", ",", "skinRootDir", ",", "skinName", ",", "localeName", ",", "true", ")", ";", "skinMapping", ".", "put", "(", "skinRootDir", ",", "variantsMap", ")", ";", "}", "// Init resolver", "cssSkinResolver", ".", "setDefaultSkin", "(", "defaultSkinName", ")", ";", "cssSkinResolver", ".", "setSkinCookieName", "(", "config", ".", "getSkinCookieName", "(", ")", ")", ";", "}" ]
Returns the skin mapping from the Jawr config, here the resource mapping type is skin_locale @param rsBrowser the resource browser @param config the jawr config @param skinMapping the skin mapping @param skinRootDirectories the skin root directories
[ "Returns", "the", "skin", "mapping", "from", "the", "Jawr", "config", "here", "the", "resource", "mapping", "type", "is", "skin_locale" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L339-L394
7,338
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.updateSkinMappingUsingTypeLocaleSkin
private void updateSkinMappingUsingTypeLocaleSkin(ResourceBrowser rsBrowser, JawrConfig config, Map<String, Map<String, VariantSet>> skinMapping, Set<String> skinRootDirectories) { String defaultSkinName = null; String defaultLocaleName = null; // Check if there are no directory which is contained in another root // directory for (Iterator<String> itRootDir = skinRootDirectories.iterator(); itRootDir.hasNext();) { String defaultLocaleDir = PathNormalizer.asDirPath(itRootDir.next()); String defaultLocaleDirName = PathNormalizer.getPathName(defaultLocaleDir); String localeRootDir = PathNormalizer.getParentPath(defaultLocaleDir); String skinName = null; String localeName = null; if (!LocaleUtils.LOCALE_SUFFIXES.contains(defaultLocaleDirName)) { // The // rootDir // point // to // a // skin // directory skinName = defaultLocaleDirName; localeName = PathNormalizer.getPathName(localeRootDir); localeRootDir = PathNormalizer.getParentPath(localeRootDir); } else { localeName = defaultLocaleDirName; } if (defaultSkinName == null) { defaultSkinName = skinName; } else if (!defaultSkinName.equals(skinName)) { throw new BundlingProcessException( "The default skin for the skin root directories are not the same. Please check your configuration."); } if (defaultLocaleName == null) { defaultLocaleName = localeName; } else if (!defaultLocaleName.equals(localeName)) { throw new BundlingProcessException( "The default locale for the skin root directories are not the same. Please check your configuration."); } checkRootDirectoryNotOverlap(defaultLocaleDir, skinRootDirectories); Map<String, VariantSet> variantsMap = getVariants(rsBrowser, localeRootDir, skinName, localeName, false); skinMapping.put(localeRootDir, variantsMap); } CssSkinVariantResolver skinResolver = (CssSkinVariantResolver) config.getGeneratorRegistry() .getVariantResolver(JawrConstant.SKIN_VARIANT_TYPE); if (skinResolver == null) { skinResolver = new CssSkinVariantResolver(defaultSkinName, config.getSkinCookieName()); config.getGeneratorRegistry().registerVariantResolver(skinResolver); } else { skinResolver.setDefaultSkin(defaultSkinName); skinResolver.setSkinCookieName(config.getSkinCookieName()); } }
java
private void updateSkinMappingUsingTypeLocaleSkin(ResourceBrowser rsBrowser, JawrConfig config, Map<String, Map<String, VariantSet>> skinMapping, Set<String> skinRootDirectories) { String defaultSkinName = null; String defaultLocaleName = null; // Check if there are no directory which is contained in another root // directory for (Iterator<String> itRootDir = skinRootDirectories.iterator(); itRootDir.hasNext();) { String defaultLocaleDir = PathNormalizer.asDirPath(itRootDir.next()); String defaultLocaleDirName = PathNormalizer.getPathName(defaultLocaleDir); String localeRootDir = PathNormalizer.getParentPath(defaultLocaleDir); String skinName = null; String localeName = null; if (!LocaleUtils.LOCALE_SUFFIXES.contains(defaultLocaleDirName)) { // The // rootDir // point // to // a // skin // directory skinName = defaultLocaleDirName; localeName = PathNormalizer.getPathName(localeRootDir); localeRootDir = PathNormalizer.getParentPath(localeRootDir); } else { localeName = defaultLocaleDirName; } if (defaultSkinName == null) { defaultSkinName = skinName; } else if (!defaultSkinName.equals(skinName)) { throw new BundlingProcessException( "The default skin for the skin root directories are not the same. Please check your configuration."); } if (defaultLocaleName == null) { defaultLocaleName = localeName; } else if (!defaultLocaleName.equals(localeName)) { throw new BundlingProcessException( "The default locale for the skin root directories are not the same. Please check your configuration."); } checkRootDirectoryNotOverlap(defaultLocaleDir, skinRootDirectories); Map<String, VariantSet> variantsMap = getVariants(rsBrowser, localeRootDir, skinName, localeName, false); skinMapping.put(localeRootDir, variantsMap); } CssSkinVariantResolver skinResolver = (CssSkinVariantResolver) config.getGeneratorRegistry() .getVariantResolver(JawrConstant.SKIN_VARIANT_TYPE); if (skinResolver == null) { skinResolver = new CssSkinVariantResolver(defaultSkinName, config.getSkinCookieName()); config.getGeneratorRegistry().registerVariantResolver(skinResolver); } else { skinResolver.setDefaultSkin(defaultSkinName); skinResolver.setSkinCookieName(config.getSkinCookieName()); } }
[ "private", "void", "updateSkinMappingUsingTypeLocaleSkin", "(", "ResourceBrowser", "rsBrowser", ",", "JawrConfig", "config", ",", "Map", "<", "String", ",", "Map", "<", "String", ",", "VariantSet", ">", ">", "skinMapping", ",", "Set", "<", "String", ">", "skinRootDirectories", ")", "{", "String", "defaultSkinName", "=", "null", ";", "String", "defaultLocaleName", "=", "null", ";", "// Check if there are no directory which is contained in another root", "// directory", "for", "(", "Iterator", "<", "String", ">", "itRootDir", "=", "skinRootDirectories", ".", "iterator", "(", ")", ";", "itRootDir", ".", "hasNext", "(", ")", ";", ")", "{", "String", "defaultLocaleDir", "=", "PathNormalizer", ".", "asDirPath", "(", "itRootDir", ".", "next", "(", ")", ")", ";", "String", "defaultLocaleDirName", "=", "PathNormalizer", ".", "getPathName", "(", "defaultLocaleDir", ")", ";", "String", "localeRootDir", "=", "PathNormalizer", ".", "getParentPath", "(", "defaultLocaleDir", ")", ";", "String", "skinName", "=", "null", ";", "String", "localeName", "=", "null", ";", "if", "(", "!", "LocaleUtils", ".", "LOCALE_SUFFIXES", ".", "contains", "(", "defaultLocaleDirName", ")", ")", "{", "// The", "// rootDir", "// point", "// to", "// a", "// skin", "// directory", "skinName", "=", "defaultLocaleDirName", ";", "localeName", "=", "PathNormalizer", ".", "getPathName", "(", "localeRootDir", ")", ";", "localeRootDir", "=", "PathNormalizer", ".", "getParentPath", "(", "localeRootDir", ")", ";", "}", "else", "{", "localeName", "=", "defaultLocaleDirName", ";", "}", "if", "(", "defaultSkinName", "==", "null", ")", "{", "defaultSkinName", "=", "skinName", ";", "}", "else", "if", "(", "!", "defaultSkinName", ".", "equals", "(", "skinName", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The default skin for the skin root directories are not the same. Please check your configuration.\"", ")", ";", "}", "if", "(", "defaultLocaleName", "==", "null", ")", "{", "defaultLocaleName", "=", "localeName", ";", "}", "else", "if", "(", "!", "defaultLocaleName", ".", "equals", "(", "localeName", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"The default locale for the skin root directories are not the same. Please check your configuration.\"", ")", ";", "}", "checkRootDirectoryNotOverlap", "(", "defaultLocaleDir", ",", "skinRootDirectories", ")", ";", "Map", "<", "String", ",", "VariantSet", ">", "variantsMap", "=", "getVariants", "(", "rsBrowser", ",", "localeRootDir", ",", "skinName", ",", "localeName", ",", "false", ")", ";", "skinMapping", ".", "put", "(", "localeRootDir", ",", "variantsMap", ")", ";", "}", "CssSkinVariantResolver", "skinResolver", "=", "(", "CssSkinVariantResolver", ")", "config", ".", "getGeneratorRegistry", "(", ")", ".", "getVariantResolver", "(", "JawrConstant", ".", "SKIN_VARIANT_TYPE", ")", ";", "if", "(", "skinResolver", "==", "null", ")", "{", "skinResolver", "=", "new", "CssSkinVariantResolver", "(", "defaultSkinName", ",", "config", ".", "getSkinCookieName", "(", ")", ")", ";", "config", ".", "getGeneratorRegistry", "(", ")", ".", "registerVariantResolver", "(", "skinResolver", ")", ";", "}", "else", "{", "skinResolver", ".", "setDefaultSkin", "(", "defaultSkinName", ")", ";", "skinResolver", ".", "setSkinCookieName", "(", "config", ".", "getSkinCookieName", "(", ")", ")", ";", "}", "}" ]
Returns the skin mapping from the Jawr config, here the resource mapping type is locale_skin @param rsBrowser the resource browser @param config the jawr config @param skinMapping the skin mapping @param skinRootDirectories the skin root directories
[ "Returns", "the", "skin", "mapping", "from", "the", "Jawr", "config", "here", "the", "resource", "mapping", "type", "is", "locale_skin" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L409-L471
7,339
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getSkinRootDir
public String getSkinRootDir(String path, Set<String> skinRootDirs) { String skinRootDir = null; for (String skinDir : skinRootDirs) { if (path.startsWith(skinDir)) { skinRootDir = skinDir; } } return skinRootDir; }
java
public String getSkinRootDir(String path, Set<String> skinRootDirs) { String skinRootDir = null; for (String skinDir : skinRootDirs) { if (path.startsWith(skinDir)) { skinRootDir = skinDir; } } return skinRootDir; }
[ "public", "String", "getSkinRootDir", "(", "String", "path", ",", "Set", "<", "String", ">", "skinRootDirs", ")", "{", "String", "skinRootDir", "=", "null", ";", "for", "(", "String", "skinDir", ":", "skinRootDirs", ")", "{", "if", "(", "path", ".", "startsWith", "(", "skinDir", ")", ")", "{", "skinRootDir", "=", "skinDir", ";", "}", "}", "return", "skinRootDir", ";", "}" ]
Returns the skin root dir of the path given in parameter @param path the resource path @param skinRootDirs the set of skin root directories @return the skin root dir
[ "Returns", "the", "skin", "root", "dir", "of", "the", "path", "given", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L482-L490
7,340
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getVariants
private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName, String defaultLocaleName, boolean mappingSkinLocale) { Set<String> paths = rsBrowser.getResourceNames(rootDir); Set<String> skinNames = new HashSet<>(); Set<String> localeVariants = new HashSet<>(); for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) { String path = rootDir + itPath.next(); if (rsBrowser.isDirectory(path)) { String dirName = PathNormalizer.getPathName(path); if (mappingSkinLocale) { skinNames.add(dirName); // check if there are locale variants for this skin, // and update the localeVariants if needed updateLocaleVariants(rsBrowser, path, localeVariants); } else { if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) { localeVariants.add(dirName); // check if there are skin variants for this locales, // and update the skinVariants if needed updateSkinVariants(rsBrowser, path, skinNames); } } } } // Initialize the variant mapping for the skin root directory return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants); }
java
private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName, String defaultLocaleName, boolean mappingSkinLocale) { Set<String> paths = rsBrowser.getResourceNames(rootDir); Set<String> skinNames = new HashSet<>(); Set<String> localeVariants = new HashSet<>(); for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) { String path = rootDir + itPath.next(); if (rsBrowser.isDirectory(path)) { String dirName = PathNormalizer.getPathName(path); if (mappingSkinLocale) { skinNames.add(dirName); // check if there are locale variants for this skin, // and update the localeVariants if needed updateLocaleVariants(rsBrowser, path, localeVariants); } else { if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) { localeVariants.add(dirName); // check if there are skin variants for this locales, // and update the skinVariants if needed updateSkinVariants(rsBrowser, path, skinNames); } } } } // Initialize the variant mapping for the skin root directory return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants); }
[ "private", "Map", "<", "String", ",", "VariantSet", ">", "getVariants", "(", "ResourceBrowser", "rsBrowser", ",", "String", "rootDir", ",", "String", "defaultSkinName", ",", "String", "defaultLocaleName", ",", "boolean", "mappingSkinLocale", ")", "{", "Set", "<", "String", ">", "paths", "=", "rsBrowser", ".", "getResourceNames", "(", "rootDir", ")", ";", "Set", "<", "String", ">", "skinNames", "=", "new", "HashSet", "<>", "(", ")", ";", "Set", "<", "String", ">", "localeVariants", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "itPath", "=", "paths", ".", "iterator", "(", ")", ";", "itPath", ".", "hasNext", "(", ")", ";", ")", "{", "String", "path", "=", "rootDir", "+", "itPath", ".", "next", "(", ")", ";", "if", "(", "rsBrowser", ".", "isDirectory", "(", "path", ")", ")", "{", "String", "dirName", "=", "PathNormalizer", ".", "getPathName", "(", "path", ")", ";", "if", "(", "mappingSkinLocale", ")", "{", "skinNames", ".", "add", "(", "dirName", ")", ";", "// check if there are locale variants for this skin,", "// and update the localeVariants if needed", "updateLocaleVariants", "(", "rsBrowser", ",", "path", ",", "localeVariants", ")", ";", "}", "else", "{", "if", "(", "LocaleUtils", ".", "LOCALE_SUFFIXES", ".", "contains", "(", "dirName", ")", ")", "{", "localeVariants", ".", "add", "(", "dirName", ")", ";", "// check if there are skin variants for this locales,", "// and update the skinVariants if needed", "updateSkinVariants", "(", "rsBrowser", ",", "path", ",", "skinNames", ")", ";", "}", "}", "}", "}", "// Initialize the variant mapping for the skin root directory", "return", "getVariants", "(", "defaultSkinName", ",", "skinNames", ",", "defaultLocaleName", ",", "localeVariants", ")", ";", "}" ]
Initialize the skinMapping from the parent path @param rsBrowser the resource browser @param rootDir the skin root dir path @param defaultSkinName the default skin name @param defaultLocaleName the default locale name
[ "Initialize", "the", "skinMapping", "from", "the", "parent", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L504-L531
7,341
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getVariants
private Map<String, VariantSet> getVariants(String defaultSkin, Set<String> skinNames, String defaultLocaleName, Set<String> localeVariants) { Map<String, VariantSet> skinVariants = new HashMap<>(); if (!skinNames.isEmpty()) { skinVariants.put(JawrConstant.SKIN_VARIANT_TYPE, new VariantSet(JawrConstant.SKIN_VARIANT_TYPE, defaultSkin, skinNames)); } if (!localeVariants.isEmpty()) { skinVariants.put(JawrConstant.LOCALE_VARIANT_TYPE, new VariantSet(JawrConstant.LOCALE_VARIANT_TYPE, defaultLocaleName, localeVariants)); } return skinVariants; }
java
private Map<String, VariantSet> getVariants(String defaultSkin, Set<String> skinNames, String defaultLocaleName, Set<String> localeVariants) { Map<String, VariantSet> skinVariants = new HashMap<>(); if (!skinNames.isEmpty()) { skinVariants.put(JawrConstant.SKIN_VARIANT_TYPE, new VariantSet(JawrConstant.SKIN_VARIANT_TYPE, defaultSkin, skinNames)); } if (!localeVariants.isEmpty()) { skinVariants.put(JawrConstant.LOCALE_VARIANT_TYPE, new VariantSet(JawrConstant.LOCALE_VARIANT_TYPE, defaultLocaleName, localeVariants)); } return skinVariants; }
[ "private", "Map", "<", "String", ",", "VariantSet", ">", "getVariants", "(", "String", "defaultSkin", ",", "Set", "<", "String", ">", "skinNames", ",", "String", "defaultLocaleName", ",", "Set", "<", "String", ">", "localeVariants", ")", "{", "Map", "<", "String", ",", "VariantSet", ">", "skinVariants", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "!", "skinNames", ".", "isEmpty", "(", ")", ")", "{", "skinVariants", ".", "put", "(", "JawrConstant", ".", "SKIN_VARIANT_TYPE", ",", "new", "VariantSet", "(", "JawrConstant", ".", "SKIN_VARIANT_TYPE", ",", "defaultSkin", ",", "skinNames", ")", ")", ";", "}", "if", "(", "!", "localeVariants", ".", "isEmpty", "(", ")", ")", "{", "skinVariants", ".", "put", "(", "JawrConstant", ".", "LOCALE_VARIANT_TYPE", ",", "new", "VariantSet", "(", "JawrConstant", ".", "LOCALE_VARIANT_TYPE", ",", "defaultLocaleName", ",", "localeVariants", ")", ")", ";", "}", "return", "skinVariants", ";", "}" ]
Returns the skin variants @param defaultSkin the default skin @param skinNames the skin names @param defaultLocaleName the default locale name @param localeVariants the locale variants @return the skin variants
[ "Returns", "the", "skin", "variants" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L546-L561
7,342
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.updateLocaleVariants
private void updateLocaleVariants(ResourceBrowser rsBrowser, String path, Set<String> localeVariants) { Set<String> skinPaths = rsBrowser.getResourceNames(path); for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) { String skinPath = path + itSkinPath.next(); if (rsBrowser.isDirectory(skinPath)) { String skinDirName = PathNormalizer.getPathName(skinPath); if (LocaleUtils.LOCALE_SUFFIXES.contains(skinDirName)) { localeVariants.add(skinDirName); } } } }
java
private void updateLocaleVariants(ResourceBrowser rsBrowser, String path, Set<String> localeVariants) { Set<String> skinPaths = rsBrowser.getResourceNames(path); for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) { String skinPath = path + itSkinPath.next(); if (rsBrowser.isDirectory(skinPath)) { String skinDirName = PathNormalizer.getPathName(skinPath); if (LocaleUtils.LOCALE_SUFFIXES.contains(skinDirName)) { localeVariants.add(skinDirName); } } } }
[ "private", "void", "updateLocaleVariants", "(", "ResourceBrowser", "rsBrowser", ",", "String", "path", ",", "Set", "<", "String", ">", "localeVariants", ")", "{", "Set", "<", "String", ">", "skinPaths", "=", "rsBrowser", ".", "getResourceNames", "(", "path", ")", ";", "for", "(", "Iterator", "<", "String", ">", "itSkinPath", "=", "skinPaths", ".", "iterator", "(", ")", ";", "itSkinPath", ".", "hasNext", "(", ")", ";", ")", "{", "String", "skinPath", "=", "path", "+", "itSkinPath", ".", "next", "(", ")", ";", "if", "(", "rsBrowser", ".", "isDirectory", "(", "skinPath", ")", ")", "{", "String", "skinDirName", "=", "PathNormalizer", ".", "getPathName", "(", "skinPath", ")", ";", "if", "(", "LocaleUtils", ".", "LOCALE_SUFFIXES", ".", "contains", "(", "skinDirName", ")", ")", "{", "localeVariants", ".", "add", "(", "skinDirName", ")", ";", "}", "}", "}", "}" ]
Update the locale variants from the directory path given in parameter @param rsBrowser the resource browser @param path the skin path @param localeVariants the set of locale variants to update
[ "Update", "the", "locale", "variants", "from", "the", "directory", "path", "given", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L573-L585
7,343
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.updateSkinVariants
private void updateSkinVariants(ResourceBrowser rsBrowser, String path, Set<String> skinVariants) { Set<String> skinPaths = rsBrowser.getResourceNames(path); for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) { String skinPath = path + itSkinPath.next(); if (rsBrowser.isDirectory(skinPath)) { String skinDirName = PathNormalizer.getPathName(skinPath); skinVariants.add(skinDirName); } } }
java
private void updateSkinVariants(ResourceBrowser rsBrowser, String path, Set<String> skinVariants) { Set<String> skinPaths = rsBrowser.getResourceNames(path); for (Iterator<String> itSkinPath = skinPaths.iterator(); itSkinPath.hasNext();) { String skinPath = path + itSkinPath.next(); if (rsBrowser.isDirectory(skinPath)) { String skinDirName = PathNormalizer.getPathName(skinPath); skinVariants.add(skinDirName); } } }
[ "private", "void", "updateSkinVariants", "(", "ResourceBrowser", "rsBrowser", ",", "String", "path", ",", "Set", "<", "String", ">", "skinVariants", ")", "{", "Set", "<", "String", ">", "skinPaths", "=", "rsBrowser", ".", "getResourceNames", "(", "path", ")", ";", "for", "(", "Iterator", "<", "String", ">", "itSkinPath", "=", "skinPaths", ".", "iterator", "(", ")", ";", "itSkinPath", ".", "hasNext", "(", ")", ";", ")", "{", "String", "skinPath", "=", "path", "+", "itSkinPath", ".", "next", "(", ")", ";", "if", "(", "rsBrowser", ".", "isDirectory", "(", "skinPath", ")", ")", "{", "String", "skinDirName", "=", "PathNormalizer", ".", "getPathName", "(", "skinPath", ")", ";", "skinVariants", ".", "add", "(", "skinDirName", ")", ";", "}", "}", "}" ]
Update the skin variants from the directory path given in parameter @param rsBrowser the resource browser @param path the skin path @param skinVariants the set of skin variants to update
[ "Update", "the", "skin", "variants", "from", "the", "directory", "path", "given", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L597-L607
7,344
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.checkRootDirectoryNotOverlap
private void checkRootDirectoryNotOverlap(String dir, Set<String> skinRootDirectories) { String rootDir = removeLocaleSuffixIfExist(dir); for (Iterator<String> itSkinDir = skinRootDirectories.iterator(); itSkinDir.hasNext();) { String skinDir = PathNormalizer.asDirPath(itSkinDir.next()); if (!skinDir.equals(dir)) { skinDir = removeLocaleSuffixIfExist(skinDir); if (skinDir.startsWith(rootDir)) { throw new BundlingProcessException( "There is a misconfiguration. It is not allowed to have a skin root directory containing another one."); } } } }
java
private void checkRootDirectoryNotOverlap(String dir, Set<String> skinRootDirectories) { String rootDir = removeLocaleSuffixIfExist(dir); for (Iterator<String> itSkinDir = skinRootDirectories.iterator(); itSkinDir.hasNext();) { String skinDir = PathNormalizer.asDirPath(itSkinDir.next()); if (!skinDir.equals(dir)) { skinDir = removeLocaleSuffixIfExist(skinDir); if (skinDir.startsWith(rootDir)) { throw new BundlingProcessException( "There is a misconfiguration. It is not allowed to have a skin root directory containing another one."); } } } }
[ "private", "void", "checkRootDirectoryNotOverlap", "(", "String", "dir", ",", "Set", "<", "String", ">", "skinRootDirectories", ")", "{", "String", "rootDir", "=", "removeLocaleSuffixIfExist", "(", "dir", ")", ";", "for", "(", "Iterator", "<", "String", ">", "itSkinDir", "=", "skinRootDirectories", ".", "iterator", "(", ")", ";", "itSkinDir", ".", "hasNext", "(", ")", ";", ")", "{", "String", "skinDir", "=", "PathNormalizer", ".", "asDirPath", "(", "itSkinDir", ".", "next", "(", ")", ")", ";", "if", "(", "!", "skinDir", ".", "equals", "(", "dir", ")", ")", "{", "skinDir", "=", "removeLocaleSuffixIfExist", "(", "skinDir", ")", ";", "if", "(", "skinDir", ".", "startsWith", "(", "rootDir", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"There is a misconfiguration. It is not allowed to have a skin root directory containing another one.\"", ")", ";", "}", "}", "}", "}" ]
Check if there are no directory which is contained in another root directory, @param dir the root directory to check @param skinRootDirectories the root directories
[ "Check", "if", "there", "are", "no", "directory", "which", "is", "contained", "in", "another", "root", "directory" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L618-L631
7,345
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.removeLocaleSuffixIfExist
private String removeLocaleSuffixIfExist(String dir) { String result = dir; String dirName = PathNormalizer.getPathName(dir); if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) { result = dir.substring(0, dir.indexOf("/" + dirName) + 1); } return result; }
java
private String removeLocaleSuffixIfExist(String dir) { String result = dir; String dirName = PathNormalizer.getPathName(dir); if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) { result = dir.substring(0, dir.indexOf("/" + dirName) + 1); } return result; }
[ "private", "String", "removeLocaleSuffixIfExist", "(", "String", "dir", ")", "{", "String", "result", "=", "dir", ";", "String", "dirName", "=", "PathNormalizer", ".", "getPathName", "(", "dir", ")", ";", "if", "(", "LocaleUtils", ".", "LOCALE_SUFFIXES", ".", "contains", "(", "dirName", ")", ")", "{", "result", "=", "dir", ".", "substring", "(", "0", ",", "dir", ".", "indexOf", "(", "\"/\"", "+", "dirName", ")", "+", "1", ")", ";", "}", "return", "result", ";", "}" ]
Removes from the directory path the locale suffix if it exists @param dir the directory path <pre> removeLocaleSuffixIfExist( "/css/panel/default/" ) = "/css/panel/default/" removeLocaleSuffixIfExist( "/css/panel/default/en_US" ) = "/css/panel/default/" </pre> @return the directory path, with the locale suffix removed if it exists
[ "Removes", "from", "the", "directory", "path", "the", "locale", "suffix", "if", "it", "exists" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L646-L654
7,346
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getVariantStrategy
private VariantResourceReaderStrategy getVariantStrategy(GeneratorContext context, Map<String, VariantSet> variantSetMap) { VariantResourceReaderStrategy strategy = null; try { strategy = (VariantResourceReaderStrategy) resourceProviderStrategyClass.newInstance(); strategy.initVariantProviderStrategy(context, variantSetMap); } catch (InstantiationException | IllegalAccessException e) { throw new BundlingProcessException(e); } return strategy; }
java
private VariantResourceReaderStrategy getVariantStrategy(GeneratorContext context, Map<String, VariantSet> variantSetMap) { VariantResourceReaderStrategy strategy = null; try { strategy = (VariantResourceReaderStrategy) resourceProviderStrategyClass.newInstance(); strategy.initVariantProviderStrategy(context, variantSetMap); } catch (InstantiationException | IllegalAccessException e) { throw new BundlingProcessException(e); } return strategy; }
[ "private", "VariantResourceReaderStrategy", "getVariantStrategy", "(", "GeneratorContext", "context", ",", "Map", "<", "String", ",", "VariantSet", ">", "variantSetMap", ")", "{", "VariantResourceReaderStrategy", "strategy", "=", "null", ";", "try", "{", "strategy", "=", "(", "VariantResourceReaderStrategy", ")", "resourceProviderStrategyClass", ".", "newInstance", "(", ")", ";", "strategy", ".", "initVariantProviderStrategy", "(", "context", ",", "variantSetMap", ")", ";", "}", "catch", "(", "InstantiationException", "|", "IllegalAccessException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "return", "strategy", ";", "}" ]
Returns the variant strategy @param context the generator context @param variantSetMap the variantSet map for the current path @return the variant strategy
[ "Returns", "the", "variant", "strategy" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L665-L677
7,347
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java
CssSkinGenerator.getResourceReader
private Reader getResourceReader(JoinableResourceBundle bundle, String originalPath, ResourceReaderHandler readerHandler, String skinRootDir, String[] paths, Map<String, String> variantMap) { Reader reader = null; StringBuilder path = new StringBuilder(skinRootDir); String skinVariant = (String) variantMap.get(JawrConstant.SKIN_VARIANT_TYPE); String localeVariant = (String) variantMap.get(JawrConstant.LOCALE_VARIANT_TYPE); if (skinMappingType.equals(JawrConstant.SKIN_TYPE_MAPPING_SKIN_LOCALE)) { paths[0] = skinVariant; if (localeVariant != null) { paths[1] = localeVariant; } } else { paths[0] = localeVariant; if (skinVariant != null) { paths[1] = skinVariant; } } for (int i = 0; i < paths.length; i++) { path.append(paths[i]); if (i + 1 < paths.length) { path.append(JawrConstant.URL_SEPARATOR); } } try { String finalPath = path.toString(); reader = readerHandler.getResource(bundle, finalPath); // Rewrite URL if the final CSS path is not the original one if (!originalPath.equals(finalPath)) { String content = IOUtils.toString(reader); StringBuffer result = urlRewriter.rewriteUrl(finalPath, originalPath, content); reader = new StringReader(result.toString()); } } catch (ResourceNotFoundException | IOException e) { // Nothing to do } return reader; }
java
private Reader getResourceReader(JoinableResourceBundle bundle, String originalPath, ResourceReaderHandler readerHandler, String skinRootDir, String[] paths, Map<String, String> variantMap) { Reader reader = null; StringBuilder path = new StringBuilder(skinRootDir); String skinVariant = (String) variantMap.get(JawrConstant.SKIN_VARIANT_TYPE); String localeVariant = (String) variantMap.get(JawrConstant.LOCALE_VARIANT_TYPE); if (skinMappingType.equals(JawrConstant.SKIN_TYPE_MAPPING_SKIN_LOCALE)) { paths[0] = skinVariant; if (localeVariant != null) { paths[1] = localeVariant; } } else { paths[0] = localeVariant; if (skinVariant != null) { paths[1] = skinVariant; } } for (int i = 0; i < paths.length; i++) { path.append(paths[i]); if (i + 1 < paths.length) { path.append(JawrConstant.URL_SEPARATOR); } } try { String finalPath = path.toString(); reader = readerHandler.getResource(bundle, finalPath); // Rewrite URL if the final CSS path is not the original one if (!originalPath.equals(finalPath)) { String content = IOUtils.toString(reader); StringBuffer result = urlRewriter.rewriteUrl(finalPath, originalPath, content); reader = new StringReader(result.toString()); } } catch (ResourceNotFoundException | IOException e) { // Nothing to do } return reader; }
[ "private", "Reader", "getResourceReader", "(", "JoinableResourceBundle", "bundle", ",", "String", "originalPath", ",", "ResourceReaderHandler", "readerHandler", ",", "String", "skinRootDir", ",", "String", "[", "]", "paths", ",", "Map", "<", "String", ",", "String", ">", "variantMap", ")", "{", "Reader", "reader", "=", "null", ";", "StringBuilder", "path", "=", "new", "StringBuilder", "(", "skinRootDir", ")", ";", "String", "skinVariant", "=", "(", "String", ")", "variantMap", ".", "get", "(", "JawrConstant", ".", "SKIN_VARIANT_TYPE", ")", ";", "String", "localeVariant", "=", "(", "String", ")", "variantMap", ".", "get", "(", "JawrConstant", ".", "LOCALE_VARIANT_TYPE", ")", ";", "if", "(", "skinMappingType", ".", "equals", "(", "JawrConstant", ".", "SKIN_TYPE_MAPPING_SKIN_LOCALE", ")", ")", "{", "paths", "[", "0", "]", "=", "skinVariant", ";", "if", "(", "localeVariant", "!=", "null", ")", "{", "paths", "[", "1", "]", "=", "localeVariant", ";", "}", "}", "else", "{", "paths", "[", "0", "]", "=", "localeVariant", ";", "if", "(", "skinVariant", "!=", "null", ")", "{", "paths", "[", "1", "]", "=", "skinVariant", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "paths", ".", "length", ";", "i", "++", ")", "{", "path", ".", "append", "(", "paths", "[", "i", "]", ")", ";", "if", "(", "i", "+", "1", "<", "paths", ".", "length", ")", "{", "path", ".", "append", "(", "JawrConstant", ".", "URL_SEPARATOR", ")", ";", "}", "}", "try", "{", "String", "finalPath", "=", "path", ".", "toString", "(", ")", ";", "reader", "=", "readerHandler", ".", "getResource", "(", "bundle", ",", "finalPath", ")", ";", "// Rewrite URL if the final CSS path is not the original one", "if", "(", "!", "originalPath", ".", "equals", "(", "finalPath", ")", ")", "{", "String", "content", "=", "IOUtils", ".", "toString", "(", "reader", ")", ";", "StringBuffer", "result", "=", "urlRewriter", ".", "rewriteUrl", "(", "finalPath", ",", "originalPath", ",", "content", ")", ";", "reader", "=", "new", "StringReader", "(", "result", ".", "toString", "(", ")", ")", ";", "}", "}", "catch", "(", "ResourceNotFoundException", "|", "IOException", "e", ")", "{", "// Nothing to do", "}", "return", "reader", ";", "}" ]
Returns the reader for the resource path defined in parameter @param bundle the resource bundle @param originalPath the original path @param skinRootDir the root directory @param paths the array of path @param variantMap the variant map @return the reader
[ "Returns", "the", "reader", "for", "the", "resource", "path", "defined", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/generator/variant/css/CssSkinGenerator.java#L694-L736
7,348
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.initTempDirectory
private void initTempDirectory(String tempDirRoot, boolean createTempSubDir) { tempDirPath = tempDirRoot; // In windows, pathnames with spaces are returned as %20 if (tempDirPath.contains("%20")) tempDirPath = tempDirPath.replaceAll("%20", " "); this.textDirPath = tempDirPath + File.separator + TEMP_TEXT_SUBDIR; this.gzipDirPath = tempDirPath + File.separator + TEMP_GZIP_SUBDIR; this.cssClasspathDirPath = tempDirPath + File.separator + TEMP_CSS_CLASSPATH_SUBDIR; if (createTempSubDir) { try { createDir(tempDirPath); createDir(textDirPath); createDir(gzipDirPath); createDir(cssClasspathDirPath); } catch (IOException e) { throw new BundlingProcessException("Unexpected IOException creating temporary jawr directory", e); } } }
java
private void initTempDirectory(String tempDirRoot, boolean createTempSubDir) { tempDirPath = tempDirRoot; // In windows, pathnames with spaces are returned as %20 if (tempDirPath.contains("%20")) tempDirPath = tempDirPath.replaceAll("%20", " "); this.textDirPath = tempDirPath + File.separator + TEMP_TEXT_SUBDIR; this.gzipDirPath = tempDirPath + File.separator + TEMP_GZIP_SUBDIR; this.cssClasspathDirPath = tempDirPath + File.separator + TEMP_CSS_CLASSPATH_SUBDIR; if (createTempSubDir) { try { createDir(tempDirPath); createDir(textDirPath); createDir(gzipDirPath); createDir(cssClasspathDirPath); } catch (IOException e) { throw new BundlingProcessException("Unexpected IOException creating temporary jawr directory", e); } } }
[ "private", "void", "initTempDirectory", "(", "String", "tempDirRoot", ",", "boolean", "createTempSubDir", ")", "{", "tempDirPath", "=", "tempDirRoot", ";", "// In windows, pathnames with spaces are returned as %20", "if", "(", "tempDirPath", ".", "contains", "(", "\"%20\"", ")", ")", "tempDirPath", "=", "tempDirPath", ".", "replaceAll", "(", "\"%20\"", ",", "\" \"", ")", ";", "this", ".", "textDirPath", "=", "tempDirPath", "+", "File", ".", "separator", "+", "TEMP_TEXT_SUBDIR", ";", "this", ".", "gzipDirPath", "=", "tempDirPath", "+", "File", ".", "separator", "+", "TEMP_GZIP_SUBDIR", ";", "this", ".", "cssClasspathDirPath", "=", "tempDirPath", "+", "File", ".", "separator", "+", "TEMP_CSS_CLASSPATH_SUBDIR", ";", "if", "(", "createTempSubDir", ")", "{", "try", "{", "createDir", "(", "tempDirPath", ")", ";", "createDir", "(", "textDirPath", ")", ";", "createDir", "(", "gzipDirPath", ")", ";", "createDir", "(", "cssClasspathDirPath", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Unexpected IOException creating temporary jawr directory\"", ",", "e", ")", ";", "}", "}", "}" ]
Initialize the temporary directories @param tempDirRoot the temporary directory root @param createTempSubDir the flag indicating if we should create the temporary directory.
[ "Initialize", "the", "temporary", "directories" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L204-L226
7,349
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.getJawrBundleMapping
@Override public Properties getJawrBundleMapping() { final Properties bundleMapping = new Properties(); InputStream is = null; try { is = getBundleMappingStream(); if (is != null) { ((Properties) bundleMapping).load(is); } else { LOGGER.info("The jawr bundle mapping '" + mappingFileName + "' is not found"); } } catch (IOException e) { LOGGER.info("Error while loading the jawr bundle mapping '" + JawrConstant.JAWR_JS_MAPPING_PROPERTIES_FILENAME + "'"); } finally { IOUtils.close(is); } return bundleMapping; }
java
@Override public Properties getJawrBundleMapping() { final Properties bundleMapping = new Properties(); InputStream is = null; try { is = getBundleMappingStream(); if (is != null) { ((Properties) bundleMapping).load(is); } else { LOGGER.info("The jawr bundle mapping '" + mappingFileName + "' is not found"); } } catch (IOException e) { LOGGER.info("Error while loading the jawr bundle mapping '" + JawrConstant.JAWR_JS_MAPPING_PROPERTIES_FILENAME + "'"); } finally { IOUtils.close(is); } return bundleMapping; }
[ "@", "Override", "public", "Properties", "getJawrBundleMapping", "(", ")", "{", "final", "Properties", "bundleMapping", "=", "new", "Properties", "(", ")", ";", "InputStream", "is", "=", "null", ";", "try", "{", "is", "=", "getBundleMappingStream", "(", ")", ";", "if", "(", "is", "!=", "null", ")", "{", "(", "(", "Properties", ")", "bundleMapping", ")", ".", "load", "(", "is", ")", ";", "}", "else", "{", "LOGGER", ".", "info", "(", "\"The jawr bundle mapping '\"", "+", "mappingFileName", "+", "\"' is not found\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "info", "(", "\"Error while loading the jawr bundle mapping '\"", "+", "JawrConstant", ".", "JAWR_JS_MAPPING_PROPERTIES_FILENAME", "+", "\"'\"", ")", ";", "}", "finally", "{", "IOUtils", ".", "close", "(", "is", ")", ";", "}", "return", "bundleMapping", ";", "}" ]
Returns the bundle mapping @return the bundle mapping
[ "Returns", "the", "bundle", "mapping" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L277-L297
7,350
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.getBundleMappingStream
private InputStream getBundleMappingStream() { InputStream is = null; try { is = getTemporaryResourceAsStream(PathNormalizer.concatWebPath(tempDirPath + "/", mappingFileName)); } catch (ResourceNotFoundException e) { // Nothing to do } return is; }
java
private InputStream getBundleMappingStream() { InputStream is = null; try { is = getTemporaryResourceAsStream(PathNormalizer.concatWebPath(tempDirPath + "/", mappingFileName)); } catch (ResourceNotFoundException e) { // Nothing to do } return is; }
[ "private", "InputStream", "getBundleMappingStream", "(", ")", "{", "InputStream", "is", "=", "null", ";", "try", "{", "is", "=", "getTemporaryResourceAsStream", "(", "PathNormalizer", ".", "concatWebPath", "(", "tempDirPath", "+", "\"/\"", ",", "mappingFileName", ")", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "e", ")", "{", "// Nothing to do", "}", "return", "is", ";", "}" ]
Returns the bundle mapping file @return the bundle mapping file
[ "Returns", "the", "bundle", "mapping", "file" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L304-L313
7,351
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.getResourceBundleChannel
public ReadableByteChannel getResourceBundleChannel(String bundleName, boolean gzipBundle) throws ResourceNotFoundException { String tempFileName = getStoredBundlePath(bundleName, gzipBundle); InputStream is = getTemporaryResourceAsStream(tempFileName); return Channels.newChannel(is); }
java
public ReadableByteChannel getResourceBundleChannel(String bundleName, boolean gzipBundle) throws ResourceNotFoundException { String tempFileName = getStoredBundlePath(bundleName, gzipBundle); InputStream is = getTemporaryResourceAsStream(tempFileName); return Channels.newChannel(is); }
[ "public", "ReadableByteChannel", "getResourceBundleChannel", "(", "String", "bundleName", ",", "boolean", "gzipBundle", ")", "throws", "ResourceNotFoundException", "{", "String", "tempFileName", "=", "getStoredBundlePath", "(", "bundleName", ",", "gzipBundle", ")", ";", "InputStream", "is", "=", "getTemporaryResourceAsStream", "(", "tempFileName", ")", ";", "return", "Channels", ".", "newChannel", "(", "is", ")", ";", "}" ]
Returns the readable byte channel from the bundle name @param bundleName the bundle name @param gzipBundle the flag indicating if we want to retrieve the gzip version or not @return the readable byte channel from the bundle name @throws ResourceNotFoundException if the resource is not found
[ "Returns", "the", "readable", "byte", "channel", "from", "the", "bundle", "name" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L412-L418
7,352
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.getStoredBundlePath
private String getStoredBundlePath(String bundleName, boolean asGzippedBundle) { String tempFileName; if (asGzippedBundle) tempFileName = gzipDirPath; else tempFileName = textDirPath; return getStoredBundlePath(tempFileName, bundleName); }
java
private String getStoredBundlePath(String bundleName, boolean asGzippedBundle) { String tempFileName; if (asGzippedBundle) tempFileName = gzipDirPath; else tempFileName = textDirPath; return getStoredBundlePath(tempFileName, bundleName); }
[ "private", "String", "getStoredBundlePath", "(", "String", "bundleName", ",", "boolean", "asGzippedBundle", ")", "{", "String", "tempFileName", ";", "if", "(", "asGzippedBundle", ")", "tempFileName", "=", "gzipDirPath", ";", "else", "tempFileName", "=", "textDirPath", ";", "return", "getStoredBundlePath", "(", "tempFileName", ",", "bundleName", ")", ";", "}" ]
Resolves the file name with which a bundle is stored. @param bundleName the bundle name @param asGzippedBundle the flag indicating if it's a gzipped bundle or not @return the file name.
[ "Resolves", "the", "file", "name", "with", "which", "a", "bundle", "is", "stored", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L429-L438
7,353
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.getStoredBundlePath
private String getStoredBundlePath(String rootDir, String bundleName) { if (bundleName.indexOf('/') != -1) { bundleName = bundleName.replace('/', File.separatorChar); } if (!bundleName.startsWith(File.separator)) { rootDir += File.separator; } return rootDir + PathNormalizer.escapeToPhysicalPath(bundleName); }
java
private String getStoredBundlePath(String rootDir, String bundleName) { if (bundleName.indexOf('/') != -1) { bundleName = bundleName.replace('/', File.separatorChar); } if (!bundleName.startsWith(File.separator)) { rootDir += File.separator; } return rootDir + PathNormalizer.escapeToPhysicalPath(bundleName); }
[ "private", "String", "getStoredBundlePath", "(", "String", "rootDir", ",", "String", "bundleName", ")", "{", "if", "(", "bundleName", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "{", "bundleName", "=", "bundleName", ".", "replace", "(", "'", "'", ",", "File", ".", "separatorChar", ")", ";", "}", "if", "(", "!", "bundleName", ".", "startsWith", "(", "File", ".", "separator", ")", ")", "{", "rootDir", "+=", "File", ".", "separator", ";", "}", "return", "rootDir", "+", "PathNormalizer", ".", "escapeToPhysicalPath", "(", "bundleName", ")", ";", "}" ]
Resolves the file path of the bundle from the root directory. @param rootDir the rootDir @param bundleName the bundle name @return the file path
[ "Resolves", "the", "file", "path", "of", "the", "bundle", "from", "the", "root", "directory", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L449-L459
7,354
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.storeBundle
@SuppressWarnings("resource") private void storeBundle(String bundleName, String bundledResources, boolean gzipFile, String rootdir) { if (LOGGER.isDebugEnabled()) { String msg = "Storing a generated " + (gzipFile ? "and gzipped" : "") + " bundle with an id of:" + bundleName; LOGGER.debug(msg); } try { // Create subdirs if needed bundleName = bundleName.replaceAll(":", "_"); if (bundleName.indexOf('/') != -1) { StringTokenizer tk = new StringTokenizer(bundleName, "/"); StringBuilder pathName = new StringBuilder(rootdir); while (tk.hasMoreTokens()) { String name = tk.nextToken(); if (tk.hasMoreTokens()) { pathName.append(File.separator).append(name); createDir(pathName.toString()); } } bundleName = bundleName.replace('/', File.separatorChar); } File store = createNewFile(rootdir + File.separator + bundleName); GZIPOutputStream gzOut = null; Writer wr = null; try { if (gzipFile) { FileOutputStream fos = new FileOutputStream(store); gzOut = new GZIPOutputStream(fos); byte[] data = bundledResources.getBytes(charset.name()); gzOut.write(data, 0, data.length); } else { FileOutputStream fos = new FileOutputStream(store); FileChannel channel = fos.getChannel(); wr = Channels.newWriter(channel, charset.newEncoder(), -1); wr.write(bundledResources); } } finally { IOUtils.close(gzOut); IOUtils.close(wr); } } catch (IOException e) { if (ThreadLocalJawrContext.isInterruptingProcessingBundle() || e instanceof ClosedByInterruptException) { throw new InterruptBundlingProcessException(); } throw new BundlingProcessException("Unexpected IOException creating temporary jawr file", e); } }
java
@SuppressWarnings("resource") private void storeBundle(String bundleName, String bundledResources, boolean gzipFile, String rootdir) { if (LOGGER.isDebugEnabled()) { String msg = "Storing a generated " + (gzipFile ? "and gzipped" : "") + " bundle with an id of:" + bundleName; LOGGER.debug(msg); } try { // Create subdirs if needed bundleName = bundleName.replaceAll(":", "_"); if (bundleName.indexOf('/') != -1) { StringTokenizer tk = new StringTokenizer(bundleName, "/"); StringBuilder pathName = new StringBuilder(rootdir); while (tk.hasMoreTokens()) { String name = tk.nextToken(); if (tk.hasMoreTokens()) { pathName.append(File.separator).append(name); createDir(pathName.toString()); } } bundleName = bundleName.replace('/', File.separatorChar); } File store = createNewFile(rootdir + File.separator + bundleName); GZIPOutputStream gzOut = null; Writer wr = null; try { if (gzipFile) { FileOutputStream fos = new FileOutputStream(store); gzOut = new GZIPOutputStream(fos); byte[] data = bundledResources.getBytes(charset.name()); gzOut.write(data, 0, data.length); } else { FileOutputStream fos = new FileOutputStream(store); FileChannel channel = fos.getChannel(); wr = Channels.newWriter(channel, charset.newEncoder(), -1); wr.write(bundledResources); } } finally { IOUtils.close(gzOut); IOUtils.close(wr); } } catch (IOException e) { if (ThreadLocalJawrContext.isInterruptingProcessingBundle() || e instanceof ClosedByInterruptException) { throw new InterruptBundlingProcessException(); } throw new BundlingProcessException("Unexpected IOException creating temporary jawr file", e); } }
[ "@", "SuppressWarnings", "(", "\"resource\"", ")", "private", "void", "storeBundle", "(", "String", "bundleName", ",", "String", "bundledResources", ",", "boolean", "gzipFile", ",", "String", "rootdir", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "String", "msg", "=", "\"Storing a generated \"", "+", "(", "gzipFile", "?", "\"and gzipped\"", ":", "\"\"", ")", "+", "\" bundle with an id of:\"", "+", "bundleName", ";", "LOGGER", ".", "debug", "(", "msg", ")", ";", "}", "try", "{", "// Create subdirs if needed", "bundleName", "=", "bundleName", ".", "replaceAll", "(", "\":\"", ",", "\"_\"", ")", ";", "if", "(", "bundleName", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "{", "StringTokenizer", "tk", "=", "new", "StringTokenizer", "(", "bundleName", ",", "\"/\"", ")", ";", "StringBuilder", "pathName", "=", "new", "StringBuilder", "(", "rootdir", ")", ";", "while", "(", "tk", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "name", "=", "tk", ".", "nextToken", "(", ")", ";", "if", "(", "tk", ".", "hasMoreTokens", "(", ")", ")", "{", "pathName", ".", "append", "(", "File", ".", "separator", ")", ".", "append", "(", "name", ")", ";", "createDir", "(", "pathName", ".", "toString", "(", ")", ")", ";", "}", "}", "bundleName", "=", "bundleName", ".", "replace", "(", "'", "'", ",", "File", ".", "separatorChar", ")", ";", "}", "File", "store", "=", "createNewFile", "(", "rootdir", "+", "File", ".", "separator", "+", "bundleName", ")", ";", "GZIPOutputStream", "gzOut", "=", "null", ";", "Writer", "wr", "=", "null", ";", "try", "{", "if", "(", "gzipFile", ")", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "store", ")", ";", "gzOut", "=", "new", "GZIPOutputStream", "(", "fos", ")", ";", "byte", "[", "]", "data", "=", "bundledResources", ".", "getBytes", "(", "charset", ".", "name", "(", ")", ")", ";", "gzOut", ".", "write", "(", "data", ",", "0", ",", "data", ".", "length", ")", ";", "}", "else", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "store", ")", ";", "FileChannel", "channel", "=", "fos", ".", "getChannel", "(", ")", ";", "wr", "=", "Channels", ".", "newWriter", "(", "channel", ",", "charset", ".", "newEncoder", "(", ")", ",", "-", "1", ")", ";", "wr", ".", "write", "(", "bundledResources", ")", ";", "}", "}", "finally", "{", "IOUtils", ".", "close", "(", "gzOut", ")", ";", "IOUtils", ".", "close", "(", "wr", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "ThreadLocalJawrContext", ".", "isInterruptingProcessingBundle", "(", ")", "||", "e", "instanceof", "ClosedByInterruptException", ")", "{", "throw", "new", "InterruptBundlingProcessException", "(", ")", ";", "}", "throw", "new", "BundlingProcessException", "(", "\"Unexpected IOException creating temporary jawr file\"", ",", "e", ")", ";", "}", "}" ]
Stores a resource bundle either in text or binary gzipped format. @param bundleName the bundle name @param bundledResources the bundledResources @param gzipFile a flag defining if the file is gzipped or not @param rootDir the root directory
[ "Stores", "a", "resource", "bundle", "either", "in", "text", "or", "binary", "gzipped", "format", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L503-L553
7,355
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.createDir
private File createDir(String path) throws IOException { // In windows, pathnames with spaces are returned as %20 if (path.contains("%20")) path = path.replaceAll("%20", " "); File dir = new File(path); if (!dir.exists() && !dir.mkdirs()) throw new BundlingProcessException("Error creating temporary jawr directory with path:" + dir.getPath()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Created dir: " + dir.getCanonicalPath()); } return dir; }
java
private File createDir(String path) throws IOException { // In windows, pathnames with spaces are returned as %20 if (path.contains("%20")) path = path.replaceAll("%20", " "); File dir = new File(path); if (!dir.exists() && !dir.mkdirs()) throw new BundlingProcessException("Error creating temporary jawr directory with path:" + dir.getPath()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Created dir: " + dir.getCanonicalPath()); } return dir; }
[ "private", "File", "createDir", "(", "String", "path", ")", "throws", "IOException", "{", "// In windows, pathnames with spaces are returned as %20", "if", "(", "path", ".", "contains", "(", "\"%20\"", ")", ")", "path", "=", "path", ".", "replaceAll", "(", "\"%20\"", ",", "\" \"", ")", ";", "File", "dir", "=", "new", "File", "(", "path", ")", ";", "if", "(", "!", "dir", ".", "exists", "(", ")", "&&", "!", "dir", ".", "mkdirs", "(", ")", ")", "throw", "new", "BundlingProcessException", "(", "\"Error creating temporary jawr directory with path:\"", "+", "dir", ".", "getPath", "(", ")", ")", ";", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Created dir: \"", "+", "dir", ".", "getCanonicalPath", "(", ")", ")", ";", "}", "return", "dir", ";", "}" ]
Creates a directory. If dir is not created for some reason a runtime exception is thrown. @param dir @throws IOException
[ "Creates", "a", "directory", ".", "If", "dir", "is", "not", "created", "for", "some", "reason", "a", "runtime", "exception", "is", "thrown", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L562-L574
7,356
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java
AbstractResourceBundleHandler.createNewFile
private File createNewFile(String path) throws IOException { // In windows, pathnames with spaces are returned as %20 if (path.contains("%20")) path = path.replaceAll("%20", " "); File newFile = new File(path); if (!newFile.exists() && !newFile.createNewFile()) { throw new BundlingProcessException("Unable to create a temporary file at " + path); } if (LOGGER.isDebugEnabled()) LOGGER.debug("Created file: " + newFile.getCanonicalPath()); return newFile; }
java
private File createNewFile(String path) throws IOException { // In windows, pathnames with spaces are returned as %20 if (path.contains("%20")) path = path.replaceAll("%20", " "); File newFile = new File(path); if (!newFile.exists() && !newFile.createNewFile()) { throw new BundlingProcessException("Unable to create a temporary file at " + path); } if (LOGGER.isDebugEnabled()) LOGGER.debug("Created file: " + newFile.getCanonicalPath()); return newFile; }
[ "private", "File", "createNewFile", "(", "String", "path", ")", "throws", "IOException", "{", "// In windows, pathnames with spaces are returned as %20", "if", "(", "path", ".", "contains", "(", "\"%20\"", ")", ")", "path", "=", "path", ".", "replaceAll", "(", "\"%20\"", ",", "\" \"", ")", ";", "File", "newFile", "=", "new", "File", "(", "path", ")", ";", "if", "(", "!", "newFile", ".", "exists", "(", ")", "&&", "!", "newFile", ".", "createNewFile", "(", ")", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Unable to create a temporary file at \"", "+", "path", ")", ";", "}", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "LOGGER", ".", "debug", "(", "\"Created file: \"", "+", "newFile", ".", "getCanonicalPath", "(", ")", ")", ";", "return", "newFile", ";", "}" ]
Creates a file. If dir is not created for some reason a runtimeexception is thrown. @param path @return @throws IOException
[ "Creates", "a", "file", ".", "If", "dir", "is", "not", "created", "for", "some", "reason", "a", "runtimeexception", "is", "thrown", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/bundle/AbstractResourceBundleHandler.java#L584-L598
7,357
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java
ResourceWatcher.stopWatching
public void stopWatching() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Stopping resource watching"); } this.stopWatching.set(true); jawrEvtProcessor.stopProcessing(); jawrEvtProcessor.interrupt(); }
java
public void stopWatching() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Stopping resource watching"); } this.stopWatching.set(true); jawrEvtProcessor.stopProcessing(); jawrEvtProcessor.interrupt(); }
[ "public", "void", "stopWatching", "(", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Stopping resource watching\"", ")", ";", "}", "this", ".", "stopWatching", ".", "set", "(", "true", ")", ";", "jawrEvtProcessor", ".", "stopProcessing", "(", ")", ";", "jawrEvtProcessor", ".", "interrupt", "(", ")", ";", "}" ]
Sets the flag indicating if we must stop the resource watching
[ "Sets", "the", "flag", "indicating", "if", "we", "must", "stop", "the", "resource", "watching" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java#L142-L150
7,358
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java
ResourceWatcher.initPathToResourceBundleMap
public synchronized void initPathToResourceBundleMap(List<JoinableResourceBundle> bundles) throws IOException { for (JoinableResourceBundle bundle : bundles) { // Remove bundle reference from existing mapping if exists removePathMappingFromPathMap(bundle); List<PathMapping> mappings = bundle.getMappings(); for (PathMapping pathMapping : mappings) { register(pathMapping); } // Register file path mapping for linked resources List<FilePathMapping> fMappings = bundle.getLinkedFilePathMappings(); for (FilePathMapping fMapping : fMappings) { register(fMapping); } } }
java
public synchronized void initPathToResourceBundleMap(List<JoinableResourceBundle> bundles) throws IOException { for (JoinableResourceBundle bundle : bundles) { // Remove bundle reference from existing mapping if exists removePathMappingFromPathMap(bundle); List<PathMapping> mappings = bundle.getMappings(); for (PathMapping pathMapping : mappings) { register(pathMapping); } // Register file path mapping for linked resources List<FilePathMapping> fMappings = bundle.getLinkedFilePathMappings(); for (FilePathMapping fMapping : fMappings) { register(fMapping); } } }
[ "public", "synchronized", "void", "initPathToResourceBundleMap", "(", "List", "<", "JoinableResourceBundle", ">", "bundles", ")", "throws", "IOException", "{", "for", "(", "JoinableResourceBundle", "bundle", ":", "bundles", ")", "{", "// Remove bundle reference from existing mapping if exists", "removePathMappingFromPathMap", "(", "bundle", ")", ";", "List", "<", "PathMapping", ">", "mappings", "=", "bundle", ".", "getMappings", "(", ")", ";", "for", "(", "PathMapping", "pathMapping", ":", "mappings", ")", "{", "register", "(", "pathMapping", ")", ";", "}", "// Register file path mapping for linked resources", "List", "<", "FilePathMapping", ">", "fMappings", "=", "bundle", ".", "getLinkedFilePathMappings", "(", ")", ";", "for", "(", "FilePathMapping", "fMapping", ":", "fMappings", ")", "{", "register", "(", "fMapping", ")", ";", "}", "}", "}" ]
Initialize the map which links path to asset bundle @param bundles the list of bundles @throws IOException if an {@link IOException} occurs
[ "Initialize", "the", "map", "which", "links", "path", "to", "asset", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java#L160-L178
7,359
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java
ResourceWatcher.register
private void register(PathMapping pathMapping) throws IOException { GeneratorRegistry generatorRegistry = bundlesHandler.getConfig().getGeneratorRegistry(); List<PathMapping> mappings = new ArrayList<>(); if (generatorRegistry.isPathGenerated(pathMapping.getPath())) { List<PathMapping> genPathMappings = generatorRegistry.getGeneratedPathMappings(pathMapping.getBundle(), pathMapping.getPath(), rsReader); if (genPathMappings != null) { mappings.addAll(genPathMappings); } else { mappings.add(pathMapping); } } else { mappings.add(pathMapping); } for (PathMapping pMapping : mappings) { String filePath = rsReader.getFilePath(pMapping.getPath()); registerPathMapping(pMapping, filePath); } }
java
private void register(PathMapping pathMapping) throws IOException { GeneratorRegistry generatorRegistry = bundlesHandler.getConfig().getGeneratorRegistry(); List<PathMapping> mappings = new ArrayList<>(); if (generatorRegistry.isPathGenerated(pathMapping.getPath())) { List<PathMapping> genPathMappings = generatorRegistry.getGeneratedPathMappings(pathMapping.getBundle(), pathMapping.getPath(), rsReader); if (genPathMappings != null) { mappings.addAll(genPathMappings); } else { mappings.add(pathMapping); } } else { mappings.add(pathMapping); } for (PathMapping pMapping : mappings) { String filePath = rsReader.getFilePath(pMapping.getPath()); registerPathMapping(pMapping, filePath); } }
[ "private", "void", "register", "(", "PathMapping", "pathMapping", ")", "throws", "IOException", "{", "GeneratorRegistry", "generatorRegistry", "=", "bundlesHandler", ".", "getConfig", "(", ")", ".", "getGeneratorRegistry", "(", ")", ";", "List", "<", "PathMapping", ">", "mappings", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "generatorRegistry", ".", "isPathGenerated", "(", "pathMapping", ".", "getPath", "(", ")", ")", ")", "{", "List", "<", "PathMapping", ">", "genPathMappings", "=", "generatorRegistry", ".", "getGeneratedPathMappings", "(", "pathMapping", ".", "getBundle", "(", ")", ",", "pathMapping", ".", "getPath", "(", ")", ",", "rsReader", ")", ";", "if", "(", "genPathMappings", "!=", "null", ")", "{", "mappings", ".", "addAll", "(", "genPathMappings", ")", ";", "}", "else", "{", "mappings", ".", "add", "(", "pathMapping", ")", ";", "}", "}", "else", "{", "mappings", ".", "add", "(", "pathMapping", ")", ";", "}", "for", "(", "PathMapping", "pMapping", ":", "mappings", ")", "{", "String", "filePath", "=", "rsReader", ".", "getFilePath", "(", "pMapping", ".", "getPath", "(", ")", ")", ";", "registerPathMapping", "(", "pMapping", ",", "filePath", ")", ";", "}", "}" ]
Register a path mapping @param pathMapping the path mapping to register @throws IOException if an IOException occurs
[ "Register", "a", "path", "mapping" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java#L188-L208
7,360
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java
ResourceWatcher.registerPathMapping
private void registerPathMapping(PathMapping pathMapping, String filePath) throws IOException { if (filePath != null) { Path p = Paths.get(filePath); boolean isDir = Files.isDirectory(p); if (!isDir) { p = p.getParent(); } if (pathMapping.isRecursive()) { registerAll(p, Arrays.asList(pathMapping)); } else { register(p, Arrays.asList(pathMapping)); } } }
java
private void registerPathMapping(PathMapping pathMapping, String filePath) throws IOException { if (filePath != null) { Path p = Paths.get(filePath); boolean isDir = Files.isDirectory(p); if (!isDir) { p = p.getParent(); } if (pathMapping.isRecursive()) { registerAll(p, Arrays.asList(pathMapping)); } else { register(p, Arrays.asList(pathMapping)); } } }
[ "private", "void", "registerPathMapping", "(", "PathMapping", "pathMapping", ",", "String", "filePath", ")", "throws", "IOException", "{", "if", "(", "filePath", "!=", "null", ")", "{", "Path", "p", "=", "Paths", ".", "get", "(", "filePath", ")", ";", "boolean", "isDir", "=", "Files", ".", "isDirectory", "(", "p", ")", ";", "if", "(", "!", "isDir", ")", "{", "p", "=", "p", ".", "getParent", "(", ")", ";", "}", "if", "(", "pathMapping", ".", "isRecursive", "(", ")", ")", "{", "registerAll", "(", "p", ",", "Arrays", ".", "asList", "(", "pathMapping", ")", ")", ";", "}", "else", "{", "register", "(", "p", ",", "Arrays", ".", "asList", "(", "pathMapping", ")", ")", ";", "}", "}", "}" ]
Register the path mapping @param pathMapping the path mapping @param filePath the file path @throws IOException if an IOException occurs
[ "Register", "the", "path", "mapping" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java#L232-L247
7,361
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java
ResourceWatcher.removePathMappingFromPathMap
private void removePathMappingFromPathMap(JoinableResourceBundle bundle) { for (List<PathMapping> pathMappings : pathToResourceBundle.values()) { for (Iterator<PathMapping> iterator = pathMappings.iterator(); iterator.hasNext();) { PathMapping pathMapping = (PathMapping) iterator.next(); if (pathMapping.getBundle().getName().equals(bundle.getName())) { iterator.remove(); } } } }
java
private void removePathMappingFromPathMap(JoinableResourceBundle bundle) { for (List<PathMapping> pathMappings : pathToResourceBundle.values()) { for (Iterator<PathMapping> iterator = pathMappings.iterator(); iterator.hasNext();) { PathMapping pathMapping = (PathMapping) iterator.next(); if (pathMapping.getBundle().getName().equals(bundle.getName())) { iterator.remove(); } } } }
[ "private", "void", "removePathMappingFromPathMap", "(", "JoinableResourceBundle", "bundle", ")", "{", "for", "(", "List", "<", "PathMapping", ">", "pathMappings", ":", "pathToResourceBundle", ".", "values", "(", ")", ")", "{", "for", "(", "Iterator", "<", "PathMapping", ">", "iterator", "=", "pathMappings", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "PathMapping", "pathMapping", "=", "(", "PathMapping", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "pathMapping", ".", "getBundle", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "bundle", ".", "getName", "(", ")", ")", ")", "{", "iterator", ".", "remove", "(", ")", ";", "}", "}", "}", "}" ]
Removes the path mapping of the bundle given in parameter from map which links Path to resource bundle @param bundle the bundle whose the path mapping should be removed
[ "Removes", "the", "path", "mapping", "of", "the", "bundle", "given", "in", "parameter", "from", "map", "which", "links", "Path", "to", "resource", "bundle" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/ResourceWatcher.java#L256-L265
7,362
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.getInitializedConfigurationManagers
private List<JawrConfigManagerMBean> getInitializedConfigurationManagers() { final List<JawrConfigManagerMBean> mBeans = new ArrayList<>(); if (jsMBean != null) { mBeans.add(jsMBean); } if (cssMBean != null) { mBeans.add(cssMBean); } if (binaryMBean != null) { mBeans.add(binaryMBean); } return mBeans; }
java
private List<JawrConfigManagerMBean> getInitializedConfigurationManagers() { final List<JawrConfigManagerMBean> mBeans = new ArrayList<>(); if (jsMBean != null) { mBeans.add(jsMBean); } if (cssMBean != null) { mBeans.add(cssMBean); } if (binaryMBean != null) { mBeans.add(binaryMBean); } return mBeans; }
[ "private", "List", "<", "JawrConfigManagerMBean", ">", "getInitializedConfigurationManagers", "(", ")", "{", "final", "List", "<", "JawrConfigManagerMBean", ">", "mBeans", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "jsMBean", "!=", "null", ")", "{", "mBeans", ".", "add", "(", "jsMBean", ")", ";", "}", "if", "(", "cssMBean", "!=", "null", ")", "{", "mBeans", ".", "add", "(", "cssMBean", ")", ";", "}", "if", "(", "binaryMBean", "!=", "null", ")", "{", "mBeans", ".", "add", "(", "binaryMBean", ")", ";", "}", "return", "mBeans", ";", "}" ]
Returns the list of initialized configuration managers. @return the list of initialized configuration managers.
[ "Returns", "the", "list", "of", "initialized", "configuration", "managers", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L144-L159
7,363
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.getConfigMgr
public JawrConfigManagerMBean getConfigMgr(String resourceType) { JawrConfigManagerMBean configMgr = null; if (resourceType.equals(JS_TYPE)) { configMgr = jsMBean; } else if (resourceType.equals(CSS_TYPE)) { configMgr = cssMBean; } else if (resourceType.equals(BINARY_TYPE)) { configMgr = binaryMBean; } return configMgr; }
java
public JawrConfigManagerMBean getConfigMgr(String resourceType) { JawrConfigManagerMBean configMgr = null; if (resourceType.equals(JS_TYPE)) { configMgr = jsMBean; } else if (resourceType.equals(CSS_TYPE)) { configMgr = cssMBean; } else if (resourceType.equals(BINARY_TYPE)) { configMgr = binaryMBean; } return configMgr; }
[ "public", "JawrConfigManagerMBean", "getConfigMgr", "(", "String", "resourceType", ")", "{", "JawrConfigManagerMBean", "configMgr", "=", "null", ";", "if", "(", "resourceType", ".", "equals", "(", "JS_TYPE", ")", ")", "{", "configMgr", "=", "jsMBean", ";", "}", "else", "if", "(", "resourceType", ".", "equals", "(", "CSS_TYPE", ")", ")", "{", "configMgr", "=", "cssMBean", ";", "}", "else", "if", "(", "resourceType", ".", "equals", "(", "BINARY_TYPE", ")", ")", "{", "configMgr", "=", "binaryMBean", ";", "}", "return", "configMgr", ";", "}" ]
Returns the config manager MBean from the resource type @param resourceType the resource type @return the config manager MBean from the resource type
[ "Returns", "the", "config", "manager", "MBean", "from", "the", "resource", "type" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L491-L503
7,364
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.getStringValue
public String getStringValue(String property) { final List<JawrConfigManagerMBean> mBeans = getInitializedConfigurationManagers(); try { if (mBeans.size() == 3) { if (areEquals(getProperty(jsMBean, property), getProperty(cssMBean, property), getProperty(binaryMBean, property))) { return getProperty(jsMBean, property); } else { return NOT_IDENTICAL_VALUES; } } if (mBeans.size() == 2) { JawrConfigManagerMBean mBean1 = mBeans.get(0); JawrConfigManagerMBean mBean2 = mBeans.get(1); if (areEquals(getProperty(mBean1, property), getProperty(mBean2, property))) { return getProperty(mBean1, property); } else { return NOT_IDENTICAL_VALUES; } } JawrConfigManagerMBean mBean1 = mBeans.get(0); return getProperty(mBean1, property); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { return ERROR_VALUE; } }
java
public String getStringValue(String property) { final List<JawrConfigManagerMBean> mBeans = getInitializedConfigurationManagers(); try { if (mBeans.size() == 3) { if (areEquals(getProperty(jsMBean, property), getProperty(cssMBean, property), getProperty(binaryMBean, property))) { return getProperty(jsMBean, property); } else { return NOT_IDENTICAL_VALUES; } } if (mBeans.size() == 2) { JawrConfigManagerMBean mBean1 = mBeans.get(0); JawrConfigManagerMBean mBean2 = mBeans.get(1); if (areEquals(getProperty(mBean1, property), getProperty(mBean2, property))) { return getProperty(mBean1, property); } else { return NOT_IDENTICAL_VALUES; } } JawrConfigManagerMBean mBean1 = mBeans.get(0); return getProperty(mBean1, property); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { return ERROR_VALUE; } }
[ "public", "String", "getStringValue", "(", "String", "property", ")", "{", "final", "List", "<", "JawrConfigManagerMBean", ">", "mBeans", "=", "getInitializedConfigurationManagers", "(", ")", ";", "try", "{", "if", "(", "mBeans", ".", "size", "(", ")", "==", "3", ")", "{", "if", "(", "areEquals", "(", "getProperty", "(", "jsMBean", ",", "property", ")", ",", "getProperty", "(", "cssMBean", ",", "property", ")", ",", "getProperty", "(", "binaryMBean", ",", "property", ")", ")", ")", "{", "return", "getProperty", "(", "jsMBean", ",", "property", ")", ";", "}", "else", "{", "return", "NOT_IDENTICAL_VALUES", ";", "}", "}", "if", "(", "mBeans", ".", "size", "(", ")", "==", "2", ")", "{", "JawrConfigManagerMBean", "mBean1", "=", "mBeans", ".", "get", "(", "0", ")", ";", "JawrConfigManagerMBean", "mBean2", "=", "mBeans", ".", "get", "(", "1", ")", ";", "if", "(", "areEquals", "(", "getProperty", "(", "mBean1", ",", "property", ")", ",", "getProperty", "(", "mBean2", ",", "property", ")", ")", ")", "{", "return", "getProperty", "(", "mBean1", ",", "property", ")", ";", "}", "else", "{", "return", "NOT_IDENTICAL_VALUES", ";", "}", "}", "JawrConfigManagerMBean", "mBean1", "=", "mBeans", ".", "get", "(", "0", ")", ";", "return", "getProperty", "(", "mBean1", ",", "property", ")", ";", "}", "catch", "(", "NoSuchMethodException", "|", "IllegalAccessException", "|", "InvocationTargetException", "e", ")", "{", "return", "ERROR_VALUE", ";", "}", "}" ]
Returns the string value of the configuration managers @param property the property to retrieve @return the string value of the configuration managers
[ "Returns", "the", "string", "value", "of", "the", "configuration", "managers" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L512-L547
7,365
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.setStringValue
public void setStringValue(String property, String value) { try { if (jsMBean != null) { setProperty(jsMBean, property, value); } if (cssMBean != null) { setProperty(cssMBean, property, value); } if (binaryMBean != null) { setProperty(binaryMBean, property, value); } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new JmxConfigException("Exception while setting the string value", e); } }
java
public void setStringValue(String property, String value) { try { if (jsMBean != null) { setProperty(jsMBean, property, value); } if (cssMBean != null) { setProperty(cssMBean, property, value); } if (binaryMBean != null) { setProperty(binaryMBean, property, value); } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new JmxConfigException("Exception while setting the string value", e); } }
[ "public", "void", "setStringValue", "(", "String", "property", ",", "String", "value", ")", "{", "try", "{", "if", "(", "jsMBean", "!=", "null", ")", "{", "setProperty", "(", "jsMBean", ",", "property", ",", "value", ")", ";", "}", "if", "(", "cssMBean", "!=", "null", ")", "{", "setProperty", "(", "cssMBean", ",", "property", ",", "value", ")", ";", "}", "if", "(", "binaryMBean", "!=", "null", ")", "{", "setProperty", "(", "binaryMBean", ",", "property", ",", "value", ")", ";", "}", "}", "catch", "(", "IllegalAccessException", "|", "InvocationTargetException", "|", "NoSuchMethodException", "e", ")", "{", "throw", "new", "JmxConfigException", "(", "\"Exception while setting the string value\"", ",", "e", ")", ";", "}", "}" ]
Update the property with the string value in each config manager. @param property the property to update @param value the value to set
[ "Update", "the", "property", "with", "the", "string", "value", "in", "each", "config", "manager", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L557-L571
7,366
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.areEquals
public boolean areEquals(String str1, String str2) { return (str1 == null && str2 == null || str1 != null && str2 != null && str1.equals(str2)); }
java
public boolean areEquals(String str1, String str2) { return (str1 == null && str2 == null || str1 != null && str2 != null && str1.equals(str2)); }
[ "public", "boolean", "areEquals", "(", "String", "str1", ",", "String", "str2", ")", "{", "return", "(", "str1", "==", "null", "&&", "str2", "==", "null", "||", "str1", "!=", "null", "&&", "str2", "!=", "null", "&&", "str1", ".", "equals", "(", "str2", ")", ")", ";", "}" ]
Returns true if the 2 string are equals. @param str1 the first string @param str2 the 2nd string @return true if the 2 string are equals.
[ "Returns", "true", "if", "the", "2", "string", "are", "equals", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L606-L609
7,367
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java
JawrApplicationConfigManager.areEquals
public boolean areEquals(String str1, String str2, String str3) { return (str1 == null && str2 == null && str3 == null || str1 != null && str2 != null && str3 != null && str1.equals(str2) && str2.equals(str3)); }
java
public boolean areEquals(String str1, String str2, String str3) { return (str1 == null && str2 == null && str3 == null || str1 != null && str2 != null && str3 != null && str1.equals(str2) && str2.equals(str3)); }
[ "public", "boolean", "areEquals", "(", "String", "str1", ",", "String", "str2", ",", "String", "str3", ")", "{", "return", "(", "str1", "==", "null", "&&", "str2", "==", "null", "&&", "str3", "==", "null", "||", "str1", "!=", "null", "&&", "str2", "!=", "null", "&&", "str3", "!=", "null", "&&", "str1", ".", "equals", "(", "str2", ")", "&&", "str2", ".", "equals", "(", "str3", ")", ")", ";", "}" ]
Returns true if the 3 string are equals. @param str1 the first string @param str2 the 2nd string @param str3 the 3rd string @return true if the 3 string are equals.
[ "Returns", "true", "if", "the", "3", "string", "are", "equals", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/config/jmx/JawrApplicationConfigManager.java#L622-L626
7,368
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java
LocaleUtils.getLocalizedBundleName
public static String getLocalizedBundleName(String bundleName, String localeKey) { String newName = bundleName; int idxSeparator = bundleName.lastIndexOf('.'); if (StringUtils.isNotEmpty(localeKey) && idxSeparator != -1) { newName = bundleName.substring(0, idxSeparator); newName += '_' + localeKey; newName += bundleName.substring(idxSeparator); } return newName; }
java
public static String getLocalizedBundleName(String bundleName, String localeKey) { String newName = bundleName; int idxSeparator = bundleName.lastIndexOf('.'); if (StringUtils.isNotEmpty(localeKey) && idxSeparator != -1) { newName = bundleName.substring(0, idxSeparator); newName += '_' + localeKey; newName += bundleName.substring(idxSeparator); } return newName; }
[ "public", "static", "String", "getLocalizedBundleName", "(", "String", "bundleName", ",", "String", "localeKey", ")", "{", "String", "newName", "=", "bundleName", ";", "int", "idxSeparator", "=", "bundleName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "localeKey", ")", "&&", "idxSeparator", "!=", "-", "1", ")", "{", "newName", "=", "bundleName", ".", "substring", "(", "0", ",", "idxSeparator", ")", ";", "newName", "+=", "'", "'", "+", "localeKey", ";", "newName", "+=", "bundleName", ".", "substring", "(", "idxSeparator", ")", ";", "}", "return", "newName", ";", "}" ]
Returns the localized bundle name @param bundleName the bundle name @param localeKey the locale key @return the localized bundle name
[ "Returns", "the", "localized", "bundle", "name" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java#L74-L85
7,369
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java
LocaleUtils.addSuffixIfAvailable
private static void addSuffixIfAvailable(String messageBundlePath, Set<String> availableLocaleSuffixes, Locale locale, String fileSuffix, ServletContext servletContext) { String localMsgResourcePath = toBundleName(messageBundlePath, locale) + fileSuffix; URL resourceUrl = getResourceBundleURL(localMsgResourcePath, servletContext); if (resourceUrl != null) { String suffix = localMsgResourcePath.substring(messageBundlePath.length()); if (suffix.length() > 0) { if (suffix.length() == fileSuffix.length()) { suffix = ""; } else { // remove the "_" before the suffix "_en_US" => "en_US" suffix = suffix.substring(1, suffix.length() - fileSuffix.length()); } } availableLocaleSuffixes.add(suffix); } }
java
private static void addSuffixIfAvailable(String messageBundlePath, Set<String> availableLocaleSuffixes, Locale locale, String fileSuffix, ServletContext servletContext) { String localMsgResourcePath = toBundleName(messageBundlePath, locale) + fileSuffix; URL resourceUrl = getResourceBundleURL(localMsgResourcePath, servletContext); if (resourceUrl != null) { String suffix = localMsgResourcePath.substring(messageBundlePath.length()); if (suffix.length() > 0) { if (suffix.length() == fileSuffix.length()) { suffix = ""; } else { // remove the "_" before the suffix "_en_US" => "en_US" suffix = suffix.substring(1, suffix.length() - fileSuffix.length()); } } availableLocaleSuffixes.add(suffix); } }
[ "private", "static", "void", "addSuffixIfAvailable", "(", "String", "messageBundlePath", ",", "Set", "<", "String", ">", "availableLocaleSuffixes", ",", "Locale", "locale", ",", "String", "fileSuffix", ",", "ServletContext", "servletContext", ")", "{", "String", "localMsgResourcePath", "=", "toBundleName", "(", "messageBundlePath", ",", "locale", ")", "+", "fileSuffix", ";", "URL", "resourceUrl", "=", "getResourceBundleURL", "(", "localMsgResourcePath", ",", "servletContext", ")", ";", "if", "(", "resourceUrl", "!=", "null", ")", "{", "String", "suffix", "=", "localMsgResourcePath", ".", "substring", "(", "messageBundlePath", ".", "length", "(", ")", ")", ";", "if", "(", "suffix", ".", "length", "(", ")", ">", "0", ")", "{", "if", "(", "suffix", ".", "length", "(", ")", "==", "fileSuffix", ".", "length", "(", ")", ")", "{", "suffix", "=", "\"\"", ";", "}", "else", "{", "// remove the \"_\" before the suffix \"_en_US\" => \"en_US\"", "suffix", "=", "suffix", ".", "substring", "(", "1", ",", "suffix", ".", "length", "(", ")", "-", "fileSuffix", ".", "length", "(", ")", ")", ";", "}", "}", "availableLocaleSuffixes", ".", "add", "(", "suffix", ")", ";", "}", "}" ]
Adds the locale suffix if the message resource bundle file exists. @param messageBundlePath the message resource bundle path @param availableLocaleSuffixes the list of available locale suffix to update @param locale the locale to check. @param fileSuffix the file suffix
[ "Adds", "the", "locale", "suffix", "if", "the", "message", "resource", "bundle", "file", "exists", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java#L228-L247
7,370
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java
LocaleUtils.getResourceBundleURL
public static URL getResourceBundleURL(String resourcePath, ServletContext servletContext) { URL resourceUrl = null; try { resourceUrl = ClassLoaderResourceUtils.getResourceURL(resourcePath, LocaleUtils.class); } catch (Exception e) { // Nothing to do } if (resourceUrl == null && servletContext != null && resourcePath.startsWith("grails-app/")) { try { resourceUrl = servletContext.getResource("/WEB-INF/" + resourcePath); } catch (MalformedURLException e) { // Nothing to do } } return resourceUrl; }
java
public static URL getResourceBundleURL(String resourcePath, ServletContext servletContext) { URL resourceUrl = null; try { resourceUrl = ClassLoaderResourceUtils.getResourceURL(resourcePath, LocaleUtils.class); } catch (Exception e) { // Nothing to do } if (resourceUrl == null && servletContext != null && resourcePath.startsWith("grails-app/")) { try { resourceUrl = servletContext.getResource("/WEB-INF/" + resourcePath); } catch (MalformedURLException e) { // Nothing to do } } return resourceUrl; }
[ "public", "static", "URL", "getResourceBundleURL", "(", "String", "resourcePath", ",", "ServletContext", "servletContext", ")", "{", "URL", "resourceUrl", "=", "null", ";", "try", "{", "resourceUrl", "=", "ClassLoaderResourceUtils", ".", "getResourceURL", "(", "resourcePath", ",", "LocaleUtils", ".", "class", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Nothing to do", "}", "if", "(", "resourceUrl", "==", "null", "&&", "servletContext", "!=", "null", "&&", "resourcePath", ".", "startsWith", "(", "\"grails-app/\"", ")", ")", "{", "try", "{", "resourceUrl", "=", "servletContext", ".", "getResource", "(", "\"/WEB-INF/\"", "+", "resourcePath", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "// Nothing to do", "}", "}", "return", "resourceUrl", ";", "}" ]
Returns the resource bundle URL @param resourcePath the resource path @param servletContext the servlet context @return the URL of the resource bundle
[ "Returns", "the", "resource", "bundle", "URL" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/locale/LocaleUtils.java#L258-L274
7,371
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.buildEngineScript
@SuppressWarnings("unchecked") private StringBuffer buildEngineScript(StringBuffer engineScript,ServletContext servletContext) { List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); String allowGetForSafariButMakeForgeryEasier = ""; String scriptTagProtection = DwrConstants.SCRIPT_TAG_PROTECTION; String pollWithXhr = ""; String sessionCookieName = "JSESSIONID"; for(Iterator<Container> it = containers.iterator();it.hasNext();) { Container container = it.next(); ServerLoadMonitor monitor = (ServerLoadMonitor) container.getBean(ServerLoadMonitor.class.getName()); pollWithXhr = monitor.supportsStreaming() ? "false" : "true"; if(null != container.getBean("allowGetForSafariButMakeForgeryEasier")){ allowGetForSafariButMakeForgeryEasier = (String)container.getBean("allowGetForSafariButMakeForgeryEasier"); } if(null != container.getBean("scriptTagProtection")){ scriptTagProtection = (String)container.getBean("scriptTagProtection"); } if(null != container.getBean("sessionCookieName")){ sessionCookieName = (String)container.getBean("sessionCookieName"); } } StringBuffer sb = new StringBuffer(); Matcher matcher = PARAMS_PATTERN.matcher(engineScript); while(matcher.find()) { String match = matcher.group(); if("${allowGetForSafariButMakeForgeryEasier}".equals(match)){ matcher.appendReplacement(sb, allowGetForSafariButMakeForgeryEasier); } else if("${pollWithXhr}".equals(match)){ matcher.appendReplacement(sb, pollWithXhr); } else if("${sessionCookieName}".equals(match)){ matcher.appendReplacement(sb, sessionCookieName); } else if("${scriptTagProtection}".equals(match)){ matcher.appendReplacement(sb, scriptTagProtection); } else if("${scriptSessionId}".equals(match)){ matcher.appendReplacement(sb, "\"+JAWR.dwr_scriptSessionId+\""); } else if("${defaultPath}".equals(match)){ matcher.appendReplacement(sb, "\"+JAWR.jawr_dwr_path+\""); } } DWRParamWriter.setUseDynamicSessionId(true); matcher.appendTail(sb); return sb; }
java
@SuppressWarnings("unchecked") private StringBuffer buildEngineScript(StringBuffer engineScript,ServletContext servletContext) { List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); String allowGetForSafariButMakeForgeryEasier = ""; String scriptTagProtection = DwrConstants.SCRIPT_TAG_PROTECTION; String pollWithXhr = ""; String sessionCookieName = "JSESSIONID"; for(Iterator<Container> it = containers.iterator();it.hasNext();) { Container container = it.next(); ServerLoadMonitor monitor = (ServerLoadMonitor) container.getBean(ServerLoadMonitor.class.getName()); pollWithXhr = monitor.supportsStreaming() ? "false" : "true"; if(null != container.getBean("allowGetForSafariButMakeForgeryEasier")){ allowGetForSafariButMakeForgeryEasier = (String)container.getBean("allowGetForSafariButMakeForgeryEasier"); } if(null != container.getBean("scriptTagProtection")){ scriptTagProtection = (String)container.getBean("scriptTagProtection"); } if(null != container.getBean("sessionCookieName")){ sessionCookieName = (String)container.getBean("sessionCookieName"); } } StringBuffer sb = new StringBuffer(); Matcher matcher = PARAMS_PATTERN.matcher(engineScript); while(matcher.find()) { String match = matcher.group(); if("${allowGetForSafariButMakeForgeryEasier}".equals(match)){ matcher.appendReplacement(sb, allowGetForSafariButMakeForgeryEasier); } else if("${pollWithXhr}".equals(match)){ matcher.appendReplacement(sb, pollWithXhr); } else if("${sessionCookieName}".equals(match)){ matcher.appendReplacement(sb, sessionCookieName); } else if("${scriptTagProtection}".equals(match)){ matcher.appendReplacement(sb, scriptTagProtection); } else if("${scriptSessionId}".equals(match)){ matcher.appendReplacement(sb, "\"+JAWR.dwr_scriptSessionId+\""); } else if("${defaultPath}".equals(match)){ matcher.appendReplacement(sb, "\"+JAWR.jawr_dwr_path+\""); } } DWRParamWriter.setUseDynamicSessionId(true); matcher.appendTail(sb); return sb; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "StringBuffer", "buildEngineScript", "(", "StringBuffer", "engineScript", ",", "ServletContext", "servletContext", ")", "{", "List", "<", "Container", ">", "containers", "=", "ContainerUtil", ".", "getAllPublishedContainers", "(", "servletContext", ")", ";", "String", "allowGetForSafariButMakeForgeryEasier", "=", "\"\"", ";", "String", "scriptTagProtection", "=", "DwrConstants", ".", "SCRIPT_TAG_PROTECTION", ";", "String", "pollWithXhr", "=", "\"\"", ";", "String", "sessionCookieName", "=", "\"JSESSIONID\"", ";", "for", "(", "Iterator", "<", "Container", ">", "it", "=", "containers", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Container", "container", "=", "it", ".", "next", "(", ")", ";", "ServerLoadMonitor", "monitor", "=", "(", "ServerLoadMonitor", ")", "container", ".", "getBean", "(", "ServerLoadMonitor", ".", "class", ".", "getName", "(", ")", ")", ";", "pollWithXhr", "=", "monitor", ".", "supportsStreaming", "(", ")", "?", "\"false\"", ":", "\"true\"", ";", "if", "(", "null", "!=", "container", ".", "getBean", "(", "\"allowGetForSafariButMakeForgeryEasier\"", ")", ")", "{", "allowGetForSafariButMakeForgeryEasier", "=", "(", "String", ")", "container", ".", "getBean", "(", "\"allowGetForSafariButMakeForgeryEasier\"", ")", ";", "}", "if", "(", "null", "!=", "container", ".", "getBean", "(", "\"scriptTagProtection\"", ")", ")", "{", "scriptTagProtection", "=", "(", "String", ")", "container", ".", "getBean", "(", "\"scriptTagProtection\"", ")", ";", "}", "if", "(", "null", "!=", "container", ".", "getBean", "(", "\"sessionCookieName\"", ")", ")", "{", "sessionCookieName", "=", "(", "String", ")", "container", ".", "getBean", "(", "\"sessionCookieName\"", ")", ";", "}", "}", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "Matcher", "matcher", "=", "PARAMS_PATTERN", ".", "matcher", "(", "engineScript", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "String", "match", "=", "matcher", ".", "group", "(", ")", ";", "if", "(", "\"${allowGetForSafariButMakeForgeryEasier}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "allowGetForSafariButMakeForgeryEasier", ")", ";", "}", "else", "if", "(", "\"${pollWithXhr}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "pollWithXhr", ")", ";", "}", "else", "if", "(", "\"${sessionCookieName}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "sessionCookieName", ")", ";", "}", "else", "if", "(", "\"${scriptTagProtection}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "scriptTagProtection", ")", ";", "}", "else", "if", "(", "\"${scriptSessionId}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "\"\\\"+JAWR.dwr_scriptSessionId+\\\"\"", ")", ";", "}", "else", "if", "(", "\"${defaultPath}\"", ".", "equals", "(", "match", ")", ")", "{", "matcher", ".", "appendReplacement", "(", "sb", ",", "\"\\\"+JAWR.jawr_dwr_path+\\\"\"", ")", ";", "}", "}", "DWRParamWriter", ".", "setUseDynamicSessionId", "(", "true", ")", ";", "matcher", ".", "appendTail", "(", "sb", ")", ";", "return", "sb", ";", "}" ]
Performs replacement on the engine.js script from DWR. Mainly copies what DWR does, only at startup. A couple params are actually replaced to references to javascript vars that jawr will create on the page. @param engineScript @return
[ "Performs", "replacement", "on", "the", "engine", ".", "js", "script", "from", "DWR", ".", "Mainly", "copies", "what", "DWR", "does", "only", "at", "startup", ".", "A", "couple", "params", "are", "actually", "replaced", "to", "references", "to", "javascript", "vars", "that", "jawr", "will", "create", "on", "the", "page", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L163-L215
7,372
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.readDWRScript
private StringBuffer readDWRScript(String classpath) { StringBuffer sb = null; try { InputStream is = ClassLoaderResourceUtils.getResourceAsStream(classpath, this); ReadableByteChannel chan = Channels.newChannel(is); Reader r = Channels.newReader(chan,"utf-8"); StringWriter sw = new StringWriter(); IOUtils.copy(r, sw, true); sb = sw.getBuffer(); } catch (FileNotFoundException e) { throw new BundlingProcessException(e); } catch (IOException e) { throw new BundlingProcessException(e); } return sb; }
java
private StringBuffer readDWRScript(String classpath) { StringBuffer sb = null; try { InputStream is = ClassLoaderResourceUtils.getResourceAsStream(classpath, this); ReadableByteChannel chan = Channels.newChannel(is); Reader r = Channels.newReader(chan,"utf-8"); StringWriter sw = new StringWriter(); IOUtils.copy(r, sw, true); sb = sw.getBuffer(); } catch (FileNotFoundException e) { throw new BundlingProcessException(e); } catch (IOException e) { throw new BundlingProcessException(e); } return sb; }
[ "private", "StringBuffer", "readDWRScript", "(", "String", "classpath", ")", "{", "StringBuffer", "sb", "=", "null", ";", "try", "{", "InputStream", "is", "=", "ClassLoaderResourceUtils", ".", "getResourceAsStream", "(", "classpath", ",", "this", ")", ";", "ReadableByteChannel", "chan", "=", "Channels", ".", "newChannel", "(", "is", ")", ";", "Reader", "r", "=", "Channels", ".", "newReader", "(", "chan", ",", "\"utf-8\"", ")", ";", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "IOUtils", ".", "copy", "(", "r", ",", "sw", ",", "true", ")", ";", "sb", "=", "sw", ".", "getBuffer", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "return", "sb", ";", "}" ]
Read a DWR utils script from the classpath. @param classpath @return
[ "Read", "a", "DWR", "utils", "script", "from", "the", "classpath", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L222-L239
7,373
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.getInterfaceScript
@SuppressWarnings("unchecked") private StringBuffer getInterfaceScript(String scriptName,ServletContext servletContext) { StringBuffer sb = new StringBuffer(ENGINE_INIT); // List all containers to find all DWR interfaces List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); boolean found = false; for(Iterator<Container> it = containers.iterator();it.hasNext() && !found;) { Container container = it.next(); // The creatormanager holds the list of beans CreatorManager ctManager = (CreatorManager) container.getBean(CreatorManager.class.getName()); if( null != ctManager ) { // The remoter builds interface scripts. Remoter remoter = (Remoter) container.getBean(Remoter.class.getName()); String path = getPathReplacementString(container); try { String script = remoter.generateInterfaceScript(scriptName, path); found = true; // Must remove the engine init script to avoid unneeded duplication script = removeEngineInit(script); sb.append(script); } catch(SecurityException ex){throw new BundlingProcessException(ex); } } } if(!found) throw new IllegalArgumentException("The DWR bean named '" + scriptName + "' was not found in any DWR configuration instance."); return sb; }
java
@SuppressWarnings("unchecked") private StringBuffer getInterfaceScript(String scriptName,ServletContext servletContext) { StringBuffer sb = new StringBuffer(ENGINE_INIT); // List all containers to find all DWR interfaces List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); boolean found = false; for(Iterator<Container> it = containers.iterator();it.hasNext() && !found;) { Container container = it.next(); // The creatormanager holds the list of beans CreatorManager ctManager = (CreatorManager) container.getBean(CreatorManager.class.getName()); if( null != ctManager ) { // The remoter builds interface scripts. Remoter remoter = (Remoter) container.getBean(Remoter.class.getName()); String path = getPathReplacementString(container); try { String script = remoter.generateInterfaceScript(scriptName, path); found = true; // Must remove the engine init script to avoid unneeded duplication script = removeEngineInit(script); sb.append(script); } catch(SecurityException ex){throw new BundlingProcessException(ex); } } } if(!found) throw new IllegalArgumentException("The DWR bean named '" + scriptName + "' was not found in any DWR configuration instance."); return sb; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "StringBuffer", "getInterfaceScript", "(", "String", "scriptName", ",", "ServletContext", "servletContext", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "ENGINE_INIT", ")", ";", "// List all containers to find all DWR interfaces", "List", "<", "Container", ">", "containers", "=", "ContainerUtil", ".", "getAllPublishedContainers", "(", "servletContext", ")", ";", "boolean", "found", "=", "false", ";", "for", "(", "Iterator", "<", "Container", ">", "it", "=", "containers", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", "&&", "!", "found", ";", ")", "{", "Container", "container", "=", "it", ".", "next", "(", ")", ";", "// The creatormanager holds the list of beans", "CreatorManager", "ctManager", "=", "(", "CreatorManager", ")", "container", ".", "getBean", "(", "CreatorManager", ".", "class", ".", "getName", "(", ")", ")", ";", "if", "(", "null", "!=", "ctManager", ")", "{", "// The remoter builds interface scripts. ", "Remoter", "remoter", "=", "(", "Remoter", ")", "container", ".", "getBean", "(", "Remoter", ".", "class", ".", "getName", "(", ")", ")", ";", "String", "path", "=", "getPathReplacementString", "(", "container", ")", ";", "try", "{", "String", "script", "=", "remoter", ".", "generateInterfaceScript", "(", "scriptName", ",", "path", ")", ";", "found", "=", "true", ";", "// Must remove the engine init script to avoid unneeded duplication", "script", "=", "removeEngineInit", "(", "script", ")", ";", "sb", ".", "append", "(", "script", ")", ";", "}", "catch", "(", "SecurityException", "ex", ")", "{", "throw", "new", "BundlingProcessException", "(", "ex", ")", ";", "}", "}", "}", "if", "(", "!", "found", ")", "throw", "new", "IllegalArgumentException", "(", "\"The DWR bean named '\"", "+", "scriptName", "+", "\"' was not found in any DWR configuration instance.\"", ")", ";", "return", "sb", ";", "}" ]
Returns a script with a specified DWR interface @param basePath @return
[ "Returns", "a", "script", "with", "a", "specified", "DWR", "interface" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L246-L276
7,374
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.getPathReplacementString
private String getPathReplacementString(Container container) { String path = JS_PATH_REF; if(null != container.getBean(DWR_OVERRIDEPATH_PARAM)) { path = (String) container.getBean(DWR_OVERRIDEPATH_PARAM); } else if(null != container.getBean(DWR_MAPPING_PARAM)) { path = JS_CTX_PATH + container.getBean(DWR_MAPPING_PARAM); } return path; }
java
private String getPathReplacementString(Container container) { String path = JS_PATH_REF; if(null != container.getBean(DWR_OVERRIDEPATH_PARAM)) { path = (String) container.getBean(DWR_OVERRIDEPATH_PARAM); } else if(null != container.getBean(DWR_MAPPING_PARAM)) { path = JS_CTX_PATH + container.getBean(DWR_MAPPING_PARAM); } return path; }
[ "private", "String", "getPathReplacementString", "(", "Container", "container", ")", "{", "String", "path", "=", "JS_PATH_REF", ";", "if", "(", "null", "!=", "container", ".", "getBean", "(", "DWR_OVERRIDEPATH_PARAM", ")", ")", "{", "path", "=", "(", "String", ")", "container", ".", "getBean", "(", "DWR_OVERRIDEPATH_PARAM", ")", ";", "}", "else", "if", "(", "null", "!=", "container", ".", "getBean", "(", "DWR_MAPPING_PARAM", ")", ")", "{", "path", "=", "JS_CTX_PATH", "+", "container", ".", "getBean", "(", "DWR_MAPPING_PARAM", ")", ";", "}", "return", "path", ";", "}" ]
Gets the appropriate path replacement string for a DWR container @param container @return
[ "Gets", "the", "appropriate", "path", "replacement", "string", "for", "a", "DWR", "container" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L285-L294
7,375
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.getAllPublishedInterfaces
@SuppressWarnings({ "unchecked", "rawtypes" }) private StringBuffer getAllPublishedInterfaces(ServletContext servletContext) { StringBuffer sb = new StringBuffer(); // List all containers to find all DWR interfaces List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); for(Iterator<Container> it = containers.iterator();it.hasNext();) { Container container = (Container) it.next(); // The creatormanager holds the list of beans CreatorManager ctManager = (CreatorManager) container.getBean(CreatorManager.class.getName()); if(null != ctManager) { // The remoter builds interface scripts. Remoter remoter = (Remoter) container.getBean(Remoter.class.getName()); String path = getPathReplacementString(container); boolean debugMode = ctManager.isDebug(); Collection creators = null; if(!(ctManager instanceof DefaultCreatorManager)) { if(!debugMode) LOGGER.warn("The current creatormanager is a custom implementation [" + ctManager.getClass().getName() + "]. Debug mode is off, so the mapping dwr:_** is likely to trigger a SecurityException." + " Attempting to get all published creators..." ); creators = ctManager.getCreatorNames(); } else { DefaultCreatorManager dfCreator = (DefaultCreatorManager) ctManager; try { dfCreator.setDebug(true); creators = ctManager.getCreatorNames(); } finally{ // restore debug mode no matter what dfCreator.setDebug(debugMode); } } for(Iterator<String> names = creators.iterator();names.hasNext();) { String script = remoter.generateInterfaceScript(names.next(), path); // Must remove the engine init script to avoid unneeded duplication script = removeEngineInit(script); sb.append(script); } } } return sb; }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) private StringBuffer getAllPublishedInterfaces(ServletContext servletContext) { StringBuffer sb = new StringBuffer(); // List all containers to find all DWR interfaces List<Container> containers = ContainerUtil.getAllPublishedContainers(servletContext); for(Iterator<Container> it = containers.iterator();it.hasNext();) { Container container = (Container) it.next(); // The creatormanager holds the list of beans CreatorManager ctManager = (CreatorManager) container.getBean(CreatorManager.class.getName()); if(null != ctManager) { // The remoter builds interface scripts. Remoter remoter = (Remoter) container.getBean(Remoter.class.getName()); String path = getPathReplacementString(container); boolean debugMode = ctManager.isDebug(); Collection creators = null; if(!(ctManager instanceof DefaultCreatorManager)) { if(!debugMode) LOGGER.warn("The current creatormanager is a custom implementation [" + ctManager.getClass().getName() + "]. Debug mode is off, so the mapping dwr:_** is likely to trigger a SecurityException." + " Attempting to get all published creators..." ); creators = ctManager.getCreatorNames(); } else { DefaultCreatorManager dfCreator = (DefaultCreatorManager) ctManager; try { dfCreator.setDebug(true); creators = ctManager.getCreatorNames(); } finally{ // restore debug mode no matter what dfCreator.setDebug(debugMode); } } for(Iterator<String> names = creators.iterator();names.hasNext();) { String script = remoter.generateInterfaceScript(names.next(), path); // Must remove the engine init script to avoid unneeded duplication script = removeEngineInit(script); sb.append(script); } } } return sb; }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "private", "StringBuffer", "getAllPublishedInterfaces", "(", "ServletContext", "servletContext", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "// List all containers to find all DWR interfaces", "List", "<", "Container", ">", "containers", "=", "ContainerUtil", ".", "getAllPublishedContainers", "(", "servletContext", ")", ";", "for", "(", "Iterator", "<", "Container", ">", "it", "=", "containers", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "Container", "container", "=", "(", "Container", ")", "it", ".", "next", "(", ")", ";", "// The creatormanager holds the list of beans", "CreatorManager", "ctManager", "=", "(", "CreatorManager", ")", "container", ".", "getBean", "(", "CreatorManager", ".", "class", ".", "getName", "(", ")", ")", ";", "if", "(", "null", "!=", "ctManager", ")", "{", "// The remoter builds interface scripts. ", "Remoter", "remoter", "=", "(", "Remoter", ")", "container", ".", "getBean", "(", "Remoter", ".", "class", ".", "getName", "(", ")", ")", ";", "String", "path", "=", "getPathReplacementString", "(", "container", ")", ";", "boolean", "debugMode", "=", "ctManager", ".", "isDebug", "(", ")", ";", "Collection", "creators", "=", "null", ";", "if", "(", "!", "(", "ctManager", "instanceof", "DefaultCreatorManager", ")", ")", "{", "if", "(", "!", "debugMode", ")", "LOGGER", ".", "warn", "(", "\"The current creatormanager is a custom implementation [\"", "+", "ctManager", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\"]. Debug mode is off, so the mapping dwr:_** is likely to trigger a SecurityException.\"", "+", "\" Attempting to get all published creators...\"", ")", ";", "creators", "=", "ctManager", ".", "getCreatorNames", "(", ")", ";", "}", "else", "{", "DefaultCreatorManager", "dfCreator", "=", "(", "DefaultCreatorManager", ")", "ctManager", ";", "try", "{", "dfCreator", ".", "setDebug", "(", "true", ")", ";", "creators", "=", "ctManager", ".", "getCreatorNames", "(", ")", ";", "}", "finally", "{", "// restore debug mode no matter what", "dfCreator", ".", "setDebug", "(", "debugMode", ")", ";", "}", "}", "for", "(", "Iterator", "<", "String", ">", "names", "=", "creators", ".", "iterator", "(", ")", ";", "names", ".", "hasNext", "(", ")", ";", ")", "{", "String", "script", "=", "remoter", ".", "generateInterfaceScript", "(", "names", ".", "next", "(", ")", ",", "path", ")", ";", "// Must remove the engine init script to avoid unneeded duplication", "script", "=", "removeEngineInit", "(", "script", ")", ";", "sb", ".", "append", "(", "script", ")", ";", "}", "}", "}", "return", "sb", ";", "}" ]
Returns a script with all the DWR interfaces available in the servletcontext @param basePath @return
[ "Returns", "a", "script", "with", "all", "the", "DWR", "interfaces", "available", "in", "the", "servletcontext" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L301-L351
7,376
j-a-w-r/jawr-main-repo
jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java
DWRBeanGenerator.removeEngineInit
private String removeEngineInit(String script) { int start = script.indexOf(ENGINE_INIT); int end = start + ENGINE_INIT.length(); StringBuffer rets = new StringBuffer(); if(start > 0) { rets.append(script.substring(0, start)).append("\n"); } rets.append(script.substring(end)); return rets.toString(); }
java
private String removeEngineInit(String script) { int start = script.indexOf(ENGINE_INIT); int end = start + ENGINE_INIT.length(); StringBuffer rets = new StringBuffer(); if(start > 0) { rets.append(script.substring(0, start)).append("\n"); } rets.append(script.substring(end)); return rets.toString(); }
[ "private", "String", "removeEngineInit", "(", "String", "script", ")", "{", "int", "start", "=", "script", ".", "indexOf", "(", "ENGINE_INIT", ")", ";", "int", "end", "=", "start", "+", "ENGINE_INIT", ".", "length", "(", ")", ";", "StringBuffer", "rets", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "start", ">", "0", ")", "{", "rets", ".", "append", "(", "script", ".", "substring", "(", "0", ",", "start", ")", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "rets", ".", "append", "(", "script", ".", "substring", "(", "end", ")", ")", ";", "return", "rets", ".", "toString", "(", ")", ";", "}" ]
Removes the engine init script so that it is not repeated unnecesarily. @param script @return
[ "Removes", "the", "engine", "init", "script", "so", "that", "it", "is", "not", "repeated", "unnecesarily", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-dwr2.x/jawr-dwr2.x-extension/src/main/java/net/jawr/web/resource/bundle/generator/dwr/DWRBeanGenerator.java#L358-L370
7,377
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/BundleProcessingStatus.java
BundleProcessingStatus.getVariant
public String getVariant(String variantType) { String variant = null; if (bundleVariants != null) { variant = (String) bundleVariants.get(variantType); } return variant; }
java
public String getVariant(String variantType) { String variant = null; if (bundleVariants != null) { variant = (String) bundleVariants.get(variantType); } return variant; }
[ "public", "String", "getVariant", "(", "String", "variantType", ")", "{", "String", "variant", "=", "null", ";", "if", "(", "bundleVariants", "!=", "null", ")", "{", "variant", "=", "(", "String", ")", "bundleVariants", ".", "get", "(", "variantType", ")", ";", "}", "return", "variant", ";", "}" ]
Returns the current variant for the variant type specified in parameter @param variantType the variant type @return the current variant
[ "Returns", "the", "current", "variant", "for", "the", "variant", "type", "specified", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/BundleProcessingStatus.java#L220-L226
7,378
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java
AbstractHtmlImageTag.prepareStyles
protected String prepareStyles() { StringBuffer styles = new StringBuffer(); prepareAttribute(styles, "id", getAttribute("styleId")); prepareAttribute(styles, "style", getAttribute("style")); prepareAttribute(styles, "class", getAttribute("styleClass")); prepareAttribute(styles, "title", getAttribute("title")); prepareAttribute(styles, "alt", getAttribute("alt")); prepareInternationalization(styles); return styles.toString(); }
java
protected String prepareStyles() { StringBuffer styles = new StringBuffer(); prepareAttribute(styles, "id", getAttribute("styleId")); prepareAttribute(styles, "style", getAttribute("style")); prepareAttribute(styles, "class", getAttribute("styleClass")); prepareAttribute(styles, "title", getAttribute("title")); prepareAttribute(styles, "alt", getAttribute("alt")); prepareInternationalization(styles); return styles.toString(); }
[ "protected", "String", "prepareStyles", "(", ")", "{", "StringBuffer", "styles", "=", "new", "StringBuffer", "(", ")", ";", "prepareAttribute", "(", "styles", ",", "\"id\"", ",", "getAttribute", "(", "\"styleId\"", ")", ")", ";", "prepareAttribute", "(", "styles", ",", "\"style\"", ",", "getAttribute", "(", "\"style\"", ")", ")", ";", "prepareAttribute", "(", "styles", ",", "\"class\"", ",", "getAttribute", "(", "\"styleClass\"", ")", ")", ";", "prepareAttribute", "(", "styles", ",", "\"title\"", ",", "getAttribute", "(", "\"title\"", ")", ")", ";", "prepareAttribute", "(", "styles", ",", "\"alt\"", ",", "getAttribute", "(", "\"alt\"", ")", ")", ";", "prepareInternationalization", "(", "styles", ")", ";", "return", "styles", ".", "toString", "(", ")", ";", "}" ]
Prepares the style attributes for inclusion in the component's HTML tag. @return The prepared String for inclusion in the HTML tag.
[ "Prepares", "the", "style", "attributes", "for", "inclusion", "in", "the", "component", "s", "HTML", "tag", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java#L57-L68
7,379
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java
AbstractHtmlImageTag.prepareEventHandlers
protected String prepareEventHandlers() { StringBuffer handlers = new StringBuffer(); prepareMouseEvents(handlers); prepareKeyEvents(handlers); return handlers.toString(); }
java
protected String prepareEventHandlers() { StringBuffer handlers = new StringBuffer(); prepareMouseEvents(handlers); prepareKeyEvents(handlers); return handlers.toString(); }
[ "protected", "String", "prepareEventHandlers", "(", ")", "{", "StringBuffer", "handlers", "=", "new", "StringBuffer", "(", ")", ";", "prepareMouseEvents", "(", "handlers", ")", ";", "prepareKeyEvents", "(", "handlers", ")", ";", "return", "handlers", ".", "toString", "(", ")", ";", "}" ]
Prepares the event handlers for inclusion in the component's HTML tag. @return The prepared String for inclusion in the HTML tag.
[ "Prepares", "the", "event", "handlers", "for", "inclusion", "in", "the", "component", "s", "HTML", "tag", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java#L88-L95
7,380
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java
AbstractHtmlImageTag.prepareMouseEvents
protected void prepareMouseEvents(StringBuffer handlers) { prepareAttribute(handlers, "onclick", getAttribute("onclick")); prepareAttribute(handlers, "ondblclick", getAttribute("ondblclick")); prepareAttribute(handlers, "onmouseover", getAttribute("onmouseover")); prepareAttribute(handlers, "onmouseout", getAttribute("onmouseout")); prepareAttribute(handlers, "onmousemove", getAttribute("onmousemove")); prepareAttribute(handlers, "onmousedown", getAttribute("onmousedown")); prepareAttribute(handlers, "onmouseup", getAttribute("onmouseup")); }
java
protected void prepareMouseEvents(StringBuffer handlers) { prepareAttribute(handlers, "onclick", getAttribute("onclick")); prepareAttribute(handlers, "ondblclick", getAttribute("ondblclick")); prepareAttribute(handlers, "onmouseover", getAttribute("onmouseover")); prepareAttribute(handlers, "onmouseout", getAttribute("onmouseout")); prepareAttribute(handlers, "onmousemove", getAttribute("onmousemove")); prepareAttribute(handlers, "onmousedown", getAttribute("onmousedown")); prepareAttribute(handlers, "onmouseup", getAttribute("onmouseup")); }
[ "protected", "void", "prepareMouseEvents", "(", "StringBuffer", "handlers", ")", "{", "prepareAttribute", "(", "handlers", ",", "\"onclick\"", ",", "getAttribute", "(", "\"onclick\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"ondblclick\"", ",", "getAttribute", "(", "\"ondblclick\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onmouseover\"", ",", "getAttribute", "(", "\"onmouseover\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onmouseout\"", ",", "getAttribute", "(", "\"onmouseout\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onmousemove\"", ",", "getAttribute", "(", "\"onmousemove\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onmousedown\"", ",", "getAttribute", "(", "\"onmousedown\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onmouseup\"", ",", "getAttribute", "(", "\"onmouseup\"", ")", ")", ";", "}" ]
Prepares the mouse event handlers, appending them to the the given StringBuffer. @param handlers The StringBuffer that output will be appended to.
[ "Prepares", "the", "mouse", "event", "handlers", "appending", "them", "to", "the", "the", "given", "StringBuffer", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java#L104-L112
7,381
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java
AbstractHtmlImageTag.prepareKeyEvents
protected void prepareKeyEvents(StringBuffer handlers) { prepareAttribute(handlers, "onkeydown", getAttribute("onkeydown")); prepareAttribute(handlers, "onkeyup", getAttribute("onkeyup")); prepareAttribute(handlers, "onkeypress", getAttribute("onkeypress")); }
java
protected void prepareKeyEvents(StringBuffer handlers) { prepareAttribute(handlers, "onkeydown", getAttribute("onkeydown")); prepareAttribute(handlers, "onkeyup", getAttribute("onkeyup")); prepareAttribute(handlers, "onkeypress", getAttribute("onkeypress")); }
[ "protected", "void", "prepareKeyEvents", "(", "StringBuffer", "handlers", ")", "{", "prepareAttribute", "(", "handlers", ",", "\"onkeydown\"", ",", "getAttribute", "(", "\"onkeydown\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onkeyup\"", ",", "getAttribute", "(", "\"onkeyup\"", ")", ")", ";", "prepareAttribute", "(", "handlers", ",", "\"onkeypress\"", ",", "getAttribute", "(", "\"onkeypress\"", ")", ")", ";", "}" ]
Prepares the keyboard event handlers, appending them to the the given StringBuffer. @param handlers The StringBuffer that output will be appended to.
[ "Prepares", "the", "keyboard", "event", "handlers", "appending", "them", "to", "the", "the", "given", "StringBuffer", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java#L121-L125
7,382
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java
AbstractHtmlImageTag.prepareImageUrl
protected void prepareImageUrl(FacesContext context, StringBuffer results) throws IOException { String src = (String) getAttributes().get("src"); boolean base64 = Boolean.parseBoolean((String) getAttributes().get("base64")); prepareAttribute(results, "src", getImageUrl(context, src, base64)); }
java
protected void prepareImageUrl(FacesContext context, StringBuffer results) throws IOException { String src = (String) getAttributes().get("src"); boolean base64 = Boolean.parseBoolean((String) getAttributes().get("base64")); prepareAttribute(results, "src", getImageUrl(context, src, base64)); }
[ "protected", "void", "prepareImageUrl", "(", "FacesContext", "context", ",", "StringBuffer", "results", ")", "throws", "IOException", "{", "String", "src", "=", "(", "String", ")", "getAttributes", "(", ")", ".", "get", "(", "\"src\"", ")", ";", "boolean", "base64", "=", "Boolean", ".", "parseBoolean", "(", "(", "String", ")", "getAttributes", "(", ")", ".", "get", "(", "\"base64\"", ")", ")", ";", "prepareAttribute", "(", "results", ",", "\"src\"", ",", "getImageUrl", "(", "context", ",", "src", ",", "base64", ")", ")", ";", "}" ]
Prepare the image URL @param context the faces context @param results the result @throws IOException if an exception occurs
[ "Prepare", "the", "image", "URL" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/taglib/jsf/AbstractHtmlImageTag.java#L179-L184
7,383
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/JawrWatchEventProcessor.java
JawrWatchEventProcessor.process
public void process(JawrWatchEvent evt) { Path resolvedPath = evt.getResolvedPath(); List<PathMapping> mappings = watcher.getPathToResourceBundle().get(evt.getDirPath()); if (mappings != null) { boolean isDir = Files.isDirectory(resolvedPath, NOFOLLOW_LINKS); List<JoinableResourceBundle> bundles = new ArrayList<>(); List<PathMapping> recursivePathMappings = new ArrayList<>(); for (PathMapping mapping : mappings) { String filePath = resolvedPath.toFile().getAbsolutePath(); if (mapping.isAsset()) { String fileName = FileNameUtils.getName(filePath); if (fileName.equals(FileNameUtils.getName(mapping.getPath()))) { bundles.add(mapping.getBundle()); } } else { if (isDir) { if (mapping.isRecursive() && (!mapping.hasFileFilter() || mapping.accept(filePath))) { bundles.add(mapping.getBundle()); } } else if (!mapping.hasFileFilter() || mapping.accept(filePath)) { bundles.add(mapping.getBundle()); } if (mapping.isRecursive()) { recursivePathMappings.add(mapping); } } } if (!bundles.isEmpty()) { bundlesHandler.notifyModification(bundles); } if (!recursivePathMappings.isEmpty()) { // if directory is created, and watching // recursively, // then // register it and its sub-directories if (evt.getKind() == ENTRY_CREATE && isDir) { try { watcher.registerAll(resolvedPath, recursivePathMappings); } catch (IOException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.getMessage()); } } } } } lastProcessTime.set(Calendar.getInstance().getTimeInMillis()); }
java
public void process(JawrWatchEvent evt) { Path resolvedPath = evt.getResolvedPath(); List<PathMapping> mappings = watcher.getPathToResourceBundle().get(evt.getDirPath()); if (mappings != null) { boolean isDir = Files.isDirectory(resolvedPath, NOFOLLOW_LINKS); List<JoinableResourceBundle> bundles = new ArrayList<>(); List<PathMapping> recursivePathMappings = new ArrayList<>(); for (PathMapping mapping : mappings) { String filePath = resolvedPath.toFile().getAbsolutePath(); if (mapping.isAsset()) { String fileName = FileNameUtils.getName(filePath); if (fileName.equals(FileNameUtils.getName(mapping.getPath()))) { bundles.add(mapping.getBundle()); } } else { if (isDir) { if (mapping.isRecursive() && (!mapping.hasFileFilter() || mapping.accept(filePath))) { bundles.add(mapping.getBundle()); } } else if (!mapping.hasFileFilter() || mapping.accept(filePath)) { bundles.add(mapping.getBundle()); } if (mapping.isRecursive()) { recursivePathMappings.add(mapping); } } } if (!bundles.isEmpty()) { bundlesHandler.notifyModification(bundles); } if (!recursivePathMappings.isEmpty()) { // if directory is created, and watching // recursively, // then // register it and its sub-directories if (evt.getKind() == ENTRY_CREATE && isDir) { try { watcher.registerAll(resolvedPath, recursivePathMappings); } catch (IOException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(e.getMessage()); } } } } } lastProcessTime.set(Calendar.getInstance().getTimeInMillis()); }
[ "public", "void", "process", "(", "JawrWatchEvent", "evt", ")", "{", "Path", "resolvedPath", "=", "evt", ".", "getResolvedPath", "(", ")", ";", "List", "<", "PathMapping", ">", "mappings", "=", "watcher", ".", "getPathToResourceBundle", "(", ")", ".", "get", "(", "evt", ".", "getDirPath", "(", ")", ")", ";", "if", "(", "mappings", "!=", "null", ")", "{", "boolean", "isDir", "=", "Files", ".", "isDirectory", "(", "resolvedPath", ",", "NOFOLLOW_LINKS", ")", ";", "List", "<", "JoinableResourceBundle", ">", "bundles", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "PathMapping", ">", "recursivePathMappings", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "PathMapping", "mapping", ":", "mappings", ")", "{", "String", "filePath", "=", "resolvedPath", ".", "toFile", "(", ")", ".", "getAbsolutePath", "(", ")", ";", "if", "(", "mapping", ".", "isAsset", "(", ")", ")", "{", "String", "fileName", "=", "FileNameUtils", ".", "getName", "(", "filePath", ")", ";", "if", "(", "fileName", ".", "equals", "(", "FileNameUtils", ".", "getName", "(", "mapping", ".", "getPath", "(", ")", ")", ")", ")", "{", "bundles", ".", "add", "(", "mapping", ".", "getBundle", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "isDir", ")", "{", "if", "(", "mapping", ".", "isRecursive", "(", ")", "&&", "(", "!", "mapping", ".", "hasFileFilter", "(", ")", "||", "mapping", ".", "accept", "(", "filePath", ")", ")", ")", "{", "bundles", ".", "add", "(", "mapping", ".", "getBundle", "(", ")", ")", ";", "}", "}", "else", "if", "(", "!", "mapping", ".", "hasFileFilter", "(", ")", "||", "mapping", ".", "accept", "(", "filePath", ")", ")", "{", "bundles", ".", "add", "(", "mapping", ".", "getBundle", "(", ")", ")", ";", "}", "if", "(", "mapping", ".", "isRecursive", "(", ")", ")", "{", "recursivePathMappings", ".", "add", "(", "mapping", ")", ";", "}", "}", "}", "if", "(", "!", "bundles", ".", "isEmpty", "(", ")", ")", "{", "bundlesHandler", ".", "notifyModification", "(", "bundles", ")", ";", "}", "if", "(", "!", "recursivePathMappings", ".", "isEmpty", "(", ")", ")", "{", "// if directory is created, and watching", "// recursively,", "// then", "// register it and its sub-directories", "if", "(", "evt", ".", "getKind", "(", ")", "==", "ENTRY_CREATE", "&&", "isDir", ")", "{", "try", "{", "watcher", ".", "registerAll", "(", "resolvedPath", ",", "recursivePathMappings", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "LOGGER", ".", "isWarnEnabled", "(", ")", ")", "{", "LOGGER", ".", "warn", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "}", "}", "lastProcessTime", ".", "set", "(", "Calendar", ".", "getInstance", "(", ")", ".", "getTimeInMillis", "(", ")", ")", ";", "}" ]
Process the event @param evt the jawr watch event
[ "Process", "the", "event" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/JawrWatchEventProcessor.java#L126-L180
7,384
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/JawrWatchEventProcessor.java
JawrWatchEventProcessor.hasNoEventToProcess
public boolean hasNoEventToProcess() { long currentTime = Calendar.getInstance().getTimeInMillis(); return watchEvents.isEmpty() && (currentTime - lastProcessTime.get() > bundlesHandler.getConfig() .getSmartBundlingDelayAfterLastEvent()); }
java
public boolean hasNoEventToProcess() { long currentTime = Calendar.getInstance().getTimeInMillis(); return watchEvents.isEmpty() && (currentTime - lastProcessTime.get() > bundlesHandler.getConfig() .getSmartBundlingDelayAfterLastEvent()); }
[ "public", "boolean", "hasNoEventToProcess", "(", ")", "{", "long", "currentTime", "=", "Calendar", ".", "getInstance", "(", ")", ".", "getTimeInMillis", "(", ")", ";", "return", "watchEvents", ".", "isEmpty", "(", ")", "&&", "(", "currentTime", "-", "lastProcessTime", ".", "get", "(", ")", ">", "bundlesHandler", ".", "getConfig", "(", ")", ".", "getSmartBundlingDelayAfterLastEvent", "(", ")", ")", ";", "}" ]
Returns true if there is no more event to process @return true if there is no more event to process
[ "Returns", "true", "if", "there", "is", "no", "more", "event", "to", "process" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/watcher/JawrWatchEventProcessor.java#L187-L192
7,385
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/js/uglify/UglifyJS.java
UglifyJS.compress
public CompressionResult compress(String scriptSource) { Object result = null; StopWatch stopWatch = new StopWatch(); stopWatch.start("Compressing using Uglify"); try { result = jsEngine.invokeFunction("minify", scriptSource, options); } catch (NoSuchMethodException | ScriptException e) { throw new BundlingProcessException(e); } stopWatch.stop(); if (PERF_LOGGER.isDebugEnabled()) { PERF_LOGGER.debug(stopWatch.prettyPrint()); } return (CompressionResult) result; }
java
public CompressionResult compress(String scriptSource) { Object result = null; StopWatch stopWatch = new StopWatch(); stopWatch.start("Compressing using Uglify"); try { result = jsEngine.invokeFunction("minify", scriptSource, options); } catch (NoSuchMethodException | ScriptException e) { throw new BundlingProcessException(e); } stopWatch.stop(); if (PERF_LOGGER.isDebugEnabled()) { PERF_LOGGER.debug(stopWatch.prettyPrint()); } return (CompressionResult) result; }
[ "public", "CompressionResult", "compress", "(", "String", "scriptSource", ")", "{", "Object", "result", "=", "null", ";", "StopWatch", "stopWatch", "=", "new", "StopWatch", "(", ")", ";", "stopWatch", ".", "start", "(", "\"Compressing using Uglify\"", ")", ";", "try", "{", "result", "=", "jsEngine", ".", "invokeFunction", "(", "\"minify\"", ",", "scriptSource", ",", "options", ")", ";", "}", "catch", "(", "NoSuchMethodException", "|", "ScriptException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "e", ")", ";", "}", "stopWatch", ".", "stop", "(", ")", ";", "if", "(", "PERF_LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "PERF_LOGGER", ".", "debug", "(", "stopWatch", ".", "prettyPrint", "(", ")", ")", ";", "}", "return", "(", "CompressionResult", ")", "result", ";", "}" ]
Invoke the uglyfication process on the given script code @param scriptSource the JS code to process @return the uglified code
[ "Invoke", "the", "uglyfication", "process", "on", "the", "given", "script", "code" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/postprocess/impl/js/uglify/UglifyJS.java#L118-L136
7,386
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssImageUrlRewriter.java
CssImageUrlRewriter.getUrlPath
protected String getUrlPath(String match, String originalPath, String newCssPath) throws IOException { String url = match.substring(match.indexOf('(') + 1, match.lastIndexOf(')')).trim(); // To keep quotes as they are, first they are checked and removed. String quoteStr = ""; if (url.startsWith("'") || url.startsWith("\"")) { quoteStr = url.charAt(0) + ""; url = url.substring(1, url.length() - 1); } // Handle URL suffix like // '/fonts/glyphicons-halflings-regular.eot?#iefix' or // '../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular' String urlSuffix = ""; int idxUrlSuffix = -1; int idx1 = url.indexOf("?"); int idx2 = url.indexOf("#"); if (idx1 != -1 && idx2 == -1 || idx1 == -1 && idx2 != -1) { idxUrlSuffix = Math.max(idx1, idx2); } else if (idx1 != -1 && idx2 != -1) { idxUrlSuffix = Math.min(idx1, idx2); } if (idxUrlSuffix != -1) { urlSuffix = url.substring(idxUrlSuffix); url = url.substring(0, idxUrlSuffix); } // Check if the URL is absolute, but in the application itself if (StringUtils.isNotEmpty(contextPath) && url.startsWith(contextPath)) { String rootRelativePath = PathNormalizer.getRootRelativePath(originalPath); url = rootRelativePath + url.substring(contextPath.length()); } // Check if the URL is absolute, if it is return it as is. int firstSlash = url.indexOf('/'); if (0 == firstSlash || (firstSlash != -1 && url.charAt(++firstSlash) == '/')) { StringBuilder sb = new StringBuilder("url("); sb.append(quoteStr).append(url).append(urlSuffix).append(quoteStr).append(")"); return sb.toString(); } if (url.startsWith(URL_SEPARATOR)) url = url.substring(1, url.length()); else if (url.startsWith("./")) url = url.substring(2, url.length()); String imgUrl = getRewrittenImagePath(originalPath, newCssPath, url); // Start rendering the result, starting by the initial quote, if any. String finalUrl = "url(" + quoteStr + imgUrl + urlSuffix + quoteStr + ")"; Matcher urlMatcher = URL_PATTERN.matcher(finalUrl); if (urlMatcher.find()) { // Normalize only if a real URL finalUrl = PathNormalizer.normalizePath(finalUrl); } return finalUrl; }
java
protected String getUrlPath(String match, String originalPath, String newCssPath) throws IOException { String url = match.substring(match.indexOf('(') + 1, match.lastIndexOf(')')).trim(); // To keep quotes as they are, first they are checked and removed. String quoteStr = ""; if (url.startsWith("'") || url.startsWith("\"")) { quoteStr = url.charAt(0) + ""; url = url.substring(1, url.length() - 1); } // Handle URL suffix like // '/fonts/glyphicons-halflings-regular.eot?#iefix' or // '../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular' String urlSuffix = ""; int idxUrlSuffix = -1; int idx1 = url.indexOf("?"); int idx2 = url.indexOf("#"); if (idx1 != -1 && idx2 == -1 || idx1 == -1 && idx2 != -1) { idxUrlSuffix = Math.max(idx1, idx2); } else if (idx1 != -1 && idx2 != -1) { idxUrlSuffix = Math.min(idx1, idx2); } if (idxUrlSuffix != -1) { urlSuffix = url.substring(idxUrlSuffix); url = url.substring(0, idxUrlSuffix); } // Check if the URL is absolute, but in the application itself if (StringUtils.isNotEmpty(contextPath) && url.startsWith(contextPath)) { String rootRelativePath = PathNormalizer.getRootRelativePath(originalPath); url = rootRelativePath + url.substring(contextPath.length()); } // Check if the URL is absolute, if it is return it as is. int firstSlash = url.indexOf('/'); if (0 == firstSlash || (firstSlash != -1 && url.charAt(++firstSlash) == '/')) { StringBuilder sb = new StringBuilder("url("); sb.append(quoteStr).append(url).append(urlSuffix).append(quoteStr).append(")"); return sb.toString(); } if (url.startsWith(URL_SEPARATOR)) url = url.substring(1, url.length()); else if (url.startsWith("./")) url = url.substring(2, url.length()); String imgUrl = getRewrittenImagePath(originalPath, newCssPath, url); // Start rendering the result, starting by the initial quote, if any. String finalUrl = "url(" + quoteStr + imgUrl + urlSuffix + quoteStr + ")"; Matcher urlMatcher = URL_PATTERN.matcher(finalUrl); if (urlMatcher.find()) { // Normalize only if a real URL finalUrl = PathNormalizer.normalizePath(finalUrl); } return finalUrl; }
[ "protected", "String", "getUrlPath", "(", "String", "match", ",", "String", "originalPath", ",", "String", "newCssPath", ")", "throws", "IOException", "{", "String", "url", "=", "match", ".", "substring", "(", "match", ".", "indexOf", "(", "'", "'", ")", "+", "1", ",", "match", ".", "lastIndexOf", "(", "'", "'", ")", ")", ".", "trim", "(", ")", ";", "// To keep quotes as they are, first they are checked and removed.", "String", "quoteStr", "=", "\"\"", ";", "if", "(", "url", ".", "startsWith", "(", "\"'\"", ")", "||", "url", ".", "startsWith", "(", "\"\\\"\"", ")", ")", "{", "quoteStr", "=", "url", ".", "charAt", "(", "0", ")", "+", "\"\"", ";", "url", "=", "url", ".", "substring", "(", "1", ",", "url", ".", "length", "(", ")", "-", "1", ")", ";", "}", "// Handle URL suffix like", "// '/fonts/glyphicons-halflings-regular.eot?#iefix' or", "// '../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular'", "String", "urlSuffix", "=", "\"\"", ";", "int", "idxUrlSuffix", "=", "-", "1", ";", "int", "idx1", "=", "url", ".", "indexOf", "(", "\"?\"", ")", ";", "int", "idx2", "=", "url", ".", "indexOf", "(", "\"#\"", ")", ";", "if", "(", "idx1", "!=", "-", "1", "&&", "idx2", "==", "-", "1", "||", "idx1", "==", "-", "1", "&&", "idx2", "!=", "-", "1", ")", "{", "idxUrlSuffix", "=", "Math", ".", "max", "(", "idx1", ",", "idx2", ")", ";", "}", "else", "if", "(", "idx1", "!=", "-", "1", "&&", "idx2", "!=", "-", "1", ")", "{", "idxUrlSuffix", "=", "Math", ".", "min", "(", "idx1", ",", "idx2", ")", ";", "}", "if", "(", "idxUrlSuffix", "!=", "-", "1", ")", "{", "urlSuffix", "=", "url", ".", "substring", "(", "idxUrlSuffix", ")", ";", "url", "=", "url", ".", "substring", "(", "0", ",", "idxUrlSuffix", ")", ";", "}", "// Check if the URL is absolute, but in the application itself", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "contextPath", ")", "&&", "url", ".", "startsWith", "(", "contextPath", ")", ")", "{", "String", "rootRelativePath", "=", "PathNormalizer", ".", "getRootRelativePath", "(", "originalPath", ")", ";", "url", "=", "rootRelativePath", "+", "url", ".", "substring", "(", "contextPath", ".", "length", "(", ")", ")", ";", "}", "// Check if the URL is absolute, if it is return it as is.", "int", "firstSlash", "=", "url", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "0", "==", "firstSlash", "||", "(", "firstSlash", "!=", "-", "1", "&&", "url", ".", "charAt", "(", "++", "firstSlash", ")", "==", "'", "'", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"url(\"", ")", ";", "sb", ".", "append", "(", "quoteStr", ")", ".", "append", "(", "url", ")", ".", "append", "(", "urlSuffix", ")", ".", "append", "(", "quoteStr", ")", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "if", "(", "url", ".", "startsWith", "(", "URL_SEPARATOR", ")", ")", "url", "=", "url", ".", "substring", "(", "1", ",", "url", ".", "length", "(", ")", ")", ";", "else", "if", "(", "url", ".", "startsWith", "(", "\"./\"", ")", ")", "url", "=", "url", ".", "substring", "(", "2", ",", "url", ".", "length", "(", ")", ")", ";", "String", "imgUrl", "=", "getRewrittenImagePath", "(", "originalPath", ",", "newCssPath", ",", "url", ")", ";", "// Start rendering the result, starting by the initial quote, if any.", "String", "finalUrl", "=", "\"url(\"", "+", "quoteStr", "+", "imgUrl", "+", "urlSuffix", "+", "quoteStr", "+", "\")\"", ";", "Matcher", "urlMatcher", "=", "URL_PATTERN", ".", "matcher", "(", "finalUrl", ")", ";", "if", "(", "urlMatcher", ".", "find", "(", ")", ")", "{", "// Normalize only if a real URL", "finalUrl", "=", "PathNormalizer", ".", "normalizePath", "(", "finalUrl", ")", ";", "}", "return", "finalUrl", ";", "}" ]
Transform a matched url so it points to the proper relative path with respect to the given path. @param match the matched URL @param originalPath the original path @param newCssPath the new Css Path @return the image URL path @throws IOException if an IO exception occurs
[ "Transform", "a", "matched", "url", "so", "it", "points", "to", "the", "proper", "relative", "path", "with", "respect", "to", "the", "given", "path", "." ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssImageUrlRewriter.java#L186-L242
7,387
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssImageUrlRewriter.java
CssImageUrlRewriter.getRewrittenImagePath
protected String getRewrittenImagePath(String originalCssPath, String newCssPath, String url) throws IOException { String imgUrl = null; // Retrieve the current CSS file from which the CSS image is referenced boolean generatedImg = false; if (binaryRsHandler != null) { GeneratorRegistry imgRsGeneratorRegistry = binaryRsHandler.getConfig().getGeneratorRegistry(); generatedImg = imgRsGeneratorRegistry.isGeneratedBinaryResource(url); } String fullImgPath = PathNormalizer.concatWebPath(originalCssPath, url); if (!generatedImg) { // Add image servlet path in the URL, if it's defined if (StringUtils.isNotEmpty(binaryServletPath)) { fullImgPath = binaryServletPath + JawrConstant.URL_SEPARATOR + fullImgPath; } imgUrl = PathNormalizer.getRelativeWebPath(PathNormalizer.getParentPath(newCssPath), fullImgPath); } else { imgUrl = url; } return imgUrl; }
java
protected String getRewrittenImagePath(String originalCssPath, String newCssPath, String url) throws IOException { String imgUrl = null; // Retrieve the current CSS file from which the CSS image is referenced boolean generatedImg = false; if (binaryRsHandler != null) { GeneratorRegistry imgRsGeneratorRegistry = binaryRsHandler.getConfig().getGeneratorRegistry(); generatedImg = imgRsGeneratorRegistry.isGeneratedBinaryResource(url); } String fullImgPath = PathNormalizer.concatWebPath(originalCssPath, url); if (!generatedImg) { // Add image servlet path in the URL, if it's defined if (StringUtils.isNotEmpty(binaryServletPath)) { fullImgPath = binaryServletPath + JawrConstant.URL_SEPARATOR + fullImgPath; } imgUrl = PathNormalizer.getRelativeWebPath(PathNormalizer.getParentPath(newCssPath), fullImgPath); } else { imgUrl = url; } return imgUrl; }
[ "protected", "String", "getRewrittenImagePath", "(", "String", "originalCssPath", ",", "String", "newCssPath", ",", "String", "url", ")", "throws", "IOException", "{", "String", "imgUrl", "=", "null", ";", "// Retrieve the current CSS file from which the CSS image is referenced", "boolean", "generatedImg", "=", "false", ";", "if", "(", "binaryRsHandler", "!=", "null", ")", "{", "GeneratorRegistry", "imgRsGeneratorRegistry", "=", "binaryRsHandler", ".", "getConfig", "(", ")", ".", "getGeneratorRegistry", "(", ")", ";", "generatedImg", "=", "imgRsGeneratorRegistry", ".", "isGeneratedBinaryResource", "(", "url", ")", ";", "}", "String", "fullImgPath", "=", "PathNormalizer", ".", "concatWebPath", "(", "originalCssPath", ",", "url", ")", ";", "if", "(", "!", "generatedImg", ")", "{", "// Add image servlet path in the URL, if it's defined", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "binaryServletPath", ")", ")", "{", "fullImgPath", "=", "binaryServletPath", "+", "JawrConstant", ".", "URL_SEPARATOR", "+", "fullImgPath", ";", "}", "imgUrl", "=", "PathNormalizer", ".", "getRelativeWebPath", "(", "PathNormalizer", ".", "getParentPath", "(", "newCssPath", ")", ",", "fullImgPath", ")", ";", "}", "else", "{", "imgUrl", "=", "url", ";", "}", "return", "imgUrl", ";", "}" ]
Returns the rewritten image path @param originalCssPath the original Css path @param newCssPath the new Css path @param url the image URL @return the rewritten image path @throws IOException if an IOException occurs
[ "Returns", "the", "rewritten", "image", "path" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/bundle/css/CssImageUrlRewriter.java#L257-L282
7,388
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/reader/ServletContextResourceReaderHandler.java
ServletContextResourceReaderHandler.isInstanceOf
private boolean isInstanceOf(Object rd, List<Class<?>> interfaces) { boolean result = false; for (Class<?> class1 : interfaces) { if (class1.isInstance(rd)) { result = true; break; } } return result; }
java
private boolean isInstanceOf(Object rd, List<Class<?>> interfaces) { boolean result = false; for (Class<?> class1 : interfaces) { if (class1.isInstance(rd)) { result = true; break; } } return result; }
[ "private", "boolean", "isInstanceOf", "(", "Object", "rd", ",", "List", "<", "Class", "<", "?", ">", ">", "interfaces", ")", "{", "boolean", "result", "=", "false", ";", "for", "(", "Class", "<", "?", ">", "class1", ":", "interfaces", ")", "{", "if", "(", "class1", ".", "isInstance", "(", "rd", ")", ")", "{", "result", "=", "true", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Checks if an object is an instance of on interface from a list of interface @param rd the object @param interfacesthe list of interfaces @return true if the object is an instance of on interface from a list of interface
[ "Checks", "if", "an", "object", "is", "an", "instance", "of", "on", "interface", "from", "a", "list", "of", "interface" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/resource/handler/reader/ServletContextResourceReaderHandler.java#L333-L345
7,389
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java
JavascriptEngine.evaluate
public Object evaluate(String scriptName, Reader reader) { try { scriptEngine.put(ScriptEngine.FILENAME, scriptName); return scriptEngine.eval(reader); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating script : " + scriptName, e); } }
java
public Object evaluate(String scriptName, Reader reader) { try { scriptEngine.put(ScriptEngine.FILENAME, scriptName); return scriptEngine.eval(reader); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating script : " + scriptName, e); } }
[ "public", "Object", "evaluate", "(", "String", "scriptName", ",", "Reader", "reader", ")", "{", "try", "{", "scriptEngine", ".", "put", "(", "ScriptEngine", ".", "FILENAME", ",", "scriptName", ")", ";", "return", "scriptEngine", ".", "eval", "(", "reader", ")", ";", "}", "catch", "(", "ScriptException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Error while evaluating script : \"", "+", "scriptName", ",", "e", ")", ";", "}", "}" ]
Evaluates the script @param scriptName the script name @param reader the script reader @return the result
[ "Evaluates", "the", "script" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java#L123-L131
7,390
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java
JavascriptEngine.evaluateString
public Object evaluateString(String scriptName, String source, Bindings bindings) { try { scriptEngine.put(ScriptEngine.FILENAME, scriptName); return scriptEngine.eval(source, bindings); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating script : " + scriptName, e); } }
java
public Object evaluateString(String scriptName, String source, Bindings bindings) { try { scriptEngine.put(ScriptEngine.FILENAME, scriptName); return scriptEngine.eval(source, bindings); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating script : " + scriptName, e); } }
[ "public", "Object", "evaluateString", "(", "String", "scriptName", ",", "String", "source", ",", "Bindings", "bindings", ")", "{", "try", "{", "scriptEngine", ".", "put", "(", "ScriptEngine", ".", "FILENAME", ",", "scriptName", ")", ";", "return", "scriptEngine", ".", "eval", "(", "source", ",", "bindings", ")", ";", "}", "catch", "(", "ScriptException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Error while evaluating script : \"", "+", "scriptName", ",", "e", ")", ";", "}", "}" ]
Evaluates the JS passed in parameter @param scriptName the script name @param source the JS script @param bindings the bindings to use @return the result
[ "Evaluates", "the", "JS", "passed", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java#L175-L182
7,391
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java
JavascriptEngine.evaluate
public Object evaluate(String scriptName, InputStream stream) { return evaluate(scriptName, new InputStreamReader(stream)); }
java
public Object evaluate(String scriptName, InputStream stream) { return evaluate(scriptName, new InputStreamReader(stream)); }
[ "public", "Object", "evaluate", "(", "String", "scriptName", ",", "InputStream", "stream", ")", "{", "return", "evaluate", "(", "scriptName", ",", "new", "InputStreamReader", "(", "stream", ")", ")", ";", "}" ]
Evaluates a script @param scriptName the name of the script to evaluate. @param stream The inputStream of the script to evaluate. @return the result of the script evaluation
[ "Evaluates", "a", "script" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java#L193-L195
7,392
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java
JavascriptEngine.parseJSON
public Object parseJSON(String strJson) throws ScriptException, NoSuchMethodException { Object json = scriptEngine.eval("JSON"); Object data = invokeMethod(json, "parse", strJson); return data; }
java
public Object parseJSON(String strJson) throws ScriptException, NoSuchMethodException { Object json = scriptEngine.eval("JSON"); Object data = invokeMethod(json, "parse", strJson); return data; }
[ "public", "Object", "parseJSON", "(", "String", "strJson", ")", "throws", "ScriptException", ",", "NoSuchMethodException", "{", "Object", "json", "=", "scriptEngine", ".", "eval", "(", "\"JSON\"", ")", ";", "Object", "data", "=", "invokeMethod", "(", "json", ",", "\"parse\"", ",", "strJson", ")", ";", "return", "data", ";", "}" ]
Returns the JSON object from a string @param strJson the json to evaluate @return the JSON object from a string @throws ScriptException if a script exception occurs @throws NoSuchMethodException if a NoSuchMethodException occurs
[ "Returns", "the", "JSON", "object", "from", "a", "string" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java#L300-L306
7,393
j-a-w-r/jawr-main-repo
jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java
JavascriptEngine.execEval
public Object execEval(String arg) { try { return scriptEngine.eval("eval(" + arg + ")"); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating a script", e); } }
java
public Object execEval(String arg) { try { return scriptEngine.eval("eval(" + arg + ")"); } catch (ScriptException e) { throw new BundlingProcessException("Error while evaluating a script", e); } }
[ "public", "Object", "execEval", "(", "String", "arg", ")", "{", "try", "{", "return", "scriptEngine", ".", "eval", "(", "\"eval(\"", "+", "arg", "+", "\")\"", ")", ";", "}", "catch", "(", "ScriptException", "e", ")", "{", "throw", "new", "BundlingProcessException", "(", "\"Error while evaluating a script\"", ",", "e", ")", ";", "}", "}" ]
Launch eval function on the argument given in parameter @param arg the argument @return the evaluated object
[ "Launch", "eval", "function", "on", "the", "argument", "given", "in", "parameter" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr/jawr-core/src/main/java/net/jawr/web/util/js/JavascriptEngine.java#L315-L321
7,394
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.getWebXmlDocument
protected Document getWebXmlDocument(String baseDir) throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException { File webXml = new File(baseDir, WEB_XML_FILE_PATH); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); docBuilder.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return null; } }); Document doc = docBuilder.parse(webXml); return doc; }
java
protected Document getWebXmlDocument(String baseDir) throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException { File webXml = new File(baseDir, WEB_XML_FILE_PATH); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); docBuilder.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return null; } }); Document doc = docBuilder.parse(webXml); return doc; }
[ "protected", "Document", "getWebXmlDocument", "(", "String", "baseDir", ")", "throws", "ParserConfigurationException", ",", "FactoryConfigurationError", ",", "SAXException", ",", "IOException", "{", "File", "webXml", "=", "new", "File", "(", "baseDir", ",", "WEB_XML_FILE_PATH", ")", ";", "DocumentBuilder", "docBuilder", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ".", "newDocumentBuilder", "(", ")", ";", "docBuilder", ".", "setEntityResolver", "(", "new", "EntityResolver", "(", ")", "{", "public", "InputSource", "resolveEntity", "(", "String", "publicId", ",", "String", "systemId", ")", "throws", "SAXException", ",", "IOException", "{", "return", "null", ";", "}", "}", ")", ";", "Document", "doc", "=", "docBuilder", ".", "parse", "(", "webXml", ")", ";", "return", "doc", ";", "}" ]
Returns the XML document of the web.xml file @param webXmlPath the web.xml path @return the Xml document of the web.xml file @throws ParserConfigurationException if a parser configuration exception occurs @throws FactoryConfigurationError if a factory configuration exception occurs @throws SAXException if a SAX exception occurs @throws IOException if an IO exception occurs
[ "Returns", "the", "XML", "document", "of", "the", "web", ".", "xml", "file" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L297-L314
7,395
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.initClassLoader
protected ClassLoader initClassLoader(String baseDirPath) throws MalformedURLException { File webAppClasses = new File(baseDirPath + WEB_INF_CLASSES_DIR_PATH); File[] webAppLibs = new File(baseDirPath + WEB_INF_LIB_DIR_PATH) .listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(JAR_FILE_EXTENSION); } }); int length = webAppLibs != null ? webAppLibs.length + 1 : 1; URL[] urls = new URL[length]; urls[0] = webAppClasses.toURI().toURL(); for (int i = 1; i < length; i++) { urls[i] = webAppLibs[i - 1].toURI().toURL(); } ClassLoader webAppClassLoader = new JawrBundleProcessorCustomClassLoader( urls, getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(webAppClassLoader); return webAppClassLoader; }
java
protected ClassLoader initClassLoader(String baseDirPath) throws MalformedURLException { File webAppClasses = new File(baseDirPath + WEB_INF_CLASSES_DIR_PATH); File[] webAppLibs = new File(baseDirPath + WEB_INF_LIB_DIR_PATH) .listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(JAR_FILE_EXTENSION); } }); int length = webAppLibs != null ? webAppLibs.length + 1 : 1; URL[] urls = new URL[length]; urls[0] = webAppClasses.toURI().toURL(); for (int i = 1; i < length; i++) { urls[i] = webAppLibs[i - 1].toURI().toURL(); } ClassLoader webAppClassLoader = new JawrBundleProcessorCustomClassLoader( urls, getClass().getClassLoader()); Thread.currentThread().setContextClassLoader(webAppClassLoader); return webAppClassLoader; }
[ "protected", "ClassLoader", "initClassLoader", "(", "String", "baseDirPath", ")", "throws", "MalformedURLException", "{", "File", "webAppClasses", "=", "new", "File", "(", "baseDirPath", "+", "WEB_INF_CLASSES_DIR_PATH", ")", ";", "File", "[", "]", "webAppLibs", "=", "new", "File", "(", "baseDirPath", "+", "WEB_INF_LIB_DIR_PATH", ")", ".", "listFiles", "(", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "return", "name", ".", "endsWith", "(", "JAR_FILE_EXTENSION", ")", ";", "}", "}", ")", ";", "int", "length", "=", "webAppLibs", "!=", "null", "?", "webAppLibs", ".", "length", "+", "1", ":", "1", ";", "URL", "[", "]", "urls", "=", "new", "URL", "[", "length", "]", ";", "urls", "[", "0", "]", "=", "webAppClasses", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "length", ";", "i", "++", ")", "{", "urls", "[", "i", "]", "=", "webAppLibs", "[", "i", "-", "1", "]", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "}", "ClassLoader", "webAppClassLoader", "=", "new", "JawrBundleProcessorCustomClassLoader", "(", "urls", ",", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "webAppClassLoader", ")", ";", "return", "webAppClassLoader", ";", "}" ]
Initialize the classloader @param baseDirPath the base directory path @return the class loader @throws MalformedURLException
[ "Initialize", "the", "classloader" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L324-L348
7,396
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.initServletContext
protected ServletContext initServletContext(Document webXmlDoc, String baseDirPath, String tmpDirPath, String springConfigFiles, String servletAPIversion) { // Parse the context parameters MockServletContext servletContext = new MockServletContext( servletAPIversion, baseDirPath, tmpDirPath); Map<String, Object> servletContextInitParams = new HashMap<String, Object>(); NodeList contextParamsNodes = webXmlDoc .getElementsByTagName(CONTEXT_TAG_NAME); for (int i = 0; i < contextParamsNodes.getLength(); i++) { Node node = contextParamsNodes.item(i); initializeInitParams(node, servletContextInitParams); } // Override spring config file if needed if (StringUtils.isNotEmpty(springConfigFiles)) { servletContextInitParams.put(CONFIG_LOCATION_PARAM, springConfigFiles.replace(" ", "%20")); } servletContext.setInitParameters(servletContextInitParams); return servletContext; }
java
protected ServletContext initServletContext(Document webXmlDoc, String baseDirPath, String tmpDirPath, String springConfigFiles, String servletAPIversion) { // Parse the context parameters MockServletContext servletContext = new MockServletContext( servletAPIversion, baseDirPath, tmpDirPath); Map<String, Object> servletContextInitParams = new HashMap<String, Object>(); NodeList contextParamsNodes = webXmlDoc .getElementsByTagName(CONTEXT_TAG_NAME); for (int i = 0; i < contextParamsNodes.getLength(); i++) { Node node = contextParamsNodes.item(i); initializeInitParams(node, servletContextInitParams); } // Override spring config file if needed if (StringUtils.isNotEmpty(springConfigFiles)) { servletContextInitParams.put(CONFIG_LOCATION_PARAM, springConfigFiles.replace(" ", "%20")); } servletContext.setInitParameters(servletContextInitParams); return servletContext; }
[ "protected", "ServletContext", "initServletContext", "(", "Document", "webXmlDoc", ",", "String", "baseDirPath", ",", "String", "tmpDirPath", ",", "String", "springConfigFiles", ",", "String", "servletAPIversion", ")", "{", "// Parse the context parameters", "MockServletContext", "servletContext", "=", "new", "MockServletContext", "(", "servletAPIversion", ",", "baseDirPath", ",", "tmpDirPath", ")", ";", "Map", "<", "String", ",", "Object", ">", "servletContextInitParams", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "NodeList", "contextParamsNodes", "=", "webXmlDoc", ".", "getElementsByTagName", "(", "CONTEXT_TAG_NAME", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "contextParamsNodes", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "Node", "node", "=", "contextParamsNodes", ".", "item", "(", "i", ")", ";", "initializeInitParams", "(", "node", ",", "servletContextInitParams", ")", ";", "}", "// Override spring config file if needed", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "springConfigFiles", ")", ")", "{", "servletContextInitParams", ".", "put", "(", "CONFIG_LOCATION_PARAM", ",", "springConfigFiles", ".", "replace", "(", "\" \"", ",", "\"%20\"", ")", ")", ";", "}", "servletContext", ".", "setInitParameters", "(", "servletContextInitParams", ")", ";", "return", "servletContext", ";", "}" ]
Initalize the servlet context @param webXmlDoc the web.xml document @param baseDirPath the base drectory path @param tmpDirPath the temp directory path @param springConfigFiles the list of spring config files @return the servlet context
[ "Initalize", "the", "servlet", "context" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L363-L386
7,397
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.getWebXmlServletDefinitions
protected List<ServletDefinition> getWebXmlServletDefinitions( Document webXmlDoc, ServletContext servletContext, List<String> servletsToInitialize, ClassLoader webAppClassLoader) throws ClassNotFoundException { // Parse the servlet configuration NodeList servletNodes = webXmlDoc .getElementsByTagName(SERVLET_TAG_NAME); List<ServletDefinition> servletDefinitions = new ArrayList<ServletDefinition>(); for (int i = 0; i < servletNodes.getLength(); i++) { String servletName = null; Class<?> servletClass = null; MockServletConfig config = new MockServletConfig(servletContext); int order = i; Node servletNode = servletNodes.item(i); Map<String, Object> initParameters = new HashMap<String, Object>(); NodeList childNodes = servletNode.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node servletChildNode = childNodes.item(j); if (servletChildNode.getNodeName() .equals(SERVLET_NAME_TAG_NAME)) { servletName = getTextValue(servletChildNode); config.setServletName(servletName); } else if (servletChildNode.getNodeName().equals( SERVLET_CLASS_TAG_NAME)) { String servletClassName = getTextValue(servletChildNode); servletClass = webAppClassLoader .loadClass(servletClassName); } else if (servletChildNode.getNodeName().equals( INIT_PARAM_TAG_NAME)) { initializeInitParams(servletChildNode, initParameters); } else if (servletChildNode.getNodeName().equals( LOAD_ON_STARTUP_TAG_NAME)) { order = Integer.parseInt(getTextValue(servletChildNode)); } } // Initialize the servlet config with the init parameters config.setInitParameters(initParameters); // If the servlet name is part of the list of servlet to initialized // Set the flag accordingly if (servletsToInitialize.contains(servletName) || JawrServlet.class.isAssignableFrom(servletClass)) { ServletDefinition servletDef = new ServletDefinition( servletClass, config, order); servletDefinitions.add(servletDef); } // Handle Spring MVC servlet definition if (servletContext.getInitParameter(CONFIG_LOCATION_PARAM) == null && servletClass .getName() .equals("org.springframework.web.servlet.DispatcherServlet")) { ((MockServletContext) servletContext).putInitParameter( CONFIG_LOCATION_PARAM, "/WEB-INF/" + servletName + "-servlet.xml"); } } return servletDefinitions; }
java
protected List<ServletDefinition> getWebXmlServletDefinitions( Document webXmlDoc, ServletContext servletContext, List<String> servletsToInitialize, ClassLoader webAppClassLoader) throws ClassNotFoundException { // Parse the servlet configuration NodeList servletNodes = webXmlDoc .getElementsByTagName(SERVLET_TAG_NAME); List<ServletDefinition> servletDefinitions = new ArrayList<ServletDefinition>(); for (int i = 0; i < servletNodes.getLength(); i++) { String servletName = null; Class<?> servletClass = null; MockServletConfig config = new MockServletConfig(servletContext); int order = i; Node servletNode = servletNodes.item(i); Map<String, Object> initParameters = new HashMap<String, Object>(); NodeList childNodes = servletNode.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node servletChildNode = childNodes.item(j); if (servletChildNode.getNodeName() .equals(SERVLET_NAME_TAG_NAME)) { servletName = getTextValue(servletChildNode); config.setServletName(servletName); } else if (servletChildNode.getNodeName().equals( SERVLET_CLASS_TAG_NAME)) { String servletClassName = getTextValue(servletChildNode); servletClass = webAppClassLoader .loadClass(servletClassName); } else if (servletChildNode.getNodeName().equals( INIT_PARAM_TAG_NAME)) { initializeInitParams(servletChildNode, initParameters); } else if (servletChildNode.getNodeName().equals( LOAD_ON_STARTUP_TAG_NAME)) { order = Integer.parseInt(getTextValue(servletChildNode)); } } // Initialize the servlet config with the init parameters config.setInitParameters(initParameters); // If the servlet name is part of the list of servlet to initialized // Set the flag accordingly if (servletsToInitialize.contains(servletName) || JawrServlet.class.isAssignableFrom(servletClass)) { ServletDefinition servletDef = new ServletDefinition( servletClass, config, order); servletDefinitions.add(servletDef); } // Handle Spring MVC servlet definition if (servletContext.getInitParameter(CONFIG_LOCATION_PARAM) == null && servletClass .getName() .equals("org.springframework.web.servlet.DispatcherServlet")) { ((MockServletContext) servletContext).putInitParameter( CONFIG_LOCATION_PARAM, "/WEB-INF/" + servletName + "-servlet.xml"); } } return servletDefinitions; }
[ "protected", "List", "<", "ServletDefinition", ">", "getWebXmlServletDefinitions", "(", "Document", "webXmlDoc", ",", "ServletContext", "servletContext", ",", "List", "<", "String", ">", "servletsToInitialize", ",", "ClassLoader", "webAppClassLoader", ")", "throws", "ClassNotFoundException", "{", "// Parse the servlet configuration", "NodeList", "servletNodes", "=", "webXmlDoc", ".", "getElementsByTagName", "(", "SERVLET_TAG_NAME", ")", ";", "List", "<", "ServletDefinition", ">", "servletDefinitions", "=", "new", "ArrayList", "<", "ServletDefinition", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "servletNodes", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "String", "servletName", "=", "null", ";", "Class", "<", "?", ">", "servletClass", "=", "null", ";", "MockServletConfig", "config", "=", "new", "MockServletConfig", "(", "servletContext", ")", ";", "int", "order", "=", "i", ";", "Node", "servletNode", "=", "servletNodes", ".", "item", "(", "i", ")", ";", "Map", "<", "String", ",", "Object", ">", "initParameters", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "NodeList", "childNodes", "=", "servletNode", ".", "getChildNodes", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "childNodes", ".", "getLength", "(", ")", ";", "j", "++", ")", "{", "Node", "servletChildNode", "=", "childNodes", ".", "item", "(", "j", ")", ";", "if", "(", "servletChildNode", ".", "getNodeName", "(", ")", ".", "equals", "(", "SERVLET_NAME_TAG_NAME", ")", ")", "{", "servletName", "=", "getTextValue", "(", "servletChildNode", ")", ";", "config", ".", "setServletName", "(", "servletName", ")", ";", "}", "else", "if", "(", "servletChildNode", ".", "getNodeName", "(", ")", ".", "equals", "(", "SERVLET_CLASS_TAG_NAME", ")", ")", "{", "String", "servletClassName", "=", "getTextValue", "(", "servletChildNode", ")", ";", "servletClass", "=", "webAppClassLoader", ".", "loadClass", "(", "servletClassName", ")", ";", "}", "else", "if", "(", "servletChildNode", ".", "getNodeName", "(", ")", ".", "equals", "(", "INIT_PARAM_TAG_NAME", ")", ")", "{", "initializeInitParams", "(", "servletChildNode", ",", "initParameters", ")", ";", "}", "else", "if", "(", "servletChildNode", ".", "getNodeName", "(", ")", ".", "equals", "(", "LOAD_ON_STARTUP_TAG_NAME", ")", ")", "{", "order", "=", "Integer", ".", "parseInt", "(", "getTextValue", "(", "servletChildNode", ")", ")", ";", "}", "}", "// Initialize the servlet config with the init parameters", "config", ".", "setInitParameters", "(", "initParameters", ")", ";", "// If the servlet name is part of the list of servlet to initialized", "// Set the flag accordingly", "if", "(", "servletsToInitialize", ".", "contains", "(", "servletName", ")", "||", "JawrServlet", ".", "class", ".", "isAssignableFrom", "(", "servletClass", ")", ")", "{", "ServletDefinition", "servletDef", "=", "new", "ServletDefinition", "(", "servletClass", ",", "config", ",", "order", ")", ";", "servletDefinitions", ".", "add", "(", "servletDef", ")", ";", "}", "// Handle Spring MVC servlet definition", "if", "(", "servletContext", ".", "getInitParameter", "(", "CONFIG_LOCATION_PARAM", ")", "==", "null", "&&", "servletClass", ".", "getName", "(", ")", ".", "equals", "(", "\"org.springframework.web.servlet.DispatcherServlet\"", ")", ")", "{", "(", "(", "MockServletContext", ")", "servletContext", ")", ".", "putInitParameter", "(", "CONFIG_LOCATION_PARAM", ",", "\"/WEB-INF/\"", "+", "servletName", "+", "\"-servlet.xml\"", ")", ";", "}", "}", "return", "servletDefinitions", ";", "}" ]
Returns the list of servlet definition, which must be initialize @param webXmlDoc the web.xml document @param servletContext the servlet context @param servletsToInitialize the list of servlet to initialize @param webAppClassLoader the web application class loader @return the list of servlet definition, which must be initialize @throws ClassNotFoundException if a class is not found
[ "Returns", "the", "list", "of", "servlet", "definition", "which", "must", "be", "initialize" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L403-L473
7,398
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.initJawrSpringControllers
protected List<ServletDefinition> initJawrSpringControllers( ServletContext servletContext) throws ServletException { SpringControllerBundleProcessor springBundleProcessor = new SpringControllerBundleProcessor(); return springBundleProcessor.initJawrSpringServlets(servletContext); }
java
protected List<ServletDefinition> initJawrSpringControllers( ServletContext servletContext) throws ServletException { SpringControllerBundleProcessor springBundleProcessor = new SpringControllerBundleProcessor(); return springBundleProcessor.initJawrSpringServlets(servletContext); }
[ "protected", "List", "<", "ServletDefinition", ">", "initJawrSpringControllers", "(", "ServletContext", "servletContext", ")", "throws", "ServletException", "{", "SpringControllerBundleProcessor", "springBundleProcessor", "=", "new", "SpringControllerBundleProcessor", "(", ")", ";", "return", "springBundleProcessor", ".", "initJawrSpringServlets", "(", "servletContext", ")", ";", "}" ]
Initialize the Jawr spring controller @param servletContext the servlet context @return the Jawr spring controller @throws ServletException if a servlet exception occurs
[ "Initialize", "the", "Jawr", "spring", "controller" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L484-L489
7,399
j-a-w-r/jawr-main-repo
jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
BundleProcessor.initServlets
protected List<ServletDefinition> initServlets( List<ServletDefinition> servletDefinitions) throws Exception { // Sort the list taking in account the load-on-startup attribute Collections.sort(servletDefinitions); // Sets the Jawr context at "bundle processing at build time" ThreadLocalJawrContext.setBundleProcessingAtBuildTime(true); List<ServletDefinition> jawrServletDefinitions = new ArrayList<ServletDefinition>(); for (Iterator<ServletDefinition> iterator = servletDefinitions .iterator(); iterator.hasNext();) { ServletDefinition servletDefinition = (ServletDefinition) iterator .next(); servletDefinition.initServlet(); if (servletDefinition.isJawrServletDefinition()) { jawrServletDefinitions.add(servletDefinition); } } return jawrServletDefinitions; }
java
protected List<ServletDefinition> initServlets( List<ServletDefinition> servletDefinitions) throws Exception { // Sort the list taking in account the load-on-startup attribute Collections.sort(servletDefinitions); // Sets the Jawr context at "bundle processing at build time" ThreadLocalJawrContext.setBundleProcessingAtBuildTime(true); List<ServletDefinition> jawrServletDefinitions = new ArrayList<ServletDefinition>(); for (Iterator<ServletDefinition> iterator = servletDefinitions .iterator(); iterator.hasNext();) { ServletDefinition servletDefinition = (ServletDefinition) iterator .next(); servletDefinition.initServlet(); if (servletDefinition.isJawrServletDefinition()) { jawrServletDefinitions.add(servletDefinition); } } return jawrServletDefinitions; }
[ "protected", "List", "<", "ServletDefinition", ">", "initServlets", "(", "List", "<", "ServletDefinition", ">", "servletDefinitions", ")", "throws", "Exception", "{", "// Sort the list taking in account the load-on-startup attribute", "Collections", ".", "sort", "(", "servletDefinitions", ")", ";", "// Sets the Jawr context at \"bundle processing at build time\"", "ThreadLocalJawrContext", ".", "setBundleProcessingAtBuildTime", "(", "true", ")", ";", "List", "<", "ServletDefinition", ">", "jawrServletDefinitions", "=", "new", "ArrayList", "<", "ServletDefinition", ">", "(", ")", ";", "for", "(", "Iterator", "<", "ServletDefinition", ">", "iterator", "=", "servletDefinitions", ".", "iterator", "(", ")", ";", "iterator", ".", "hasNext", "(", ")", ";", ")", "{", "ServletDefinition", "servletDefinition", "=", "(", "ServletDefinition", ")", "iterator", ".", "next", "(", ")", ";", "servletDefinition", ".", "initServlet", "(", ")", ";", "if", "(", "servletDefinition", ".", "isJawrServletDefinition", "(", ")", ")", "{", "jawrServletDefinitions", ".", "add", "(", "servletDefinition", ")", ";", "}", "}", "return", "jawrServletDefinitions", ";", "}" ]
Initialize the servlets and returns only the list of Jawr servlets @param servletDefinitions the list of servlet definition @throws Exception if an exception occurs
[ "Initialize", "the", "servlets", "and", "returns", "only", "the", "list", "of", "Jawr", "servlets" ]
5381f6acf461cd2502593c67a77bd6ef9eab848d
https://github.com/j-a-w-r/jawr-main-repo/blob/5381f6acf461cd2502593c67a77bd6ef9eab848d/jawr-tools/jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java#L499-L520